Bug 1387481 - Part 1: Don't eagerly style editor-created NAC if it's appended to an element in a display:none subtree. r=hiro
MozReview-Commit-ID: 7bucY7JKRS0
--- a/editor/libeditor/HTMLAnonymousNodeEditor.cpp
+++ b/editor/libeditor/HTMLAnonymousNodeEditor.cpp
@@ -234,17 +234,21 @@ HTMLEditor::CreateAnonymousElement(nsIAt
}
}
ManualNACPtr newContent(newContentRaw.forget());
// Must style the new element, otherwise the PostRecreateFramesFor call
// below will do nothing.
if (ServoStyleSet* styleSet = ps->StyleSet()->GetAsServo()) {
- styleSet->StyleNewSubtree(newContent);
+ // Sometimes editor likes to append anonymous content to elements
+ // in display:none subtrees, so avoid styling in those cases.
+ if (styleSet->MayTraverseFrom(newContent)) {
+ styleSet->StyleNewSubtree(newContent);
+ }
}
ElementDeletionObserver* observer =
new ElementDeletionObserver(newContent, parentContent);
NS_ADDREF(observer); // NodeWillBeDestroyed releases.
parentContent->AddMutationObserver(observer);
newContent->AddMutationObserver(observer);