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

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

Issue 1471943003: Introduce SVGPathQuery to hold SVG path query methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years 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
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,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #include "config.h" 21 #include "config.h"
22 #include "core/svg/SVGPathElement.h" 22 #include "core/svg/SVGPathElement.h"
23 23
24 #include "core/layout/svg/LayoutSVGPath.h" 24 #include "core/layout/svg/LayoutSVGPath.h"
25 #include "core/svg/SVGDocumentExtensions.h" 25 #include "core/svg/SVGDocumentExtensions.h"
26 #include "core/svg/SVGMPathElement.h" 26 #include "core/svg/SVGMPathElement.h"
27 #include "core/svg/SVGPathUtilities.h" 27 #include "core/svg/SVGPathQuery.h"
28 #include "core/svg/SVGPointTearOff.h" 28 #include "core/svg/SVGPointTearOff.h"
29 29
30 namespace blink { 30 namespace blink {
31 31
32 class SVGAnimatedPathLength final : public SVGAnimatedNumber { 32 class SVGAnimatedPathLength final : public SVGAnimatedNumber {
33 public: 33 public:
34 static PassRefPtrWillBeRawPtr<SVGAnimatedPathLength> create(SVGPathElement* contextElement) 34 static PassRefPtrWillBeRawPtr<SVGAnimatedPathLength> create(SVGPathElement* contextElement)
35 { 35 {
36 return adoptRefWillBeNoop(new SVGAnimatedPathLength(contextElement)); 36 return adoptRefWillBeNoop(new SVGAnimatedPathLength(contextElement));
37 } 37 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 { 74 {
75 // If this is a <use> instance, return the referenced path to maximize geome try sharing. 75 // If this is a <use> instance, return the referenced path to maximize geome try sharing.
76 if (const SVGElement* element = correspondingElement()) 76 if (const SVGElement* element = correspondingElement())
77 return toSVGPathElement(element)->asPath(); 77 return toSVGPathElement(element)->asPath();
78 78
79 return m_path->currentValue()->path(); 79 return m_path->currentValue()->path();
80 } 80 }
81 81
82 float SVGPathElement::getTotalLength() 82 float SVGPathElement::getTotalLength()
83 { 83 {
84 return getTotalLengthOfSVGPathByteStream(pathByteStream()); 84 return SVGPathQuery(pathByteStream()).getTotalLength();
85 } 85 }
86 86
87 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGPathElement::getPointAtLength(float l ength) 87 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGPathElement::getPointAtLength(float l ength)
88 { 88 {
89 FloatPoint point = getPointAtLengthOfSVGPathByteStream(pathByteStream(), len gth); 89 FloatPoint point = SVGPathQuery(pathByteStream()).getPointAtLength(length);
90 return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnim Val); 90 return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnim Val);
91 } 91 }
92 92
93 unsigned SVGPathElement::getPathSegAtLength(float length) 93 unsigned SVGPathElement::getPathSegAtLength(float length)
94 { 94 {
95 return getSVGPathSegAtLengthFromSVGPathByteStream(pathByteStream(), length); 95 return SVGPathQuery(pathByteStream()).getPathSegIndexAtLength(length);
96 } 96 }
97 97
98 void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName) 98 void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName)
99 { 99 {
100 if (attrName == SVGNames::dAttr || attrName == SVGNames::pathLengthAttr) { 100 if (attrName == SVGNames::dAttr || attrName == SVGNames::pathLengthAttr) {
101 SVGElement::InvalidationGuard invalidationGuard(this); 101 SVGElement::InvalidationGuard invalidationGuard(this);
102 102
103 LayoutSVGShape* layoutObject = toLayoutSVGShape(this->layoutObject()); 103 LayoutSVGShape* layoutObject = toLayoutSVGShape(this->layoutObject());
104 104
105 if (attrName == SVGNames::dAttr) { 105 if (attrName == SVGNames::dAttr) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return InsertionDone; 137 return InsertionDone;
138 } 138 }
139 139
140 void SVGPathElement::removedFrom(ContainerNode* rootParent) 140 void SVGPathElement::removedFrom(ContainerNode* rootParent)
141 { 141 {
142 SVGGeometryElement::removedFrom(rootParent); 142 SVGGeometryElement::removedFrom(rootParent);
143 invalidateMPathDependencies(); 143 invalidateMPathDependencies();
144 } 144 }
145 145
146 } // namespace blink 146 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGPathConsumer.h ('k') | third_party/WebKit/Source/core/svg/SVGPathParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698