Bug 1439036: Fix some other miscellaneous issues with the caller. r=bz
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 17 Feb 2018 01:46:35 +0100
changeset 405210 c1a45d6a53909e929f253fe5b6522ba2de3baaee
parent 405209 1e9461ca597bc56959b02bda1c635b9bbe671c1a
child 405211 ef984964576b10af234557b817e3398bb465b966
push id60127
push userecoal95@gmail.com
push dateSat, 24 Feb 2018 12:48:51 +0000
treeherderautoland@c1a45d6a5390 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1439036
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1439036: Fix some other miscellaneous issues with the caller. r=bz While we're here... MozReview-Commit-ID: 7B79vec0bYS
editor/libeditor/HTMLAnonymousNodeEditor.cpp
--- a/editor/libeditor/HTMLAnonymousNodeEditor.cpp
+++ b/editor/libeditor/HTMLAnonymousNodeEditor.cpp
@@ -292,35 +292,38 @@ HTMLEditor::DeleteRefToAnonymousNode(Man
   nsIContent* parentContent = aContent->GetParent();
   if (NS_WARN_IF(!parentContent)) {
     // aContent was already removed?
     return;
   }
 
   nsAutoScriptBlocker scriptBlocker;
   // Need to check whether aShell has been destroyed (but not yet deleted).
-  // In that case presContext->GetPresShell() returns nullptr.
   // See bug 338129.
-  if (aContent->IsInComposedDoc() && aShell && aShell->GetPresContext() &&
-      aShell->GetPresContext()->GetPresShell() == aShell) {
-    nsCOMPtr<nsIDocumentObserver> docObserver = do_QueryInterface(aShell);
-    if (docObserver) {
-      // Call BeginUpdate() so that the nsCSSFrameConstructor/PresShell
-      // knows we're messing with the frame tree.
-      nsCOMPtr<nsIDocument> document = GetDocument();
-      if (document) {
-        docObserver->BeginUpdate(document, UPDATE_CONTENT_MODEL);
-      }
+  if (aContent->IsInComposedDoc() && aShell && !aShell->IsDestroying()) {
+    // Call BeginUpdate() so that the nsCSSFrameConstructor/PresShell
+    // knows we're messing with the frame tree.
+    //
+    // FIXME(emilio): Shouldn't this use the document update mechanism instead?
+    // Also, is it really needed? This is NAC anyway.
+    nsCOMPtr<nsIDocument> document = GetDocument();
+    if (document) {
+      aShell->BeginUpdate(document, UPDATE_CONTENT_MODEL);
+    }
 
-      docObserver->ContentRemoved(aContent->GetComposedDoc(),
-                                  parentContent, aContent,
-                                  aContent->GetPreviousSibling());
-      if (document) {
-        docObserver->EndUpdate(document, UPDATE_CONTENT_MODEL);
-      }
+    MOZ_ASSERT(aContent->IsRootOfAnonymousSubtree());
+    MOZ_ASSERT(!aContent->GetPreviousSibling(), "NAC has no siblings");
+
+    // FIXME(emilio): This is the only caller to PresShell::ContentRemoved that
+    // passes NAC into it. This is not great!
+    aShell->ContentRemoved(
+      aContent->GetComposedDoc(), parentContent, aContent, nullptr);
+
+    if (document) {
+      aShell->EndUpdate(document, UPDATE_CONTENT_MODEL);
     }
   }
 
   // The ManualNACPtr destructor will invoke UnbindFromTree.
 }
 
 // The following method is mostly called by a selection listener. When a
 // selection change is notified, the method is called to check if resizing