Bug 860579. Make FindContentInDocument use the frame tree as much as possible. r=mattwoodrow
☠☠ backed out by 7c596ffafa29 ☠ ☠
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 16 Apr 2013 18:14:56 +1200
changeset 128894 cff9eab960e39ac98d38f9ef62bb4b032a02cdcf
parent 128893 64abee9b00f1b03f6b5d735f44628e93e63a73c4
child 128895 3581b3d60886c34edb1c9366c0d04c2a2a577ee7
push id24545
push userryanvm@gmail.com
push dateTue, 16 Apr 2013 13:13:04 +0000
treeherdermozilla-central@09f78adf4e79 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs860579
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 860579. Make FindContentInDocument use the frame tree as much as possible. r=mattwoodrow
layout/base/crashtests/860579-1.html
layout/base/crashtests/crashtests.list
layout/base/nsDisplayList.cpp
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/860579-1.html
@@ -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>
--- a/layout/base/crashtests/crashtests.list
+++ b/layout/base/crashtests/crashtests.list
@@ -386,10 +386,11 @@ asserts(0-2) load 736389-1.xhtml # somet
 asserts-if(winWidget,0-2) load 736924-1.html # bug 738803
 load 749816-1.html
 load 763223-1.html
 test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.lineThreshold,100) load 763702.xhtml
 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
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -1391,38 +1391,25 @@ static void Sort(nsDisplayList* aList, i
       aList->AppendToTop(list1.RemoveBottom());
     } else {
       aList->AppendToTop(list2.RemoveBottom());
     }
   }
 }
 
 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();
+  nsIFrame* f = aItem->GetUnderlyingFrame();
+  while (f) {
+    nsPresContext* pc = f->PresContext();
+    if (pc->Document() == aDoc) {
+      return f->GetContent();
     }
-    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;
-    }
+    f = nsLayoutUtils::GetCrossDocParentFrame(pc->PresShell()->GetRootFrame());
   }
+  return nullptr;
 }
 
 static bool IsContentLEQ(nsDisplayItem* aItem1, nsDisplayItem* aItem2,
                          void* aClosure) {
   nsIContent* commonAncestor = static_cast<nsIContent*>(aClosure);
   // It's possible that the nsIContent for aItem1 or aItem2 is in a subdocument
   // of commonAncestor, because display items for subdocuments have been
   // mixed into the same list. Ensure that we're looking at content