LCOV - code coverage report
Current view: top level - dom/svg - SVGTransformList.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 15 31 48.4 %
Date: 2017-07-14 16:53:18 Functions: 4 5 80.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 "SVGTransformList.h"
       8             : #include "SVGTransformListParser.h"
       9             : #include "nsString.h"
      10             : #include "nsError.h"
      11             : 
      12             : namespace mozilla {
      13             : 
      14             : gfxMatrix
      15          42 : SVGTransformList::GetConsolidationMatrix() const
      16             : {
      17             :   // To benefit from Return Value Optimization and avoid copy constructor calls
      18             :   // due to our use of return-by-value, we must return the exact same object
      19             :   // from ALL return points. This function must only return THIS variable:
      20          42 :   gfxMatrix result;
      21             : 
      22          42 :   if (mItems.IsEmpty())
      23           0 :     return result;
      24             : 
      25          42 :   result = mItems[0].GetMatrix();
      26             : 
      27          42 :   if (mItems.Length() == 1)
      28          42 :     return result;
      29             : 
      30           0 :   for (uint32_t i = 1; i < mItems.Length(); ++i) {
      31           0 :     result.PreMultiply(mItems[i].GetMatrix());
      32             :   }
      33             : 
      34           0 :   return result;
      35             : }
      36             : 
      37             : nsresult
      38           7 : SVGTransformList::CopyFrom(const SVGTransformList& rhs)
      39             : {
      40           7 :   return CopyFrom(rhs.mItems);
      41             : }
      42             : 
      43             : nsresult
      44          14 : SVGTransformList::CopyFrom(const nsTArray<nsSVGTransform>& aTransformArray)
      45             : {
      46          14 :   if (!mItems.Assign(aTransformArray, fallible)) {
      47           0 :     return NS_ERROR_OUT_OF_MEMORY;
      48             :   }
      49          14 :   return NS_OK;
      50             : }
      51             : 
      52             : void
      53           0 : SVGTransformList::GetValueAsString(nsAString& aValue) const
      54             : {
      55           0 :   aValue.Truncate();
      56           0 :   uint32_t last = mItems.Length() - 1;
      57           0 :   for (uint32_t i = 0; i < mItems.Length(); ++i) {
      58           0 :     nsAutoString length;
      59           0 :     mItems[i].GetValueAsString(length);
      60             :     // We ignore OOM, since it's not useful for us to return an error.
      61           0 :     aValue.Append(length);
      62           0 :     if (i != last) {
      63           0 :       aValue.Append(' ');
      64             :     }
      65             :   }
      66           0 : }
      67             : 
      68             : nsresult
      69           7 : SVGTransformList::SetValueFromString(const nsAString& aValue)
      70             : {
      71          14 :   SVGTransformListParser parser(aValue);
      72           7 :   if (!parser.Parse()) {
      73             :     // there was a parse error.
      74           0 :     return NS_ERROR_DOM_SYNTAX_ERR;
      75             :   }
      76             : 
      77           7 :   return CopyFrom(parser.GetTransformList());
      78             : }
      79             : 
      80             : } // namespace mozilla

Generated by: LCOV version 1.13