Bug 860579. Make FindContentInDocument use the frame tree as much as possible. r=mattwoodrow

--HG--
extra : rebase_source : c4d05d33fdc6b2bcc99437808f78ada8770f9263
This commit is contained in:
Robert O'Callahan 2013-04-16 18:14:56 +12:00
parent 3de0e9b4f7
commit 31d25be8bf
3 changed files with 29 additions and 20 deletions

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<script>
function addFrame(contents)
{
var frame = document.createElement("iframe");
frame.src = "data:text/html," + contents;
document.body.appendChild(frame);
}
function boom()
{
addFrame("1");
document.documentElement.offsetHeight;
addFrame("2");
document.body.style.display = "table-caption";
}
</script>
</head>
<body onload="boom();"></body>
</html>

View File

@ -391,5 +391,6 @@ load 770381-1.html
load 795646.html
load 813372-1.html
load 836990-1.html
load 860579-1.html
pref(layers.force-active,true) load 859526-1.html
pref(layers.force-active,true) load 859630-1.html

View File

@ -1396,28 +1396,15 @@ static void Sort(nsDisplayList* aList, int32_t aCount, nsDisplayList::SortLEQ aC
}
static nsIContent* FindContentInDocument(nsDisplayItem* aItem, nsIDocument* aDoc) {
nsIFrame* frame = aItem->GetUnderlyingFrame();
nsIContent* c = frame->GetContent();
for (;;) {
nsIDocument* d;
if (c) {
d = c->OwnerDoc();
} else {
d = frame->PresContext()->Document();
}
if (d == aDoc) {
return c;
}
nsIDocument* parentDoc = d->GetParentDocument();
if (!parentDoc) {
return nullptr;
}
c = parentDoc->FindContentForSubDocument(d);
if (!c) {
NS_ERROR("No content for subdocument?");
return nullptr;
nsIFrame* f = aItem->GetUnderlyingFrame();
while (f) {
nsPresContext* pc = f->PresContext();
if (pc->Document() == aDoc) {
return f->GetContent();
}
f = nsLayoutUtils::GetCrossDocParentFrame(pc->PresShell()->GetRootFrame());
}
return nullptr;
}
static bool IsContentLEQ(nsDisplayItem* aItem1, nsDisplayItem* aItem2,