From 31d25be8bf17c3707d1de2ae4cac770a4a767fdc Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Tue, 16 Apr 2013 18:14:56 +1200 Subject: [PATCH] Bug 860579. Make FindContentInDocument use the frame tree as much as possible. r=mattwoodrow --HG-- extra : rebase_source : c4d05d33fdc6b2bcc99437808f78ada8770f9263 --- layout/base/crashtests/860579-1.html | 21 ++++++++++++++++++++ layout/base/crashtests/crashtests.list | 1 + layout/base/nsDisplayList.cpp | 27 +++++++------------------- 3 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 layout/base/crashtests/860579-1.html diff --git a/layout/base/crashtests/860579-1.html b/layout/base/crashtests/860579-1.html new file mode 100644 index 00000000000..3f7ef558b2e --- /dev/null +++ b/layout/base/crashtests/860579-1.html @@ -0,0 +1,21 @@ + + + + + + + diff --git a/layout/base/crashtests/crashtests.list b/layout/base/crashtests/crashtests.list index b3deafebf51..392fac8a084 100644 --- a/layout/base/crashtests/crashtests.list +++ b/layout/base/crashtests/crashtests.list @@ -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 diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index a01878d57b0..a8740991766 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -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,