Bug 1676062 - Use a dummy URL data in Servo_ParseEasing and drop Document* and URLExtraData* arguments from relevant functions. r=boris

Differential Revision: https://phabricator.services.mozilla.com/D96791
This commit is contained in:
Hiroyuki Ikezoe 2020-11-12 20:34:01 +00:00
Родитель bd1f96ff2d
Коммит fc509369c5
9 изменённых файлов: 26 добавлений и 43 удалений

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

@ -321,7 +321,7 @@ void AnimationEffect::GetComputedTimingAsDict(
void AnimationEffect::UpdateTiming(const OptionalEffectTiming& aTiming,
ErrorResult& aRv) {
TimingParams timing =
TimingParams::MergeOptionalEffectTiming(mTiming, aTiming, mDocument, aRv);
TimingParams::MergeOptionalEffectTiming(mTiming, aTiming, aRv);
if (aRv.Failed()) {
return;
}

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

@ -835,8 +835,7 @@ already_AddRefed<KeyframeEffect> KeyframeEffect::ConstructKeyframeEffect(
return nullptr;
}
TimingParams timingParams =
TimingParams::FromOptionsUnion(aOptions, doc, aRv);
TimingParams timingParams = TimingParams::FromOptionsUnion(aOptions, aRv);
if (aRv.Failed()) {
return nullptr;
}

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

@ -444,8 +444,8 @@ static bool ConvertKeyframeSequence(JSContext* aCx, dom::Document* aDocument,
}
if (!parseEasingResult.Failed()) {
keyframe->mTimingFunction = TimingParams::ParseEasing(
keyframeDict.mEasing, aDocument, parseEasingResult);
keyframe->mTimingFunction =
TimingParams::ParseEasing(keyframeDict.mEasing, parseEasingResult);
// Even if the above fails, we still need to continue reading off all the
// properties since checking the validity of easing should be treated as
// a separate step that happens *after* all the other processing in this
@ -1099,7 +1099,7 @@ static void GetKeyframeListFromPropertyIndexedKeyframe(
FallibleTArray<Maybe<ComputedTimingFunction>> easings;
auto parseAndAppendEasing = [&](const nsString& easingString,
ErrorResult& aRv) {
auto easing = TimingParams::ParseEasing(easingString, aDocument, aRv);
auto easing = TimingParams::ParseEasing(easingString, aRv);
if (!aRv.Failed() && !easings.AppendElement(std::move(easing), fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
}

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

@ -38,7 +38,6 @@ const dom::EffectTiming& GetTimingProperties(
template <class OptionsType>
/* static */
TimingParams TimingParams::FromOptionsType(const OptionsType& aOptions,
dom::Document* aDocument,
ErrorResult& aRv) {
TimingParams result;
@ -55,7 +54,7 @@ TimingParams TimingParams::FromOptionsType(const OptionsType& aOptions,
result.Update();
} else {
const dom::EffectTiming& timing = GetTimingProperties(aOptions);
result = FromEffectTiming(timing, aDocument, aRv);
result = FromEffectTiming(timing, aRv);
}
return result;
@ -64,21 +63,20 @@ TimingParams TimingParams::FromOptionsType(const OptionsType& aOptions,
/* static */
TimingParams TimingParams::FromOptionsUnion(
const dom::UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
dom::Document* aDocument, ErrorResult& aRv) {
return FromOptionsType(aOptions, aDocument, aRv);
ErrorResult& aRv) {
return FromOptionsType(aOptions, aRv);
}
/* static */
TimingParams TimingParams::FromOptionsUnion(
const dom::UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
dom::Document* aDocument, ErrorResult& aRv) {
return FromOptionsType(aOptions, aDocument, aRv);
ErrorResult& aRv) {
return FromOptionsType(aOptions, aRv);
}
/* static */
TimingParams TimingParams::FromEffectTiming(
const dom::EffectTiming& aEffectTiming, dom::Document* aDocument,
ErrorResult& aRv) {
const dom::EffectTiming& aEffectTiming, ErrorResult& aRv) {
TimingParams result;
Maybe<StickyTimeDuration> duration =
@ -95,7 +93,7 @@ TimingParams TimingParams::FromEffectTiming(
return result;
}
Maybe<ComputedTimingFunction> easing =
TimingParams::ParseEasing(aEffectTiming.mEasing, aDocument, aRv);
TimingParams::ParseEasing(aEffectTiming.mEasing, aRv);
if (aRv.Failed()) {
return result;
}
@ -117,7 +115,7 @@ TimingParams TimingParams::FromEffectTiming(
/* static */
TimingParams TimingParams::MergeOptionalEffectTiming(
const TimingParams& aSource, const dom::OptionalEffectTiming& aEffectTiming,
dom::Document* aDocument, ErrorResult& aRv) {
ErrorResult& aRv) {
MOZ_ASSERT(!aRv.Failed(), "Initially return value should be ok");
TimingParams result = aSource;
@ -150,8 +148,7 @@ TimingParams TimingParams::MergeOptionalEffectTiming(
Maybe<ComputedTimingFunction> easing;
if (aEffectTiming.mEasing.WasPassed()) {
easing = TimingParams::ParseEasing(aEffectTiming.mEasing.Value(), aDocument,
aRv);
easing = TimingParams::ParseEasing(aEffectTiming.mEasing.Value(), aRv);
if (aRv.Failed()) {
return result;
}
@ -193,12 +190,9 @@ TimingParams TimingParams::MergeOptionalEffectTiming(
/* static */
Maybe<ComputedTimingFunction> TimingParams::ParseEasing(
const nsAString& aEasing, dom::Document* aDocument, ErrorResult& aRv) {
MOZ_ASSERT(aDocument);
const nsAString& aEasing, ErrorResult& aRv) {
nsTimingFunction timingFunction;
RefPtr<URLExtraData> url = ServoCSSParser::GetURLExtraData(aDocument);
if (!ServoCSSParser::ParseEasing(aEasing, url, timingFunction)) {
if (!ServoCSSParser::ParseEasing(aEasing, timingFunction)) {
aRv.ThrowTypeError<dom::MSG_INVALID_EASING_ERROR>(
NS_ConvertUTF16toUTF8(aEasing));
return Nothing();

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

@ -23,7 +23,6 @@
namespace mozilla {
namespace dom {
class Document;
class UnrestrictedDoubleOrKeyframeEffectOptions;
class UnrestrictedDoubleOrKeyframeAnimationOptions;
} // namespace dom
@ -57,16 +56,14 @@ struct TimingParams {
template <class OptionsType>
static TimingParams FromOptionsType(const OptionsType& aOptions,
dom::Document* aDocument,
ErrorResult& aRv);
static TimingParams FromOptionsUnion(
const dom::UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
dom::Document* aDocument, ErrorResult& aRv);
ErrorResult& aRv);
static TimingParams FromOptionsUnion(
const dom::UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
dom::Document* aDocument, ErrorResult& aRv);
ErrorResult& aRv);
static TimingParams FromEffectTiming(const dom::EffectTiming& aEffectTiming,
dom::Document* aDocument,
ErrorResult& aRv);
// Returns a copy of |aSource| where each timing property in |aSource| that
// is also specified in |aEffectTiming| is replaced with the value from
@ -76,8 +73,7 @@ struct TimingParams {
// true and an unmodified copy of |aSource| will be returned.
static TimingParams MergeOptionalEffectTiming(
const TimingParams& aSource,
const dom::OptionalEffectTiming& aEffectTiming, dom::Document* aDocument,
ErrorResult& aRv);
const dom::OptionalEffectTiming& aEffectTiming, ErrorResult& aRv);
// Range-checks and validates an UnrestrictedDoubleOrString or
// OwningUnrestrictedDoubleOrString object and converts to a
@ -123,7 +119,6 @@ struct TimingParams {
}
static Maybe<ComputedTimingFunction> ParseEasing(const nsAString& aEasing,
dom::Document* aDocument,
ErrorResult& aRv);
static StickyTimeDuration CalcActiveDuration(

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

@ -13,9 +13,9 @@ class nsISerialEventTarget;
namespace mozilla {
namespace ipc {
class PBackgroundChild;
class PBackgroundParent;
} // namespace ipc
class PBackgroundChild;
class PBackgroundParent;
} // namespace ipc
namespace dom {

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

@ -44,9 +44,9 @@ already_AddRefed<RawServoDeclarationBlock> ServoCSSParser::ParseProperty(
}
/* static */
bool ServoCSSParser::ParseEasing(const nsAString& aValue, URLExtraData* aUrl,
bool ServoCSSParser::ParseEasing(const nsAString& aValue,
nsTimingFunction& aResult) {
return Servo_ParseEasing(&aValue, aUrl, &aResult);
return Servo_ParseEasing(&aValue, &aResult);
}
/* static */

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

@ -89,12 +89,10 @@ class ServoCSSParser {
* Parse a animation timing function.
*
* @param aValue The specified value.
* @param aUrl The parser url extra data.
* @param aResult The output timing function. (output)
* @return Whether the value was successfully parsed.
*/
static bool ParseEasing(const nsAString& aValue, URLExtraData* aUrl,
nsTimingFunction& aResult);
static bool ParseEasing(const nsAString& aValue, nsTimingFunction& aResult);
/**
* Parse a specified transform list into a gfx matrix.

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

@ -4124,16 +4124,13 @@ pub unsafe extern "C" fn Servo_ParseProperty(
#[no_mangle]
pub extern "C" fn Servo_ParseEasing(
easing: &nsAString,
data: *mut URLExtraData,
output: &mut nsTimingFunction,
) -> bool {
use style::properties::longhands::transition_timing_function;
// FIXME Dummy URL data would work fine here.
let url_data = unsafe { UrlExtraData::from_ptr_ref(&data) };
let context = ParserContext::new(
Origin::Author,
url_data,
unsafe { dummy_url_data() },
Some(CssRuleType::Style),
ParsingMode::DEFAULT,
QuirksMode::NoQuirks,