Bug 1273804 - Use nsChangeHint_RepaintFrame hint for position change of a mask layer draft
authorcku <cku@mozilla.com>
Tue, 14 Jun 2016 12:36:01 +0100
changeset 377974 6a5157eab15739409872698bc166dce181247f31
parent 377951 ddb6b30149221f00eb5dd180530e9033093d4c2b
child 523444 a138cab804163ea0b73cf52c265eb45de178fae8
push id20910
push usercku@mozilla.com
push dateTue, 14 Jun 2016 11:37:58 +0000
bugs1273804
milestone50.0a1
Bug 1273804 - Use nsChangeHint_RepaintFrame hint for position change of a mask layer MozReview-Commit-ID: 4W9Qmk6MVri
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -1283,17 +1283,17 @@ nsStyleSVGReset::CalcDifference(const ns
              mFloodColor    != aOther.mFloodColor    ||
              mLightingColor != aOther.mLightingColor ||
              mStopOpacity   != aOther.mStopOpacity   ||
              mFloodOpacity  != aOther.mFloodOpacity  ||
              mMaskType      != aOther.mMaskType) {
     hint |= nsChangeHint_RepaintFrame;
   }
 
-  hint |= mMask.CalcDifference(aOther.mMask);
+  hint |= mMask.CalcDifference(aOther.mMask, nsChangeHint_RepaintFrame);
 
   return hint;
 }
 
 // nsStyleSVGPaint implementation
 nsStyleSVGPaint::nsStyleSVGPaint(nsStyleSVGPaintType aType)
   : mType(nsStyleSVGPaintType(0))
   , mFallbackColor(NS_RGB(0, 0, 0))
@@ -2298,31 +2298,33 @@ nsStyleImageLayers::nsStyleImageLayers(c
     mSizeCount = std::max(mSizeCount, count);
     mMaskModeCount = std::max(mMaskModeCount, count);
     mBlendModeCount = std::max(mBlendModeCount, count);
     mCompositeCount = std::max(mCompositeCount, count);
   }
 }
 
 nsChangeHint
-nsStyleImageLayers::CalcDifference(const nsStyleImageLayers& aOther) const
+nsStyleImageLayers::CalcDifference(const nsStyleImageLayers& aOther,
+                                   nsChangeHint aPositionChangeHint) const
 {
   nsChangeHint hint = nsChangeHint(0);
 
   const nsStyleImageLayers& moreLayers =
     mImageCount > aOther.mImageCount ?
       *this : aOther;
   const nsStyleImageLayers& lessLayers =
     mImageCount > aOther.mImageCount ?
       aOther : *this;
 
   NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(i, moreLayers) {
     if (i < lessLayers.mImageCount) {
       nsChangeHint layerDifference =
-        moreLayers.mLayers[i].CalcDifference(lessLayers.mLayers[i]);
+        moreLayers.mLayers[i].CalcDifference(lessLayers.mLayers[i],
+                                             aPositionChangeHint);
       hint |= layerDifference;
       if (layerDifference &&
           ((moreLayers.mLayers[i].mImage.GetType() == eStyleImageType_Element) ||
            (lessLayers.mLayers[i].mImage.GetType() == eStyleImageType_Element))) {
         hint |= nsChangeHint_UpdateEffects | nsChangeHint_RepaintFrame;
       }
     } else {
       hint |= nsChangeHint_RepaintFrame;
@@ -2587,17 +2589,18 @@ nsStyleImageLayers::Layer::operator==(co
          mSize == aOther.mSize &&
          mImage == aOther.mImage &&
          mMaskMode == aOther.mMaskMode &&
          mComposite == aOther.mComposite &&
          EqualURIs(mSourceURI, aOther.mSourceURI);
 }
 
 nsChangeHint
-nsStyleImageLayers::Layer::CalcDifference(const nsStyleImageLayers::Layer& aOther) const
+nsStyleImageLayers::Layer::CalcDifference(const nsStyleImageLayers::Layer& aOther,
+                                          nsChangeHint aPositionChangeHint) const
 {
   nsChangeHint hint = nsChangeHint(0);
   if (!EqualURIs(mSourceURI, aOther.mSourceURI)) {
     hint |= nsChangeHint_UpdateEffects |
             nsChangeHint_RepaintFrame;
     // Mask changes require that we update the PreEffectsBBoxProperty,
     // which is done during overflow computation.
     hint |= nsChangeHint_UpdateOverflow;
@@ -2609,17 +2612,17 @@ nsStyleImageLayers::Layer::CalcDifferenc
              mSize != aOther.mSize ||
              mImage != aOther.mImage ||
              mMaskMode != aOther.mMaskMode ||
              mComposite != aOther.mComposite) {
     hint |= nsChangeHint_RepaintFrame;
   }
 
   if (mPosition != aOther.mPosition) {
-    hint |= nsChangeHint_UpdateBackgroundPosition;
+    hint |= aPositionChangeHint;
   }
 
   return hint;
 }
 
 // --------------------
 // nsStyleBackground
 //
@@ -2657,17 +2660,18 @@ nsStyleBackground::Destroy(nsPresContext
 nsChangeHint
 nsStyleBackground::CalcDifference(const nsStyleBackground& aOther) const
 {
   nsChangeHint hint = nsChangeHint(0);
   if (mBackgroundColor != aOther.mBackgroundColor) {
     hint |= nsChangeHint_RepaintFrame;
   }
 
-  hint |= mImage.CalcDifference(aOther.mImage);
+  hint |= mImage.CalcDifference(aOther.mImage,
+                                nsChangeHint_UpdateBackgroundPosition);
 
   return hint;
 }
 
 bool
 nsStyleBackground::HasFixedBackground(nsIFrame* aFrame) const
 {
   NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(i, mImage) {
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -686,17 +686,19 @@ struct nsStyleImageLayers {
     // True if the rendering of this layer might change when the size
     // of the background positioning area changes.  This is true for any
     // non-solid-color background whose position or size depends on
     // the size of the positioning area.  It's also true for SVG images
     // whose root <svg> node has a viewBox.
     bool RenderingMightDependOnPositioningAreaSizeChange() const;
 
     // Compute the change hint required by changes in just this layer.
-    nsChangeHint CalcDifference(const Layer& aOther) const;
+    // aPositionChangeHint indicates the hint for position change.
+    nsChangeHint CalcDifference(const Layer& aOther,
+                                nsChangeHint aPositionChangeHint) const;
 
     // An equality operator that compares the images using URL-equality
     // rather than pointer-equality.
     bool operator==(const Layer& aOther) const;
     bool operator!=(const Layer& aOther) const {
       return !(*this == aOther);
     }
   };
@@ -734,17 +736,18 @@ struct nsStyleImageLayers {
         mLayers[i].TrackImages(aContext);
     }
   }
   void UntrackImages(nsPresContext* aContext) {
     for (uint32_t i = 0; i < mImageCount; ++i)
       mLayers[i].UntrackImages(aContext);
   }
 
-  nsChangeHint CalcDifference(const nsStyleImageLayers& aOther) const;
+  nsChangeHint CalcDifference(const nsStyleImageLayers& aOther,
+                              nsChangeHint aPositionChangeHint) const;
 
   bool HasLayerWithImage() const;
 
   static const nsCSSProperty kBackgroundLayerTable[];
   static const nsCSSProperty kMaskLayerTable[];
 
   #define NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(var_, layers_) \
     for (uint32_t var_ = (layers_).mImageCount; var_-- != 0; )
@@ -3574,17 +3577,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
   }
   void Destroy(nsPresContext* aContext);
 
   nsChangeHint CalcDifference(const nsStyleSVGReset& aOther) const;
   static nsChangeHint MaxDifference() {
     return nsChangeHint_UpdateEffects |
            nsChangeHint_UpdateOverflow |
            nsChangeHint_NeutralChange |
-           nsChangeHint_UpdateBackgroundPosition |
+           nsChangeHint_RepaintFrame |
            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;