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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGShape.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 | « no previous file | third_party/WebKit/Source/core/svg/SVGPathElement.h » ('j') | 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, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org>
4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. 5 * Copyright (C) 2009 Google, Inc.
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> 8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com>
9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> 9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>
10 * Copyright (C) 2011 University of Szeged 10 * Copyright (C) 2011 University of Szeged
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 { 60 {
61 if (!m_path) 61 if (!m_path)
62 m_path = adoptPtr(new Path()); 62 m_path = adoptPtr(new Path());
63 *m_path = toSVGGeometryElement(element())->asPath(); 63 *m_path = toSVGGeometryElement(element())->asPath();
64 if (m_rareData.get()) 64 if (m_rareData.get())
65 m_rareData->m_cachedNonScalingStrokePath.clear(); 65 m_rareData->m_cachedNonScalingStrokePath.clear();
66 } 66 }
67 67
68 float LayoutSVGShape::dashScaleFactor() const 68 float LayoutSVGShape::dashScaleFactor() const
69 { 69 {
70 if (!isSVGPathElement(element())) 70 if (!isSVGPathElement(element())
71 || !styleRef().svgStyle().strokeDashArray()->size())
71 return 1; 72 return 1;
72 SVGPathElement& pathElement = toSVGPathElement(*element()); 73 return toSVGPathElement(*element()).pathLengthScaleFactor();
73 if (!pathElement.pathLength()->isSpecified())
74 return 1;
75 const SVGComputedStyle& svgStyle = styleRef().svgStyle();
76 float authorPathLength = pathElement.pathLength()->currentValue()->value();
77 if (authorPathLength < 0 || !svgStyle.strokeDashArray()->size())
78 return 1;
79 if (!authorPathLength)
80 return 0;
81 // Since we know this is a <path> element, we also know the source of the
82 // path - the 'd' presentation attribute. Since the StylePath already
83 // caches the computed path length for use, use that here directly.
84 float computedPathLength = svgStyle.d()->length();
85 if (!computedPathLength)
86 return 1;
87 return computedPathLength / authorPathLength;
88 } 74 }
89 75
90 void LayoutSVGShape::updateShapeFromElement() 76 void LayoutSVGShape::updateShapeFromElement()
91 { 77 {
92 createPath(); 78 createPath();
93 79
94 m_fillBoundingBox = calculateObjectBoundingBox(); 80 m_fillBoundingBox = calculateObjectBoundingBox();
95 m_strokeBoundingBox = calculateStrokeBoundingBox(); 81 m_strokeBoundingBox = calculateStrokeBoundingBox();
96 } 82 }
97 83
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 305 }
320 306
321 LayoutSVGShapeRareData& LayoutSVGShape::ensureRareData() const 307 LayoutSVGShapeRareData& LayoutSVGShape::ensureRareData() const
322 { 308 {
323 if (!m_rareData) 309 if (!m_rareData)
324 m_rareData = adoptPtr(new LayoutSVGShapeRareData()); 310 m_rareData = adoptPtr(new LayoutSVGShapeRareData());
325 return *m_rareData.get(); 311 return *m_rareData.get();
326 } 312 }
327 313
328 } // namespace blink 314 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/svg/SVGPathElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698