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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGUseElement.cpp

Issue 1757993007: Correct initial width/height for <use>d <symbol>s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « third_party/WebKit/LayoutTests/svg/custom/use-symbol-initial-width-height-expected.html ('k') | no next file » | 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, 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // Gracefully handle error condition. 144 // Gracefully handle error condition.
145 if (!resourceIsValid()) 145 if (!resourceIsValid())
146 return nullptr; 146 return nullptr;
147 ASSERT(m_resource->document()); 147 ASSERT(m_resource->document());
148 return m_resource->document(); 148 return m_resource->document();
149 } 149 }
150 150
151 static void transferUseWidthAndHeightIfNeeded(const SVGUseElement& use, SVGEleme nt& shadowElement, const SVGElement& originalElement) 151 static void transferUseWidthAndHeightIfNeeded(const SVGUseElement& use, SVGEleme nt& shadowElement, const SVGElement& originalElement)
152 { 152 {
153 DEFINE_STATIC_LOCAL(const AtomicString, hundredPercentString, ("100%", Atomi cString::ConstructFromLiteral)); 153 DEFINE_STATIC_LOCAL(const AtomicString, hundredPercentString, ("100%", Atomi cString::ConstructFromLiteral));
154 if (isSVGSymbolElement(shadowElement)) { 154 // Use |originalElement| for checking the element type, because we will
155 // Spec (<use> on <symbol>): This generated 'svg' will always have expli cit values for attributes width and height. 155 // have replaced a <symbol> with an <svg> in the instance tree.
156 // If attributes width and/or height are provided on the 'use' element, then these attributes 156 if (isSVGSymbolElement(originalElement)) {
157 // will be transferred to the generated 'svg'. If attributes width and/o r height are not specified, 157 // Spec (<use> on <symbol>): This generated 'svg' will always have
158 // the generated 'svg' element will use values of 100% for these attribu tes. 158 // explicit values for attributes width and height. If attributes
159 shadowElement.setAttribute(SVGNames::widthAttr, use.width()->isSpecified () ? AtomicString(use.width()->currentValue()->valueAsString()) : hundredPercent String); 159 // width and/or height are provided on the 'use' element, then these
160 shadowElement.setAttribute(SVGNames::heightAttr, use.height()->isSpecifi ed() ? AtomicString(use.height()->currentValue()->valueAsString()) : hundredPerc entString); 160 // attributes will be transferred to the generated 'svg'. If attributes
161 } else if (isSVGSVGElement(shadowElement)) { 161 // width and/or height are not specified, the generated 'svg' element
162 // Spec (<use> on <svg>): If attributes width and/or height are provided on the 'use' element, then these 162 // will use values of 100% for these attributes.
163 // values will override the corresponding attributes on the 'svg' in the generated tree. 163 shadowElement.setAttribute(SVGNames::widthAttr,
164 if (use.width()->isSpecified()) 164 use.width()->isSpecified() ? AtomicString(use.width()->currentValue( )->valueAsString()) : hundredPercentString);
165 shadowElement.setAttribute(SVGNames::widthAttr, AtomicString(use.wid th()->currentValue()->valueAsString())); 165 shadowElement.setAttribute(SVGNames::heightAttr,
166 else 166 use.height()->isSpecified() ? AtomicString(use.height()->currentValu e()->valueAsString()) : hundredPercentString);
167 shadowElement.setAttribute(SVGNames::widthAttr, originalElement.getA ttribute(SVGNames::widthAttr)); 167 } else if (isSVGSVGElement(originalElement)) {
168 if (use.height()->isSpecified()) 168 // Spec (<use> on <svg>): If attributes width and/or height are
169 shadowElement.setAttribute(SVGNames::heightAttr, AtomicString(use.he ight()->currentValue()->valueAsString())); 169 // provided on the 'use' element, then these values will override the
170 else 170 // corresponding attributes on the 'svg' in the generated tree.
171 shadowElement.setAttribute(SVGNames::heightAttr, originalElement.get Attribute(SVGNames::heightAttr)); 171 shadowElement.setAttribute(SVGNames::widthAttr,
172 use.width()->isSpecified() ? AtomicString(use.width()->currentValue( )->valueAsString()) : originalElement.getAttribute(SVGNames::widthAttr));
173 shadowElement.setAttribute(SVGNames::heightAttr,
174 use.height()->isSpecified() ? AtomicString(use.height()->currentValu e()->valueAsString()) : originalElement.getAttribute(SVGNames::heightAttr));
172 } 175 }
173 } 176 }
174 177
175 bool SVGUseElement::isPresentationAttribute(const QualifiedName& attrName) const 178 bool SVGUseElement::isPresentationAttribute(const QualifiedName& attrName) const
176 { 179 {
177 if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr) 180 if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr)
178 return true; 181 return true;
179 return SVGGraphicsElement::isPresentationAttribute(attrName); 182 return SVGGraphicsElement::isPresentationAttribute(attrName);
180 } 183 }
181 184
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 767
765 if (m_resource) 768 if (m_resource)
766 m_resource->removeClient(this); 769 m_resource->removeClient(this);
767 770
768 m_resource = resource; 771 m_resource = resource;
769 if (m_resource) 772 if (m_resource)
770 m_resource->addClient(this); 773 m_resource->addClient(this);
771 } 774 }
772 775
773 } // namespace blink 776 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/custom/use-symbol-initial-width-height-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698