Bug 1301305 - Add AnimationEffectReadOnly::AffectsGeometry() helper to identify effects that animate geometric properties; r?hiro
MozReview-Commit-ID: 7Q6wvm7ddxy
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -721,17 +721,16 @@ Animation::AnimationTimeToTimeStamp(cons
TimeStamp
Animation::ElapsedTimeToTimeStamp(
const StickyTimeDuration& aElapsedTime) const
{
return AnimationTimeToTimeStamp(aElapsedTime +
mEffect->SpecifiedTiming().mDelay);
}
-
// https://w3c.github.io/web-animations/#silently-set-the-current-time
void
Animation::SilentlySetCurrentTime(const TimeDuration& aSeekTime)
{
if (!mHoldTime.IsNull() ||
mStartTime.IsNull() ||
!mTimeline ||
mTimeline->GetCurrentTime().IsNull() ||
--- a/dom/animation/AnimationEffectReadOnly.h
+++ b/dom/animation/AnimationEffectReadOnly.h
@@ -80,16 +80,24 @@ public:
// Shortcut that gets the computed timing using the current local time as
// calculated from the timeline time.
ComputedTiming GetComputedTiming(const TimingParams* aTiming = nullptr) const;
void GetComputedTimingAsDict(ComputedTimingProperties& aRetVal) const;
virtual void SetAnimation(Animation* aAnimation) = 0;
Animation* GetAnimation() const { return mAnimation; };
+ /**
+ * Returns true if this effect animates one of the properties we consider
+ * geometric properties, e.g. properties such as 'width' or 'margin-left'
+ * that we try to synchronize with transform animations, on a valid target
+ * element.
+ */
+ virtual bool AffectsGeometry() const = 0;
+
protected:
virtual ~AnimationEffectReadOnly();
Nullable<TimeDuration> GetLocalTime() const;
protected:
RefPtr<nsIDocument> mDocument;
RefPtr<AnimationEffectTimingReadOnly> mTiming;
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -1353,16 +1353,28 @@ KeyframeEffectReadOnly::ShouldBlockAsync
return true;
}
}
}
return false;
}
+bool
+KeyframeEffectReadOnly::HasGeometricProperties() const
+{
+ for (const AnimationProperty& property : mProperties) {
+ if (IsGeometricProperty(property.mProperty)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
void
KeyframeEffectReadOnly::SetPerformanceWarning(
nsCSSPropertyID aProperty,
const AnimationPerformanceWarning& aWarning)
{
for (AnimationProperty& property : mProperties) {
if (property.mProperty == aProperty &&
(!property.mPerformanceWarning ||
--- a/dom/animation/KeyframeEffectReadOnly.h
+++ b/dom/animation/KeyframeEffectReadOnly.h
@@ -311,16 +311,21 @@ public:
// and 'top' on an element, we force all 'transform' animations running at
// the same time on the same element to run on the main thread.
//
// When returning true, |aPerformanceWarning| stores the reason why
// we shouldn't run the transform animations.
bool ShouldBlockAsyncTransformAnimations(
const nsIFrame* aFrame,
AnimationPerformanceWarning::Type& aPerformanceWarning) const;
+ bool HasGeometricProperties() const;
+ bool AffectsGeometry() const override
+ {
+ return GetTarget() && HasGeometricProperties();
+ }
nsIDocument* GetRenderedDocument() const;
nsPresContext* GetPresContext() const;
nsIPresShell* GetPresShell() const;
// Associates a warning with the animated property on the specified frame
// indicating why, for example, the property could not be animated on the
// compositor. |aParams| and |aParamsLength| are optional parameters which