diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 3746340a677..dd121c92aac 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -4099,6 +4099,21 @@ nsEventStateManager::ContentRemoved(nsIContent* aContent) NS_RELEASE(mCurrentFocus); } + if (aContent == mHoverContent) { + // Since hover is hierarchical, set the current hover to the + // content's parent node. + NS_RELEASE(mHoverContent); + aContent->GetParent(mHoverContent); + } + + if (aContent == mActiveContent) { + NS_RELEASE(mActiveContent); + } + + if (aContent == mDragOverContent) { + NS_RELEASE(mDragOverContent); + } + return NS_OK; } diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 2cd5c290b81..b69bdc1efc9 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -5264,6 +5264,13 @@ PresShell::ContentReplaced(nsIDocument* aDocument, nsIContent* aNewChild, PRInt32 aIndexInContainer) { + // Notify the ESM that the content has been removed, so that + // it can clean up any state related to the content. + nsCOMPtr esm; + mPresContext->GetEventStateManager(getter_AddRefs(esm)); + if (esm) + esm->ContentRemoved(aOldChild); + WillCauseReflow(); nsresult rv = mStyleSet->ContentReplaced(mPresContext, aContainer, aOldChild, aNewChild, aIndexInContainer); @@ -5280,7 +5287,6 @@ PresShell::ContentRemoved(nsIDocument *aDocument, { // Notify the ESM that the content has been removed, so that // it can clean up any state related to the content. - nsCOMPtr esm; mPresContext->GetEventStateManager(getter_AddRefs(esm)); if (esm) diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 2cd5c290b81..b69bdc1efc9 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -5264,6 +5264,13 @@ PresShell::ContentReplaced(nsIDocument* aDocument, nsIContent* aNewChild, PRInt32 aIndexInContainer) { + // Notify the ESM that the content has been removed, so that + // it can clean up any state related to the content. + nsCOMPtr esm; + mPresContext->GetEventStateManager(getter_AddRefs(esm)); + if (esm) + esm->ContentRemoved(aOldChild); + WillCauseReflow(); nsresult rv = mStyleSet->ContentReplaced(mPresContext, aContainer, aOldChild, aNewChild, aIndexInContainer); @@ -5280,7 +5287,6 @@ PresShell::ContentRemoved(nsIDocument *aDocument, { // Notify the ESM that the content has been removed, so that // it can clean up any state related to the content. - nsCOMPtr esm; mPresContext->GetEventStateManager(getter_AddRefs(esm)); if (esm)