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

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

Issue 18328007: Move SVGTests attributes parsing to SVGGraphicsElement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 5 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
« no previous file with comments | « Source/core/svg/SVGSVGElement.h ('k') | Source/core/svg/SVGTextContentElement.cpp » ('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, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2007 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 void SVGSVGElement::updateCurrentTranslate() 215 void SVGSVGElement::updateCurrentTranslate()
216 { 216 {
217 if (RenderObject* object = renderer()) 217 if (RenderObject* object = renderer())
218 object->setNeedsLayout(true); 218 object->setNeedsLayout(true);
219 219
220 if (parentNode() == document() && document()->renderer()) 220 if (parentNode() == document() && document()->renderer())
221 document()->renderer()->repaint(); 221 document()->renderer()->repaint();
222 } 222 }
223 223
224 bool SVGSVGElement::isSupportedAttribute(const QualifiedName& attrName)
do-not-use 2013/07/02 19:47:30 This is actually not needed, sorry. The real issue
225 {
226 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
227 if (supportedAttributes.isEmpty()) {
228 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes );
229 SVGFitToViewBox::addSupportedAttributes(supportedAttributes);
230 SVGLangSpace::addSupportedAttributes(supportedAttributes);
231 SVGZoomAndPan::addSupportedAttributes(supportedAttributes);
232 supportedAttributes.add(SVGNames::xAttr);
233 supportedAttributes.add(SVGNames::yAttr);
234 supportedAttributes.add(SVGNames::widthAttr);
235 supportedAttributes.add(SVGNames::heightAttr);
236 supportedAttributes.add(SVGNames::onzoomAttr);
237 supportedAttributes.add(HTMLNames::onabortAttr);
238 supportedAttributes.add(HTMLNames::onerrorAttr);
239 supportedAttributes.add(HTMLNames::onunloadAttr);
240 supportedAttributes.add(HTMLNames::onresizeAttr);
241 supportedAttributes.add(HTMLNames::onscrollAttr);
242 }
243 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
244 }
245
224 void SVGSVGElement::parseAttribute(const QualifiedName& name, const AtomicString & value) 246 void SVGSVGElement::parseAttribute(const QualifiedName& name, const AtomicString & value)
225 { 247 {
248 if (!isSupportedAttribute(name)) {
249 SVGGraphicsElement::parseAttribute(name, value);
250 return;
251 }
252
226 SVGParsingError parseError = NoError; 253 SVGParsingError parseError = NoError;
227 254
228 if (!nearestViewportElement()) { 255 if (!nearestViewportElement()) {
229 bool setListener = true; 256 bool setListener = true;
230 257
231 // Only handle events if we're the outermost <svg> element 258 // Only handle events if we're the outermost <svg> element
232 if (name == HTMLNames::onunloadAttr) 259 if (name == HTMLNames::onunloadAttr)
233 document()->setWindowAttributeEventListener(eventNames().unloadEvent , createAttributeEventListener(document()->frame(), name, value)); 260 document()->setWindowAttributeEventListener(eventNames().unloadEvent , createAttributeEventListener(document()->frame(), name, value));
234 else if (name == HTMLNames::onresizeAttr) 261 else if (name == HTMLNames::onresizeAttr)
235 document()->setWindowAttributeEventListener(eventNames().resizeEvent , createAttributeEventListener(document()->frame(), name, value)); 262 document()->setWindowAttributeEventListener(eventNames().resizeEvent , createAttributeEventListener(document()->frame(), name, value));
(...skipping 13 matching lines...) Expand all
249 else if (name == HTMLNames::onerrorAttr) 276 else if (name == HTMLNames::onerrorAttr)
250 document()->setWindowAttributeEventListener(eventNames().errorEvent, cre ateAttributeEventListener(document()->frame(), name, value)); 277 document()->setWindowAttributeEventListener(eventNames().errorEvent, cre ateAttributeEventListener(document()->frame(), name, value));
251 else if (name == SVGNames::xAttr) 278 else if (name == SVGNames::xAttr)
252 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); 279 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError));
253 else if (name == SVGNames::yAttr) 280 else if (name == SVGNames::yAttr)
254 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)) ; 281 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)) ;
255 else if (name == SVGNames::widthAttr) 282 else if (name == SVGNames::widthAttr)
256 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro r, ForbidNegativeLengths)); 283 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro r, ForbidNegativeLengths));
257 else if (name == SVGNames::heightAttr) 284 else if (name == SVGNames::heightAttr)
258 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr ror, ForbidNegativeLengths)); 285 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr ror, ForbidNegativeLengths));
259 else if (SVGTests::parseAttribute(name, value) 286 else if (SVGLangSpace::parseAttribute(name, value)
260 || SVGLangSpace::parseAttribute(name, value)
261 || SVGExternalResourcesRequired::parseAttribute(name, value) 287 || SVGExternalResourcesRequired::parseAttribute(name, value)
262 || SVGFitToViewBox::parseAttribute(this, name, value) 288 || SVGFitToViewBox::parseAttribute(this, name, value)
263 || SVGZoomAndPan::parseAttribute(this, name, value)) { 289 || SVGZoomAndPan::parseAttribute(this, name, value)) {
264 } else 290 } else
265 SVGGraphicsElement::parseAttribute(name, value); 291 SVGGraphicsElement::parseAttribute(name, value);
266 292
267 reportAttributeParsingError(parseError, name, value); 293 reportAttributeParsingError(parseError, name, value);
268 } 294 }
269 295
270 void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName) 296 void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName)
271 { 297 {
298 if (!isSupportedAttribute(attrName)) {
299 SVGGraphicsElement::svgAttributeChanged(attrName);
300 return;
301 }
302
272 bool updateRelativeLengthsOrViewBox = false; 303 bool updateRelativeLengthsOrViewBox = false;
273 bool widthChanged = attrName == SVGNames::widthAttr; 304 bool widthChanged = attrName == SVGNames::widthAttr;
274 if (widthChanged 305 if (widthChanged
275 || attrName == SVGNames::heightAttr 306 || attrName == SVGNames::heightAttr
276 || attrName == SVGNames::xAttr 307 || attrName == SVGNames::xAttr
277 || attrName == SVGNames::yAttr) { 308 || attrName == SVGNames::yAttr) {
278 updateRelativeLengthsOrViewBox = true; 309 updateRelativeLengthsOrViewBox = true;
279 updateRelativeLengthsInformation(); 310 updateRelativeLengthsInformation();
280 311
281 // At the SVG/HTML boundary (aka RenderSVGRoot), the width attribute can 312 // At the SVG/HTML boundary (aka RenderSVGRoot), the width attribute can
282 // affect the replaced size so we need to mark it for updating. 313 // affect the replaced size so we need to mark it for updating.
283 if (widthChanged) { 314 if (widthChanged) {
284 RenderObject* renderObject = renderer(); 315 RenderObject* renderObject = renderer();
285 if (renderObject && renderObject->isSVGRoot()) 316 if (renderObject && renderObject->isSVGRoot())
286 toRenderSVGRoot(renderObject)->setNeedsLayoutAndPrefWidthsRecalc (); 317 toRenderSVGRoot(renderObject)->setNeedsLayoutAndPrefWidthsRecalc ();
287 } 318 }
288 } 319 }
289 320
290 if (SVGFitToViewBox::isKnownAttribute(attrName)) { 321 if (SVGFitToViewBox::isKnownAttribute(attrName)) {
291 updateRelativeLengthsOrViewBox = true; 322 updateRelativeLengthsOrViewBox = true;
292 if (RenderObject* object = renderer()) 323 if (RenderObject* object = renderer())
293 object->setNeedsTransformUpdate(); 324 object->setNeedsTransformUpdate();
294 } 325 }
295 326
296 SVGElementInstance::InvalidationGuard invalidationGuard(this); 327 SVGElementInstance::InvalidationGuard invalidationGuard(this);
297 if (SVGTests::handleAttributeChange(this, attrName))
298 return;
299 328
300 if (updateRelativeLengthsOrViewBox 329 if (updateRelativeLengthsOrViewBox
301 || SVGLangSpace::isKnownAttribute(attrName) 330 || SVGLangSpace::isKnownAttribute(attrName)
302 || SVGExternalResourcesRequired::isKnownAttribute(attrName) 331 || SVGExternalResourcesRequired::isKnownAttribute(attrName)
303 || SVGZoomAndPan::isKnownAttribute(attrName)) { 332 || SVGZoomAndPan::isKnownAttribute(attrName)) {
304 if (renderer()) 333 if (renderer())
305 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render er()); 334 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render er());
306 return; 335 return;
307 } 336 }
308 337
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 continue; 800 continue;
772 801
773 Element* element = toElement(node); 802 Element* element = toElement(node);
774 if (element->getIdAttribute() == id) 803 if (element->getIdAttribute() == id)
775 return element; 804 return element;
776 } 805 }
777 return 0; 806 return 0;
778 } 807 }
779 808
780 } 809 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGSVGElement.h ('k') | Source/core/svg/SVGTextContentElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698