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

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

Issue 896773002: [svg2] Make 'x' and 'y' presentation attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: cleanup Created 5 years, 10 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
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 * Copyright (C) 2014 Google, Inc. 5 * Copyright (C) 2014 Google, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } else if (SVGZoomAndPan::parseAttribute(name, value)) { 236 } else if (SVGZoomAndPan::parseAttribute(name, value)) {
237 } else { 237 } else {
238 parseAttributeNew(name, value); 238 parseAttributeNew(name, value);
239 } 239 }
240 } 240 }
241 241
242 bool SVGSVGElement::isPresentationAttribute(const QualifiedName& name) const 242 bool SVGSVGElement::isPresentationAttribute(const QualifiedName& name) const
243 { 243 {
244 if (isOutermostSVGSVGElement() && (name == SVGNames::widthAttr || name == SV GNames::heightAttr)) 244 if (isOutermostSVGSVGElement() && (name == SVGNames::widthAttr || name == SV GNames::heightAttr))
245 return true; 245 return true;
246 else if (name == SVGNames::xAttr || name == SVGNames::yAttr)
247 return true;
248
246 return SVGGraphicsElement::isPresentationAttribute(name); 249 return SVGGraphicsElement::isPresentationAttribute(name);
247 } 250 }
248 251
249 void SVGSVGElement::collectStyleForPresentationAttribute(const QualifiedName& na me, const AtomicString& value, MutableStylePropertySet* style) 252 void SVGSVGElement::collectStyleForPresentationAttribute(const QualifiedName& na me, const AtomicString& value, MutableStylePropertySet* style)
250 { 253 {
251 if (isOutermostSVGSVGElement() && (name == SVGNames::widthAttr || name == SV GNames::heightAttr)) { 254 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> property = propertyFromAttribute (name);
255 if (property == m_x) {
256 addPropertyToPresentationAttributeStyle(style, CSSPropertyX, m_x->curren tValue()->valueInSpecifiedUnits(), m_x->currentValue()->cssUnitTypeQuirk());
257 } else if (property == m_y) {
258 addPropertyToPresentationAttributeStyle(style, CSSPropertyY, m_y->curren tValue()->valueInSpecifiedUnits(), m_y->currentValue()->cssUnitTypeQuirk());
259 } else if (isOutermostSVGSVGElement() && (property == m_width || property == m_height)) {
252 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(LengthModeOther ); 260 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(LengthModeOther );
253 TrackExceptionState exceptionState; 261 TrackExceptionState exceptionState;
254 length->setValueAsString(value, exceptionState); 262 length->setValueAsString(value, exceptionState);
255 if (!exceptionState.hadException()) { 263 if (!exceptionState.hadException()) {
256 if (name == SVGNames::widthAttr) 264 if (property == m_width)
257 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value); 265 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value);
258 else if (name == SVGNames::heightAttr) 266 else if (property == m_height)
259 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight , value); 267 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight , value);
260 } 268 }
261 } else { 269 } else {
262 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle); 270 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle);
263 } 271 }
264 } 272 }
265 273
266 void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName) 274 void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName)
267 { 275 {
268 bool updateRelativeLengthsOrViewBox = false; 276 bool updateRelativeLengthsOrViewBox = false;
(...skipping 12 matching lines...) Expand all
281 // 289 //
282 // FIXME: For width/height animated as XML attributes on SVG 290 // FIXME: For width/height animated as XML attributes on SVG
283 // roots, there is an attribute synchronization missing. See 291 // roots, there is an attribute synchronization missing. See
284 // http://crbug.com/364807 292 // http://crbug.com/364807
285 if (widthChanged || heightChanged) { 293 if (widthChanged || heightChanged) {
286 RenderObject* renderObject = renderer(); 294 RenderObject* renderObject = renderer();
287 if (renderObject && renderObject->isSVGRoot()) { 295 if (renderObject && renderObject->isSVGRoot()) {
288 invalidateSVGPresentationAttributeStyle(); 296 invalidateSVGPresentationAttributeStyle();
289 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin g::create(StyleChangeReason::SVGContainerSizeChange)); 297 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin g::create(StyleChangeReason::SVGContainerSizeChange));
290 } 298 }
299 } else {
300 invalidateSVGPresentationAttributeStyle();
301 setNeedsStyleRecalc(LocalStyleChange,
302 StyleChangeReasonForTracing::fromAttribute(attrName));
291 } 303 }
292 } 304 }
293 305
294 if (SVGFitToViewBox::isKnownAttribute(attrName)) { 306 if (SVGFitToViewBox::isKnownAttribute(attrName)) {
295 updateRelativeLengthsOrViewBox = true; 307 updateRelativeLengthsOrViewBox = true;
296 if (RenderObject* object = renderer()) 308 if (RenderObject* object = renderer())
297 object->setNeedsTransformUpdate(); 309 object->setNeedsTransformUpdate();
298 } 310 }
299 311
300 SVGElement::InvalidationGuard invalidationGuard(this); 312 SVGElement::InvalidationGuard invalidationGuard(this);
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 visitor->trace(m_width); 783 visitor->trace(m_width);
772 visitor->trace(m_height); 784 visitor->trace(m_height);
773 visitor->trace(m_translation); 785 visitor->trace(m_translation);
774 visitor->trace(m_timeContainer); 786 visitor->trace(m_timeContainer);
775 visitor->trace(m_viewSpec); 787 visitor->trace(m_viewSpec);
776 SVGGraphicsElement::trace(visitor); 788 SVGGraphicsElement::trace(visitor);
777 SVGFitToViewBox::trace(visitor); 789 SVGFitToViewBox::trace(visitor);
778 } 790 }
779 791
780 } // namespace blink 792 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698