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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGPathElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/svg/SVGPathElement.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGPathElement.cpp b/third_party/WebKit/Source/core/svg/SVGPathElement.cpp
index 5cd714a5d5b4bd2f451a88ae857dfacac7992fcb..2833019000ec367ba6f9a313be3c9cf7006b5617 100644
--- a/third_party/WebKit/Source/core/svg/SVGPathElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGPathElement.cpp
@@ -68,14 +68,31 @@ DEFINE_TRACE(SVGPathElement)
DEFINE_NODE_FACTORY(SVGPathElement)
-Path SVGPathElement::asPath() const
+const StylePath* SVGPathElement::stylePath() const
{
- if (layoutObject()) {
- const SVGComputedStyle& svgStyle = layoutObject()->styleRef().svgStyle();
- return svgStyle.d()->path();
- }
+ if (LayoutObject* layoutObject = this->layoutObject())
+ return layoutObject->styleRef().svgStyle().d();
+ return m_path->currentValue()->pathValue()->cachedPath();
+}
- return m_path->currentValue()->pathValue()->cachedPath()->path();
+float SVGPathElement::pathLengthScaleFactor() const
+{
+ if (!pathLength()->isSpecified())
+ return 1;
+ float authorPathLength = pathLength()->currentValue()->value();
+ if (authorPathLength < 0)
+ return 1;
+ if (!authorPathLength)
+ return 0;
+ float computedPathLength = stylePath()->length();
+ if (!computedPathLength)
+ return 1;
+ return computedPathLength / authorPathLength;
+}
+
+Path SVGPathElement::asPath() const
+{
+ return stylePath()->path();
}
const SVGPathByteStream& SVGPathElement::pathByteStream() const
« 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