LCOV - code coverage report
Current view: top level - dom/svg - SVGStringList.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 29 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "SVGStringList.h"
       8             : #include "nsError.h"
       9             : #include "nsCharSeparatedTokenizer.h"
      10             : #include "nsString.h"
      11             : #include "nsWhitespaceTokenizer.h"
      12             : #include "SVGContentUtils.h"
      13             : 
      14             : namespace mozilla {
      15             : 
      16             : nsresult
      17           0 : SVGStringList::CopyFrom(const SVGStringList& rhs)
      18             : {
      19           0 :   if (!mStrings.Assign(rhs.mStrings, fallible)) {
      20           0 :     return NS_ERROR_OUT_OF_MEMORY;
      21             :   }
      22           0 :   mIsSet = true;
      23           0 :   return NS_OK;
      24             : }
      25             : 
      26             : void
      27           0 : SVGStringList::GetValue(nsAString& aValue) const
      28             : {
      29           0 :   aValue.Truncate();
      30           0 :   uint32_t last = mStrings.Length() - 1;
      31           0 :   for (uint32_t i = 0; i < mStrings.Length(); ++i) {
      32           0 :     aValue.Append(mStrings[i]);
      33           0 :     if (i != last) {
      34           0 :       if (mIsCommaSeparated) {
      35           0 :         aValue.Append(',');
      36             :       }
      37           0 :       aValue.Append(' ');
      38             :     }
      39             :   }
      40           0 : }
      41             : 
      42             : nsresult
      43           0 : SVGStringList::SetValue(const nsAString& aValue)
      44             : {
      45           0 :   SVGStringList temp;
      46             : 
      47           0 :   if (mIsCommaSeparated) {
      48             :     nsCharSeparatedTokenizerTemplate<IsSVGWhitespace>
      49           0 :       tokenizer(aValue, ',');
      50             : 
      51           0 :     while (tokenizer.hasMoreTokens()) {
      52           0 :       if (!temp.AppendItem(tokenizer.nextToken())) {
      53           0 :         return NS_ERROR_OUT_OF_MEMORY;
      54             :       }
      55             :     }
      56           0 :     if (tokenizer.separatorAfterCurrentToken()) {
      57           0 :       return NS_ERROR_DOM_SYNTAX_ERR; // trailing comma
      58             :     }
      59             :   } else {
      60           0 :     nsWhitespaceTokenizerTemplate<IsSVGWhitespace> tokenizer(aValue);
      61             : 
      62           0 :     while (tokenizer.hasMoreTokens()) {
      63           0 :       if (!temp.AppendItem(tokenizer.nextToken())) {
      64           0 :         return NS_ERROR_OUT_OF_MEMORY;
      65             :       }
      66             :     }
      67             :   }
      68             : 
      69           0 :   return CopyFrom(temp);
      70             : }
      71             : 
      72             : } // namespace mozilla

Generated by: LCOV version 1.13