Bug 1383988 - stylo: Ensure editor handle elements are styled before attempting to construct frames for them. r?hiro draft
authorCameron McCormack <cam@mcc.id.au>
Tue, 25 Jul 2017 14:08:19 +0800
changeset 614943 e23d9d3ca53eaa0db53cba2726ca215b797b8b13
parent 614015 5928d905c0bc0b28f5488b236444c7d7991cf8d4
child 639028 707979e5e0ae1adc773dea2b9afff05717511e51
push id70190
push userbmo:cam@mcc.id.au
push dateTue, 25 Jul 2017 07:42:54 +0000
reviewershiro
bugs1383988
milestone56.0a1
Bug 1383988 - stylo: Ensure editor handle elements are styled before attempting to construct frames for them. r?hiro MozReview-Commit-ID: 2T0ZjP00U7A
editor/libeditor/HTMLAnonymousNodeEditor.cpp
--- 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