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

This commit is contained in:
gavin%gavinsharp.com 2008-04-05 01:15:32 +00:00
Родитель 97bfff65bd
Коммит babd445376
4 изменённых файлов: 17 добавлений и 20 удалений

Просмотреть файл

@ -3191,22 +3191,15 @@ nsContentUtils::HasMutationListeners(nsINode* aNode,
return PR_FALSE; return PR_FALSE;
} }
doc->MayDispatchMutationEvent(aTargetForSubtreeModified);
// global object will be null for documents that don't have windows. // global object will be null for documents that don't have windows.
nsCOMPtr<nsPIDOMWindow> window; nsCOMPtr<nsPIDOMWindow> window;
window = do_QueryInterface(doc->GetScriptGlobalObject()); 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)) { if (window && !window->HasMutationListeners(aType)) {
return PR_FALSE; 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. // If we have a window, we can check it for mutation listeners now.
nsCOMPtr<nsPIDOMEventTarget> piTarget(do_QueryInterface(window)); nsCOMPtr<nsPIDOMEventTarget> piTarget(do_QueryInterface(window));
if (piTarget) { if (piTarget) {

Просмотреть файл

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

Просмотреть файл

@ -2289,11 +2289,13 @@ nsGenericElement::doPreHandleEvent(nsIContent* aContent,
nsCOMPtr<nsIContent> parent = aContent->GetParent(); nsCOMPtr<nsIContent> parent = aContent->GetParent();
if (isAnonForEvents) { if (isAnonForEvents) {
// If a DOM event is explicitly dispatched using node.dispatchEvent(), then // Don't propagate mutation events which are dispatched somewhere inside
// all the events are allowed even in the native anonymous content.. // native anonymous content.
NS_ASSERTION(aVisitor.mEvent->eventStructType != NS_MUTATION_EVENT || if (aVisitor.mEvent->eventStructType == NS_MUTATION_EVENT) {
aVisitor.mDOMEvent, aVisitor.mParentTarget = nsnull;
"Mutation event dispatched in native anonymous content!?!"); return NS_OK;
}
aVisitor.mEventTargetAtParent = parent; aVisitor.mEventTargetAtParent = parent;
} else if (parent) { } else if (parent) {
nsCOMPtr<nsIContent> content(do_QueryInterface(aVisitor.mEvent->target)); nsCOMPtr<nsIContent> content(do_QueryInterface(aVisitor.mEvent->target));

Просмотреть файл

@ -519,7 +519,7 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
NS_ASSERTION(window->IsInnerWindow(), NS_ASSERTION(window->IsInnerWindow(),
"Setting mutation listener bits on outer window?"); "Setting mutation listener bits on outer window?");
// If aType is NS_MUTATION_SUBTREEMODIFIED, we need to listen all // If aType is NS_MUTATION_SUBTREEMODIFIED, we need to listen all
// mutations. nsContentUtils::HasMutationListeners relies on this. // mutations.
window->SetMutationListeners((aType == NS_MUTATION_SUBTREEMODIFIED) ? window->SetMutationListeners((aType == NS_MUTATION_SUBTREEMODIFIED) ?
kAllMutationBits : kAllMutationBits :
MutationBitForEventType(aType)); MutationBitForEventType(aType));