Bug 1303229: Get the proper viewport size for animations. r?hiro,heycam
While we're here, don't re-recompute the default computed values, just grab them
from the device.
MozReview-Commit-ID: GqqnPLIwN2F
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
--- a/dom/animation/KeyframeUtils.cpp
+++ b/dom/animation/KeyframeUtils.cpp
@@ -593,32 +593,23 @@ KeyframeUtils::ApplyDistributeSpacing(ns
/* static */ nsTArray<ComputedKeyframeValues>
KeyframeUtils::GetComputedKeyframeValues(
const nsTArray<Keyframe>& aKeyframes,
dom::Element* aElement,
const ServoComputedStyleValues& aServoValues)
{
MOZ_ASSERT(aElement);
- MOZ_ASSERT(aElement->OwnerDoc()->IsStyledByServo());
+ MOZ_ASSERT(aElement->IsStyledByServo());
nsPresContext* presContext = nsContentUtils::GetContextForContent(aElement);
MOZ_ASSERT(presContext);
- nsTArray<ComputedKeyframeValues> result(aKeyframes.Length());
-
- // Construct each nsTArray<PropertyStyleAnimationValuePair> here.
- result.AppendElements(aKeyframes.Length());
-
- Servo_GetComputedKeyframeValues(&aKeyframes,
- aServoValues.mCurrentStyle,
- aServoValues.mParentStyle,
- presContext,
- &result);
- return result;
+ return presContext->StyleSet()->AsServo()
+ ->GetComputedKeyframeValuesFor(aKeyframes, aElement, aServoValues);
}
/* static */ nsTArray<ComputedKeyframeValues>
KeyframeUtils::GetComputedKeyframeValues(const nsTArray<Keyframe>& aKeyframes,
dom::Element* aElement,
nsStyleContext* aStyleContext)
{
MOZ_ASSERT(aStyleContext);
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -103,17 +103,17 @@ SERVO_BINDING_FUNC(Servo_ParseProperty,
RawServoDeclarationBlockStrong,
const nsACString* property, const nsACString* value,
const nsACString* base,
const GeckoParserExtraData* data)
SERVO_BINDING_FUNC(Servo_GetComputedKeyframeValues, void,
RawGeckoKeyframeListBorrowed keyframes,
ServoComputedValuesBorrowed style,
ServoComputedValuesBorrowedOrNull parent_style,
- RawGeckoPresContextBorrowed pres_context,
+ RawServoStyleSetBorrowed set,
RawGeckoComputedKeyframeValuesListBorrowedMut result)
// AnimationValues handling
SERVO_BINDING_FUNC(Servo_AnimationValues_Interpolate,
RawServoAnimationValueStrong,
RawServoAnimationValueBorrowed from,
RawServoAnimationValueBorrowed to,
double progress)
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -6,16 +6,17 @@
#include "mozilla/ServoStyleSet.h"
#include "mozilla/DocumentStyleRootIterator.h"
#include "mozilla/ServoRestyleManager.h"
#include "mozilla/dom/ChildIterator.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ElementInlines.h"
+#include "mozilla/dom/KeyframeEffectReadOnly.h"
#include "nsCSSAnonBoxes.h"
#include "nsCSSPseudoElements.h"
#include "nsHTMLStyleSheet.h"
#include "nsIDocumentInlines.h"
#include "nsPrintfCString.h"
#include "nsStyleContext.h"
#include "nsStyleSet.h"
@@ -705,16 +706,34 @@ ServoStyleSet::FillKeyframesForName(cons
NS_ConvertUTF16toUTF8 name(aName);
return Servo_StyleSet_FillKeyframesForName(mRawSet.get(),
&name,
&aTimingFunction,
aComputedValues,
&aKeyframes);
}
+nsTArray<ComputedKeyframeValues>
+ServoStyleSet::GetComputedKeyframeValuesFor(const nsTArray<Keyframe>& aKeyframes,
+ dom::Element* aElement,
+ const ServoComputedStyleValues& aServoValues)
+{
+ nsTArray<ComputedKeyframeValues> result(aKeyframes.Length());
+
+ // Construct each nsTArray<PropertyStyleAnimationValuePair> here.
+ result.AppendElements(aKeyframes.Length());
+
+ Servo_GetComputedKeyframeValues(&aKeyframes,
+ aServoValues.mCurrentStyle,
+ aServoValues.mParentStyle,
+ mRawSet.get(),
+ &result);
+ return result;
+}
+
void
ServoStyleSet::RebuildData()
{
ClearNonInheritingStyleContexts();
Servo_StyleSet_RebuildData(mRawSet.get());
}
already_AddRefed<ServoComputedValues>
@@ -723,17 +742,17 @@ ServoStyleSet::ResolveServoStyle(Element
return Servo_ResolveStyle(aElement, mRawSet.get()).Consume();
}
void
ServoStyleSet::ClearNonInheritingStyleContexts()
{
for (RefPtr<nsStyleContext>& ptr : mNonInheritingStyleContexts) {
ptr = nullptr;
- }
+ }
}
already_AddRefed<ServoComputedValues>
ServoStyleSet::ResolveStyleLazily(Element* aElement, nsIAtom* aPseudoTag)
{
mPresContext->EffectCompositor()->PreTraverse(aElement, aPseudoTag);
MOZ_ASSERT(!sInServoTraversal);
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -23,16 +23,17 @@
namespace mozilla {
namespace dom {
class Element;
} // namespace dom
class CSSStyleSheet;
class ServoRestyleManager;
class ServoStyleSheet;
struct Keyframe;
+struct ServoComputedStyleValues;
} // namespace mozilla
class nsIDocument;
class nsStyleContext;
class nsPresContext;
struct nsTimingFunction;
struct TreeMatchContext;
namespace mozilla {
@@ -236,16 +237,21 @@ public:
*/
already_AddRefed<ServoComputedValues> ResolveServoStyle(dom::Element* aElement);
bool FillKeyframesForName(const nsString& aName,
const nsTimingFunction& aTimingFunction,
const ServoComputedValues* aComputedValues,
nsTArray<Keyframe>& aKeyframes);
+ nsTArray<ComputedKeyframeValues>
+ GetComputedKeyframeValuesFor(const nsTArray<Keyframe>& aKeyframes,
+ dom::Element* aElement,
+ const ServoComputedStyleValues& aServoValues);
+
private:
already_AddRefed<nsStyleContext> GetContext(already_AddRefed<ServoComputedValues>,
nsStyleContext* aParentContext,
nsIAtom* aPseudoTag,
CSSPseudoElementType aPseudoType,
dom::Element* aElementForAnimation);
already_AddRefed<nsStyleContext> GetContext(nsIContent* aContent,