LCOV - code coverage report
Current view: directory - content/svg/content/src - nsSVGPathElement.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 177 0 0.0 %
Date: 2012-06-02 Functions: 43 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is the Mozilla SVG project.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Crocodile Clips Ltd..
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2001
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      27                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #include "mozilla/Util.h"
      40                 : 
      41                 : #include "nsGkAtoms.h"
      42                 : #include "nsIDOMSVGPathSeg.h"
      43                 : #include "DOMSVGPathSeg.h"
      44                 : #include "DOMSVGPathSegList.h"
      45                 : #include "nsCOMPtr.h"
      46                 : #include "nsIFrame.h"
      47                 : #include "nsContentUtils.h"
      48                 : #include "nsSVGPathDataParser.h"
      49                 : #include "nsSVGPathElement.h"
      50                 : #include "nsSVGUtils.h"
      51                 : #include "DOMSVGPoint.h"
      52                 : #include "gfxContext.h"
      53                 : #include "gfxPlatform.h"
      54                 : 
      55                 : using namespace mozilla;
      56                 : 
      57                 : nsSVGElement::NumberInfo nsSVGPathElement::sNumberInfo = 
      58                 : { &nsGkAtoms::pathLength, 0, false };
      59                 : 
      60               0 : NS_IMPL_NS_NEW_SVG_ELEMENT(Path)
      61                 : 
      62                 : //----------------------------------------------------------------------
      63                 : // nsISupports methods
      64                 : 
      65               0 : NS_IMPL_ADDREF_INHERITED(nsSVGPathElement,nsSVGPathElementBase)
      66               0 : NS_IMPL_RELEASE_INHERITED(nsSVGPathElement,nsSVGPathElementBase)
      67                 : 
      68               0 : DOMCI_NODE_DATA(SVGPathElement, nsSVGPathElement)
      69                 : 
      70               0 : NS_INTERFACE_TABLE_HEAD(nsSVGPathElement)
      71               0 :   NS_NODE_INTERFACE_TABLE6(nsSVGPathElement, nsIDOMNode, nsIDOMElement,
      72                 :                            nsIDOMSVGElement, nsIDOMSVGTests,
      73                 :                            nsIDOMSVGPathElement, nsIDOMSVGAnimatedPathData)
      74               0 :   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGPathElement)
      75               0 : NS_INTERFACE_MAP_END_INHERITING(nsSVGPathElementBase)
      76                 : 
      77                 : //----------------------------------------------------------------------
      78                 : // Implementation
      79                 : 
      80               0 : nsSVGPathElement::nsSVGPathElement(already_AddRefed<nsINodeInfo> aNodeInfo)
      81               0 :   : nsSVGPathElementBase(aNodeInfo)
      82                 : {
      83               0 : }
      84                 : 
      85                 : //----------------------------------------------------------------------
      86                 : // nsIDOMNode methods
      87                 : 
      88               0 : NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGPathElement)
      89                 : 
      90                 : //----------------------------------------------------------------------
      91                 : // nsIDOMSVGPathElement methods:
      92                 : 
      93                 : /* readonly attribute nsIDOMSVGAnimatedNumber pathLength; */
      94                 : NS_IMETHODIMP
      95               0 : nsSVGPathElement::GetPathLength(nsIDOMSVGAnimatedNumber * *aPathLength)
      96                 : {
      97               0 :   return mPathLength.ToDOMAnimatedNumber(aPathLength, this);
      98                 : }
      99                 : 
     100                 : /* float getTotalLength (); */
     101                 : NS_IMETHODIMP
     102               0 : nsSVGPathElement::GetTotalLength(float *_retval)
     103                 : {
     104               0 :   *_retval = 0;
     105                 : 
     106               0 :   nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(gfxMatrix());
     107                 : 
     108               0 :   if (!flat)
     109               0 :     return NS_ERROR_FAILURE;
     110                 : 
     111               0 :   *_retval = flat->GetLength();
     112                 : 
     113               0 :   return NS_OK;
     114                 : }
     115                 : 
     116                 : /* nsIDOMSVGPoint getPointAtLength (in float distance); */
     117                 : NS_IMETHODIMP
     118               0 : nsSVGPathElement::GetPointAtLength(float distance, nsIDOMSVGPoint **_retval)
     119                 : {
     120               0 :   NS_ENSURE_FINITE(distance, NS_ERROR_ILLEGAL_VALUE);
     121                 : 
     122               0 :   nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(gfxMatrix());
     123               0 :   if (!flat)
     124               0 :     return NS_ERROR_FAILURE;
     125                 : 
     126               0 :   float totalLength = flat->GetLength();
     127               0 :   if (mPathLength.IsExplicitlySet()) {
     128               0 :     float pathLength = mPathLength.GetAnimValue();
     129               0 :     if (pathLength <= 0) {
     130               0 :       return NS_ERROR_FAILURE;
     131                 :     }
     132               0 :     distance *= totalLength / pathLength;
     133                 :   }
     134               0 :   distance = NS_MAX(0.f,         distance);
     135               0 :   distance = NS_MIN(totalLength, distance);
     136                 : 
     137               0 :   NS_ADDREF(*_retval = new DOMSVGPoint(flat->FindPoint(gfxPoint(distance, 0))));
     138               0 :   return NS_OK;
     139                 : }
     140                 : 
     141                 : /* unsigned long getPathSegAtLength (in float distance); */
     142                 : NS_IMETHODIMP
     143               0 : nsSVGPathElement::GetPathSegAtLength(float distance, PRUint32 *_retval)
     144                 : {
     145               0 :   NS_ENSURE_FINITE(distance, NS_ERROR_ILLEGAL_VALUE);
     146               0 :   *_retval = mD.GetAnimValue().GetPathSegAtLength(distance);
     147               0 :   return NS_OK;
     148                 : }
     149                 : 
     150                 : /* nsIDOMSVGPathSegClosePath createSVGPathSegClosePath (); */
     151                 : NS_IMETHODIMP
     152               0 : nsSVGPathElement::CreateSVGPathSegClosePath(nsIDOMSVGPathSegClosePath **_retval)
     153                 : {
     154               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegClosePath();
     155               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     156               0 :   return CallQueryInterface(seg, _retval);
     157                 : }
     158                 : 
     159                 : /* nsIDOMSVGPathSegMovetoAbs createSVGPathSegMovetoAbs (in float x, in float y); */
     160                 : NS_IMETHODIMP
     161               0 : nsSVGPathElement::CreateSVGPathSegMovetoAbs(float x, float y, nsIDOMSVGPathSegMovetoAbs **_retval)
     162                 : {
     163               0 :   NS_ENSURE_FINITE2(x, y, NS_ERROR_ILLEGAL_VALUE);
     164               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegMovetoAbs(x, y);
     165               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     166               0 :   return CallQueryInterface(seg, _retval);
     167                 : }
     168                 : 
     169                 : /* nsIDOMSVGPathSegMovetoRel createSVGPathSegMovetoRel (in float x, in float y); */
     170                 : NS_IMETHODIMP
     171               0 : nsSVGPathElement::CreateSVGPathSegMovetoRel(float x, float y, nsIDOMSVGPathSegMovetoRel **_retval)
     172                 : {
     173               0 :   NS_ENSURE_FINITE2(x, y, NS_ERROR_ILLEGAL_VALUE);
     174               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegMovetoRel(x, y);
     175               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     176               0 :   return CallQueryInterface(seg, _retval);
     177                 : }
     178                 : 
     179                 : /* nsIDOMSVGPathSegLinetoAbs createSVGPathSegLinetoAbs (in float x, in float y); */
     180                 : NS_IMETHODIMP
     181               0 : nsSVGPathElement::CreateSVGPathSegLinetoAbs(float x, float y, nsIDOMSVGPathSegLinetoAbs **_retval)
     182                 : {
     183               0 :   NS_ENSURE_FINITE2(x, y, NS_ERROR_ILLEGAL_VALUE);
     184               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegLinetoAbs(x, y);
     185               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     186               0 :   return CallQueryInterface(seg, _retval);
     187                 : }
     188                 : 
     189                 : /* nsIDOMSVGPathSegLinetoRel createSVGPathSegLinetoRel (in float x, in float y); */
     190                 : NS_IMETHODIMP
     191               0 : nsSVGPathElement::CreateSVGPathSegLinetoRel(float x, float y, nsIDOMSVGPathSegLinetoRel **_retval)
     192                 : {
     193               0 :   NS_ENSURE_FINITE2(x, y, NS_ERROR_ILLEGAL_VALUE);
     194               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegLinetoRel(x, y);
     195               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     196               0 :   return CallQueryInterface(seg, _retval);
     197                 : }
     198                 : 
     199                 : /* nsIDOMSVGPathSegCurvetoCubicAbs createSVGPathSegCurvetoCubicAbs (in float x, in float y, in float x1, in float y1, in float x2, in float y2); */
     200                 : NS_IMETHODIMP
     201               0 : nsSVGPathElement::CreateSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2, nsIDOMSVGPathSegCurvetoCubicAbs **_retval)
     202                 : {
     203               0 :   NS_ENSURE_FINITE6(x, y, x1, y1, x2, y2, NS_ERROR_ILLEGAL_VALUE);
     204               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegCurvetoCubicAbs(x, y, x1, y1, x2, y2);
     205               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     206               0 :   return CallQueryInterface(seg, _retval);
     207                 : }
     208                 : 
     209                 : /* nsIDOMSVGPathSegCurvetoCubicRel createSVGPathSegCurvetoCubicRel (in float x, in float y, in float x1, in float y1, in float x2, in float y2); */
     210                 : NS_IMETHODIMP
     211               0 : nsSVGPathElement::CreateSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2, nsIDOMSVGPathSegCurvetoCubicRel **_retval)
     212                 : {
     213               0 :   NS_ENSURE_FINITE6(x, y, x1, y1, x2, y2, NS_ERROR_ILLEGAL_VALUE);
     214               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegCurvetoCubicRel(x, y, x1, y1, x2, y2);
     215               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     216               0 :   return CallQueryInterface(seg, _retval);
     217                 : }
     218                 : 
     219                 : /* nsIDOMSVGPathSegCurvetoQuadraticAbs createSVGPathSegCurvetoQuadraticAbs (in float x, in float y, in float x1, in float y1); */
     220                 : NS_IMETHODIMP
     221               0 : nsSVGPathElement::CreateSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1, nsIDOMSVGPathSegCurvetoQuadraticAbs **_retval)
     222                 : {
     223               0 :   NS_ENSURE_FINITE4(x, y, x1, y1, NS_ERROR_ILLEGAL_VALUE);
     224               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegCurvetoQuadraticAbs(x, y, x1, y1);
     225               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     226               0 :   return CallQueryInterface(seg, _retval);
     227                 : }
     228                 : 
     229                 : /* nsIDOMSVGPathSegCurvetoQuadraticRel createSVGPathSegCurvetoQuadraticRel (in float x, in float y, in float x1, in float y1); */
     230                 : NS_IMETHODIMP
     231               0 : nsSVGPathElement::CreateSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1, nsIDOMSVGPathSegCurvetoQuadraticRel **_retval)
     232                 : {
     233               0 :   NS_ENSURE_FINITE4(x, y, x1, y1, NS_ERROR_ILLEGAL_VALUE);
     234               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegCurvetoQuadraticRel(x, y, x1, y1);
     235               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     236               0 :   return CallQueryInterface(seg, _retval);
     237                 : }
     238                 : 
     239                 : /* nsIDOMSVGPathSegArcAbs createSVGPathSegArcAbs (in float x, in float y, in float r1, in float r2, in float angle, in boolean largeArcFlag, in boolean sweepFlag); */
     240                 : NS_IMETHODIMP
     241               0 : nsSVGPathElement::CreateSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, nsIDOMSVGPathSegArcAbs **_retval)
     242                 : {
     243               0 :   NS_ENSURE_FINITE5(x, y, r1, r2, angle, NS_ERROR_ILLEGAL_VALUE);
     244                 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegArcAbs(x, y, r1, r2, angle,
     245               0 :                                                  largeArcFlag, sweepFlag);
     246               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     247               0 :   return CallQueryInterface(seg, _retval);
     248                 : }
     249                 : 
     250                 : /* nsIDOMSVGPathSegArcRel createSVGPathSegArcRel (in float x, in float y, in float r1, in float r2, in float angle, in boolean largeArcFlag, in boolean sweepFlag); */
     251                 : NS_IMETHODIMP
     252               0 : nsSVGPathElement::CreateSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, nsIDOMSVGPathSegArcRel **_retval)
     253                 : {
     254               0 :   NS_ENSURE_FINITE5(x, y, r1, r2, angle, NS_ERROR_ILLEGAL_VALUE);
     255                 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegArcRel(x, y, r1, r2, angle,
     256               0 :                                                  largeArcFlag, sweepFlag);
     257               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     258               0 :   return CallQueryInterface(seg, _retval);
     259                 : }
     260                 : 
     261                 : /* nsIDOMSVGPathSegLinetoHorizontalAbs createSVGPathSegLinetoHorizontalAbs (in float x); */
     262                 : NS_IMETHODIMP
     263               0 : nsSVGPathElement::CreateSVGPathSegLinetoHorizontalAbs(float x, nsIDOMSVGPathSegLinetoHorizontalAbs **_retval)
     264                 : {
     265               0 :   NS_ENSURE_FINITE(x, NS_ERROR_ILLEGAL_VALUE);
     266               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegLinetoHorizontalAbs(x);
     267               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     268               0 :   return CallQueryInterface(seg, _retval);
     269                 : }
     270                 : 
     271                 : /* nsIDOMSVGPathSegLinetoHorizontalRel createSVGPathSegLinetoHorizontalRel (in float x); */
     272                 : NS_IMETHODIMP
     273               0 : nsSVGPathElement::CreateSVGPathSegLinetoHorizontalRel(float x, nsIDOMSVGPathSegLinetoHorizontalRel **_retval)
     274                 : {
     275               0 :   NS_ENSURE_FINITE(x, NS_ERROR_ILLEGAL_VALUE);
     276               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegLinetoHorizontalRel(x);
     277               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     278               0 :   return CallQueryInterface(seg, _retval);
     279                 : }
     280                 : 
     281                 : /* nsIDOMSVGPathSegLinetoVerticalAbs createSVGPathSegLinetoVerticalAbs (in float y); */
     282                 : NS_IMETHODIMP
     283               0 : nsSVGPathElement::CreateSVGPathSegLinetoVerticalAbs(float y, nsIDOMSVGPathSegLinetoVerticalAbs **_retval)
     284                 : {
     285               0 :   NS_ENSURE_FINITE(y, NS_ERROR_ILLEGAL_VALUE);
     286               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegLinetoVerticalAbs(y);
     287               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     288               0 :   return CallQueryInterface(seg, _retval);
     289                 : }
     290                 : 
     291                 : /* nsIDOMSVGPathSegLinetoVerticalRel createSVGPathSegLinetoVerticalRel (in float y); */
     292                 : NS_IMETHODIMP
     293               0 : nsSVGPathElement::CreateSVGPathSegLinetoVerticalRel(float y, nsIDOMSVGPathSegLinetoVerticalRel **_retval)
     294                 : {
     295               0 :   NS_ENSURE_FINITE(y, NS_ERROR_ILLEGAL_VALUE);
     296               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegLinetoVerticalRel(y);
     297               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     298               0 :   return CallQueryInterface(seg, _retval);
     299                 : }
     300                 : 
     301                 : /* nsIDOMSVGPathSegCurvetoCubicSmoothAbs createSVGPathSegCurvetoCubicSmoothAbs (in float x, in float y, in float x2, in float y2); */
     302                 : NS_IMETHODIMP
     303               0 : nsSVGPathElement::CreateSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2, nsIDOMSVGPathSegCurvetoCubicSmoothAbs **_retval)
     304                 : {
     305               0 :   NS_ENSURE_FINITE4(x, y, x2, y2, NS_ERROR_ILLEGAL_VALUE);
     306               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegCurvetoCubicSmoothAbs(x, y, x2, y2);
     307               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     308               0 :   return CallQueryInterface(seg, _retval);
     309                 : }
     310                 : 
     311                 : /* nsIDOMSVGPathSegCurvetoCubicSmoothRel createSVGPathSegCurvetoCubicSmoothRel (in float x, in float y, in float x2, in float y2); */
     312                 : NS_IMETHODIMP
     313               0 : nsSVGPathElement::CreateSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2, nsIDOMSVGPathSegCurvetoCubicSmoothRel **_retval)
     314                 : {
     315               0 :   NS_ENSURE_FINITE4(x, y, x2, y2, NS_ERROR_ILLEGAL_VALUE);
     316               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegCurvetoCubicSmoothRel(x, y, x2, y2);
     317               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     318               0 :   return CallQueryInterface(seg, _retval);
     319                 : }
     320                 : 
     321                 : /* nsIDOMSVGPathSegCurvetoQuadraticSmoothAbs createSVGPathSegCurvetoQuadraticSmoothAbs (in float x, in float y); */
     322                 : NS_IMETHODIMP
     323               0 : nsSVGPathElement::CreateSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y, nsIDOMSVGPathSegCurvetoQuadraticSmoothAbs **_retval)
     324                 : {
     325               0 :   NS_ENSURE_FINITE2(x, y, NS_ERROR_ILLEGAL_VALUE);
     326               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegCurvetoQuadraticSmoothAbs(x, y);
     327               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     328               0 :   return CallQueryInterface(seg, _retval);
     329                 : }
     330                 : 
     331                 : /* nsIDOMSVGPathSegCurvetoQuadraticSmoothRel createSVGPathSegCurvetoQuadraticSmoothRel (in float x, in float y); */
     332                 : NS_IMETHODIMP
     333               0 : nsSVGPathElement::CreateSVGPathSegCurvetoQuadraticSmoothRel(float x, float y, nsIDOMSVGPathSegCurvetoQuadraticSmoothRel **_retval)
     334                 : {
     335               0 :   NS_ENSURE_FINITE2(x, y, NS_ERROR_ILLEGAL_VALUE);
     336               0 :   nsIDOMSVGPathSeg* seg = NS_NewSVGPathSegCurvetoQuadraticSmoothRel(x, y);
     337               0 :   NS_ENSURE_TRUE(seg, NS_ERROR_OUT_OF_MEMORY);
     338               0 :   return CallQueryInterface(seg, _retval);
     339                 : }
     340                 : 
     341                 : //----------------------------------------------------------------------
     342                 : // nsSVGElement methods
     343                 : 
     344                 : /* virtual */ bool
     345               0 : nsSVGPathElement::HasValidDimensions() const
     346                 : {
     347               0 :   return !mD.GetAnimValue().IsEmpty();
     348                 : }
     349                 : 
     350                 : nsSVGElement::NumberAttributesInfo
     351               0 : nsSVGPathElement::GetNumberInfo()
     352                 : {
     353               0 :   return NumberAttributesInfo(&mPathLength, &sNumberInfo, 1);
     354                 : }
     355                 : 
     356                 : //----------------------------------------------------------------------
     357                 : // nsIDOMSVGAnimatedPathData methods:
     358                 : 
     359                 : /* readonly attribute nsIDOMSVGPathSegList pathSegList; */
     360               0 : NS_IMETHODIMP nsSVGPathElement::GetPathSegList(nsIDOMSVGPathSegList * *aPathSegList)
     361                 : {
     362               0 :   void *key = mD.GetBaseValKey();
     363               0 :   *aPathSegList = DOMSVGPathSegList::GetDOMWrapper(key, this, false).get();
     364               0 :   return *aPathSegList ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
     365                 : }
     366                 : 
     367                 : /* readonly attribute nsIDOMSVGPathSegList normalizedPathSegList; */
     368               0 : NS_IMETHODIMP nsSVGPathElement::GetNormalizedPathSegList(nsIDOMSVGPathSegList * *aNormalizedPathSegList)
     369                 : {
     370               0 :   return NS_ERROR_NOT_IMPLEMENTED;
     371                 : }
     372                 : 
     373                 : /* readonly attribute nsIDOMSVGPathSegList animatedPathSegList; */
     374               0 : NS_IMETHODIMP nsSVGPathElement::GetAnimatedPathSegList(nsIDOMSVGPathSegList * *aAnimatedPathSegList)
     375                 : {
     376               0 :   void *key = mD.GetAnimValKey();
     377                 :   *aAnimatedPathSegList =
     378               0 :     DOMSVGPathSegList::GetDOMWrapper(key, this, true).get();
     379               0 :   return *aAnimatedPathSegList ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
     380                 : }
     381                 : 
     382                 : /* readonly attribute nsIDOMSVGPathSegList animatedNormalizedPathSegList; */
     383               0 : NS_IMETHODIMP nsSVGPathElement::GetAnimatedNormalizedPathSegList(nsIDOMSVGPathSegList * *aAnimatedNormalizedPathSegList)
     384                 : {
     385               0 :   return NS_ERROR_NOT_IMPLEMENTED;
     386                 : }
     387                 : 
     388                 : //----------------------------------------------------------------------
     389                 : // nsIContent methods
     390                 : 
     391                 : NS_IMETHODIMP_(bool)
     392               0 : nsSVGPathElement::IsAttributeMapped(const nsIAtom* name) const
     393                 : {
     394                 :   static const MappedAttributeEntry* const map[] = {
     395                 :     sMarkersMap
     396                 :   };
     397                 : 
     398               0 :   return FindAttributeDependence(name, map) ||
     399               0 :     nsSVGPathElementBase::IsAttributeMapped(name);
     400                 : }
     401                 : 
     402                 : already_AddRefed<gfxFlattenedPath>
     403               0 : nsSVGPathElement::GetFlattenedPath(const gfxMatrix &aMatrix)
     404                 : {
     405               0 :   return mD.GetAnimValue().ToFlattenedPath(aMatrix);
     406                 : }
     407                 : 
     408                 : //----------------------------------------------------------------------
     409                 : // nsSVGPathGeometryElement methods
     410                 : 
     411                 : bool
     412               0 : nsSVGPathElement::AttributeDefinesGeometry(const nsIAtom *aName)
     413                 : {
     414                 :   return aName == nsGkAtoms::d ||
     415               0 :          aName == nsGkAtoms::pathLength;
     416                 : }
     417                 : 
     418                 : bool
     419               0 : nsSVGPathElement::IsMarkable()
     420                 : {
     421               0 :   return true;
     422                 : }
     423                 : 
     424                 : void
     425               0 : nsSVGPathElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
     426                 : {
     427               0 :   mD.GetAnimValue().GetMarkerPositioningData(aMarks);
     428               0 : }
     429                 : 
     430                 : void
     431               0 : nsSVGPathElement::ConstructPath(gfxContext *aCtx)
     432                 : {
     433               0 :   mD.GetAnimValue().ConstructPath(aCtx);
     434               0 : }
     435                 : 
     436                 : gfxFloat
     437               0 : nsSVGPathElement::GetPathLengthScale(PathLengthScaleForType aFor)
     438                 : {
     439               0 :   NS_ABORT_IF_FALSE(aFor == eForTextPath || aFor == eForStroking,
     440                 :                     "Unknown enum");
     441               0 :   if (mPathLength.IsExplicitlySet()) {
     442               0 :     float authorsPathLengthEstimate = mPathLength.GetAnimValue();
     443               0 :     if (authorsPathLengthEstimate > 0) {
     444               0 :       gfxMatrix matrix;
     445               0 :       if (aFor == eForTextPath) {
     446                 :         // For textPath, a transform on the referenced path affects the
     447                 :         // textPath layout, so when calculating the actual path length
     448                 :         // we need to take that into account.
     449               0 :         matrix = PrependLocalTransformsTo(matrix);
     450                 :       }
     451               0 :       nsRefPtr<gfxFlattenedPath> path = GetFlattenedPath(matrix);
     452               0 :       if (path) {
     453               0 :         return path->GetLength() / authorsPathLengthEstimate;
     454                 :       }
     455                 :     }
     456                 :   }
     457               0 :   return 1.0;
     458                 : }

Generated by: LCOV version 1.7