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

Side by Side Diff: Source/core/svg/SVGUseElement.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, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> 2 * Copyright (C) 2004, 2005, 2006, 2007, 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 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
6 * Copyright (C) 2012 University of Szeged 6 * Copyright (C) 2012 University of Szeged
7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org> 7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org>
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 { 82 {
83 visitor->trace(m_x); 83 visitor->trace(m_x);
84 visitor->trace(m_y); 84 visitor->trace(m_y);
85 visitor->trace(m_width); 85 visitor->trace(m_width);
86 visitor->trace(m_height); 86 visitor->trace(m_height);
87 visitor->trace(m_targetElementInstance); 87 visitor->trace(m_targetElementInstance);
88 SVGGraphicsElement::trace(visitor); 88 SVGGraphicsElement::trace(visitor);
89 SVGURIReference::trace(visitor); 89 SVGURIReference::trace(visitor);
90 } 90 }
91 91
92 bool SVGUseElement::isSupportedAttribute(const QualifiedName& attrName)
93 {
94 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
95 if (supportedAttributes.isEmpty()) {
96 SVGURIReference::addSupportedAttributes(supportedAttributes);
97 supportedAttributes.add(SVGNames::xAttr);
98 supportedAttributes.add(SVGNames::yAttr);
99 supportedAttributes.add(SVGNames::widthAttr);
100 supportedAttributes.add(SVGNames::heightAttr);
101 }
102 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
103 }
104
105 #if ENABLE(ASSERT) 92 #if ENABLE(ASSERT)
106 static inline bool isWellFormedDocument(Document* document) 93 static inline bool isWellFormedDocument(Document* document)
107 { 94 {
108 if (document->isXMLDocument()) 95 if (document->isXMLDocument())
109 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed() ; 96 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed() ;
110 return true; 97 return true;
111 } 98 }
112 #endif 99 #endif
113 100
114 Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode* ro otParent) 101 Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode* ro otParent)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (property == m_x) 183 if (property == m_x)
197 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyX, *m _x->currentValue()); 184 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyX, *m _x->currentValue());
198 else if (property == m_y) 185 else if (property == m_y)
199 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyY, *m _y->currentValue()); 186 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyY, *m _y->currentValue());
200 else 187 else
201 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle); 188 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle);
202 } 189 }
203 190
204 void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName) 191 void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName)
205 { 192 {
206 if (!isSupportedAttribute(attrName)) {
207 SVGGraphicsElement::svgAttributeChanged(attrName);
208 return;
209 }
210
211 SVGElement::InvalidationGuard invalidationGuard(this);
212
213 if (attrName == SVGNames::xAttr 193 if (attrName == SVGNames::xAttr
214 || attrName == SVGNames::yAttr) { 194 || attrName == SVGNames::yAttr) {
215 invalidateSVGPresentationAttributeStyle(); 195 invalidateSVGPresentationAttributeStyle();
216 setNeedsStyleRecalc(LocalStyleChange, 196 setNeedsStyleRecalc(LocalStyleChange,
217 StyleChangeReasonForTracing::fromAttribute(attrName)); 197 StyleChangeReasonForTracing::fromAttribute(attrName));
218 } 198 }
219 199
220 LayoutObject* renderer = this->layoutObject(); 200 LayoutObject* renderer = this->layoutObject();
221 if (attrName == SVGNames::xAttr 201 if (attrName == SVGNames::xAttr
222 || attrName == SVGNames::yAttr 202 || attrName == SVGNames::yAttr
223 || attrName == SVGNames::widthAttr 203 || attrName == SVGNames::widthAttr
224 || attrName == SVGNames::heightAttr) { 204 || attrName == SVGNames::heightAttr) {
205 SVGElement::InvalidationGuard invalidationGuard(this);
225 updateRelativeLengthsInformation(); 206 updateRelativeLengthsInformation();
226 if (m_targetElementInstance) { 207 if (m_targetElementInstance) {
227 ASSERT(m_targetElementInstance->correspondingElement()); 208 ASSERT(m_targetElementInstance->correspondingElement());
228 transferUseWidthAndHeightIfNeeded(*this, m_targetElementInstance.get (), *m_targetElementInstance->correspondingElement()); 209 transferUseWidthAndHeightIfNeeded(*this, m_targetElementInstance.get (), *m_targetElementInstance->correspondingElement());
229 } 210 }
230 if (renderer) 211 if (renderer)
231 markForLayoutAndParentResourceInvalidation(renderer); 212 markForLayoutAndParentResourceInvalidation(renderer);
232 return; 213 return;
233 } 214 }
234 215
235 if (SVGURIReference::isKnownAttribute(attrName)) { 216 if (SVGURIReference::isKnownAttribute(attrName)) {
217 SVGElement::InvalidationGuard invalidationGuard(this);
236 bool isExternalReference = isExternalURIReference(hrefString(), document ()); 218 bool isExternalReference = isExternalURIReference(hrefString(), document ());
237 if (isExternalReference) { 219 if (isExternalReference) {
238 KURL url = document().completeURL(hrefString()); 220 KURL url = document().completeURL(hrefString());
239 if (url.hasFragmentIdentifier()) { 221 if (url.hasFragmentIdentifier()) {
240 FetchRequest request(ResourceRequest(url), localName()); 222 FetchRequest request(ResourceRequest(url), localName());
241 setDocumentResource(document().fetcher()->fetchSVGDocument(reque st)); 223 setDocumentResource(document().fetcher()->fetchSVGDocument(reque st));
242 } 224 }
243 } else { 225 } else {
244 setDocumentResource(0); 226 setDocumentResource(0);
245 } 227 }
246 228
247 invalidateShadowTree(); 229 invalidateShadowTree();
248 230
249 return; 231 return;
250 } 232 }
251 233
252 if (!renderer) 234 SVGGraphicsElement::svgAttributeChanged(attrName);
253 return;
254
255 ASSERT_NOT_REACHED();
256 } 235 }
257 236
258 static bool isDisallowedElement(Node* node) 237 static bool isDisallowedElement(Node* node)
259 { 238 {
260 // Spec: "Any 'svg', 'symbol', 'g', graphics element or other 'use' is poten tially a template object that can be re-used 239 // Spec: "Any 'svg', 'symbol', 'g', graphics element or other 'use' is poten tially a template object that can be re-used
261 // (i.e., "instanced") in the SVG document via a 'use' element." 240 // (i.e., "instanced") in the SVG document via a 'use' element."
262 // "Graphics Element" is defined as 'circle', 'ellipse', 'image', 'line', 'p ath', 'polygon', 'polyline', 'rect', 'text' 241 // "Graphics Element" is defined as 'circle', 'ellipse', 'image', 'line', 'p ath', 'polygon', 'polyline', 'rect', 'text'
263 // Excluded are anything that is used by reference or that only make sense t o appear once in a document. 242 // Excluded are anything that is used by reference or that only make sense t o appear once in a document.
264 // We must also allow the shadow roots of other use elements. 243 // We must also allow the shadow roots of other use elements.
265 if (node->isShadowRoot() || node->isTextNode()) 244 if (node->isShadowRoot() || node->isTextNode())
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 760
782 if (m_resource) 761 if (m_resource)
783 m_resource->removeClient(this); 762 m_resource->removeClient(this);
784 763
785 m_resource = resource; 764 m_resource = resource;
786 if (m_resource) 765 if (m_resource)
787 m_resource->addClient(this); 766 m_resource->addClient(this);
788 } 767 }
789 768
790 } 769 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698