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

This commit is contained in:
roc+@cs.cmu.edu 2007-10-07 19:42:50 -07:00
Родитель e65eb51316
Коммит d7402d3ddb
5 изменённых файлов: 73 добавлений и 1 удалений

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

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

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

@ -0,0 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<body>
Kitty
</body>
</html>

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

@ -0,0 +1,20 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<head>
<style>
.base { -moz-binding: url("395331-xbl.xml#base"); }
.inner { -moz-binding: url("395331-xbl.xml#inner"); }
</style>
<script>
function boom()
{
var x = document.getElementById("x");
x.removeChild(x.firstChild);
}
</script>
</head>
<body onload="boom();">
<xul:box class="base" id="x" style="height:2em;">Hello</xul:box>
Kitty
</body>
</html>

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

@ -0,0 +1,30 @@
<?xml version="1.0"?>
<!DOCTYPE bindings>
<bindings id="testBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="base">
<content>
<xul:box flex="1">
<xul:box class="inner" flex="1">
<children/>
</xul:box>
</xul:box>
</content>
</binding>
<binding id="inner">
<content>
<xul:box flex="1">
<xul:box flex="1">
<children/>
</xul:box>
</xul:box>
</content>
</binding>
</bindings>

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

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