Bug 1343139 - Part 2. (Main) Add nsChangeHint_UpdateContainingBlock hint when HasMask state changed. draft
authorcku <cku@mozilla.com>
Tue, 07 Mar 2017 13:39:15 +0800
changeset 494520 bc649892d40aaf86dfa481f6c8a61b02c4500b0c
parent 494515 c531aa4381bea57da54314f69cbc11016689f98a
child 494521 c90e2304744318f22a6d637553461a64dd49adfe
push id48049
push userbmo:cku@mozilla.com
push dateTue, 07 Mar 2017 08:11:23 +0000
bugs1343139
milestone55.0a1
Bug 1343139 - Part 2. (Main) Add nsChangeHint_UpdateContainingBlock hint when HasMask state changed. Look into the test case on bugzilla attachment: o1.animate([{"mask": "linear-gradient(red,blue)", "transform": "none"}], 100); If I replace mask by a filter effect, we won't hit that assertion. Then I looked into nsStyleStruct, compared nsStyleSVGReset::CalcDifference with nsStyleEffects::CalcDifference, and noticed that we miss a hint in nsStyleSVGReset: nsStyleEffects::CalcDifference(const nsStyleEffects& aNewData) const { //.... if (HasFilters() != aNewData.HasFilters()) { // A change from/to being a containing block for position:fixed. hint |= nsChangeHint_UpdateContainingBlock; } } MozReview-Commit-ID: KeViMShnMAK
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -1201,16 +1201,20 @@ nsStyleSVGReset::CalcDifference(const ns
              mFloodColor    != aNewData.mFloodColor    ||
              mLightingColor != aNewData.mLightingColor ||
              mStopOpacity   != aNewData.mStopOpacity   ||
              mFloodOpacity  != aNewData.mFloodOpacity  ||
              mMaskType      != aNewData.mMaskType) {
     hint |= nsChangeHint_RepaintFrame;
   }
 
+  if (HasMask() != aNewData.HasMask()) {
+    hint |= nsChangeHint_UpdateContainingBlock;
+  }
+
   hint |= mMask.CalcDifference(aNewData.mMask,
                                nsStyleImageLayers::LayerType::Mask);
 
   return hint;
 }
 
 bool
 nsStyleSVGReset::HasMask() const
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -3862,16 +3862,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
 
   nsChangeHint CalcDifference(const nsStyleSVGReset& aNewData) const;
   static nsChangeHint MaxDifference() {
     return nsChangeHint_UpdateEffects |
            nsChangeHint_UpdateOverflow |
            nsChangeHint_NeutralChange |
            nsChangeHint_RepaintFrame |
            nsChangeHint_UpdateBackgroundPosition |
+           nsChangeHint_UpdateContainingBlock |
            NS_STYLE_HINT_REFLOW;
   }
   static nsChangeHint DifferenceAlwaysHandledForDescendants() {
     // CalcDifference never returns the reflow hints that are sometimes
     // handled for descendants as hints not handled for descendants.
     return nsChangeHint_NeedReflow |
            nsChangeHint_ReflowChangesSizeOrPosition |
            nsChangeHint_ClearAncestorIntrinsics;