Bug 550426 - Use background-position-x/y in ActiveLayerTracker. r?dbaron
MozReview-Commit-ID: 4gBWTOLfX0i
--- 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);
}