Back out 2nd patch for bug 423355 due to unit test failures

This commit is contained in:
gavin@gavinsharp.com 2008-04-04 18:15:32 -07:00
parent aaac62d073
commit 2ff7b4b7c9
4 changed files with 17 additions and 20 deletions

View File

@ -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<nsPIDOMWindow> 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<nsIContent*>(aNode)->IsInNativeAnonymousSubtree()) {
return PR_FALSE;
}
doc->MayDispatchMutationEvent(aTargetForSubtreeModified);
// If we have a window, we can check it for mutation listeners now.
nsCOMPtr<nsPIDOMEventTarget> piTarget(do_QueryInterface(window));
if (piTarget) {

View File

@ -5836,11 +5836,13 @@ nsDocument::MutationEventDispatched(nsINode* aTarget)
nsCOMArray<nsINode> realTargets;
for (PRInt32 i = 0; i < count; ++i) {
nsINode* possibleTarget = mSubtreeModifiedTargets[i];
NS_ASSERTION(!possibleTarget ||
!possibleTarget->IsNodeOfType(nsINode::eCONTENT) ||
!static_cast<nsIContent*>(possibleTarget)->
IsInNativeAnonymousSubtree(),
"Mutation event targeted to native anonymous content!?!");
nsCOMPtr<nsIContent> content = do_QueryInterface(possibleTarget);
if (content && content->IsInNativeAnonymousSubtree()) {
if (realTargets.IndexOf(possibleTarget) == -1) {
realTargets.AppendObject(possibleTarget);
}
continue;
}
nsINode* commonAncestor = nsnull;
PRInt32 realTargetCount = realTargets.Count();

View File

@ -2289,11 +2289,13 @@ nsGenericElement::doPreHandleEvent(nsIContent* aContent,
nsCOMPtr<nsIContent> 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<nsIContent> content(do_QueryInterface(aVisitor.mEvent->target));

View File

@ -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));