Bug 1439036: Fix some other miscellaneous issues with the caller. r?bz
While we're here...
MozReview-Commit-ID: 7B79vec0bYS
--- 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