Bug 1343153 - Part 2: Use Servo css-parser for ParseEasing. r=birtles,emilio

We use Servo css-parser to parse keyframe property-value pairs, so we
should also use it to parse easing for Web Animations.

MozReview-Commit-ID: FsfHQaNT2xO

--HG--
extra : rebase_source : f0426f90e4698363b0ce0271943b31418458301d
This commit is contained in:
Boris Chiou 2017-03-21 14:27:46 +08:00
Родитель e846f398cc
Коммит bc0746fe3d
3 изменённых файлов: 28 добавлений и 0 удалений

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozilla/dom/AnimatableBinding.h"
#include "mozilla/dom/KeyframeAnimationOptionsBinding.h"
#include "mozilla/dom/KeyframeEffectBinding.h"
#include "mozilla/ServoBindings.h"
#include "nsCSSParser.h" // For nsCSSParser
#include "nsIDocument.h"
#include "nsRuleNode.h"
@ -113,6 +114,26 @@ TimingParams::ParseEasing(const nsAString& aEasing,
{
MOZ_ASSERT(aDocument);
if (aDocument->IsStyledByServo()) {
nsTimingFunction timingFunction;
nsCString baseString;
// FIXME this is using the wrong base uri (bug 1343919)
GeckoParserExtraData data(aDocument->GetDocumentURI(),
aDocument->GetDocumentURI(),
aDocument->NodePrincipal());
aDocument->GetDocumentURI()->GetSpec(baseString);
if (!Servo_ParseEasing(&aEasing, &baseString, &data, &timingFunction)) {
aRv.ThrowTypeError<dom::MSG_INVALID_EASING_ERROR>(aEasing);
return Nothing();
}
if (timingFunction.mType == nsTimingFunction::Type::Linear) {
return Nothing();
}
return Some(ComputedTimingFunction(timingFunction));
}
nsCSSValue value;
nsCSSParser parser;
parser.ParseLonghandProperty(eCSSProperty_animation_timing_function,

Просмотреть файл

@ -118,6 +118,11 @@ SERVO_BINDING_FUNC(Servo_ParseProperty,
const nsACString* property, const nsACString* value,
const nsACString* base,
const GeckoParserExtraData* data)
SERVO_BINDING_FUNC(Servo_ParseEasing, bool,
const nsAString* easing,
const nsACString* base,
const GeckoParserExtraData* data,
nsTimingFunctionBorrowedMut output)
SERVO_BINDING_FUNC(Servo_GetComputedKeyframeValues, void,
RawGeckoKeyframeListBorrowed keyframes,
ServoComputedValuesBorrowed style,

Просмотреть файл

@ -35,6 +35,7 @@ class nsCSSValue;
class nsIDocument;
class nsINode;
class nsPresContext;
struct nsTimingFunction;
using mozilla::dom::StyleChildrenIterator;
using mozilla::ServoElementSnapshot;
@ -121,6 +122,7 @@ DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoKeyframeList)
DECL_BORROWED_REF_TYPE_FOR(RawGeckoKeyframeList)
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoComputedKeyframeValuesList)
DECL_BORROWED_REF_TYPE_FOR(RawGeckoStyleAnimationList)
DECL_BORROWED_MUT_REF_TYPE_FOR(nsTimingFunction)
#undef DECL_ARC_REF_TYPE_FOR
#undef DECL_OWNED_REF_TYPE_FOR