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

Unified 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, 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/svg/SVGUseElement.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGUseElement.cpp b/third_party/WebKit/Source/core/svg/SVGUseElement.cpp
index c7cc2a1c8f75c12e48ba7f68d46d31ff4086c945..2f5b90d41c7d39e05e037919eb643dff37e4a085 100644
--- a/third_party/WebKit/Source/core/svg/SVGUseElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGUseElement.cpp
@@ -151,24 +151,27 @@ Document* SVGUseElement::externalDocument() const
static void transferUseWidthAndHeightIfNeeded(const SVGUseElement& use, SVGElement& shadowElement, const SVGElement& originalElement)
{
DEFINE_STATIC_LOCAL(const AtomicString, hundredPercentString, ("100%", AtomicString::ConstructFromLiteral));
- if (isSVGSymbolElement(shadowElement)) {
- // Spec (<use> on <symbol>): This generated 'svg' will always have explicit values for attributes width and height.
- // If attributes width and/or height are provided on the 'use' element, then these attributes
- // will be transferred to the generated 'svg'. If attributes width and/or height are not specified,
- // the generated 'svg' element will use values of 100% for these attributes.
- shadowElement.setAttribute(SVGNames::widthAttr, use.width()->isSpecified() ? AtomicString(use.width()->currentValue()->valueAsString()) : hundredPercentString);
- shadowElement.setAttribute(SVGNames::heightAttr, use.height()->isSpecified() ? AtomicString(use.height()->currentValue()->valueAsString()) : hundredPercentString);
- } else if (isSVGSVGElement(shadowElement)) {
- // Spec (<use> on <svg>): If attributes width and/or height are provided on the 'use' element, then these
- // values will override the corresponding attributes on the 'svg' in the generated tree.
- if (use.width()->isSpecified())
- shadowElement.setAttribute(SVGNames::widthAttr, AtomicString(use.width()->currentValue()->valueAsString()));
- else
- shadowElement.setAttribute(SVGNames::widthAttr, originalElement.getAttribute(SVGNames::widthAttr));
- if (use.height()->isSpecified())
- shadowElement.setAttribute(SVGNames::heightAttr, AtomicString(use.height()->currentValue()->valueAsString()));
- else
- shadowElement.setAttribute(SVGNames::heightAttr, originalElement.getAttribute(SVGNames::heightAttr));
+ // Use |originalElement| for checking the element type, because we will
+ // have replaced a <symbol> with an <svg> in the instance tree.
+ if (isSVGSymbolElement(originalElement)) {
+ // Spec (<use> on <symbol>): This generated 'svg' will always have
+ // explicit values for attributes width and height. If attributes
+ // width and/or height are provided on the 'use' element, then these
+ // attributes will be transferred to the generated 'svg'. If attributes
+ // width and/or height are not specified, the generated 'svg' element
+ // will use values of 100% for these attributes.
+ shadowElement.setAttribute(SVGNames::widthAttr,
+ use.width()->isSpecified() ? AtomicString(use.width()->currentValue()->valueAsString()) : hundredPercentString);
+ shadowElement.setAttribute(SVGNames::heightAttr,
+ use.height()->isSpecified() ? AtomicString(use.height()->currentValue()->valueAsString()) : hundredPercentString);
+ } else if (isSVGSVGElement(originalElement)) {
+ // Spec (<use> on <svg>): If attributes width and/or height are
+ // provided on the 'use' element, then these values will override the
+ // corresponding attributes on the 'svg' in the generated tree.
+ shadowElement.setAttribute(SVGNames::widthAttr,
+ use.width()->isSpecified() ? AtomicString(use.width()->currentValue()->valueAsString()) : originalElement.getAttribute(SVGNames::widthAttr));
+ shadowElement.setAttribute(SVGNames::heightAttr,
+ use.height()->isSpecified() ? AtomicString(use.height()->currentValue()->valueAsString()) : originalElement.getAttribute(SVGNames::heightAttr));
}
}
« 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