Put the root element in the undisplayed map so that we reconstruct it when it has its 'display' changed from 'none' to something else. (Bug 283686) r+sr=bzbarsky
authorMats Palmgren <mats.palmgren@bredband.net>, L. David Baron <dbaron@dbaron.org>
Sat, 10 Jan 2009 08:28:15 -0800
changeset 23523 7bf1d1b7f3b8b57bf49016347bb15414f6c24425
parent 23522 ebc083cea40bd0a4cabe89e91775e34134ceada9
child 23524 5a85468e0174674fe7d9a426d594870376db1743
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs283686
milestone1.9.2a1pre
Put the root element in the undisplayed map so that we reconstruct it when it has its 'display' changed from 'none' to something else. (Bug 283686) r+sr=bzbarsky
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsFrameManager.cpp
layout/reftests/bugs/283686-1.html
layout/reftests/bugs/283686-2-ref.html
layout/reftests/bugs/283686-2.html
layout/reftests/bugs/283686-3.html
layout/reftests/bugs/reftest.list
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -4137,16 +4137,17 @@ nsCSSFrameConstructor::ConstructDocEleme
 
   NS_ASSERTION(!display->IsScrollableOverflow() || 
                aState.mPresContext->IsPaginated() ||
                propagatedScrollToViewport,
                "Scrollbars should have been propagated to the viewport");
 #endif
 
   if (NS_UNLIKELY(display->mDisplay == NS_STYLE_DISPLAY_NONE)) {
+    aState.mFrameManager->SetUndisplayedContent(aDocElement, styleContext);
     mInitialContainingBlock = nsnull;
     mRootElementStyleFrame = nsnull;
     return NS_OK;
   }
 
   nsFrameConstructorSaveState absoluteSaveState;
   if (mHasRootAbsPosContainingBlock) {
     // Push the absolute containing block now so we can absolutely position
--- a/layout/base/nsFrameManager.cpp
+++ b/layout/base/nsFrameManager.cpp
@@ -552,19 +552,16 @@ nsFrameManager::ClearPlaceholderFrameMap
 
 nsStyleContext*
 nsFrameManager::GetUndisplayedContent(nsIContent* aContent)
 {
   if (!aContent || !mUndisplayedMap)
     return nsnull;
 
   nsIContent* parent = aContent->GetParent();
-  if (!parent)
-    return nsnull;
-
   for (UndisplayedNode* node = mUndisplayedMap->GetFirstNode(parent);
          node; node = node->mNext) {
     if (node->mContent == aContent)
       return node->mStyle;
   }
 
   return nsnull;
 }
@@ -581,20 +578,20 @@ nsFrameManager::SetUndisplayedContent(ns
   NS_ASSERTION(!GetUndisplayedContent(aContent),
                "Already have an undisplayed context entry for aContent");
 
   if (! mUndisplayedMap) {
     mUndisplayedMap = new UndisplayedMap;
   }
   if (mUndisplayedMap) {
     nsIContent* parent = aContent->GetParent();
-    NS_ASSERTION(parent, "undisplayed content must have a parent");
-    if (parent) {
-      mUndisplayedMap->AddNodeFor(parent, aContent, aStyleContext);
-    }
+    NS_ASSERTION(parent || (mPresShell && mPresShell->GetDocument() &&
+                 mPresShell->GetDocument()->GetRootContent() == aContent),
+                 "undisplayed content must have a parent, unless it's the root content");
+    mUndisplayedMap->AddNodeFor(parent, aContent, aStyleContext);
   }
 }
 
 void
 nsFrameManager::ChangeUndisplayedContent(nsIContent* aContent, 
                                          nsStyleContext* aStyleContext)
 {
   NS_ASSERTION(mUndisplayedMap, "no existing undisplayed content");
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/283686-1.html
@@ -0,0 +1,5 @@
+<!DOCTYPE HTML>
+<html style="display:none">
+<title>Testcase, bug 283686 (root element having display:none)</title>
+<p>Hello world!</p>
+
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/283686-2-ref.html
@@ -0,0 +1,5 @@
+<!DOCTYPE HTML>
+<html>
+<title>Testcase, bug 283686 (root element having display:none)</title>
+<p>Hello world!</p>
+
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/283686-2.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML>
+<html class="reftest-wait" style="display:none">
+<script type="text/javascript">
+function run() {
+    document.documentElement.style.display = '';
+    document.documentElement.className = '';
+}
+</script>
+<body onload="run()">
+<title>Testcase, bug 283686 (root element having display:none)</title>
+<p>Hello world!</p>
+
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/283686-3.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML>
+<html class="reftest-wait">
+<script type="text/javascript">
+function run() {
+    document.documentElement.style.display = 'none';
+    document.documentElement.className = '';
+}
+</script>
+<body onload="run()">
+<title>Testcase, bug 283686 (root element having display:none)</title>
+<p>Hello world!</p>
+
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -208,16 +208,19 @@ random == 99850-1b.html 99850-1-ref.html
 == 253701-1.html 253701-1-ref.html
 == 255820-1.html 255820-1-ref.html
 == 262151-1.html 262151-1-ref.html
 #== 263683-1.html 263683-1-ref.html
 == 267353-1.html 267353-1-ref.html
 == 271747-1a.html 271747-1-ref.html
 == 271747-1b.html 271747-1-ref.html
 == 273681-1.html 273681-1-ref.html
+== 283686-1.html about:blank
+== 283686-2.html 283686-2-ref.html
+== 283686-3.html about:blank
 fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") HTTP == 289480.html#top 289480-ref.html # basically-verbatim acid2 test, HTTP for a 404 page -- bug 409329 for the non-Mac failures
 == 290129-1.html 290129-1-ref.html
 == 291078-1.html 291078-1-ref.html
 == 291078-2.html 291078-2-ref.html
 == 291262-1.html 291262-1-ref.html
 == 294306-1.html 294306-1a-ref.html
 != 294306-1.html 294306-1b-ref.html
 == 296904-1.html 296904-1-ref.html