Bug 1467209 - Update some baseline-querying utility functions to bail on frames that have 'contain:size'. draft
authorMorgan Rae Reschenberg <mreschenberg@mozilla.com>
Thu, 07 Jun 2018 10:00:24 -0700
changeset 810857 2e0d9af9deb7f806adf78682e53af79757de9e18
parent 806725 9941eb8c3b29d152851220b5d9791326c35e1c68
child 810858 7a40ef9f0555ecd255c53e59c51509cf9b229548
child 810861 f5e77760225525b0426233193a1ed0e72f007ca2
push id114136
push userbmo:mreschenberg@berkeley.edu
push dateTue, 26 Jun 2018 16:30:10 +0000
bugs1467209
milestone62.0a1
Bug 1467209 - Update some baseline-querying utility functions to bail on frames that have 'contain:size'. MozReview-Commit-ID: 4q9t6nW7gBW
layout/base/nsLayoutUtils.cpp
layout/style/nsStyleStruct.h
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -6191,16 +6191,19 @@ nsLayoutUtils::GetFirstLineBaseline(Writ
   return true;
 }
 
 /* static */ bool
 nsLayoutUtils::GetFirstLinePosition(WritingMode aWM,
                                     const nsIFrame* aFrame,
                                     LinePosition* aResult)
 {
+  if (aFrame->StyleDisplay()->IsContainSize()) {
+    return false;
+  }
   const nsBlockFrame* block = nsLayoutUtils::GetAsBlock(const_cast<nsIFrame*>(aFrame));
   if (!block) {
     // For the first-line baseline we also have to check for a table, and if
     // so, use the baseline of its first row.
     LayoutFrameType fType = aFrame->Type();
     if (fType == LayoutFrameType::TableWrapper ||
         fType == LayoutFrameType::FlexContainer ||
         fType == LayoutFrameType::GridContainer) {
@@ -6289,16 +6292,20 @@ nsLayoutUtils::GetFirstLinePosition(Writ
   }
   return false;
 }
 
 /* static */ bool
 nsLayoutUtils::GetLastLineBaseline(WritingMode aWM,
                                    const nsIFrame* aFrame, nscoord* aResult)
 {
+  if (aFrame->StyleDisplay()->IsContainSize()) {
+    return false;
+  }
+
   const nsBlockFrame* block = nsLayoutUtils::GetAsBlock(const_cast<nsIFrame*>(aFrame));
   if (!block)
     // No baseline.  (We intentionally don't descend into scroll frames.)
     return false;
 
   for (nsBlockFrame::ConstReverseLineIterator line = block->LinesRBegin(),
                                               line_end = block->LinesREnd();
        line != line_end; ++line) {
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2399,41 +2399,59 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
   }
   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 ||
-           mozilla::StyleDisplay::RubyBase == aDisplay ||
+           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;
   }
 
   bool IsRubyDisplayType() const {
     return IsRubyDisplayType(mDisplay);
   }
 
-  bool IsOutOfFlowStyle() const {
-    return (IsAbsolutelyPositionedStyle() || IsFloatingStyle());
+  bool IsInternalRubyDisplayType() const {
+    return IsInternalRubyDisplayType(mDisplay);
   }
 
   bool IsScrollableOverflow() const {
     // mOverflowX and mOverflowY always match when one of them is
     // NS_STYLE_OVERFLOW_VISIBLE or NS_STYLE_OVERFLOW_CLIP.
     return mOverflowX != NS_STYLE_OVERFLOW_VISIBLE &&
            mOverflowX != NS_STYLE_OVERFLOW_CLIP;
   }
 
   bool IsContainPaint() const {
     return NS_STYLE_CONTAIN_PAINT & mContain;
   }
 
+  bool IsContainSize() const {
+    // Note: The spec for size containment says it should
+    // have no effect on non-atomic, inline-level boxes. We
+    // don't check for these here because we don't know
+    // what type of element is involved. Callers are
+    // responsibble for checking if the box in question is
+    // non-atomic and inline-level, and creating an
+    // exemption as necessary.
+    return (NS_STYLE_CONTAIN_SIZE & mContain) &&
+            !IsInternalRubyDisplayType() &&
+            !(mozilla::StyleDisplay::Table == mDisplay) &&
+            !IsInnerTableStyle();
+  }
+
   /* Returns whether the element has the -moz-transform property
    * or a related property. */
   bool HasTransformStyle() const {
     return mSpecifiedTransform || mSpecifiedRotate || mSpecifiedTranslate ||
            mSpecifiedScale ||
            mTransformStyle == NS_STYLE_TRANSFORM_STYLE_PRESERVE_3D ||
            (mWillChangeBitField & NS_STYLE_WILL_CHANGE_TRANSFORM);
   }