Bug 1383988 - stylo: Ensure editor handle elements are styled before attempting to construct frames for them. r?hiro
MozReview-Commit-ID: 2T0ZjP00U7A
--- a/editor/libeditor/HTMLAnonymousNodeEditor.cpp
+++ b/editor/libeditor/HTMLAnonymousNodeEditor.cpp
@@ -231,16 +231,22 @@ HTMLEditor::CreateAnonymousElement(nsIAt
parentContent->GetProperty(nsGkAtoms::manualNACProperty));
if (!nac) {
nac = new ManualNAC();
parentContent->SetProperty(nsGkAtoms::manualNACProperty, nac,
nsINode::DeleteProperty<ManualNAC>);
}
nac->AppendElement(newContent);
+ // Must style the new element, otherwise the PostRecreateFramesFor call
+ // below will do nothing.
+ if (ServoStyleSet* styleSet = ps->StyleSet()->GetAsServo()) {
+ styleSet->StyleNewSubtree(newContent);
+ }
+
ElementDeletionObserver* observer =
new ElementDeletionObserver(newContent, parentContent);
NS_ADDREF(observer); // NodeWillBeDestroyed releases.
parentContent->AddMutationObserver(observer);
newContent->AddMutationObserver(observer);
#ifdef DEBUG
// Editor anonymous content gets passed to PostRecreateFramesFor... which