Bug 1038294 part 15 - Change a few existing nsStyleDisplay accessors to use DisplayInside()/DisplayOutside(). r=emilio
authorMats Palmgren <mats@mozilla.com>
Wed, 14 Aug 2019 14:35:19 +0000
changeset 487943 f919a62c86d1bebfd677f590b64ed04f974ae0cc
parent 487942 6c19f13a6082638e3b83d07196e99fb92f4dbf8d
child 487944 57bcf2eea1098285fa30160590eaea97bf483692
push id36433
push userbtara@mozilla.com
push dateWed, 14 Aug 2019 21:57:52 +0000
treeherdermozilla-central@7d9a2196d313 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1038294
milestone70.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 1038294 part 15 - Change a few existing nsStyleDisplay accessors to use DisplayInside()/DisplayOutside(). r=emilio Differential Revision: https://phabricator.services.mozilla.com/D39767
layout/generic/ReflowInput.cpp
layout/style/nsStyleStruct.h
--- a/layout/generic/ReflowInput.cpp
+++ b/layout/generic/ReflowInput.cpp
@@ -889,56 +889,45 @@ void ReflowInput::InitFrameType(LayoutFr
     } else if (disp->IsFloating(mFrame)) {
       frameType = NS_CSS_FRAME_TYPE_FLOATING;
     } else {
       NS_ASSERTION(disp->mDisplay == StyleDisplay::MozPopup,
                    "unknown out of flow frame type");
       frameType = NS_CSS_FRAME_TYPE_UNKNOWN;
     }
   } else {
-    switch (GetDisplay()) {
-      case StyleDisplay::Block:
-      case StyleDisplay::ListItem:
-      case StyleDisplay::Table:
-      case StyleDisplay::TableCaption:
-      case StyleDisplay::Flex:
-      case StyleDisplay::WebkitBox:
-      case StyleDisplay::Grid:
-      case StyleDisplay::FlowRoot:
-      case StyleDisplay::RubyTextContainer:
+    switch (disp->DisplayOutside()) {
+      case StyleDisplayOutside::Block:
+      case StyleDisplayOutside::TableCaption:
         frameType = NS_CSS_FRAME_TYPE_BLOCK;
         break;
 
-      case StyleDisplay::Inline:
-      case StyleDisplay::InlineBlock:
-      case StyleDisplay::InlineTable:
-      case StyleDisplay::MozInlineBox:
-      case StyleDisplay::MozInlineGrid:
-      case StyleDisplay::MozInlineStack:
-      case StyleDisplay::InlineFlex:
-      case StyleDisplay::WebkitInlineBox:
-      case StyleDisplay::InlineGrid:
-      case StyleDisplay::Ruby:
-      case StyleDisplay::RubyBase:
-      case StyleDisplay::RubyText:
-      case StyleDisplay::RubyBaseContainer:
+      case StyleDisplayOutside::Inline:
         frameType = NS_CSS_FRAME_TYPE_INLINE;
         break;
 
-      case StyleDisplay::TableCell:
-      case StyleDisplay::TableRowGroup:
-      case StyleDisplay::TableColumn:
-      case StyleDisplay::TableColumnGroup:
-      case StyleDisplay::TableHeaderGroup:
-      case StyleDisplay::TableFooterGroup:
-      case StyleDisplay::TableRow:
+      case StyleDisplayOutside::InternalTable:
         frameType = NS_CSS_FRAME_TYPE_INTERNAL_TABLE;
         break;
 
-      case StyleDisplay::None:
+      case StyleDisplayOutside::InternalRuby:
+        switch (disp->DisplayInside()) {
+          case StyleDisplayInside::RubyTextContainer:
+            frameType = NS_CSS_FRAME_TYPE_BLOCK;
+            break;
+          case StyleDisplayInside::RubyBase:
+          case StyleDisplayInside::RubyText:
+          case StyleDisplayInside::RubyBaseContainer:
+            frameType = NS_CSS_FRAME_TYPE_INLINE;
+            break;
+          default:
+            MOZ_ASSERT_UNREACHABLE("unexpected inside for InternalRuby");
+        }
+        break;
+
       default:
         frameType = NS_CSS_FRAME_TYPE_UNKNOWN;
         break;
     }
   }
 
   // See if the frame is replaced
   if (mFrame->IsFrameOfType(nsIFrame::eReplacedContainsBlock)) {
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -1626,71 +1626,61 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
            mozilla::StyleDisplay::TableCaption == mDisplay ||
            mozilla::StyleDisplay::FlowRoot == mDisplay;
     // Should TABLE_CELL be included here?  They have
     // block frames nested inside of them.
     // (But please audit all callers before changing.)
   }
 
   bool IsInlineInsideStyle() const {
-    return mozilla::StyleDisplay::Inline == mDisplay ||
-           mozilla::StyleDisplay::Ruby == mDisplay ||
-           mozilla::StyleDisplay::RubyBase == mDisplay ||
-           mozilla::StyleDisplay::RubyBaseContainer == mDisplay ||
-           mozilla::StyleDisplay::RubyText == mDisplay ||
-           mozilla::StyleDisplay::RubyTextContainer == mDisplay;
+    auto inside = DisplayInside();
+    return inside == mozilla::StyleDisplayInside::Inline ||
+           inside == mozilla::StyleDisplayInside::Ruby ||
+           inside == mozilla::StyleDisplayInside::RubyBase ||
+           inside == mozilla::StyleDisplayInside::RubyBaseContainer ||
+           inside == mozilla::StyleDisplayInside::RubyText ||
+           inside == mozilla::StyleDisplayInside::RubyTextContainer;
   }
 
   bool IsBlockOutsideStyle() const {
-    return mozilla::StyleDisplay::Block == mDisplay ||
-           mozilla::StyleDisplay::Flex == mDisplay ||
-           mozilla::StyleDisplay::WebkitBox == mDisplay ||
-           mozilla::StyleDisplay::Grid == mDisplay ||
-           mozilla::StyleDisplay::ListItem == mDisplay ||
-           mozilla::StyleDisplay::Table == mDisplay ||
-           mozilla::StyleDisplay::FlowRoot == mDisplay;
+    return DisplayOutside() == mozilla::StyleDisplayOutside::Block;
   }
 
   static bool IsDisplayTypeInlineOutside(mozilla::StyleDisplay aDisplay) {
-    return mozilla::StyleDisplay::Inline == aDisplay ||
-           mozilla::StyleDisplay::InlineBlock == aDisplay ||
-           mozilla::StyleDisplay::InlineTable == aDisplay ||
-           mozilla::StyleDisplay::MozInlineBox == aDisplay ||
-           mozilla::StyleDisplay::InlineFlex == aDisplay ||
-           mozilla::StyleDisplay::WebkitInlineBox == aDisplay ||
-           mozilla::StyleDisplay::InlineGrid == aDisplay ||
+    auto outside = DisplayOutside(aDisplay);
+    if (outside == mozilla::StyleDisplayOutside::Inline) {
+      return true;
+    }
+    // just an optimization for the common case:
+    if (outside == mozilla::StyleDisplayOutside::Block) {
+      return false;
+    }
+    return mozilla::StyleDisplay::MozInlineBox == aDisplay ||
            mozilla::StyleDisplay::MozInlineGrid == aDisplay ||
            mozilla::StyleDisplay::MozInlineStack == aDisplay ||
-           mozilla::StyleDisplay::Ruby == aDisplay ||
            mozilla::StyleDisplay::RubyBase == aDisplay ||
            mozilla::StyleDisplay::RubyBaseContainer == aDisplay ||
            mozilla::StyleDisplay::RubyText == aDisplay ||
            mozilla::StyleDisplay::RubyTextContainer == aDisplay;
   }
 
   bool IsInlineOutsideStyle() const {
     return IsDisplayTypeInlineOutside(mDisplay);
   }
 
   bool IsOriginalDisplayInlineOutsideStyle() const {
     return IsDisplayTypeInlineOutside(mOriginalDisplay);
   }
 
   bool IsInnerTableStyle() const {
-    return mozilla::StyleDisplay::TableCell == mDisplay ||
-           IsInternalTableStyleExceptCell();
+    return DisplayOutside() == mozilla::StyleDisplayOutside::InternalTable;
   }
 
   bool IsInternalTableStyleExceptCell() const {
-    return mozilla::StyleDisplay::TableRow == mDisplay ||
-           mozilla::StyleDisplay::TableRowGroup == mDisplay ||
-           mozilla::StyleDisplay::TableHeaderGroup == mDisplay ||
-           mozilla::StyleDisplay::TableFooterGroup == mDisplay ||
-           mozilla::StyleDisplay::TableColumn == mDisplay ||
-           mozilla::StyleDisplay::TableColumnGroup == mDisplay;
+    return IsInnerTableStyle() && mozilla::StyleDisplay::TableCell != mDisplay;
   }
 
   bool IsFloatingStyle() const { return mozilla::StyleFloat::None != mFloat; }
 
   bool IsAbsolutelyPositionedStyle() const {
     return NS_STYLE_POSITION_ABSOLUTE == mPosition ||
            NS_STYLE_POSITION_FIXED == mPosition;
   }
@@ -1703,17 +1693,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
     return NS_STYLE_POSITION_STICKY == mPosition;
   }
   bool IsPositionForcingStackingContext() const {
     return NS_STYLE_POSITION_STICKY == mPosition ||
            NS_STYLE_POSITION_FIXED == mPosition;
   }
 
   static bool IsRubyDisplayType(mozilla::StyleDisplay aDisplay) {
-    return mozilla::StyleDisplay::Ruby == aDisplay ||
+    return DisplayInside(aDisplay) == mozilla::StyleDisplayInside::Ruby ||
            IsInternalRubyDisplayType(aDisplay);
   }
 
   static bool IsInternalRubyDisplayType(mozilla::StyleDisplay aDisplay) {
     return mozilla::StyleDisplay::RubyBase == aDisplay ||
            mozilla::StyleDisplay::RubyBaseContainer == aDisplay ||
            mozilla::StyleDisplay::RubyText == aDisplay ||
            mozilla::StyleDisplay::RubyTextContainer == aDisplay;