From babd445376c03f4677ae31fdd81a914d1d63f62a Mon Sep 17 00:00:00 2001 From: "gavin%gavinsharp.com" Date: Sat, 5 Apr 2008 01:15:32 +0000 Subject: [PATCH] Back out 2nd patch for bug 423355 due to unit test failures --- content/base/src/nsContentUtils.cpp | 11 ++--------- content/base/src/nsDocument.cpp | 12 +++++++----- content/base/src/nsGenericElement.cpp | 12 +++++++----- content/events/src/nsEventListenerManager.cpp | 2 +- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 0b9220f1eb2..25e2ad85c23 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -3191,22 +3191,15 @@ nsContentUtils::HasMutationListeners(nsINode* aNode, return PR_FALSE; } + doc->MayDispatchMutationEvent(aTargetForSubtreeModified); + // global object will be null for documents that don't have windows. nsCOMPtr window; window = do_QueryInterface(doc->GetScriptGlobalObject()); - // This relies on nsEventListenerManager::AddEventListener, which sets - // all mutation bits when there is a listener for DOMSubtreeModified event. if (window && !window->HasMutationListeners(aType)) { return PR_FALSE; } - if (aNode->IsNodeOfType(nsINode::eCONTENT) && - static_cast(aNode)->IsInNativeAnonymousSubtree()) { - return PR_FALSE; - } - - doc->MayDispatchMutationEvent(aTargetForSubtreeModified); - // If we have a window, we can check it for mutation listeners now. nsCOMPtr piTarget(do_QueryInterface(window)); if (piTarget) { diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index f757b0a4911..b80ece6a43c 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -5836,11 +5836,13 @@ nsDocument::MutationEventDispatched(nsINode* aTarget) nsCOMArray realTargets; for (PRInt32 i = 0; i < count; ++i) { nsINode* possibleTarget = mSubtreeModifiedTargets[i]; - NS_ASSERTION(!possibleTarget || - !possibleTarget->IsNodeOfType(nsINode::eCONTENT) || - !static_cast(possibleTarget)-> - IsInNativeAnonymousSubtree(), - "Mutation event targeted to native anonymous content!?!"); + nsCOMPtr content = do_QueryInterface(possibleTarget); + if (content && content->IsInNativeAnonymousSubtree()) { + if (realTargets.IndexOf(possibleTarget) == -1) { + realTargets.AppendObject(possibleTarget); + } + continue; + } nsINode* commonAncestor = nsnull; PRInt32 realTargetCount = realTargets.Count(); diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 5abcd3a77da..a5382247941 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -2289,11 +2289,13 @@ nsGenericElement::doPreHandleEvent(nsIContent* aContent, nsCOMPtr parent = aContent->GetParent(); if (isAnonForEvents) { - // If a DOM event is explicitly dispatched using node.dispatchEvent(), then - // all the events are allowed even in the native anonymous content.. - NS_ASSERTION(aVisitor.mEvent->eventStructType != NS_MUTATION_EVENT || - aVisitor.mDOMEvent, - "Mutation event dispatched in native anonymous content!?!"); + // Don't propagate mutation events which are dispatched somewhere inside + // native anonymous content. + if (aVisitor.mEvent->eventStructType == NS_MUTATION_EVENT) { + aVisitor.mParentTarget = nsnull; + return NS_OK; + } + aVisitor.mEventTargetAtParent = parent; } else if (parent) { nsCOMPtr content(do_QueryInterface(aVisitor.mEvent->target)); diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 6c02f1a7504..2f7cdae5037 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -519,7 +519,7 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener, NS_ASSERTION(window->IsInnerWindow(), "Setting mutation listener bits on outer window?"); // If aType is NS_MUTATION_SUBTREEMODIFIED, we need to listen all - // mutations. nsContentUtils::HasMutationListeners relies on this. + // mutations. window->SetMutationListeners((aType == NS_MUTATION_SUBTREEMODIFIED) ? kAllMutationBits : MutationBitForEventType(aType));