Change the binding parent for native anonymous content to work like the binding parent for XBL anonymous content, and be the parent of the anonymous content subtree rather than the root of the anonymous content subtree. (Bug 436453) r=bzbarsky,smaug,surkov sr=bzbarsky

This commit is contained in:
L. David Baron
2008-07-22 21:50:20 -07:00
parent d3aeeff293
commit d89cbf0d17
24 changed files with 120 additions and 106 deletions

View File

@@ -435,18 +435,15 @@ nsIContent*
nsIContent::FindFirstNonNativeAnonymous() const
{
// This handles also nested native anonymous content.
nsIContent* content = GetBindingParent();
nsIContent* possibleResult =
!IsNativeAnonymous() ? const_cast<nsIContent*>(this) : nsnull;
while (content) {
if (content->IsNativeAnonymous()) {
content = possibleResult = content->GetParent();
} else {
content = content->GetBindingParent();
for (const nsIContent *content = this; content;
content = content->GetBindingParent()) {
if (!content->IsInNativeAnonymousSubtree()) {
// Oops, this function signature allows casting const to
// non-const. (Then again, so does GetChildAt(0)->GetParent().)
return const_cast<nsIContent*>(content);
}
}
return possibleResult;
return nsnull;
}
//----------------------------------------------------------------------
@@ -2091,11 +2088,11 @@ nsGenericElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
NS_PRECONDITION(!aParent || !aDocument ||
!aParent->HasFlag(NODE_FORCE_XBL_BINDINGS),
"Parent in document but flagged as forcing XBL");
NS_PRECONDITION(aBindingParent != this || IsNativeAnonymous(),
"Only native anonymous content should have itself as its "
"own binding parent");
NS_PRECONDITION(!IsNativeAnonymous() || aBindingParent == this,
"Native anonymous content must have itself as its "
NS_PRECONDITION(aBindingParent != this,
"Content must not be its own binding parent");
NS_PRECONDITION(!IsRootOfNativeAnonymousSubtree() ||
aBindingParent == aParent,
"Native anonymous content must have its parent as its "
"own binding parent");
if (!aBindingParent && aParent) {
@@ -2121,13 +2118,13 @@ nsGenericElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
slots->mBindingParent = aBindingParent; // Weak, so no addref happens.
}
}
NS_ASSERTION(!aBindingParent || IsNativeAnonymous() ||
NS_ASSERTION(!aBindingParent || IsRootOfNativeAnonymousSubtree() ||
!HasFlag(NODE_IS_IN_ANONYMOUS_SUBTREE) ||
aBindingParent->IsInNativeAnonymousSubtree(),
"Trying to re-bind content from native anonymous subtree to"
"non-native anonymous parent!");
if (IsNativeAnonymous() ||
aBindingParent && aBindingParent->IsInNativeAnonymousSubtree()) {
if (IsRootOfNativeAnonymousSubtree() ||
aParent && aParent->IsInNativeAnonymousSubtree()) {
SetFlags(NODE_IS_IN_ANONYMOUS_SUBTREE);
}
@@ -2302,7 +2299,7 @@ FindNativeAnonymousSubtreeOwner(nsIContent* aContent)
if (aContent->IsInNativeAnonymousSubtree()) {
PRBool isNativeAnon = PR_FALSE;
while (aContent && !isNativeAnon) {
isNativeAnon = aContent->IsNativeAnonymous();
isNativeAnon = aContent->IsRootOfNativeAnonymousSubtree();
aContent = aContent->GetParent();
}
}
@@ -2318,7 +2315,7 @@ nsGenericElement::doPreHandleEvent(nsIContent* aContent,
// Don't propagate mouseover and mouseout events when mouse is moving
// inside native anonymous content.
PRBool isAnonForEvents = aContent->IsNativeAnonymous();
PRBool isAnonForEvents = aContent->IsRootOfNativeAnonymousSubtree();
if ((aVisitor.mEvent->message == NS_MOUSE_ENTER_SYNTH ||
aVisitor.mEvent->message == NS_MOUSE_EXIT_SYNTH) &&
// This is an optimization - try to stop event propagation when