From 7b135748b010da7a516b109a67ff44636364d709 Mon Sep 17 00:00:00 2001 From: "roc+@cs.cmu.edu" Date: Sun, 7 Oct 2007 19:42:50 -0700 Subject: [PATCH] Bug 395331. Fix FindPrimaryFrameFor by noticing that an element can be in anonymous content if the binding root is a binding *ancestor*, not just a binding *parent*. r+sr=bzbarsy --- layout/base/nsCSSFrameConstructor.cpp | 17 ++++++++++++++- layout/reftests/bugs/395331-1-ref.xml | 6 ++++++ layout/reftests/bugs/395331-1.xml | 20 ++++++++++++++++++ layout/reftests/bugs/395331-xbl.xml | 30 +++++++++++++++++++++++++++ layout/reftests/bugs/reftest.list | 1 + 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 layout/reftests/bugs/395331-1-ref.xml create mode 100644 layout/reftests/bugs/395331-1.xml create mode 100644 layout/reftests/bugs/395331-xbl.xml diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index c7492c311bd..a494790fc85 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -10644,6 +10644,21 @@ nsCSSFrameConstructor::ReplicateFixedFrames(nsPageContentFrame* aParentFrame) return NS_OK; } +static PRBool +IsBindingAncestor(nsIContent* aContent, nsIContent* aBindingRoot) +{ + while (PR_TRUE) { + nsIContent* bindingParent = aContent->GetBindingParent(); + if (!bindingParent) + return PR_FALSE; + if (bindingParent == aBindingRoot) + return PR_TRUE; + if (bindingParent == aContent) + return PR_FALSE; + aContent = bindingParent; + } +} + // Helper function that searches the immediate child frames // (and their children if the frames are "special") // for a frame that maps the specified content object @@ -10738,7 +10753,7 @@ nsCSSFrameConstructor::FindFrameWithContent(nsFrameManager* aFrameManager, // We also need to search if the child content is anonymous and scoped // to the parent content. if (aParentContent == kidContent || - (aParentContent && (aParentContent == kidContent->GetBindingParent()))) + (aParentContent && IsBindingAncestor(kidContent, aParentContent))) { #ifdef NOISY_FINDFRAME FFWC_recursions++; diff --git a/layout/reftests/bugs/395331-1-ref.xml b/layout/reftests/bugs/395331-1-ref.xml new file mode 100644 index 00000000000..09c3b180ad4 --- /dev/null +++ b/layout/reftests/bugs/395331-1-ref.xml @@ -0,0 +1,6 @@ + + +Kitty + + diff --git a/layout/reftests/bugs/395331-1.xml b/layout/reftests/bugs/395331-1.xml new file mode 100644 index 00000000000..466edc55cab --- /dev/null +++ b/layout/reftests/bugs/395331-1.xml @@ -0,0 +1,20 @@ + + + + + + +Hello +Kitty + + diff --git a/layout/reftests/bugs/395331-xbl.xml b/layout/reftests/bugs/395331-xbl.xml new file mode 100644 index 00000000000..4b0c9772d4a --- /dev/null +++ b/layout/reftests/bugs/395331-xbl.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index b51ec8e6b4d..2337335f9f6 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -397,5 +397,6 @@ fails == 386310-1d.html 386310-1-ref.html == 394676-1.xhtml 394676-1-ref.xhtml == 395130-1.html 395130-1-ref.html == 395130-2.html 395130-2-ref.html +== 395331-1.xml 395331-1-ref.xml == 396286-1.html about:blank # crash test == 398289-1.html 398289-1-ref.html