LCOV - code coverage report
Current view: top level - dom/svg - SVGLengthList.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 33 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 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 "SVGLengthList.h"
       8             : #include "nsCharSeparatedTokenizer.h"
       9             : #include "nsError.h"
      10             : #include "nsString.h"
      11             : #include "nsSVGElement.h"
      12             : #include "SVGAnimatedLengthList.h"
      13             : #include "SVGContentUtils.h"
      14             : #include "SVGLength.h"
      15             : 
      16             : namespace mozilla {
      17             : 
      18             : nsresult
      19           0 : SVGLengthList::CopyFrom(const SVGLengthList& rhs)
      20             : {
      21           0 :   if (!mLengths.Assign(rhs.mLengths, fallible)) {
      22           0 :     return NS_ERROR_OUT_OF_MEMORY;
      23             :   }
      24           0 :   return NS_OK;
      25             : }
      26             : 
      27             : void
      28           0 : SVGLengthList::GetValueAsString(nsAString& aValue) const
      29             : {
      30           0 :   aValue.Truncate();
      31           0 :   uint32_t last = mLengths.Length() - 1;
      32           0 :   for (uint32_t i = 0; i < mLengths.Length(); ++i) {
      33           0 :     nsAutoString length;
      34           0 :     mLengths[i].GetValueAsString(length);
      35             :     // We ignore OOM, since it's not useful for us to return an error.
      36           0 :     aValue.Append(length);
      37           0 :     if (i != last) {
      38           0 :       aValue.Append(' ');
      39             :     }
      40             :   }
      41           0 : }
      42             : 
      43             : nsresult
      44           0 : SVGLengthList::SetValueFromString(const nsAString& aValue)
      45             : {
      46           0 :   SVGLengthList temp;
      47             : 
      48             :   nsCharSeparatedTokenizerTemplate<IsSVGWhitespace>
      49           0 :     tokenizer(aValue, ',', nsCharSeparatedTokenizer::SEPARATOR_OPTIONAL);
      50             : 
      51           0 :   while (tokenizer.hasMoreTokens()) {
      52           0 :     SVGLength length;
      53           0 :     if (!length.SetValueFromString(tokenizer.nextToken())) {
      54           0 :       return NS_ERROR_DOM_SYNTAX_ERR;
      55             :     }
      56           0 :     if (!temp.AppendItem(length)) {
      57           0 :       return NS_ERROR_OUT_OF_MEMORY;
      58             :     }
      59             :   }
      60           0 :   if (tokenizer.separatorAfterCurrentToken()) {
      61           0 :     return NS_ERROR_DOM_SYNTAX_ERR; // trailing comma
      62             :   }
      63           0 :   return CopyFrom(temp);
      64             : }
      65             : 
      66             : bool
      67           0 : SVGLengthList::operator==(const SVGLengthList& rhs) const
      68             : {
      69           0 :   if (Length() != rhs.Length()) {
      70           0 :     return false;
      71             :   }
      72           0 :   for (uint32_t i = 0; i < Length(); ++i) {
      73           0 :     if (!(mLengths[i] == rhs.mLengths[i])) {
      74           0 :       return false;
      75             :     }
      76             :   }
      77           0 :   return true;
      78             : }
      79             : 
      80             : } // namespace mozilla

Generated by: LCOV version 1.13