Bug 265894 - Part 3. Setup display prop value of the cloned symbol element.
The spec said:
The generated instance of a ‘symbol’ that is the direct referenced element of a
‘use’ element must always have a computed value of inline for the display
property. In other words, it must be rendered whenever the host ‘use’ element is
rendered.
MozReview-Commit-ID: DpqOaQcUdI
--- a/dom/svg/SVGSVGElement.cpp
+++ b/dom/svg/SVGSVGElement.cpp
@@ -1235,15 +1235,38 @@ SVGSVGElement::CloneFromSymbol(Element*
// move the children over
uint32_t num = aSymbol->GetChildCount();
for (i = 0; i < num; i++) {
nsCOMPtr<nsIContent> child = aSymbol->GetFirstChild();
aSymbol->RemoveChildAt(0, false);
svgNode->InsertChildAt(child, i, true);
}
+ // Read the display prop value of the host 'use' element.
+ nsAutoString displayOfHost;
+ if (aShadowHost->GetPrimaryFrame()) {
+ nsCSSKeyword keyword =
+ nsCSSProps::ValueToKeywordEnum(aShadowHost->GetPrimaryFrame()->StyleDisplay()->mDisplay,
+ nsCSSProps::kDisplayKTable);
+
+ AppendUTF8toUTF16(nsCSSKeywords::GetStringValue(keyword), displayOfHost);
+
+ displayOfHost =
+ NS_LITERAL_STRING("display:") + displayOfHost + NS_LITERAL_STRING(";");
+ } else {
+ displayOfHost = NS_LITERAL_STRING("display:block;");
+ }
+
+ // The generated instance of a ‘symbol’ that is the direct referenced
+ // element of a ‘use’ element must always have a computed value of inline
+ // for the display property. In other words, it must be rendered whenever
+ // the host ‘use’ element is rendered.
+ nsAutoString inlineStyle;
+ svgNode->GetAttr(kNameSpaceID_None, nsGkAtoms::style, inlineStyle);
+ inlineStyle += displayOfHost;
+ svgNode->SetAttr(kNameSpaceID_None, nsGkAtoms::style, inlineStyle, true);
+
static_cast<SVGSVGElement*>(svgNode.get())->mCloneFromSymbol = true;
-
return svgNode.forget();
}
} // namespace dom
} // namespace mozilla