mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 1875441 - Pass entire AnimatedPropertyID to AnimationValue::FromString r=layout-reviewers,emilio
When only an nsCSSPropertyID was passed, AnimationValue::FromString would create an AnimatedPropertyID anyway, sometimes from eCSSPropertyExtra_variable without a custom name. Also removed an unused argument from AnimationValue::ComputeDistance. Drive-by: Remove an unnecessary include and forward declaration. Differential Revision: https://phabricator.services.mozilla.com/D199189
This commit is contained in:
parent
c130c69b7b
commit
711dafb913
12
dom/animation/test/crashtests/1875441.html
Normal file
12
dom/animation/test/crashtests/1875441.html
Normal file
@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<style>
|
||||
@property --my-property {
|
||||
syntax: "<length>",
|
||||
inherits: false,
|
||||
initial-value: 0,
|
||||
}
|
||||
</style>
|
||||
<div id="box"></div>
|
||||
<script>
|
||||
SpecialPowers.DOMWindowUtils.computeAnimationDistance(box, "--my-property", "red", "blue");
|
||||
</script>
|
@ -59,3 +59,4 @@ load 1706157.html
|
||||
pref(gfx.omta.background-color,true) load 1699890.html
|
||||
pref(dom.animations-api.getAnimations.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1714421.html
|
||||
load 1807966.html
|
||||
load 1875441.html
|
||||
|
@ -3146,12 +3146,17 @@ nsDOMWindowUtils::ComputeAnimationDistance(Element* aElement,
|
||||
double* aResult) {
|
||||
NS_ENSURE_ARG_POINTER(aElement);
|
||||
|
||||
nsCSSPropertyID property =
|
||||
nsCSSPropertyID propertyID =
|
||||
nsCSSProps::LookupProperty(NS_ConvertUTF16toUTF8(aProperty));
|
||||
if (property == eCSSProperty_UNKNOWN || nsCSSProps::IsShorthand(property)) {
|
||||
if (propertyID == eCSSProperty_UNKNOWN ||
|
||||
nsCSSProps::IsShorthand(propertyID)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
AnimatedPropertyID property = propertyID == eCSSPropertyExtra_variable
|
||||
? AnimatedPropertyID(NS_Atomize(aProperty))
|
||||
: AnimatedPropertyID(propertyID);
|
||||
|
||||
AnimationValue v1 = AnimationValue::FromString(
|
||||
property, NS_ConvertUTF16toUTF8(aValue1), aElement);
|
||||
AnimationValue v2 = AnimationValue::FromString(
|
||||
@ -3160,7 +3165,7 @@ nsDOMWindowUtils::ComputeAnimationDistance(Element* aElement,
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
*aResult = v1.ComputeDistance(property, v2);
|
||||
*aResult = v1.ComputeDistance(v2);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/AnimatedPropertyID.h"
|
||||
#include "mozilla/ComputedStyle.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
@ -175,8 +174,7 @@ bool AnimationValue::IsInterpolableWith(const AnimatedPropertyID& aProperty,
|
||||
return Servo_AnimationValues_IsInterpolable(mServo, aToValue.mServo);
|
||||
}
|
||||
|
||||
double AnimationValue::ComputeDistance(nsCSSPropertyID aProperty,
|
||||
const AnimationValue& aOther) const {
|
||||
double AnimationValue::ComputeDistance(const AnimationValue& aOther) const {
|
||||
if (IsNull() || aOther.IsNull()) {
|
||||
return 0.0;
|
||||
}
|
||||
@ -190,7 +188,7 @@ double AnimationValue::ComputeDistance(nsCSSPropertyID aProperty,
|
||||
}
|
||||
|
||||
/* static */
|
||||
AnimationValue AnimationValue::FromString(nsCSSPropertyID aProperty,
|
||||
AnimationValue AnimationValue::FromString(AnimatedPropertyID& aProperty,
|
||||
const nsACString& aValue,
|
||||
Element* aElement) {
|
||||
MOZ_ASSERT(aElement);
|
||||
@ -213,9 +211,8 @@ AnimationValue AnimationValue::FromString(nsCSSPropertyID aProperty,
|
||||
nsComputedDOMStyle::GetComputedStyle(aElement);
|
||||
MOZ_ASSERT(computedStyle);
|
||||
|
||||
AnimatedPropertyID property(aProperty);
|
||||
RefPtr<StyleLockedDeclarationBlock> declarations =
|
||||
ServoCSSParser::ParseProperty(property, aValue,
|
||||
ServoCSSParser::ParseProperty(aProperty, aValue,
|
||||
ServoCSSParser::GetParsingEnvironment(doc),
|
||||
StyleParsingMode::DEFAULT);
|
||||
|
||||
|
@ -44,7 +44,6 @@ class Animatable;
|
||||
|
||||
enum class PseudoStyleType : uint8_t;
|
||||
struct PropertyStyleAnimationValuePair;
|
||||
struct AnimatedPropertyID;
|
||||
|
||||
struct AnimationValue {
|
||||
explicit AnimationValue(const RefPtr<StyleAnimationValue>& aValue)
|
||||
@ -102,13 +101,12 @@ struct AnimationValue {
|
||||
const AnimationValue& aToValue) const;
|
||||
|
||||
// Compute the distance between *this and aOther.
|
||||
double ComputeDistance(nsCSSPropertyID aProperty,
|
||||
const AnimationValue& aOther) const;
|
||||
double ComputeDistance(const AnimationValue& aOther) const;
|
||||
|
||||
// Create an AnimaitonValue from a string. This method flushes style, so we
|
||||
// should use this carefully. Now, it is only used by
|
||||
// nsDOMWindowUtils::ComputeAnimationDistance.
|
||||
static AnimationValue FromString(nsCSSPropertyID aProperty,
|
||||
static AnimationValue FromString(AnimatedPropertyID& aProperty,
|
||||
const nsACString& aValue,
|
||||
dom::Element* aElement);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user