Bug 1247336 - De-dupe changes in ActiveLayerTracker before treating property as animated. r=roc

In ActiveLayerTracker check if the value of a property has actually
changed, rather than being set to its existing value, before treating
the property as animated. This will help avoid over-layerization of some
frames.
This commit is contained in:
Jamie Nicol 2016-02-12 14:38:50 +00:00
parent c7d63dde29
commit 7ce587820a
3 changed files with 29 additions and 8 deletions

View File

@ -20,6 +20,7 @@
#include "nsStyleTransformMatrix.h"
#include "nsTransitionManager.h"
#include "nsDisplayList.h"
#include "nsDOMCSSDeclaration.h"
namespace mozilla {
@ -311,12 +312,21 @@ ActiveLayerTracker::NotifyOffsetRestyle(nsIFrame* aFrame)
}
/* static */ void
ActiveLayerTracker::NotifyAnimated(nsIFrame* aFrame, nsCSSProperty aProperty)
ActiveLayerTracker::NotifyAnimated(nsIFrame* aFrame,
nsCSSProperty aProperty,
const nsAString& aNewValue,
nsDOMCSSDeclaration* aDOMCSSDecl)
{
LayerActivity* layerActivity = GetLayerActivityForUpdate(aFrame);
uint8_t& mutationCount = layerActivity->RestyleCountForProperty(aProperty);
// We know this is animated, so just hack the mutation count.
mutationCount = 0xFF;
if (mutationCount != 0xFF) {
nsAutoString oldValue;
aDOMCSSDecl->GetPropertyValue(aProperty, oldValue);
if (aNewValue != oldValue) {
// We know this is animated, so just hack the mutation count.
mutationCount = 0xFF;
}
}
}
/* static */ void
@ -354,10 +364,12 @@ IsPresContextInScriptAnimationCallback(nsPresContext* aPresContext)
/* static */ void
ActiveLayerTracker::NotifyInlineStyleRuleModified(nsIFrame* aFrame,
nsCSSProperty aProperty)
nsCSSProperty aProperty,
const nsAString& aNewValue,
nsDOMCSSDeclaration* aDOMCSSDecl)
{
if (IsPresContextInScriptAnimationCallback(aFrame->PresContext())) {
NotifyAnimated(aFrame, aProperty);
NotifyAnimated(aFrame, aProperty, aNewValue, aDOMCSSDecl);
}
if (gLayerActivityTracker &&
gLayerActivityTracker->mCurrentScrollHandlerFrame.IsAlive()) {

View File

@ -10,6 +10,7 @@
class nsIFrame;
class nsIContent;
class nsDisplayListBuilder;
class nsDOMCSSDeclaration;
namespace mozilla {
@ -47,8 +48,12 @@ public:
/**
* Mark aFrame as being known to have an animation of aProperty.
* Any such marking will time out after a short period.
* aNewValue and aDOMCSSDecl are used to determine whether the property's
* value has changed.
*/
static void NotifyAnimated(nsIFrame* aFrame, nsCSSProperty aProperty);
static void NotifyAnimated(nsIFrame* aFrame, nsCSSProperty aProperty,
const nsAString& aNewValue,
nsDOMCSSDeclaration* aDOMCSSDecl);
/**
* Notify aFrame as being known to have an animation of aProperty through an
* inline style modification during aScrollFrame's scroll event handler.
@ -60,8 +65,12 @@ public:
* has been modified.
* This notification is incomplete --- not all modifications to inline
* style will trigger this.
* aNewValue and aDOMCSSDecl are used to determine whether the property's
* value has changed.
*/
static void NotifyInlineStyleRuleModified(nsIFrame* aFrame, nsCSSProperty aProperty);
static void NotifyInlineStyleRuleModified(nsIFrame* aFrame, nsCSSProperty aProperty,
const nsAString& aNewValue,
nsDOMCSSDeclaration* aDOMCSSDecl);
/**
* Return true if aFrame's aProperty style should be considered as being animated
* for pre-rendering.

View File

@ -186,7 +186,7 @@ nsDOMCSSAttributeDeclaration::SetPropertyValue(const nsCSSProperty aPropID,
aPropID == eCSSProperty_background_position) {
nsIFrame* frame = mElement->GetPrimaryFrame();
if (frame) {
ActiveLayerTracker::NotifyInlineStyleRuleModified(frame, aPropID);
ActiveLayerTracker::NotifyInlineStyleRuleModified(frame, aPropID, aValue, this);
}
}
return nsDOMCSSDeclaration::SetPropertyValue(aPropID, aValue);