Bug 1261754 - Part 11: Move opacity from nsStyleDisplay to nsStyleEffects. r=dholbert

This commit is contained in:
Cameron McCormack 2016-04-12 15:52:43 +10:00
Родитель 0ef9faa708
Коммит 672aaef5a4
17 изменённых файлов: 57 добавлений и 58 удалений

Просмотреть файл

@ -901,7 +901,7 @@ RuleCache::ApplyFilter(Accessible* aAccessible, uint16_t* aResult)
if ((nsIAccessibleTraversalRule::PREFILTER_TRANSPARENT & mPreFilter) &&
!(state & states::OPAQUE1)) {
nsIFrame* frame = aAccessible->GetFrame();
if (frame->StyleDisplay()->mOpacity == 0.0f) {
if (frame->StyleEffects()->mOpacity == 0.0f) {
*aResult |= nsIAccessibleTraversalRule::FILTER_IGNORE_SUBTREE;
return NS_OK;
}

Просмотреть файл

@ -1205,8 +1205,7 @@ Accessible::State()
if (!frame)
return state;
const nsStyleDisplay* display = frame->StyleDisplay();
if (display && display->mOpacity == 1.0f &&
if (frame->StyleEffects()->mOpacity == 1.0f &&
!(state & states::INVISIBLE)) {
state |= states::OPAQUE1;
}

Просмотреть файл

@ -1524,7 +1524,7 @@ TreatAsOpaque(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder)
// children, which might be a large area their contents don't really cover).
nsIFrame* f = aItem->Frame();
if (f->PresContext()->IsChrome() && !aItem->GetChildren() &&
f->StyleDisplay()->mOpacity != 0.0) {
f->StyleEffects()->mOpacity != 0.0) {
opaque = aItem->GetBounds(aBuilder, &snap);
}
}
@ -4170,7 +4170,7 @@ nsDisplayOpacity::nsDisplayOpacity(nsDisplayListBuilder* aBuilder,
const DisplayItemScrollClip* aScrollClip,
bool aForEventsOnly)
: nsDisplayWrapList(aBuilder, aFrame, aList, aScrollClip)
, mOpacity(aFrame->StyleDisplay()->mOpacity)
, mOpacity(aFrame->StyleEffects()->mOpacity)
, mForEventsOnly(aForEventsOnly)
, mParticipatesInPreserve3D(false)
{
@ -6568,7 +6568,7 @@ nsDisplaySVGEffects::BuildLayer(nsDisplayListBuilder* aBuilder,
}
}
float opacity = mFrame->StyleDisplay()->mOpacity;
float opacity = mFrame->StyleEffects()->mOpacity;
if (opacity == 0.0f)
return nullptr;
@ -6678,9 +6678,9 @@ nsDisplaySVGEffects::PrintEffects(nsACString& aTo)
nsSVGClipPathFrame *clipPathFrame = effectProperties.GetClipPathFrame(&isOK);
bool first = true;
aTo += " effects=(";
if (mFrame->StyleDisplay()->mOpacity != 1.0f) {
if (mFrame->StyleEffects()->mOpacity != 1.0f) {
first = false;
aTo += nsPrintfCString("opacity(%f)", mFrame->StyleDisplay()->mOpacity);
aTo += nsPrintfCString("opacity(%f)", mFrame->StyleEffects()->mOpacity);
}
if (clipPathFrame) {
if (!first) {

Просмотреть файл

@ -6869,7 +6869,7 @@ nsLayoutUtils::HasNonZeroCornerOnSide(const nsStyleCorners& aCorners,
/* static */ nsTransparencyMode
nsLayoutUtils::GetFrameTransparency(nsIFrame* aBackgroundFrame,
nsIFrame* aCSSRootFrame) {
if (aCSSRootFrame->StyleDisplay()->mOpacity < 1.0f)
if (aCSSRootFrame->StyleEffects()->mOpacity < 1.0f)
return eTransparencyTransparent;
if (HasNonZeroCorner(aCSSRootFrame->StyleBorder()->mBorderRadius))

Просмотреть файл

@ -1153,9 +1153,8 @@ bool
nsIFrame::HasOpacityInternal(float aThreshold) const
{
MOZ_ASSERT(0.0 <= aThreshold && aThreshold <= 1.0, "Invalid argument");
const nsStyleDisplay* displayStyle = StyleDisplay();
return StyleDisplay()->mOpacity < aThreshold ||
(displayStyle->mWillChangeBitField & NS_STYLE_WILL_CHANGE_OPACITY) ||
return StyleEffects()->mOpacity < aThreshold ||
(StyleDisplay()->mWillChangeBitField & NS_STYLE_WILL_CHANGE_OPACITY) ||
(mContent &&
EffectCompositor::HasAnimationsForCompositor(
this, eCSSProperty_opacity) &&
@ -2148,6 +2147,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
return;
const nsStyleDisplay* disp = StyleDisplay();
const nsStyleEffects* effects = StyleEffects();
// We can stop right away if this is a zero-opacity stacking context and
// we're painting, and we're not animating opacity. Don't do this
// if we're going to compute plugin geometry, since opacity-0 plugins
@ -2157,7 +2157,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
StyleUserInterface()->GetEffectivePointerEvents(this) !=
NS_STYLE_POINTER_EVENTS_NONE;
bool opacityItemForEventsOnly = false;
if (disp->mOpacity == 0.0 && aBuilder->IsForPainting() &&
if (effects->mOpacity == 0.0 && aBuilder->IsForPainting() &&
!aBuilder->WillComputePluginGeometry() &&
!(disp->mWillChangeBitField & NS_STYLE_WILL_CHANGE_OPACITY) &&
!nsLayoutUtils::HasCurrentAnimationOfProperty(this,
@ -2235,7 +2235,6 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
aBuilder->EnterSVGEffectsContents(&hoistedScrollInfoItemsStorage);
}
const nsStyleEffects* effects = StyleEffects();
bool useOpacity = HasVisualOpacity() && !nsSVGUtils::CanOptimizeOpacity(this) && !usingSVGEffects;
bool useBlendMode = effects->mMixBlendMode != NS_STYLE_BLEND_NORMAL;
bool useStickyPosition = disp->mPosition == NS_STYLE_POSITION_STICKY &&
@ -9304,11 +9303,13 @@ nsIFrame::DestroyContentArray(ContentArray* aArray)
bool
nsIFrame::IsPseudoStackingContextFromStyle() {
const nsStyleDisplay* disp = StyleDisplay();
// If you change this, also change the computation of pseudoStackingContext
// in BuildDisplayListForChild()
return disp->mOpacity != 1.0f ||
disp->IsAbsPosContainingBlock(this) ||
if (StyleEffects()->mOpacity != 1.0f) {
return true;
}
const nsStyleDisplay* disp = StyleDisplay();
return disp->IsAbsPosContainingBlock(this) ||
disp->IsFloating(this) ||
(disp->mWillChangeBitField & NS_STYLE_WILL_CHANGE_STACKING_CONTEXT);
}

Просмотреть файл

@ -2731,7 +2731,7 @@ CSS_PROP_LOGICAL(
Position,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
CSS_PROP_DISPLAY(
CSS_PROP_EFFECTS(
opacity,
opacity,
Opacity,
@ -2742,7 +2742,7 @@ CSS_PROP_DISPLAY(
"",
VARIANT_HN,
nullptr,
offsetof(nsStyleDisplay, mOpacity),
offsetof(nsStyleEffects, mOpacity),
eStyleAnimType_float)
CSS_PROP_DISPLAY(
-moz-orient,

Просмотреть файл

@ -993,7 +993,7 @@ already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetOpacity()
{
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetNumber(StyleDisplay()->mOpacity);
val->SetNumber(StyleEffects()->mOpacity);
return val.forget();
}

Просмотреть файл

@ -5630,11 +5630,6 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
}
}
// opacity: factor, inherit, initial
SetFactor(*aRuleData->ValueForOpacity(), display->mOpacity, conditions,
parentDisplay->mOpacity, 1.0f,
SETFCT_OPACITY | SETFCT_UNSET_INITIAL);
// display: enum, inherit, initial
SetDiscrete(*aRuleData->ValueForDisplay(), display->mDisplay, conditions,
SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
@ -10025,6 +10020,11 @@ nsRuleNode::ComputeEffectsData(void* aStartStruct,
MOZ_ASSERT(false, "unrecognized clip unit");
}
// opacity: factor, inherit, initial
SetFactor(*aRuleData->ValueForOpacity(), effects->mOpacity, conditions,
parentEffects->mOpacity, 1.0f,
SETFCT_OPACITY | SETFCT_UNSET_INITIAL);
// mix-blend-mode: enum, inherit, initial
SetDiscrete(*aRuleData->ValueForMixBlendMode(), effects->mMixBlendMode,
conditions,

Просмотреть файл

@ -2871,7 +2871,6 @@ nsStyleDisplay::nsStyleDisplay(StyleStructContext aContext)
mOverflowY = NS_STYLE_OVERFLOW_VISIBLE;
mOverflowClipBox = NS_STYLE_OVERFLOW_CLIP_BOX_PADDING_BOX;
mResize = NS_STYLE_RESIZE_NONE;
mOpacity = 1.0f;
mSpecifiedTransform = nullptr;
mTransformOrigin[0].SetPercentValue(0.5f); // Transform is centered on origin
mTransformOrigin[1].SetPercentValue(0.5f);
@ -2920,7 +2919,6 @@ nsStyleDisplay::nsStyleDisplay(StyleStructContext aContext)
nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
: mBinding(aSource.mBinding)
, mOpacity(aSource.mOpacity)
, mDisplay(aSource.mDisplay)
, mOriginalDisplay(aSource.mOriginalDisplay)
, mContain(aSource.mContain)
@ -3052,21 +3050,6 @@ nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
NS_UpdateHint(hint, NS_CombineHint(nsChangeHint_AllReflowHints,
nsChangeHint_RepaintFrame));
if (mOpacity != aOther.mOpacity) {
// If we're going from the optimized >=0.99 opacity value to 1.0 or back, then
// repaint the frame because DLBI will not catch the invalidation. Otherwise,
// just update the opacity layer.
if ((mOpacity >= 0.99f && mOpacity < 1.0f && aOther.mOpacity == 1.0f) ||
(aOther.mOpacity >= 0.99f && aOther.mOpacity < 1.0f && mOpacity == 1.0f)) {
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
} else {
NS_UpdateHint(hint, nsChangeHint_UpdateOpacityLayer);
if ((mOpacity == 1.0f) != (aOther.mOpacity == 1.0f)) {
NS_UpdateHint(hint, nsChangeHint_UpdateUsesOpacity);
}
}
}
if (mIsolation != aOther.mIsolation) {
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
}
@ -3985,6 +3968,7 @@ nsStyleVariables::CalcDifference(const nsStyleVariables& aOther) const
nsStyleEffects::nsStyleEffects(StyleStructContext aContext)
: mBoxShadow(nullptr)
, mClip(0, 0, 0, 0)
, mOpacity(1.0f)
, mClipFlags(NS_STYLE_CLIP_AUTO)
, mMixBlendMode(NS_STYLE_BLEND_NORMAL)
{
@ -3994,6 +3978,7 @@ nsStyleEffects::nsStyleEffects(StyleStructContext aContext)
nsStyleEffects::nsStyleEffects(const nsStyleEffects& aSource)
: mBoxShadow(aSource.mBoxShadow)
, mClip(aSource.mClip)
, mOpacity(aSource.mOpacity)
, mClipFlags(aSource.mClipFlags)
, mMixBlendMode(aSource.mMixBlendMode)
{
@ -4032,6 +4017,21 @@ nsStyleEffects::CalcDifference(const nsStyleEffects& aOther) const
nsChangeHint_SchedulePaint;
}
if (mOpacity != aOther.mOpacity) {
// If we're going from the optimized >=0.99 opacity value to 1.0 or back, then
// repaint the frame because DLBI will not catch the invalidation. Otherwise,
// just update the opacity layer.
if ((mOpacity >= 0.99f && mOpacity < 1.0f && aOther.mOpacity == 1.0f) ||
(aOther.mOpacity >= 0.99f && aOther.mOpacity < 1.0f && mOpacity == 1.0f)) {
hint |= nsChangeHint_RepaintFrame;
} else {
hint |= nsChangeHint_UpdateOpacityLayer;
if ((mOpacity == 1.0f) != (aOther.mOpacity == 1.0f)) {
hint |= nsChangeHint_UpdateUsesOpacity;
}
}
}
if (mMixBlendMode != aOther.mMixBlendMode) {
hint |= nsChangeHint_RepaintFrame;
}

Просмотреть файл

@ -2443,8 +2443,6 @@ struct nsStyleDisplay
static nsChangeHint MaxDifference() {
// All the parts of FRAMECHANGE are present in CalcDifference.
return nsChangeHint(NS_STYLE_HINT_FRAMECHANGE |
nsChangeHint_UpdateOpacityLayer |
nsChangeHint_UpdateUsesOpacity |
nsChangeHint_UpdateTransformLayer |
nsChangeHint_UpdateOverflow |
nsChangeHint_UpdatePostTransformOverflow |
@ -2466,7 +2464,6 @@ struct nsStyleDisplay
// We guarantee that if mBinding is non-null, so are mBinding->GetURI() and
// mBinding->mOriginPrincipal.
RefPtr<mozilla::css::URLValue> mBinding; // [reset]
float mOpacity; // [reset]
uint8_t mDisplay; // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_*
uint8_t mOriginalDisplay; // [reset] saved mDisplay for position:absolute/fixed
// and float:left/right; otherwise equal
@ -3584,6 +3581,8 @@ struct nsStyleEffects
nsChangeHint_UpdateOverflow |
nsChangeHint_SchedulePaint |
nsChangeHint_RepaintFrame |
nsChangeHint_UpdateOpacityLayer |
nsChangeHint_UpdateUsesOpacity |
nsChangeHint_NeutralChange;
}
static nsChangeHint DifferenceAlwaysHandledForDescendants() {
@ -3595,7 +3594,8 @@ struct nsStyleEffects
}
RefPtr<nsCSSShadowArray> mBoxShadow; // [reset] nullptr for 'none'
nsRect mClip; // [reset] offsets from UL border edge
nsRect mClip; // [reset] offsets from UL border edge
float mOpacity; // [reset]
uint8_t mClipFlags; // [reset] see nsStyleConsts.h
uint8_t mMixBlendMode; // [reset] see nsStyleConsts.h
};

Просмотреть файл

@ -259,8 +259,7 @@ nsSVGDisplayContainerFrame::PaintSVG(gfxContext& aContext,
"If display lists are enabled, only painting of non-display "
"SVG should take this code path");
const nsStyleDisplay *display = StyleDisplay();
if (display->mOpacity == 0.0) {
if (StyleEffects()->mOpacity == 0.0) {
return NS_OK;
}

Просмотреть файл

@ -366,7 +366,7 @@ nsSVGImageFrame::PaintSVG(gfxContext& aContext,
// image into the current canvas is just the group opacity.
float opacity = 1.0f;
if (nsSVGUtils::CanOptimizeOpacity(this)) {
opacity = StyleDisplay()->mOpacity;
opacity = StyleEffects()->mOpacity;
}
if (opacity != 1.0f || StyleEffects()->mMixBlendMode != NS_STYLE_BLEND_NORMAL) {

Просмотреть файл

@ -451,7 +451,7 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(gfxContext& aContext,
}
}
float opacity = aFrame->StyleDisplay()->mOpacity;
float opacity = aFrame->StyleEffects()->mOpacity;
if (opacity == 0.0f) {
return;
}

Просмотреть файл

@ -153,9 +153,9 @@ nsSVGPathGeometryFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
nsSVGPathGeometryFrameBase::DidSetStyleContext(aOldStyleContext);
if (aOldStyleContext) {
auto oldStyleDisplay = aOldStyleContext->PeekStyleDisplay();
if (oldStyleDisplay &&
StyleDisplay()->mOpacity != oldStyleDisplay->mOpacity &&
auto oldStyleEffects = aOldStyleContext->PeekStyleEffects();
if (oldStyleEffects &&
StyleEffects()->mOpacity != oldStyleEffects->mOpacity &&
nsSVGUtils::CanOptimizeOpacity(this)) {
// nsIFrame::BuildDisplayListForStackingContext() is not going to create an
// nsDisplayOpacity display list item, so DLBI won't invalidate for us.

Просмотреть файл

@ -114,7 +114,7 @@ nsSVGSwitchFrame::PaintSVG(gfxContext& aContext,
"If display lists are enabled, only painting of non-display "
"SVG should take this code path");
if (StyleDisplay()->mOpacity == 0.0)
if (StyleEffects()->mOpacity == 0.0)
return NS_OK;
nsIFrame *kid = GetActiveChildFrame();

Просмотреть файл

@ -501,7 +501,7 @@ nsSVGUtils::PaintFrameWithEffects(nsIFrame *aFrame,
if (!svgChildFrame)
return;
float opacity = aFrame->StyleDisplay()->mOpacity;
float opacity = aFrame->StyleEffects()->mOpacity;
if (opacity == 0.0f)
return;
@ -1296,7 +1296,7 @@ nsSVGUtils::GetFallbackOrPaintColor(nsStyleContext *aStyleContext,
static float
MaybeOptimizeOpacity(nsIFrame *aFrame, float aFillOrStrokeOpacity)
{
float opacity = aFrame->StyleDisplay()->mOpacity;
float opacity = aFrame->StyleEffects()->mOpacity;
if (opacity < 1 && nsSVGUtils::CanOptimizeOpacity(aFrame)) {
return aFillOrStrokeOpacity * opacity;
}

Просмотреть файл

@ -3517,7 +3517,7 @@ nsTreeBodyFrame::PaintImage(int32_t aRowIndex,
nsStyleContext* imageContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreeimage);
// Obtain opacity value for the image.
float opacity = imageContext->StyleDisplay()->mOpacity;
float opacity = imageContext->StyleEffects()->mOpacity;
// Obtain the margins for the image and then deflate our rect by that
// amount. The image is assumed to be contained within the deflated rect.
@ -3715,7 +3715,7 @@ nsTreeBodyFrame::PaintText(int32_t aRowIndex,
nsStyleContext* textContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext);
// Obtain opacity value for the image.
float opacity = textContext->StyleDisplay()->mOpacity;
float opacity = textContext->StyleEffects()->mOpacity;
// Obtain the margins for the text and then deflate our rect by that
// amount. The text is assumed to be contained within the deflated rect.