diff --git a/layout/style/ComputedStyle.cpp b/layout/style/ComputedStyle.cpp index 612093bc3a26..1cb291b27bf8 100644 --- a/layout/style/ComputedStyle.cpp +++ b/layout/style/ComputedStyle.cpp @@ -153,7 +153,7 @@ nsChangeHint ComputedStyle::CalcStyleDifference(const ComputedStyle& aNewStyle, // FIXME: The order of these DO_STRUCT_DIFFERENCE calls is no longer // significant. With a small amount of effort, we could replace them with a // #include "nsStyleStructList.h". - DO_STRUCT_DIFFERENCE_WITH_ARGS(Display, (, *StylePosition())); + DO_STRUCT_DIFFERENCE_WITH_ARGS(Display, (, *this)); DO_STRUCT_DIFFERENCE(XUL); DO_STRUCT_DIFFERENCE(Column); DO_STRUCT_DIFFERENCE(Content); @@ -164,10 +164,10 @@ nsChangeHint ComputedStyle::CalcStyleDifference(const ComputedStyle& aNewStyle, DO_STRUCT_DIFFERENCE(Table); DO_STRUCT_DIFFERENCE(UIReset); DO_STRUCT_DIFFERENCE(Text); - DO_STRUCT_DIFFERENCE_WITH_ARGS(List, (, *StyleDisplay())); + DO_STRUCT_DIFFERENCE_WITH_ARGS(List, (, *this)); DO_STRUCT_DIFFERENCE(SVGReset); DO_STRUCT_DIFFERENCE(SVG); - DO_STRUCT_DIFFERENCE_WITH_ARGS(Position, (, *StyleVisibility())); + DO_STRUCT_DIFFERENCE_WITH_ARGS(Position, (, *this)); DO_STRUCT_DIFFERENCE(Font); DO_STRUCT_DIFFERENCE(Margin); DO_STRUCT_DIFFERENCE(Padding); diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index e78f09ec8818..5d66040729f8 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -628,8 +628,8 @@ void nsStyleList::TriggerImageLoads(Document& aDocument, aDocument, aOldStyle ? &aOldStyle->mListStyleImage : nullptr); } -nsChangeHint nsStyleList::CalcDifference( - const nsStyleList& aNewData, const nsStyleDisplay& aOldDisplay) const { +nsChangeHint nsStyleList::CalcDifference(const nsStyleList& aNewData, + const ComputedStyle& aOldStyle) const { // If the quotes implementation is ever going to change we might not need // a framechange here and a reflow should be sufficient. See bug 35768. if (mQuotes != aNewData.mQuotes) { @@ -637,26 +637,19 @@ nsChangeHint nsStyleList::CalcDifference( } nsChangeHint hint = nsChangeHint(0); // Only elements whose display value is list-item can be affected by - // list-style-position and list-style-type. If the old display struct - // doesn't exist, assume it isn't affected by display value at all, - // and thus these properties should not affect it either. This also - // relies on that when the display value changes from something else - // to list-item, that change itself would cause ReconstructFrame. - if (aOldDisplay.IsListItem()) { - if (mListStylePosition != aNewData.mListStylePosition || - mCounterStyle != aNewData.mCounterStyle || - mListStyleImage != aNewData.mListStyleImage) { + // list-style-{position,type,image}. This also relies on that when the display + // value changes from something else to list-item, that change itself would + // cause ReconstructFrame. + if (mListStylePosition != aNewData.mListStylePosition || + mCounterStyle != aNewData.mCounterStyle || + mListStyleImage != aNewData.mListStyleImage) { + if (aOldStyle.StyleDisplay()->IsListItem()) { return nsChangeHint_ReconstructFrame; } - } else if (mListStylePosition != aNewData.mListStylePosition || - mCounterStyle != aNewData.mCounterStyle) { + // list-style-image may affect nsImageFrame for XUL elements, but that is + // dealt with explicitly in nsImageFrame::DidSetComputedStyle. hint = nsChangeHint_NeutralChange; } - // list-style-image and -moz-image-region may affect some XUL elements - // regardless of display value, so we still need to check them. - if (mListStyleImage != aNewData.mListStyleImage) { - return NS_STYLE_HINT_REFLOW; - } return hint; } @@ -1152,8 +1145,7 @@ static bool IsAutonessEqual(const StyleRect& aSides1, } nsChangeHint nsStylePosition::CalcDifference( - const nsStylePosition& aNewData, - const nsStyleVisibility& aOldStyleVisibility) const { + const nsStylePosition& aNewData, const ComputedStyle& aOldStyle) const { if (mGridTemplateColumns.IsMasonry() != aNewData.mGridTemplateColumns.IsMasonry() || mGridTemplateRows.IsMasonry() != aNewData.mGridTemplateRows.IsMasonry()) { @@ -1271,17 +1263,18 @@ nsChangeHint nsStylePosition::CalcDifference( mMinHeight != aNewData.mMinHeight || mMaxHeight != aNewData.mMaxHeight; - // It doesn't matter whether we're looking at the old or new visibility - // struct, since a change between vertical and horizontal writing-mode will - // cause a reframe. - bool isVertical = aOldStyleVisibility.mWritingMode != - StyleWritingModeProperty::HorizontalTb; - if (isVertical ? widthChanged : heightChanged) { - hint |= nsChangeHint_ReflowHintsForBSizeChange; - } - - if (isVertical ? heightChanged : widthChanged) { - hint |= nsChangeHint_ReflowHintsForISizeChange; + if (widthChanged || heightChanged) { + // It doesn't matter whether we're looking at the old or new visibility + // struct, since a change between vertical and horizontal writing-mode will + // cause a reframe. + const bool isVertical = aOldStyle.StyleVisibility()->mWritingMode != + StyleWritingModeProperty::HorizontalTb; + if (isVertical ? widthChanged : heightChanged) { + hint |= nsChangeHint_ReflowHintsForBSizeChange; + } + if (isVertical ? heightChanged : widthChanged) { + hint |= nsChangeHint_ReflowHintsForISizeChange; + } } if (mAspectRatio != aNewData.mAspectRatio) { @@ -2254,7 +2247,7 @@ static bool AppearanceValueAffectsFrames(StyleAppearance aAppearance, } nsChangeHint nsStyleDisplay::CalcDifference( - const nsStyleDisplay& aNewData, const nsStylePosition& aOldPosition) const { + const nsStyleDisplay& aNewData, const ComputedStyle& aOldStyle) const { if (mDisplay != aNewData.mDisplay || mContain != aNewData.mContain || (mFloat == StyleFloat::None) != (aNewData.mFloat == StyleFloat::None) || mTopLayer != aNewData.mTopLayer || mResize != aNewData.mResize) { @@ -2489,7 +2482,7 @@ nsChangeHint nsStyleDisplay::CalcDifference( // since a change on whether we need a hypothetical position would trigger // reflow anyway. if (IsAbsolutelyPositionedStyle() && - aOldPosition.NeedsHypotheticalPositionIfAbsPos()) { + aOldStyle.StylePosition()->NeedsHypotheticalPositionIfAbsPos()) { hint |= nsChangeHint_NeedReflow | nsChangeHint_ReflowChangesSizeOrPosition; } else { diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 32fb1e9d4d4e..6bd14e505c9a 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -632,7 +632,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleList { nsStyleList& operator=(const nsStyleList& aOther) = delete; nsChangeHint CalcDifference(const nsStyleList& aNewData, - const nsStyleDisplay& aOldDisplay) const; + const mozilla::ComputedStyle& aOldStyle) const; already_AddRefed GetListStyleImageURI() const; @@ -676,9 +676,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition { using StyleAlignSelf = mozilla::StyleAlignSelf; using StyleJustifySelf = mozilla::StyleJustifySelf; - nsChangeHint CalcDifference( - const nsStylePosition& aNewData, - const nsStyleVisibility& aOldStyleVisibility) const; + nsChangeHint CalcDifference(const nsStylePosition& aNewData, + const ComputedStyle& aOldStyle) const; // Returns whether we need to compute an hypothetical position if we were // absolutely positioned. @@ -1225,7 +1224,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay { using StyleContentVisibility = mozilla::StyleContentVisibility; nsChangeHint CalcDifference(const nsStyleDisplay& aNewData, - const nsStylePosition& aOldPosition) const; + const mozilla::ComputedStyle& aOldStyle) const; nsChangeHint CalcTransformPropertyDifference( const nsStyleDisplay& aNewData) const;