зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1377256 - Part 1: Don't pass parent explicitly into HTMLEditor::DeleteRefToAnonymousNode. r=m_kato
MozReview-Commit-ID: HUySaoG07jg --HG-- extra : rebase_source : adb3a65387eb209073d95211fa185bcab2791b0f
This commit is contained in:
Родитель
2e8ba7dadc
Коммит
fdb731a4d4
|
@ -289,12 +289,9 @@ HTMLEditor::HideGrabber()
|
|||
// are no document observers to notify, but we still want to
|
||||
// UnbindFromTree.
|
||||
|
||||
nsCOMPtr<nsIContent> parentContent = mGrabber->GetParent();
|
||||
NS_ENSURE_TRUE(parentContent, NS_ERROR_NULL_POINTER);
|
||||
|
||||
DeleteRefToAnonymousNode(mGrabber, parentContent, ps);
|
||||
DeleteRefToAnonymousNode(mGrabber, ps);
|
||||
mGrabber = nullptr;
|
||||
DeleteRefToAnonymousNode(mPositioningShadow, parentContent, ps);
|
||||
DeleteRefToAnonymousNode(mPositioningShadow, ps);
|
||||
mPositioningShadow = nullptr;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -394,10 +391,7 @@ HTMLEditor::EndMoving()
|
|||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsCOMPtr<nsIContent> parentContent = mGrabber->GetParent();
|
||||
NS_ENSURE_TRUE(parentContent, NS_ERROR_FAILURE);
|
||||
|
||||
DeleteRefToAnonymousNode(mPositioningShadow, parentContent, ps);
|
||||
DeleteRefToAnonymousNode(mPositioningShadow, ps);
|
||||
|
||||
mPositioningShadow = nullptr;
|
||||
}
|
||||
|
|
|
@ -263,20 +263,18 @@ HTMLEditor::RemoveListenerAndDeleteRef(const nsAString& aEvent,
|
|||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture,
|
||||
Element* aElement,
|
||||
nsIContent* aParentContent,
|
||||
nsIPresShell* aShell)
|
||||
{
|
||||
nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(aElement));
|
||||
if (evtTarget) {
|
||||
evtTarget->RemoveEventListener(aEvent, aListener, aUseCapture);
|
||||
}
|
||||
DeleteRefToAnonymousNode(aElement, aParentContent, aShell);
|
||||
DeleteRefToAnonymousNode(aElement, aShell);
|
||||
}
|
||||
|
||||
// Deletes all references to an anonymous element
|
||||
void
|
||||
HTMLEditor::DeleteRefToAnonymousNode(nsIContent* aContent,
|
||||
nsIContent* aParentContent,
|
||||
nsIPresShell* aShell)
|
||||
{
|
||||
// call ContentRemoved() for the anonymous content
|
||||
|
@ -287,6 +285,12 @@ HTMLEditor::DeleteRefToAnonymousNode(nsIContent* aContent,
|
|||
return;
|
||||
}
|
||||
|
||||
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.
|
||||
|
@ -306,7 +310,7 @@ HTMLEditor::DeleteRefToAnonymousNode(nsIContent* aContent,
|
|||
// in RestyleManager::RestyleForRemove should be changed back
|
||||
// to an assertion.
|
||||
docObserver->ContentRemoved(aContent->GetComposedDoc(),
|
||||
aParentContent, aContent, -1,
|
||||
parentContent, aContent, -1,
|
||||
aContent->GetPreviousSibling());
|
||||
if (document) {
|
||||
docObserver->EndUpdate(document, UPDATE_CONTENT_MODEL);
|
||||
|
@ -316,11 +320,11 @@ HTMLEditor::DeleteRefToAnonymousNode(nsIContent* aContent,
|
|||
|
||||
// Remove reference from the parent element.
|
||||
auto nac = static_cast<mozilla::ManualNAC*>(
|
||||
aParentContent->GetProperty(nsGkAtoms::manualNACProperty));
|
||||
parentContent->GetProperty(nsGkAtoms::manualNACProperty));
|
||||
MOZ_ASSERT(nac);
|
||||
nac->RemoveElement(aContent);
|
||||
if (nac->IsEmpty()) {
|
||||
aParentContent->DeleteProperty(nsGkAtoms::manualNACProperty);
|
||||
parentContent->DeleteProperty(nsGkAtoms::manualNACProperty);
|
||||
}
|
||||
|
||||
aContent->UnbindFromTree();
|
||||
|
|
|
@ -858,10 +858,8 @@ protected:
|
|||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture,
|
||||
Element* aElement,
|
||||
nsIContent* aParentContent,
|
||||
nsIPresShell* aShell);
|
||||
void DeleteRefToAnonymousNode(nsIContent* aContent,
|
||||
nsIContent* aParentContent,
|
||||
nsIPresShell* aShell);
|
||||
|
||||
nsresult ShowResizersInner(nsIDOMElement *aResizedElement);
|
||||
|
|
|
@ -383,52 +383,46 @@ HTMLEditor::HideResizers()
|
|||
// are no document observers to notify, but we still want to
|
||||
// UnbindFromTree.
|
||||
|
||||
nsCOMPtr<nsIContent> parentContent;
|
||||
|
||||
if (mTopLeftHandle) {
|
||||
parentContent = mTopLeftHandle->GetParent();
|
||||
}
|
||||
|
||||
NS_NAMED_LITERAL_STRING(mousedown, "mousedown");
|
||||
|
||||
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
||||
mTopLeftHandle, parentContent, ps);
|
||||
mTopLeftHandle, ps);
|
||||
mTopLeftHandle = nullptr;
|
||||
|
||||
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
||||
mTopHandle, parentContent, ps);
|
||||
mTopHandle, ps);
|
||||
mTopHandle = nullptr;
|
||||
|
||||
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
||||
mTopRightHandle, parentContent, ps);
|
||||
mTopRightHandle, ps);
|
||||
mTopRightHandle = nullptr;
|
||||
|
||||
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
||||
mLeftHandle, parentContent, ps);
|
||||
mLeftHandle, ps);
|
||||
mLeftHandle = nullptr;
|
||||
|
||||
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
||||
mRightHandle, parentContent, ps);
|
||||
mRightHandle, ps);
|
||||
mRightHandle = nullptr;
|
||||
|
||||
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
||||
mBottomLeftHandle, parentContent, ps);
|
||||
mBottomLeftHandle, ps);
|
||||
mBottomLeftHandle = nullptr;
|
||||
|
||||
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
||||
mBottomHandle, parentContent, ps);
|
||||
mBottomHandle, ps);
|
||||
mBottomHandle = nullptr;
|
||||
|
||||
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
||||
mBottomRightHandle, parentContent, ps);
|
||||
mBottomRightHandle, ps);
|
||||
mBottomRightHandle = nullptr;
|
||||
|
||||
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
||||
mResizingShadow, parentContent, ps);
|
||||
mResizingShadow, ps);
|
||||
mResizingShadow = nullptr;
|
||||
|
||||
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
||||
mResizingInfo, parentContent, ps);
|
||||
mResizingInfo, ps);
|
||||
mResizingInfo = nullptr;
|
||||
|
||||
if (mActivatedHandle) {
|
||||
|
|
|
@ -110,20 +110,17 @@ HTMLEditor::HideInlineTableEditingUI()
|
|||
// are no document observers to notify, but we still want to
|
||||
// UnbindFromTree.
|
||||
|
||||
// get the root content node.
|
||||
nsCOMPtr<nsIContent> bodyContent = GetRoot();
|
||||
|
||||
DeleteRefToAnonymousNode(mAddColumnBeforeButton, bodyContent, ps);
|
||||
DeleteRefToAnonymousNode(mAddColumnBeforeButton, ps);
|
||||
mAddColumnBeforeButton = nullptr;
|
||||
DeleteRefToAnonymousNode(mRemoveColumnButton, bodyContent, ps);
|
||||
DeleteRefToAnonymousNode(mRemoveColumnButton, ps);
|
||||
mRemoveColumnButton = nullptr;
|
||||
DeleteRefToAnonymousNode(mAddColumnAfterButton, bodyContent, ps);
|
||||
DeleteRefToAnonymousNode(mAddColumnAfterButton, ps);
|
||||
mAddColumnAfterButton = nullptr;
|
||||
DeleteRefToAnonymousNode(mAddRowBeforeButton, bodyContent, ps);
|
||||
DeleteRefToAnonymousNode(mAddRowBeforeButton, ps);
|
||||
mAddRowBeforeButton = nullptr;
|
||||
DeleteRefToAnonymousNode(mRemoveRowButton, bodyContent, ps);
|
||||
DeleteRefToAnonymousNode(mRemoveRowButton, ps);
|
||||
mRemoveRowButton = nullptr;
|
||||
DeleteRefToAnonymousNode(mAddRowAfterButton, bodyContent, ps);
|
||||
DeleteRefToAnonymousNode(mAddRowAfterButton, ps);
|
||||
mAddRowAfterButton = nullptr;
|
||||
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче