Bug 1467209 - Update some baseline-querying utility functions to bail on frames that have 'contain:size'.
MozReview-Commit-ID: 4q9t6nW7gBW
--- 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);
}