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

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: rebase 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
« no previous file with comments | « Source/core/svg/SVGSVGElement.h ('k') | Source/core/svg/SVGUseElement.h » ('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 * 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } else if (SVGZoomAndPan::parseAttribute(name, value)) { 237 } else if (SVGZoomAndPan::parseAttribute(name, value)) {
238 } else { 238 } else {
239 parseAttributeNew(name, value); 239 parseAttributeNew(name, value);
240 } 240 }
241 } 241 }
242 242
243 bool SVGSVGElement::isPresentationAttribute(const QualifiedName& name) const 243 bool SVGSVGElement::isPresentationAttribute(const QualifiedName& name) const
244 { 244 {
245 if (isOutermostSVGSVGElement() && (name == SVGNames::widthAttr || name == SV GNames::heightAttr)) 245 if (isOutermostSVGSVGElement() && (name == SVGNames::widthAttr || name == SV GNames::heightAttr))
246 return true; 246 return true;
247 else if (name == SVGNames::xAttr || name == SVGNames::yAttr)
248 return true;
249
247 return SVGGraphicsElement::isPresentationAttribute(name); 250 return SVGGraphicsElement::isPresentationAttribute(name);
248 } 251 }
249 252
253 bool SVGSVGElement::isPresentationAttributeWithSVGDOM(const QualifiedName& attrN ame) const
254 {
255 if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr)
256 return true;
257 return SVGGraphicsElement::isPresentationAttributeWithSVGDOM(attrName);
258 }
259
250 void SVGSVGElement::collectStyleForPresentationAttribute(const QualifiedName& na me, const AtomicString& value, MutableStylePropertySet* style) 260 void SVGSVGElement::collectStyleForPresentationAttribute(const QualifiedName& na me, const AtomicString& value, MutableStylePropertySet* style)
251 { 261 {
252 if (isOutermostSVGSVGElement() && (name == SVGNames::widthAttr || name == SV GNames::heightAttr)) { 262 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> property = propertyFromAttribute (name);
263 if (property == m_x) {
264 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyX, *m _x->currentValue());
265 } else if (property == m_y) {
266 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyY, *m _y->currentValue());
267 } else if (isOutermostSVGSVGElement() && (property == m_width || property == m_height)) {
253 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(LengthModeOther ); 268 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(LengthModeOther );
254 TrackExceptionState exceptionState; 269 TrackExceptionState exceptionState;
255 length->setValueAsString(value, exceptionState); 270 length->setValueAsString(value, exceptionState);
256 if (!exceptionState.hadException()) { 271 if (!exceptionState.hadException()) {
257 if (name == SVGNames::widthAttr) 272 if (property == m_width)
258 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value); 273 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value);
259 else if (name == SVGNames::heightAttr) 274 else if (property == m_height)
260 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight , value); 275 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight , value);
261 } 276 }
262 } else { 277 } else {
263 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle); 278 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle);
264 } 279 }
265 } 280 }
266 281
267 void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName) 282 void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName)
268 { 283 {
269 bool updateRelativeLengthsOrViewBox = false; 284 bool updateRelativeLengthsOrViewBox = false;
(...skipping 12 matching lines...) Expand all
282 // 297 //
283 // FIXME: For width/height animated as XML attributes on SVG 298 // FIXME: For width/height animated as XML attributes on SVG
284 // roots, there is an attribute synchronization missing. See 299 // roots, there is an attribute synchronization missing. See
285 // http://crbug.com/364807 300 // http://crbug.com/364807
286 if (widthChanged || heightChanged) { 301 if (widthChanged || heightChanged) {
287 LayoutObject* layoutObject = renderer(); 302 LayoutObject* layoutObject = renderer();
288 if (layoutObject && layoutObject->isSVGRoot()) { 303 if (layoutObject && layoutObject->isSVGRoot()) {
289 invalidateSVGPresentationAttributeStyle(); 304 invalidateSVGPresentationAttributeStyle();
290 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin g::create(StyleChangeReason::SVGContainerSizeChange)); 305 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin g::create(StyleChangeReason::SVGContainerSizeChange));
291 } 306 }
307 } else {
308 invalidateSVGPresentationAttributeStyle();
309 setNeedsStyleRecalc(LocalStyleChange,
310 StyleChangeReasonForTracing::fromAttribute(attrName));
292 } 311 }
293 } 312 }
294 313
295 if (SVGFitToViewBox::isKnownAttribute(attrName)) { 314 if (SVGFitToViewBox::isKnownAttribute(attrName)) {
296 updateRelativeLengthsOrViewBox = true; 315 updateRelativeLengthsOrViewBox = true;
297 if (LayoutObject* object = renderer()) 316 if (LayoutObject* object = renderer())
298 object->setNeedsTransformUpdate(); 317 object->setNeedsTransformUpdate();
299 } 318 }
300 319
301 SVGElement::InvalidationGuard invalidationGuard(this); 320 SVGElement::InvalidationGuard invalidationGuard(this);
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 visitor->trace(m_width); 790 visitor->trace(m_width);
772 visitor->trace(m_height); 791 visitor->trace(m_height);
773 visitor->trace(m_translation); 792 visitor->trace(m_translation);
774 visitor->trace(m_timeContainer); 793 visitor->trace(m_timeContainer);
775 visitor->trace(m_viewSpec); 794 visitor->trace(m_viewSpec);
776 SVGGraphicsElement::trace(visitor); 795 SVGGraphicsElement::trace(visitor);
777 SVGFitToViewBox::trace(visitor); 796 SVGFitToViewBox::trace(visitor);
778 } 797 }
779 798
780 } // namespace blink 799 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/svg/SVGSVGElement.h ('k') | Source/core/svg/SVGUseElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698