mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1333846 - Part 1: Move ContainsAnimatedScale() codes into dom/animation/. r=birtles a=abillings
MozReview-Commit-ID: 6bWeTfCmjtd
This commit is contained in:
parent
bf582d23fa
commit
4047570520
@ -13,6 +13,8 @@
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsString.h"
|
||||
#include "xpcpublic.h" // For xpc::NativeGlobal
|
||||
#include "mozilla/EffectSet.h"
|
||||
#include "mozilla/dom/KeyframeEffectReadOnly.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -83,4 +85,17 @@ AnimationUtils::IsCoreAPIEnabledForCaller(dom::CallerType aCallerType)
|
||||
return IsCoreAPIEnabled() || aCallerType == dom::CallerType::System;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
AnimationUtils::EffectSetContainsAnimatedScale(EffectSet& aEffects,
|
||||
const nsIFrame* aFrame)
|
||||
{
|
||||
for (const dom::KeyframeEffectReadOnly* effect : aEffects) {
|
||||
if (effect->ContainsAnimatedScale(aFrame)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -14,11 +14,13 @@
|
||||
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIFrame;
|
||||
struct JSContext;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ComputedTimingFunction;
|
||||
class EffectSet;
|
||||
|
||||
class AnimationUtils
|
||||
{
|
||||
@ -73,6 +75,13 @@ public:
|
||||
* true or the caller is chrome.
|
||||
*/
|
||||
static bool IsCoreAPIEnabledForCaller(dom::CallerType aCallerType);
|
||||
|
||||
/**
|
||||
* Returns true if the given EffectSet contains a current effect that animates
|
||||
* scale. |aFrame| is used for calculation of scale values.
|
||||
*/
|
||||
static bool EffectSetContainsAnimatedScale(EffectSet& aEffects,
|
||||
const nsIFrame* aFrame);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -1763,5 +1763,32 @@ KeyframeEffectReadOnly::NeedsBaseStyle(nsCSSPropertyID aProperty) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
KeyframeEffectReadOnly::ContainsAnimatedScale(const nsIFrame* aFrame) const
|
||||
{
|
||||
if (!IsCurrent()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const AnimationProperty& prop : mProperties) {
|
||||
if (prop.mProperty != eCSSProperty_transform) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const AnimationPropertySegment& segment : prop.mSegments) {
|
||||
gfxSize from = segment.mFromValue.GetScaleValue(aFrame);
|
||||
if (from != gfxSize(1.0f, 1.0f)) {
|
||||
return true;
|
||||
}
|
||||
gfxSize to = segment.mToValue.GetScaleValue(aFrame);
|
||||
if (to != gfxSize(1.0f, 1.0f)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -288,6 +288,10 @@ public:
|
||||
// needs a base style to composite with.
|
||||
bool NeedsBaseStyle(nsCSSPropertyID aProperty) const;
|
||||
|
||||
// Returns true if the effect is current state and has scale animation.
|
||||
// |aFrame| is used for calculation of scale values.
|
||||
bool ContainsAnimatedScale(const nsIFrame* aFrame) const;
|
||||
|
||||
protected:
|
||||
KeyframeEffectReadOnly(nsIDocument* aDocument,
|
||||
const Maybe<OwningAnimationTarget>& aTarget,
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
#include "ActiveLayerTracker.h"
|
||||
|
||||
#include "mozilla/AnimationUtils.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/dom/KeyframeEffectReadOnly.h"
|
||||
#include "mozilla/gfx/Matrix.h"
|
||||
#include "mozilla/EffectSet.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
@ -473,36 +473,6 @@ ActiveLayerTracker::IsOffsetOrMarginStyleAnimated(nsIFrame* aFrame)
|
||||
return false;
|
||||
}
|
||||
|
||||
// A helper function for IsScaleSubjectToAnimation which returns true if the
|
||||
// given EffectSet contains a current effect that animates scale.
|
||||
static bool
|
||||
ContainsAnimatedScale(EffectSet& aEffects, nsIFrame* aFrame)
|
||||
{
|
||||
for (dom::KeyframeEffectReadOnly* effect : aEffects) {
|
||||
if (!effect->IsCurrent()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const AnimationProperty& prop : effect->Properties()) {
|
||||
if (prop.mProperty != eCSSProperty_transform) {
|
||||
continue;
|
||||
}
|
||||
for (AnimationPropertySegment segment : prop.mSegments) {
|
||||
gfxSize from = segment.mFromValue.GetScaleValue(aFrame);
|
||||
if (from != gfxSize(1.0f, 1.0f)) {
|
||||
return true;
|
||||
}
|
||||
gfxSize to = segment.mToValue.GetScaleValue(aFrame);
|
||||
if (to != gfxSize(1.0f, 1.0f)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
ActiveLayerTracker::IsScaleSubjectToAnimation(nsIFrame* aFrame)
|
||||
{
|
||||
@ -515,7 +485,8 @@ ActiveLayerTracker::IsScaleSubjectToAnimation(nsIFrame* aFrame)
|
||||
// Check if any animations, transitions, etc. associated with this frame may
|
||||
// animate its scale.
|
||||
EffectSet* effects = EffectSet::GetEffectSet(aFrame);
|
||||
if (effects && ContainsAnimatedScale(*effects, aFrame)) {
|
||||
if (effects &&
|
||||
AnimationUtils::EffectSetContainsAnimatedScale(*effects, aFrame)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user