Index: Source/core/svg/SVGUseElement.cpp |
diff --git a/Source/core/svg/SVGUseElement.cpp b/Source/core/svg/SVGUseElement.cpp |
index ecdea38ef69b5fd4692b2d62d0236f271d2b4403..a638624ce3a2bf97d5a18742170af593ee1952b9 100644 |
--- a/Source/core/svg/SVGUseElement.cpp |
+++ b/Source/core/svg/SVGUseElement.cpp |
@@ -400,6 +400,25 @@ void SVGUseElement::buildPendingResource() |
ASSERT(!m_needsShadowTreeRecreation); |
} |
+inline void transferUseWidthAndHeightIfNeeded(const SVGUseElement& use, Element& element) |
pdr.
2014/04/29 04:30:59
It may be better to put the relevant code from thi
|
+{ |
+ if (isSVGSymbolElement(element)) { |
+ // 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. |
+ element.setAttribute(SVGNames::widthAttr, use.hasAttribute(SVGNames::widthAttr) ? use.getAttribute(SVGNames::widthAttr) : "100%"); |
+ element.setAttribute(SVGNames::heightAttr, use.hasAttribute(SVGNames::heightAttr) ? use.getAttribute(SVGNames::heightAttr) : "100%"); |
+ } else if (isSVGSVGElement(element)) { |
+ // 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.hasAttribute(SVGNames::widthAttr)) |
Erik Dahlström (inactive)
2014/04/29 13:01:02
Will this work if the width/height attributes are
|
+ element.setAttribute(SVGNames::widthAttr, use.getAttribute(SVGNames::widthAttr)); |
+ if (use.hasAttribute(SVGNames::heightAttr)) |
+ element.setAttribute(SVGNames::heightAttr, use.getAttribute(SVGNames::heightAttr)); |
+ } |
+} |
+ |
void SVGUseElement::buildShadowAndInstanceTree(SVGElement* target) |
{ |
ASSERT(!m_targetElementInstance); |
@@ -452,13 +471,14 @@ void SVGUseElement::buildShadowAndInstanceTree(SVGElement* target) |
ASSERT(shadowTreeRootElement); |
// Build shadow tree from instance tree |
- // This also handles the special cases: <use> on <symbol>, <use> on <svg>. |
+ // This clones the element corresponding to the target element instance |
buildShadowTree(target, m_targetElementInstance.get()); |
// Expand all <use> elements in the shadow tree. |
// Expand means: replace the actual <use> element by what it references. |
expandUseElementsInShadowTree(shadowTreeRootElement); |
+ transferUseWidthAndHeightIfNeeded(*this, *toSVGElement(shadowTreeRootElement->firstChild())); |
// Expand all <symbol> elements in the shadow tree. |
// Expand means: replace the actual <symbol> element by the <svg> element. |
expandSymbolElementsInShadowTree(shadowTreeRootElement); |
@@ -702,6 +722,8 @@ void SVGUseElement::expandUseElementsInShadowTree(Node* element) |
if (target && !isDisallowedElement(target)) { |
RefPtr<Element> newChild = target->cloneElementWithChildren(); |
ASSERT(newChild->isSVGElement()); |
+ transferUseWidthAndHeightIfNeeded(*use, *newChild); |
pdr.
2014/04/29 04:30:59
I think the use width/height code would go here.
|
+ |
cloneParent->appendChild(newChild.release()); |
} |