Bug 969460 part 2: Use EnsureBlockDisplay to determine the 'display' of the root node, and let nsCSSFrameConstructor::ConstructDocElementFrame create flex containers. r=bz
authorDaniel Holbert <dholbert@cs.stanford.edu>
Sat, 15 Feb 2014 10:42:37 -0800
changeset 169041 90c1ec4ae807618ed69662ea6057dd1c1d6b461c
parent 169040 ddac6a90ceb664ade501ec1d80bcd97eb9c36f18
child 169042 509cfc636986025dbcdaaa14b3a623ea5690c331
push id39843
push userdholbert@mozilla.com
push dateSat, 15 Feb 2014 18:43:57 +0000
treeherdermozilla-inbound@509cfc636986 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs969460
milestone30.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 969460 part 2: Use EnsureBlockDisplay to determine the 'display' of the root node, and let nsCSSFrameConstructor::ConstructDocElementFrame create flex containers. r=bz
layout/base/nsCSSFrameConstructor.cpp
layout/style/nsStyleContext.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -2410,16 +2410,22 @@ nsCSSFrameConstructor::ConstructDocEleme
                                nullptr, extraRef.forget(), true, nullptr);
 
     nsFrameItems frameItems;
     contentFrame = ConstructOuterSVG(state, item, mDocElementContainingBlock,
                                      styleContext->StyleDisplay(),
                                      frameItems);
     newFrame = frameItems.FirstChild();
     NS_ASSERTION(frameItems.OnlyChild(), "multiple root element frames");
+  } else if (display->mDisplay == NS_STYLE_DISPLAY_FLEX) {
+    contentFrame = NS_NewFlexContainerFrame(mPresShell, styleContext);
+    InitAndRestoreFrame(state, aDocElement, mDocElementContainingBlock,
+                        contentFrame);
+    newFrame = contentFrame;
+    processChildren = true;
   } else if (display->mDisplay == NS_STYLE_DISPLAY_TABLE) {
     // We're going to call the right function ourselves, so no need to give a
     // function to this FrameConstructionData.
 
     // XXXbz on the other hand, if we converted this whole function to
     // FrameConstructionData/Item, then we'd need the right function
     // here... but would probably be able to get away with less code in this
     // function in general.
@@ -2433,16 +2439,18 @@ nsCSSFrameConstructor::ConstructDocEleme
     nsFrameItems frameItems;
     // if the document is a table then just populate it.
     contentFrame = ConstructTable(state, item, mDocElementContainingBlock,
                                   styleContext->StyleDisplay(),
                                   frameItems);
     newFrame = frameItems.FirstChild();
     NS_ASSERTION(frameItems.OnlyChild(), "multiple root element frames");
   } else {
+    MOZ_ASSERT(display->mDisplay == NS_STYLE_DISPLAY_BLOCK,
+               "Unhandled display type for root element");
     contentFrame = NS_NewBlockFormattingContext(mPresShell, styleContext);
     nsFrameItems frameItems;
     // Use a null PendingBinding, since our binding is not in fact pending.
     ConstructBlock(state, display, aDocElement,
                    state.GetGeometricParent(display,
                                             mDocElementContainingBlock),
                    mDocElementContainingBlock, styleContext,
                    &contentFrame, frameItems,
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -333,32 +333,29 @@ nsStyleContext::ApplyStyleFixups(bool aS
   // CSS2.1 section 9.2.4 specifies fixups for the 'display' property of
   // the root element.  We can't implement them in nsRuleNode because we
   // don't want to store all display structs that aren't 'block',
   // 'inline', or 'table' in the style context tree on the off chance
   // that the root element has its style reresolved later.  So do them
   // here if needed, by changing the style data, so that other code
   // doesn't get confused by looking at the style data.
   if (!mParent) {
-    if (disp->mDisplay != NS_STYLE_DISPLAY_NONE &&
-        disp->mDisplay != NS_STYLE_DISPLAY_BLOCK &&
-        disp->mDisplay != NS_STYLE_DISPLAY_TABLE) {
-      nsStyleDisplay *mutable_display = static_cast<nsStyleDisplay*>
-                                                   (GetUniqueStyleData(eStyleStruct_Display));
+    uint8_t displayVal = disp->mDisplay;
+    nsRuleNode::EnsureBlockDisplay(displayVal, true);
+    if (displayVal != disp->mDisplay) {
+      nsStyleDisplay *mutable_display =
+        static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display));
+
       // If we're in this code, then mOriginalDisplay doesn't matter
       // for purposes of the cascade (because this nsStyleDisplay
       // isn't living in the ruletree anyway), and for determining
       // hypothetical boxes it's better to have mOriginalDisplay
       // matching mDisplay here.
-      if (mutable_display->mDisplay == NS_STYLE_DISPLAY_INLINE_TABLE)
-        mutable_display->mOriginalDisplay = mutable_display->mDisplay =
-          NS_STYLE_DISPLAY_TABLE;
-      else
-        mutable_display->mOriginalDisplay = mutable_display->mDisplay =
-          NS_STYLE_DISPLAY_BLOCK;
+      mutable_display->mOriginalDisplay = mutable_display->mDisplay =
+        displayVal;
     }
   }
 
   // Adjust the "display" values of flex items (but not for raw text,
   // placeholders, or table-parts). CSS3 Flexbox section 4 says:
   //   # The computed 'display' of a flex item is determined
   //   # by applying the table in CSS 2.1 Chapter 9.7.
   // ...which converts inline-level elements to their block-level equivalents.