Bug 550426 - Use background-position-x/y in ActiveLayerTracker. r=dbaron
☠☠ backed out by 2e2c516bd64f ☠ ☠
authorMarkus Stange <mstange@themasta.com>
Wed, 20 Apr 2016 23:34:46 -0400
changeset 295469 324f4f602730ee0724b3e41e64491ebe49eb0931
parent 295468 81306e78ccaab15b911a55bb1a4344537c7774ae
child 295470 10ee68fd318edf36cace00236ec3614f70f0f855
push id75939
push usermstange@themasta.com
push dateFri, 29 Apr 2016 20:32:28 +0000
treeherdermozilla-inbound@6ff2e12738ca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs550426
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 550426 - Use background-position-x/y in ActiveLayerTracker. r=dbaron MozReview-Commit-ID: 4gBWTOLfX0i
layout/base/ActiveLayerTracker.cpp
layout/base/ActiveLayerTracker.h
layout/base/nsDisplayList.cpp
layout/style/nsDOMCSSAttrDeclaration.cpp
--- a/layout/base/ActiveLayerTracker.cpp
+++ b/layout/base/ActiveLayerTracker.cpp
@@ -80,16 +80,18 @@ public:
     case eCSSProperty_top: return ACTIVITY_TOP;
     case eCSSProperty_right: return ACTIVITY_RIGHT;
     case eCSSProperty_bottom: return ACTIVITY_BOTTOM;
     case eCSSProperty_margin_left: return ACTIVITY_MARGIN_LEFT;
     case eCSSProperty_margin_top: return ACTIVITY_MARGIN_TOP;
     case eCSSProperty_margin_right: return ACTIVITY_MARGIN_RIGHT;
     case eCSSProperty_margin_bottom: return ACTIVITY_MARGIN_BOTTOM;
     case eCSSProperty_background_position: return ACTIVITY_BACKGROUND_POSITION;
+    case eCSSProperty_background_position_x: return ACTIVITY_BACKGROUND_POSITION;
+    case eCSSProperty_background_position_y: return ACTIVITY_BACKGROUND_POSITION;
     default: MOZ_ASSERT(false); return ACTIVITY_OPACITY;
     }
   }
 
   // While tracked, exactly one of mFrame or mContent is non-null, depending
   // on whether this property is stored on a frame or on a content node.
   // When this property is expired by the layer activity tracker, both mFrame
   // and mContent are nulled-out and the property is deleted.
@@ -379,16 +381,24 @@ ActiveLayerTracker::NotifyInlineStyleRul
 }
 
 /* static */ bool
 ActiveLayerTracker::IsStyleMaybeAnimated(nsIFrame* aFrame, nsCSSProperty aProperty)
 {
   return IsStyleAnimated(nullptr, aFrame, aProperty);
 }
 
+/* static */ bool
+ActiveLayerTracker::IsBackgroundPositionAnimated(nsDisplayListBuilder* aBuilder,
+                                                 nsIFrame* aFrame)
+{
+  return IsStyleAnimated(aBuilder, aFrame, eCSSProperty_background_position_x) ||
+         IsStyleAnimated(aBuilder, aFrame, eCSSProperty_background_position_y);
+}
+
 static bool
 CheckScrollInducedActivity(LayerActivity* aLayerActivity,
                            LayerActivity::ActivityIndex aActivityIndex,
                            nsDisplayListBuilder* aBuilder)
 {
   if (!aLayerActivity->mScrollHandlerInducedActivity.contains(aActivityIndex) ||
       !aLayerActivity->mAnimatingScrollHandlerFrame.IsAlive()) {
     return false;
--- a/layout/base/ActiveLayerTracker.h
+++ b/layout/base/ActiveLayerTracker.h
@@ -82,17 +82,22 @@ public:
    */
   static bool IsStyleAnimated(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
                               nsCSSProperty aProperty);
   /**
    * Return true if any of aFrame's offset property styles should be considered
    * as being animated for constructing active layers.
    */
   static bool IsOffsetOrMarginStyleAnimated(nsIFrame* aFrame);
-
+  /**
+   * Return true if aFrame's background-position-x or background-position-y
+   * property is animated.
+   */
+  static bool IsBackgroundPositionAnimated(nsDisplayListBuilder* aBuilder,
+                                           nsIFrame* aFrame);
   /**
    * Return true if aFrame either has an animated scale now, or is likely to
    * have one in the future because it has a CSS animation or transition
    * (which may not be playing right now) that affects its scale.
    */
   static bool IsScaleSubjectToAnimation(nsIFrame* aFrame);
 
   /**
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -2648,18 +2648,18 @@ nsDisplayBackgroundImage::GetImage()
   return image.forget();
 }
 
 nsDisplayBackgroundImage::ImageLayerization
 nsDisplayBackgroundImage::ShouldCreateOwnLayer(nsDisplayListBuilder* aBuilder,
                                                LayerManager* aManager)
 {
   nsIFrame* backgroundStyleFrame = nsCSSRendering::FindBackgroundStyleFrame(mFrame);
-  if (ActiveLayerTracker::IsStyleAnimated(aBuilder, backgroundStyleFrame,
-                                          eCSSProperty_background_position)) {
+  if (ActiveLayerTracker::IsBackgroundPositionAnimated(aBuilder,
+                                                       backgroundStyleFrame)) {
     return WHENEVER_POSSIBLE;
   }
 
   if (nsLayoutUtils::AnimatedImageLayersEnabled() && mBackgroundStyle) {
     const nsStyleImageLayers::Layer &layer = mBackgroundStyle->mImage.mLayers[mLayer];
     const nsStyleImage* image = &layer.mImage;
     if (image->GetType() == eStyleImageType_Image) {
       imgIRequest* imgreq = image->GetImageData();
--- a/layout/style/nsDOMCSSAttrDeclaration.cpp
+++ b/layout/style/nsDOMCSSAttrDeclaration.cpp
@@ -173,21 +173,25 @@ nsDOMCSSAttributeDeclaration::GetParentO
 
 NS_IMETHODIMP
 nsDOMCSSAttributeDeclaration::SetPropertyValue(const nsCSSProperty aPropID,
                                                const nsAString& aValue)
 {
   // Scripted modifications to style.opacity or style.transform
   // could immediately force us into the animated state if heuristics suggest
   // this is scripted animation.
+  // FIXME: This is missing the margin shorthand and the logical versions of
+  // the margin properties, see bug 1266287.
   if (aPropID == eCSSProperty_opacity || aPropID == eCSSProperty_transform ||
       aPropID == eCSSProperty_left || aPropID == eCSSProperty_top ||
       aPropID == eCSSProperty_right || aPropID == eCSSProperty_bottom ||
       aPropID == eCSSProperty_margin_left || aPropID == eCSSProperty_margin_top ||
       aPropID == eCSSProperty_margin_right || aPropID == eCSSProperty_margin_bottom ||
+      aPropID == eCSSProperty_background_position_x ||
+      aPropID == eCSSProperty_background_position_y ||
       aPropID == eCSSProperty_background_position) {
     nsIFrame* frame = mElement->GetPrimaryFrame();
     if (frame) {
       ActiveLayerTracker::NotifyInlineStyleRuleModified(frame, aPropID, aValue, this);
     }
   }
   return nsDOMCSSDeclaration::SetPropertyValue(aPropID, aValue);
 }