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

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

Issue 1074813002: Remove isSupportedAttribute in svg (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixups 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 { 43 {
44 visitor->trace(m_cx); 44 visitor->trace(m_cx);
45 visitor->trace(m_cy); 45 visitor->trace(m_cy);
46 visitor->trace(m_rx); 46 visitor->trace(m_rx);
47 visitor->trace(m_ry); 47 visitor->trace(m_ry);
48 SVGGeometryElement::trace(visitor); 48 SVGGeometryElement::trace(visitor);
49 } 49 }
50 50
51 DEFINE_NODE_FACTORY(SVGEllipseElement) 51 DEFINE_NODE_FACTORY(SVGEllipseElement)
52 52
53 bool SVGEllipseElement::isSupportedAttribute(const QualifiedName& attrName)
54 {
55 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
56 if (supportedAttributes.isEmpty()) {
57 supportedAttributes.add(SVGNames::cxAttr);
58 supportedAttributes.add(SVGNames::cyAttr);
59 supportedAttributes.add(SVGNames::rxAttr);
60 supportedAttributes.add(SVGNames::ryAttr);
61 }
62 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
63 }
64
65 bool SVGEllipseElement::isPresentationAttribute(const QualifiedName& attrName) c onst 53 bool SVGEllipseElement::isPresentationAttribute(const QualifiedName& attrName) c onst
66 { 54 {
67 if (attrName == SVGNames::cxAttr || attrName == SVGNames::cyAttr 55 if (attrName == SVGNames::cxAttr || attrName == SVGNames::cyAttr
68 || attrName == SVGNames::rxAttr || attrName == SVGNames::ryAttr) 56 || attrName == SVGNames::rxAttr || attrName == SVGNames::ryAttr)
69 return true; 57 return true;
70 return SVGGeometryElement::isPresentationAttribute(attrName); 58 return SVGGeometryElement::isPresentationAttribute(attrName);
71 } 59 }
72 60
73 bool SVGEllipseElement::isPresentationAttributeWithSVGDOM(const QualifiedName& a ttrName) const 61 bool SVGEllipseElement::isPresentationAttributeWithSVGDOM(const QualifiedName& a ttrName) const
74 { 62 {
(...skipping 14 matching lines...) Expand all
89 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyRx, * m_rx->currentValue()); 77 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyRx, * m_rx->currentValue());
90 else if (property == m_ry) 78 else if (property == m_ry)
91 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyRy, * m_ry->currentValue()); 79 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyRy, * m_ry->currentValue());
92 else 80 else
93 SVGGeometryElement::collectStyleForPresentationAttribute(name, value, st yle); 81 SVGGeometryElement::collectStyleForPresentationAttribute(name, value, st yle);
94 } 82 }
95 83
96 84
97 void SVGEllipseElement::svgAttributeChanged(const QualifiedName& attrName) 85 void SVGEllipseElement::svgAttributeChanged(const QualifiedName& attrName)
98 { 86 {
99 if (!isSupportedAttribute(attrName)) { 87 SVGElement::InvalidationGuard invalidationGuard(this);
100 SVGGeometryElement::svgAttributeChanged(attrName); 88
89 bool lengthAttrs =
90 attrName == SVGNames::cxAttr || attrName == SVGNames::cyAttr
91 || attrName == SVGNames::rxAttr || attrName == SVGNames::ryAttr;
92
93 if (lengthAttrs) {
94 invalidateSVGPresentationAttributeStyle();
95 setNeedsStyleRecalc(LocalStyleChange,
96 StyleChangeReasonForTracing::fromAttribute(attrName));
97 updateRelativeLengthsInformation();
98 }
99
100 if (lengthAttrs) {
fs 2015/04/10 14:25:24 Join these two blocks, and then put the Invalidati
Erik Dahlström (inactive) 2015/04/10 15:33:44 Done.
101 LayoutSVGShape* object = toLayoutSVGShape(this->layoutObject());
102 if (!object)
103 return;
104
105 object->setNeedsShapeUpdate();
106 markForLayoutAndParentResourceInvalidation(object);
101 return; 107 return;
102 } 108 }
103 109
104 SVGElement::InvalidationGuard invalidationGuard(this); 110 SVGGeometryElement::svgAttributeChanged(attrName);
105
106 invalidateSVGPresentationAttributeStyle();
107 setNeedsStyleRecalc(LocalStyleChange,
108 StyleChangeReasonForTracing::fromAttribute(attrName));
109 updateRelativeLengthsInformation();
110
111 LayoutSVGShape* renderer = toLayoutSVGShape(this->layoutObject());
112 if (!renderer)
113 return;
114
115 renderer->setNeedsShapeUpdate();
116 markForLayoutAndParentResourceInvalidation(renderer);
117 } 111 }
118 112
119 bool SVGEllipseElement::selfHasRelativeLengths() const 113 bool SVGEllipseElement::selfHasRelativeLengths() const
120 { 114 {
121 return m_cx->currentValue()->isRelative() 115 return m_cx->currentValue()->isRelative()
122 || m_cy->currentValue()->isRelative() 116 || m_cy->currentValue()->isRelative()
123 || m_rx->currentValue()->isRelative() 117 || m_rx->currentValue()->isRelative()
124 || m_ry->currentValue()->isRelative(); 118 || m_ry->currentValue()->isRelative();
125 } 119 }
126 120
127 LayoutObject* SVGEllipseElement::createLayoutObject(const ComputedStyle&) 121 LayoutObject* SVGEllipseElement::createLayoutObject(const ComputedStyle&)
128 { 122 {
129 return new LayoutSVGEllipse(this); 123 return new LayoutSVGEllipse(this);
130 } 124 }
131 125
132 } // namespace blink 126 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698