Bug 1431255 - (To be replaced by
bug 1450250) Allow Shadow DOM in SVG <use> subtree creation
Before calling into restyle when attaching shadow root, checking if the element
is in a SVG <use> subtree. This prevents us from recurring into frame construction
when the video element is bound into a SVG <use> subtree.
Specifically, this allow UA Widget to pass in dom/svg/crashtests/1282985-1.svg.
MozReview-Commit-ID: FobLm20Rhie
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1224,19 +1224,24 @@ Element::AttachShadowWithoutNameChecks(S
{
nsAutoScriptBlocker scriptBlocker;
RefPtr<mozilla::dom::NodeInfo> nodeInfo =
mNodeInfo->NodeInfoManager()->GetNodeInfo(
nsGkAtoms::documentFragmentNodeName, nullptr, kNameSpaceID_None,
DOCUMENT_FRAGMENT_NODE);
- if (nsIDocument* doc = GetComposedDoc()) {
- if (nsIPresShell* shell = doc->GetShell()) {
- shell->DestroyFramesForAndRestyle(this);
+ bool inSVGUseSubtree =
+ IsInAnonymousSubtree() && IsAnonymousContentInSVGUseSubtree();
+
+ if (!inSVGUseSubtree) {
+ if (nsIDocument* doc = GetComposedDoc()) {
+ if (nsIPresShell* shell = doc->GetShell()) {
+ shell->DestroyFramesForAndRestyle(this);
+ }
}
}
MOZ_ASSERT(!GetPrimaryFrame());
/**
* 4. Let shadow be a new shadow root whose node document is
* context object’s node document, host is context object,
* and mode is init’s mode.
@@ -1272,19 +1277,24 @@ void
Element::UnattachShadow()
{
if (!GetShadowRoot()) {
return;
}
nsAutoScriptBlocker scriptBlocker;
- if (nsIDocument* doc = GetComposedDoc()) {
- if (nsIPresShell* shell = doc->GetShell()) {
- shell->DestroyFramesForAndRestyle(this);
+ bool inSVGUseSubtree =
+ IsInAnonymousSubtree() && IsAnonymousContentInSVGUseSubtree();
+
+ if (!inSVGUseSubtree) {
+ if (nsIDocument* doc = GetComposedDoc()) {
+ if (nsIPresShell* shell = doc->GetShell()) {
+ shell->DestroyFramesForAndRestyle(this);
+ }
}
}
MOZ_ASSERT(!GetPrimaryFrame());
// Simply unhook the shadow root from the element.
MOZ_ASSERT(!GetShadowRoot()->HasSlots(), "Won't work when shadow root has slots!");
SetShadowRoot(nullptr);
}