Bug 964885 - Implement stacking context behavior of CSS will-change. r=dbaron

--HG--
extra : rebase_source : 9417239e40a13df22c207838faf64b67d9027f6e
This commit is contained in:
Benoit Girard 2014-02-05 23:50:22 -05:00
parent d333e69b9c
commit 17b6ab9f8b
7 changed files with 49 additions and 18 deletions

View File

@ -2180,6 +2180,7 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
bool isStackingContext =
(isPositioned && (disp->mPosition == NS_STYLE_POSITION_STICKY ||
pos->mZIndex.GetUnit() == eStyleUnit_Integer)) ||
(disp->mWillChangeBitField & NS_STYLE_WILL_CHANGE_STACKING_CONTEXT) ||
isVisuallyAtomic || (aFlags & DISPLAY_CHILD_FORCE_STACKING_CONTEXT);
if (isVisuallyAtomic || isPositioned || (!isSVG && disp->IsFloating(child)) ||

View File

@ -2389,7 +2389,8 @@ CSS_PROP_DISPLAY(
mix-blend-mode,
mix_blend_mode,
MixBlendMode,
CSS_PROPERTY_PARSE_VALUE,
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_CREATES_STACKING_CONTEXT,
"layout.css.mix-blend-mode.enabled",
VARIANT_HK,
kBlendModeKTable,
@ -2759,7 +2760,9 @@ CSS_PROP_DISPLAY(
position,
position,
Position,
CSS_PROPERTY_PARSE_VALUE,
CSS_PROPERTY_PARSE_VALUE |
// For position: sticky
CSS_PROPERTY_CREATES_STACKING_CONTEXT,
"",
VARIANT_HK,
kPositionKTable,
@ -2974,7 +2977,8 @@ CSS_PROP_DISPLAY(
transform,
Transform,
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_GETCS_NEEDS_LAYOUT_FLUSH,
CSS_PROPERTY_GETCS_NEEDS_LAYOUT_FLUSH |
CSS_PROPERTY_CREATES_STACKING_CONTEXT,
"",
0,
nullptr,
@ -3008,7 +3012,8 @@ CSS_PROP_DISPLAY(
perspective,
perspective,
Perspective,
CSS_PROPERTY_PARSE_VALUE,
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_CREATES_STACKING_CONTEXT,
"",
VARIANT_NONE | VARIANT_INHERIT | VARIANT_LENGTH | VARIANT_POSITIVE_DIMENSION,
nullptr,
@ -3018,7 +3023,8 @@ CSS_PROP_DISPLAY(
transform-style,
transform_style,
TransformStyle,
CSS_PROPERTY_PARSE_VALUE,
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_CREATES_STACKING_CONTEXT,
"",
VARIANT_HK,
kTransformStyleKTable,
@ -3289,7 +3295,8 @@ CSS_PROP_POSITION(
z-index,
z_index,
ZIndex,
CSS_PROPERTY_PARSE_VALUE,
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_CREATES_STACKING_CONTEXT,
"",
VARIANT_AHI,
nullptr,
@ -3437,7 +3444,8 @@ CSS_PROP_SVGRESET(
clip-path,
clip_path,
ClipPath,
CSS_PROPERTY_PARSE_VALUE,
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_CREATES_STACKING_CONTEXT,
"",
VARIANT_HUO,
nullptr,
@ -3517,7 +3525,8 @@ CSS_PROP_SVGRESET(
filter,
filter,
Filter,
CSS_PROPERTY_PARSE_FUNCTION,
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_CREATES_STACKING_CONTEXT,
"",
0,
nullptr,
@ -3603,7 +3612,8 @@ CSS_PROP_SVGRESET(
mask,
mask,
Mask,
CSS_PROPERTY_PARSE_VALUE,
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_CREATES_STACKING_CONTEXT,
"",
VARIANT_HUO,
nullptr,

View File

@ -191,6 +191,9 @@ static_assert((CSS_PROPERTY_PARSE_PROPERTY_MASK &
// flushed.
#define CSS_PROPERTY_GETCS_NEEDS_LAYOUT_FLUSH (1<<20)
// This property requires a stacking context.
#define CSS_PROPERTY_CREATES_STACKING_CONTEXT (1<<21)
/**
* Types of animatable values.
*/

View File

@ -5477,6 +5477,8 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
if (item->mValue.UnitHasStringValue()) {
nsAutoString buffer;
item->mValue.GetStringValue(buffer);
display->mWillChange.AppendElement(buffer);
if (buffer.EqualsLiteral("transform")) {
display->mWillChangeBitField |= NS_STYLE_WILL_CHANGE_TRANSFORM;
}
@ -5486,7 +5488,13 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
if (buffer.EqualsLiteral("scroll-position")) {
display->mWillChangeBitField |= NS_STYLE_WILL_CHANGE_SCROLL;
}
display->mWillChange.AppendElement(buffer);
nsCSSProperty prop =
nsCSSProps::LookupProperty(buffer, nsCSSProps::eEnabled);
if (nsCSSProps::PropHasFlags(prop,
CSS_PROPERTY_CREATES_STACKING_CONTEXT)) {
display->mWillChangeBitField |= NS_STYLE_WILL_CHANGE_STACKING_CONTEXT;
}
}
}
break;

View File

@ -212,9 +212,10 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_COLOR_CONTEXT_STROKE -8
// See nsStyleDisplay
#define NS_STYLE_WILL_CHANGE_TRANSFORM (1<<0)
#define NS_STYLE_WILL_CHANGE_SCROLL (1<<1)
#define NS_STYLE_WILL_CHANGE_OPACITY (1<<2)
#define NS_STYLE_WILL_CHANGE_STACKING_CONTEXT (1<<0)
#define NS_STYLE_WILL_CHANGE_TRANSFORM (1<<1)
#define NS_STYLE_WILL_CHANGE_SCROLL (1<<2)
#define NS_STYLE_WILL_CHANGE_OPACITY (1<<3)
// See nsStyleDisplay
#define NS_STYLE_ANIMATION_DIRECTION_NORMAL 0

View File

@ -2467,7 +2467,13 @@ nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
}
if (mWillChangeBitField != aOther.mWillChangeBitField) {
uint8_t willChangeBitsChanged =
mWillChangeBitField ^ aOther.mWillChangeBitField;
if (willChangeBitsChanged & NS_STYLE_WILL_CHANGE_STACKING_CONTEXT) {
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
}
if (willChangeBitsChanged & ~uint8_t(NS_STYLE_WILL_CHANGE_STACKING_CONTEXT)) {
// FIXME (Bug 974125): Don't reconstruct the frame
NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
}

View File

@ -1801,10 +1801,12 @@ struct nsStyleDisplay {
uint8_t mClipFlags; // [reset] see nsStyleConsts.h
uint8_t mOrient; // [reset] see nsStyleConsts.h
uint8_t mMixBlendMode; // [reset] see nsStyleConsts.h
uint8_t mWillChangeBitField; // [reset] see nsStyleConsts.h. Stores a bitfield
// representation of the property that
// are frequently queried. This should match
// mWillChange
uint8_t mWillChangeBitField; // [reset] see nsStyleConsts.h. Stores a
// bitfield representation of the properties
// that are frequently queried. This should
// match mWillChange. Also tracks if any of the
// properties in the will-change list require
// a stacking context.
nsAutoTArray<nsString, 1> mWillChange;
uint8_t mTouchAction; // [reset] see nsStyleConsts.h