Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGPathElement.cpp

Issue 1680183002: Move pathLength scale-factor computation to SVGPathElement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGPathElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 DEFINE_TRACE(SVGPathElement) 62 DEFINE_TRACE(SVGPathElement)
63 { 63 {
64 visitor->trace(m_pathLength); 64 visitor->trace(m_pathLength);
65 visitor->trace(m_path); 65 visitor->trace(m_path);
66 SVGGeometryElement::trace(visitor); 66 SVGGeometryElement::trace(visitor);
67 } 67 }
68 68
69 DEFINE_NODE_FACTORY(SVGPathElement) 69 DEFINE_NODE_FACTORY(SVGPathElement)
70 70
71 const StylePath* SVGPathElement::stylePath() const
72 {
73 if (LayoutObject* layoutObject = this->layoutObject())
74 return layoutObject->styleRef().svgStyle().d();
75 return m_path->currentValue()->pathValue()->cachedPath();
76 }
77
78 float SVGPathElement::pathLengthScaleFactor() const
79 {
80 if (!pathLength()->isSpecified())
81 return 1;
82 float authorPathLength = pathLength()->currentValue()->value();
83 if (authorPathLength < 0)
84 return 1;
85 if (!authorPathLength)
86 return 0;
87 float computedPathLength = stylePath()->length();
88 if (!computedPathLength)
89 return 1;
90 return computedPathLength / authorPathLength;
91 }
92
71 Path SVGPathElement::asPath() const 93 Path SVGPathElement::asPath() const
72 { 94 {
73 if (layoutObject()) { 95 return stylePath()->path();
74 const SVGComputedStyle& svgStyle = layoutObject()->styleRef().svgStyle() ;
75 return svgStyle.d()->path();
76 }
77
78 return m_path->currentValue()->pathValue()->cachedPath()->path();
79 } 96 }
80 97
81 const SVGPathByteStream& SVGPathElement::pathByteStream() const 98 const SVGPathByteStream& SVGPathElement::pathByteStream() const
82 { 99 {
83 if (layoutObject()) { 100 if (layoutObject()) {
84 const SVGComputedStyle& svgStyle = layoutObject()->styleRef().svgStyle() ; 101 const SVGComputedStyle& svgStyle = layoutObject()->styleRef().svgStyle() ;
85 return svgStyle.d()->byteStream(); 102 return svgStyle.d()->byteStream();
86 } 103 }
87 104
88 return m_path->currentValue()->byteStream(); 105 return m_path->currentValue()->byteStream();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return InsertionDone; 199 return InsertionDone;
183 } 200 }
184 201
185 void SVGPathElement::removedFrom(ContainerNode* rootParent) 202 void SVGPathElement::removedFrom(ContainerNode* rootParent)
186 { 203 {
187 SVGGeometryElement::removedFrom(rootParent); 204 SVGGeometryElement::removedFrom(rootParent);
188 invalidateMPathDependencies(); 205 invalidateMPathDependencies();
189 } 206 }
190 207
191 } // namespace blink 208 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGPathElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698