From d588bfd40b3db18b3b59f23bc95c756328cc0e77 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Mon, 7 Dec 2015 18:39:41 -0500 Subject: [PATCH] Bug 1230701 - Make will-change:position create a containing block for absolutely-positioned elements. r=dholbert --HG-- extra : commitid : 99HuPIkGhg5 --- layout/style/nsCSSPropList.h | 3 ++- layout/style/nsCSSProps.h | 9 +++++++++ layout/style/nsRuleNode.cpp | 6 ++++-- layout/style/nsStyleConsts.h | 1 + layout/style/nsStyleStructInlines.h | 7 +++++-- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index 66915495cda4..6c3c3fe45043 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -3029,7 +3029,8 @@ CSS_PROP_DISPLAY( Position, CSS_PROPERTY_PARSE_VALUE | // For position: sticky/fixed - CSS_PROPERTY_CREATES_STACKING_CONTEXT, + CSS_PROPERTY_CREATES_STACKING_CONTEXT | + CSS_PROPERTY_ABSPOS_CB, "", VARIANT_HK, kPositionKTable, diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h index 0ee81f148387..45be06c891cc 100644 --- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -262,6 +262,15 @@ static_assert((CSS_PROPERTY_PARSE_PROPERTY_MASK & // nsStyleDisplay::IsFixedPosContainingBlock. #define CSS_PROPERTY_FIXPOS_CB (1<<29) +// This property has values that can establish a containing block for +// absolutely positioned elements. +// This should be set for any properties that can cause an element to be +// such a containing block, as implemented in +// nsStyleDisplay::IsAbsPosContainingBlock. +// It does not need to be set for properties that also have +// CSS_PROPERTY_FIXPOS_CB set. +#define CSS_PROPERTY_ABSPOS_CB (1<<30) + /** * Types of animatable values. */ diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 9692407e44c5..a6c0869607dc 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -6084,8 +6084,10 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct, NS_STYLE_WILL_CHANGE_STACKING_CONTEXT; } if (nsCSSProps::PropHasFlags(prop, CSS_PROPERTY_FIXPOS_CB)) { - display->mWillChangeBitField |= - NS_STYLE_WILL_CHANGE_FIXPOS_CB; + display->mWillChangeBitField |= NS_STYLE_WILL_CHANGE_FIXPOS_CB; + } + if (nsCSSProps::PropHasFlags(prop, CSS_PROPERTY_ABSPOS_CB)) { + display->mWillChangeBitField |= NS_STYLE_WILL_CHANGE_ABSPOS_CB; } } } diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index e71fe7029593..2b0874e74225 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -244,6 +244,7 @@ enum class StyleBoxSizing : uint8_t { #define NS_STYLE_WILL_CHANGE_SCROLL (1<<2) #define NS_STYLE_WILL_CHANGE_OPACITY (1<<3) #define NS_STYLE_WILL_CHANGE_FIXPOS_CB (1<<4) +#define NS_STYLE_WILL_CHANGE_ABSPOS_CB (1<<5) // See AnimationEffectReadOnly.webidl // and mozilla/dom/AnimationEffectReadOnlyBinding.h diff --git a/layout/style/nsStyleStructInlines.h b/layout/style/nsStyleStructInlines.h index 963856e2eaad..6e845646ad66 100644 --- a/layout/style/nsStyleStructInlines.h +++ b/layout/style/nsStyleStructInlines.h @@ -154,8 +154,11 @@ nsStyleDisplay::IsAbsPosContainingBlock(const nsIFrame* aContextFrame) const { NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); - return ((IsAbsolutelyPositionedStyle() || IsRelativelyPositionedStyle()) && - !aContextFrame->IsSVGText()) || IsFixedPosContainingBlock(aContextFrame); + return ((IsAbsolutelyPositionedStyle() || + IsRelativelyPositionedStyle() || + (mWillChangeBitField & NS_STYLE_WILL_CHANGE_ABSPOS_CB)) && + !aContextFrame->IsSVGText()) || + IsFixedPosContainingBlock(aContextFrame); } bool