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

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

Issue 1074813002: Remove isSupportedAttribute in svg (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: invalidation guard tweaks Created 5 years, 8 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 | Annotate | Revision Log
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 PassRefPtrWillBeRawPtr<SVGPathSegCurvetoQuadraticSmoothAbs> SVGPathElement::crea teSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y) 193 PassRefPtrWillBeRawPtr<SVGPathSegCurvetoQuadraticSmoothAbs> SVGPathElement::crea teSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y)
194 { 194 {
195 return SVGPathSegCurvetoQuadraticSmoothAbs::create(0, x, y); 195 return SVGPathSegCurvetoQuadraticSmoothAbs::create(0, x, y);
196 } 196 }
197 197
198 PassRefPtrWillBeRawPtr<SVGPathSegCurvetoQuadraticSmoothRel> SVGPathElement::crea teSVGPathSegCurvetoQuadraticSmoothRel(float x, float y) 198 PassRefPtrWillBeRawPtr<SVGPathSegCurvetoQuadraticSmoothRel> SVGPathElement::crea teSVGPathSegCurvetoQuadraticSmoothRel(float x, float y)
199 { 199 {
200 return SVGPathSegCurvetoQuadraticSmoothRel::create(0, x, y); 200 return SVGPathSegCurvetoQuadraticSmoothRel::create(0, x, y);
201 } 201 }
202 202
203 bool SVGPathElement::isSupportedAttribute(const QualifiedName& attrName)
204 {
205 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
206 if (supportedAttributes.isEmpty()) {
207 supportedAttributes.add(SVGNames::dAttr);
208 supportedAttributes.add(SVGNames::pathLengthAttr);
209 }
210 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
211 }
212
213 void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName) 203 void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName)
214 { 204 {
215 if (!isSupportedAttribute(attrName)) { 205 if (attrName == SVGNames::dAttr || attrName == SVGNames::pathLengthAttr) {
216 SVGGeometryElement::svgAttributeChanged(attrName); 206 SVGElement::InvalidationGuard invalidationGuard(this);
207
208 LayoutSVGShape* renderer = toLayoutSVGShape(this->layoutObject());
209
210 if (attrName == SVGNames::dAttr) {
211 if (renderer)
212 renderer->setNeedsShapeUpdate();
213
214 invalidateMPathDependencies();
215 }
216
217 if (renderer)
218 markForLayoutAndParentResourceInvalidation(renderer);
219
217 return; 220 return;
218 } 221 }
219 222
220 SVGElement::InvalidationGuard invalidationGuard(this); 223 SVGGeometryElement::svgAttributeChanged(attrName);
221
222 LayoutSVGShape* renderer = toLayoutSVGShape(this->layoutObject());
223
224 if (attrName == SVGNames::dAttr) {
225 if (renderer)
226 renderer->setNeedsShapeUpdate();
227
228 invalidateMPathDependencies();
229 }
230
231 if (renderer)
232 markForLayoutAndParentResourceInvalidation(renderer);
233 } 224 }
234 225
235 void SVGPathElement::invalidateMPathDependencies() 226 void SVGPathElement::invalidateMPathDependencies()
236 { 227 {
237 // <mpath> can only reference <path> but this dependency is not handled in 228 // <mpath> can only reference <path> but this dependency is not handled in
238 // markForLayoutAndParentResourceInvalidation so we update any mpath depende ncies manually. 229 // markForLayoutAndParentResourceInvalidation so we update any mpath depende ncies manually.
239 if (SVGElementSet* dependencies = setOfIncomingReferences()) { 230 if (SVGElementSet* dependencies = setOfIncomingReferences()) {
240 for (SVGElement* element : *dependencies) { 231 for (SVGElement* element : *dependencies) {
241 if (isSVGMPathElement(*element)) 232 if (isSVGMPathElement(*element))
242 toSVGMPathElement(element)->targetPathChanged(); 233 toSVGMPathElement(element)->targetPathChanged();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 271
281 // FIXME: Eventually we should support getBBox for detached elements. 272 // FIXME: Eventually we should support getBBox for detached elements.
282 if (!layoutObject()) 273 if (!layoutObject())
283 return FloatRect(); 274 return FloatRect();
284 275
285 LayoutSVGShape* renderer = toLayoutSVGShape(this->layoutObject()); 276 LayoutSVGShape* renderer = toLayoutSVGShape(this->layoutObject());
286 return renderer->path().boundingRect(); 277 return renderer->path().boundingRect();
287 } 278 }
288 279
289 } // namespace blink 280 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698