forked from mirrors/gecko-dev
Bug 1832173 - Remove HasArcFFI for AnimationValue. r=boris
See previous patches for context. Differential Revision: https://phabricator.services.mozilla.com/D177622
This commit is contained in:
parent
266108bffa
commit
6f904444e8
28 changed files with 240 additions and 377 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -2035,6 +2035,7 @@ dependencies = [
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"style",
|
"style",
|
||||||
"style_traits",
|
"style_traits",
|
||||||
|
"thin-vec",
|
||||||
"to_shmem",
|
"to_shmem",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -878,7 +878,7 @@ void Animation::CommitStyles(ErrorResult& aRv) {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
nsCSSPropertyIDSet properties = keyframeEffect->GetPropertySet();
|
nsCSSPropertyIDSet properties = keyframeEffect->GetPropertySet();
|
||||||
for (nsCSSPropertyID property : properties) {
|
for (nsCSSPropertyID property : properties) {
|
||||||
RefPtr<RawServoAnimationValue> computedValue =
|
RefPtr<StyleAnimationValue> computedValue =
|
||||||
Servo_AnimationValueMap_GetValue(animationValues.get(), property)
|
Servo_AnimationValueMap_GetValue(animationValues.get(), property)
|
||||||
.Consume();
|
.Consume();
|
||||||
if (computedValue) {
|
if (computedValue) {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace mozilla {
|
||||||
class ComputedStyle;
|
class ComputedStyle;
|
||||||
class EffectSet;
|
class EffectSet;
|
||||||
class RestyleTracker;
|
class RestyleTracker;
|
||||||
class StyleAnimationValue;
|
struct StyleAnimationValue;
|
||||||
struct StyleAnimationValueMap;
|
struct StyleAnimationValueMap;
|
||||||
struct AnimationProperty;
|
struct AnimationProperty;
|
||||||
struct NonOwningAnimationTarget;
|
struct NonOwningAnimationTarget;
|
||||||
|
|
|
||||||
|
|
@ -598,7 +598,7 @@ void KeyframeEffect::EnsureBaseStyle(
|
||||||
aBaseComputedStyle = aPresContext->StyleSet()->GetBaseContextForElement(
|
aBaseComputedStyle = aPresContext->StyleSet()->GetBaseContextForElement(
|
||||||
animatingElement, aComputedStyle);
|
animatingElement, aComputedStyle);
|
||||||
}
|
}
|
||||||
RefPtr<RawServoAnimationValue> baseValue =
|
RefPtr<StyleAnimationValue> baseValue =
|
||||||
Servo_ComputedValues_ExtractAnimationValue(aBaseComputedStyle,
|
Servo_ComputedValues_ExtractAnimationValue(aBaseComputedStyle,
|
||||||
aProperty.mProperty)
|
aProperty.mProperty)
|
||||||
.Consume();
|
.Consume();
|
||||||
|
|
@ -1322,10 +1322,7 @@ void KeyframeEffect::GetKeyframes(JSContext* aCx, nsTArray<JSObject*>& aResult,
|
||||||
propertyValue.mServoDeclarationBlock, propertyValue.mProperty,
|
propertyValue.mServoDeclarationBlock, propertyValue.mProperty,
|
||||||
&stringValue, computedStyle, customProperties, rawData);
|
&stringValue, computedStyle, customProperties, rawData);
|
||||||
} else {
|
} else {
|
||||||
RawServoAnimationValue* value =
|
if (auto* value = mBaseValues.GetWeak(propertyValue.mProperty)) {
|
||||||
mBaseValues.GetWeak(propertyValue.mProperty);
|
|
||||||
|
|
||||||
if (value) {
|
|
||||||
Servo_AnimationValue_Serialize(value, propertyValue.mProperty,
|
Servo_AnimationValue_Serialize(value, propertyValue.mProperty,
|
||||||
rawData, &stringValue);
|
rawData, &stringValue);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -328,7 +328,7 @@ class KeyframeEffect : public AnimationEffect {
|
||||||
AnimationValue BaseStyle(nsCSSPropertyID aProperty) const {
|
AnimationValue BaseStyle(nsCSSPropertyID aProperty) const {
|
||||||
AnimationValue result;
|
AnimationValue result;
|
||||||
bool hasProperty = false;
|
bool hasProperty = false;
|
||||||
// We cannot use getters_AddRefs on RawServoAnimationValue because it is
|
// We cannot use getters_AddRefs on StyleAnimationValue because it is
|
||||||
// an incomplete type, so Get() doesn't work. Instead, use GetWeak, and
|
// an incomplete type, so Get() doesn't work. Instead, use GetWeak, and
|
||||||
// then assign the raw pointer to a RefPtr.
|
// then assign the raw pointer to a RefPtr.
|
||||||
result.mServo = mBaseValues.GetWeak(aProperty, &hasProperty);
|
result.mServo = mBaseValues.GetWeak(aProperty, &hasProperty);
|
||||||
|
|
@ -464,7 +464,7 @@ class KeyframeEffect : public AnimationEffect {
|
||||||
// least one animation value that is composited with the underlying value
|
// least one animation value that is composited with the underlying value
|
||||||
// (i.e. it uses the additive or accumulate composite mode).
|
// (i.e. it uses the additive or accumulate composite mode).
|
||||||
using BaseValuesHashmap =
|
using BaseValuesHashmap =
|
||||||
nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>;
|
nsRefPtrHashtable<nsUint32HashKey, StyleAnimationValue>;
|
||||||
BaseValuesHashmap mBaseValues;
|
BaseValuesHashmap mBaseValues;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -3244,7 +3244,7 @@ nsDOMWindowUtils::GetUnanimatedComputedStyle(Element* aElement,
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<RawServoAnimationValue> value =
|
RefPtr<StyleAnimationValue> value =
|
||||||
Servo_ComputedValues_ExtractAnimationValue(computedStyle, propertyID)
|
Servo_ComputedValues_ExtractAnimationValue(computedStyle, propertyID)
|
||||||
.Consume();
|
.Consume();
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,7 @@ using namespace mozilla::dom;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
using ServoAnimationValues =
|
using ServoAnimationValues = CopyableAutoTArray<RefPtr<StyleAnimationValue>, 1>;
|
||||||
CopyableAutoTArray<RefPtr<RawServoAnimationValue>, 1>;
|
|
||||||
|
|
||||||
/*static*/
|
/*static*/
|
||||||
SMILCSSValueType SMILCSSValueType::sSingleton;
|
SMILCSSValueType SMILCSSValueType::sSingleton;
|
||||||
|
|
@ -47,7 +46,7 @@ struct ValueWrapper {
|
||||||
mServoValues.AppendElement(aValue.mServo);
|
mServoValues.AppendElement(aValue.mServo);
|
||||||
}
|
}
|
||||||
ValueWrapper(nsCSSPropertyID aPropID,
|
ValueWrapper(nsCSSPropertyID aPropID,
|
||||||
const RefPtr<RawServoAnimationValue>& aValue)
|
const RefPtr<StyleAnimationValue>& aValue)
|
||||||
: mPropID(aPropID), mServoValues{(aValue)} {}
|
: mPropID(aPropID), mServoValues{(aValue)} {}
|
||||||
ValueWrapper(nsCSSPropertyID aPropID, ServoAnimationValues&& aValues)
|
ValueWrapper(nsCSSPropertyID aPropID, ServoAnimationValues&& aValues)
|
||||||
: mPropID(aPropID), mServoValues{std::move(aValues)} {}
|
: mPropID(aPropID), mServoValues{std::move(aValues)} {}
|
||||||
|
|
@ -90,14 +89,14 @@ struct ValueWrapper {
|
||||||
// If both arguments are null, this method returns false.
|
// If both arguments are null, this method returns false.
|
||||||
//
|
//
|
||||||
// |aZeroValueStorage| should be a reference to a
|
// |aZeroValueStorage| should be a reference to a
|
||||||
// RefPtr<RawServoAnimationValue>. This is used where we may need to allocate a
|
// RefPtr<StyleAnimationValue>. This is used where we may need to allocate a
|
||||||
// new ServoAnimationValue to represent the appropriate zero value.
|
// new ServoAnimationValue to represent the appropriate zero value.
|
||||||
//
|
//
|
||||||
// Returns true on success, or otherwise.
|
// Returns true on success, or otherwise.
|
||||||
static bool FinalizeServoAnimationValues(
|
static bool FinalizeServoAnimationValues(
|
||||||
const RefPtr<RawServoAnimationValue>*& aValue1,
|
const RefPtr<StyleAnimationValue>*& aValue1,
|
||||||
const RefPtr<RawServoAnimationValue>*& aValue2,
|
const RefPtr<StyleAnimationValue>*& aValue2,
|
||||||
RefPtr<RawServoAnimationValue>& aZeroValueStorage) {
|
RefPtr<StyleAnimationValue>& aZeroValueStorage) {
|
||||||
if (!aValue1 && !aValue2) {
|
if (!aValue1 && !aValue2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -203,11 +202,11 @@ static bool AddOrAccumulateForServo(SMILValue& aDest,
|
||||||
"both of them exist");
|
"both of them exist");
|
||||||
|
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
const RefPtr<RawServoAnimationValue>* valueToAdd =
|
const RefPtr<StyleAnimationValue>* valueToAdd =
|
||||||
aValueToAddWrapper ? &aValueToAddWrapper->mServoValues[i] : nullptr;
|
aValueToAddWrapper ? &aValueToAddWrapper->mServoValues[i] : nullptr;
|
||||||
const RefPtr<RawServoAnimationValue>* destValue =
|
const RefPtr<StyleAnimationValue>* destValue =
|
||||||
aDestWrapper ? &aDestWrapper->mServoValues[i] : nullptr;
|
aDestWrapper ? &aDestWrapper->mServoValues[i] : nullptr;
|
||||||
RefPtr<RawServoAnimationValue> zeroValueStorage;
|
RefPtr<StyleAnimationValue> zeroValueStorage;
|
||||||
if (!FinalizeServoAnimationValues(valueToAdd, destValue,
|
if (!FinalizeServoAnimationValues(valueToAdd, destValue,
|
||||||
zeroValueStorage)) {
|
zeroValueStorage)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -223,7 +222,7 @@ static bool AddOrAccumulateForServo(SMILValue& aDest,
|
||||||
aDestWrapper->mServoValues.SetLength(len);
|
aDestWrapper->mServoValues.SetLength(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<RawServoAnimationValue> result;
|
RefPtr<StyleAnimationValue> result;
|
||||||
if (aCompositeOp == CompositeOperation::Add) {
|
if (aCompositeOp == CompositeOperation::Add) {
|
||||||
result = Servo_AnimationValues_Add(*destValue, *valueToAdd).Consume();
|
result = Servo_AnimationValues_Add(*destValue, *valueToAdd).Consume();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -307,10 +306,10 @@ static nsresult ComputeDistanceForServo(const ValueWrapper* aFromWrapper,
|
||||||
double squareDistance = 0;
|
double squareDistance = 0;
|
||||||
|
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
const RefPtr<RawServoAnimationValue>* fromValue =
|
const RefPtr<StyleAnimationValue>* fromValue =
|
||||||
aFromWrapper ? &aFromWrapper->mServoValues[0] : nullptr;
|
aFromWrapper ? &aFromWrapper->mServoValues[0] : nullptr;
|
||||||
const RefPtr<RawServoAnimationValue>* toValue = &aToWrapper.mServoValues[0];
|
const RefPtr<StyleAnimationValue>* toValue = &aToWrapper.mServoValues[0];
|
||||||
RefPtr<RawServoAnimationValue> zeroValueStorage;
|
RefPtr<StyleAnimationValue> zeroValueStorage;
|
||||||
if (!FinalizeServoAnimationValues(fromValue, toValue, zeroValueStorage)) {
|
if (!FinalizeServoAnimationValues(fromValue, toValue, zeroValueStorage)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
@ -370,16 +369,15 @@ static nsresult InterpolateForServo(const ValueWrapper* aStartWrapper,
|
||||||
"Start and end values length should be the same if "
|
"Start and end values length should be the same if "
|
||||||
"the start value exists");
|
"the start value exists");
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
const RefPtr<RawServoAnimationValue>* startValue =
|
const RefPtr<StyleAnimationValue>* startValue =
|
||||||
aStartWrapper ? &aStartWrapper->mServoValues[i] : nullptr;
|
aStartWrapper ? &aStartWrapper->mServoValues[i] : nullptr;
|
||||||
const RefPtr<RawServoAnimationValue>* endValue =
|
const RefPtr<StyleAnimationValue>* endValue = &aEndWrapper.mServoValues[i];
|
||||||
&aEndWrapper.mServoValues[i];
|
RefPtr<StyleAnimationValue> zeroValueStorage;
|
||||||
RefPtr<RawServoAnimationValue> zeroValueStorage;
|
|
||||||
if (!FinalizeServoAnimationValues(startValue, endValue, zeroValueStorage)) {
|
if (!FinalizeServoAnimationValues(startValue, endValue, zeroValueStorage)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<RawServoAnimationValue> result =
|
RefPtr<StyleAnimationValue> result =
|
||||||
Servo_AnimationValues_Interpolate(*startValue, *endValue, aUnitDistance)
|
Servo_AnimationValues_Interpolate(*startValue, *endValue, aUnitDistance)
|
||||||
.Consume();
|
.Consume();
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|
@ -558,8 +556,8 @@ void SMILCSSValueType::FinalizeValue(SMILValue& aValue,
|
||||||
ServoAnimationValues zeroValues;
|
ServoAnimationValues zeroValues;
|
||||||
zeroValues.SetCapacity(valueToMatchWrapper->mServoValues.Length());
|
zeroValues.SetCapacity(valueToMatchWrapper->mServoValues.Length());
|
||||||
|
|
||||||
for (auto& valueToMatch : valueToMatchWrapper->mServoValues) {
|
for (const auto& valueToMatch : valueToMatchWrapper->mServoValues) {
|
||||||
RefPtr<RawServoAnimationValue> zeroValue =
|
RefPtr<StyleAnimationValue> zeroValue =
|
||||||
Servo_AnimationValues_GetZeroValue(valueToMatch).Consume();
|
Servo_AnimationValues_GetZeroValue(valueToMatch).Consume();
|
||||||
if (!zeroValue) {
|
if (!zeroValue) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ static AnimationHelper::SampleResult SampleAnimationForProperty(
|
||||||
TimeStamp aCurrentFrameTime, const AnimatedValue* aPreviousValue,
|
TimeStamp aCurrentFrameTime, const AnimatedValue* aPreviousValue,
|
||||||
CanSkipCompose aCanSkipCompose,
|
CanSkipCompose aCanSkipCompose,
|
||||||
nsTArray<PropertyAnimation>& aPropertyAnimations,
|
nsTArray<PropertyAnimation>& aPropertyAnimations,
|
||||||
RefPtr<RawServoAnimationValue>& aAnimationValue) {
|
RefPtr<StyleAnimationValue>& aAnimationValue) {
|
||||||
MOZ_ASSERT(!aPropertyAnimations.IsEmpty(), "Should have animations");
|
MOZ_ASSERT(!aPropertyAnimations.IsEmpty(), "Should have animations");
|
||||||
|
|
||||||
auto reason = AnimationHelper::SampleResult::Reason::None;
|
auto reason = AnimationHelper::SampleResult::Reason::None;
|
||||||
|
|
@ -318,17 +318,17 @@ AnimationHelper::SampleResult AnimationHelper::SampleAnimationForEachNode(
|
||||||
const MutexAutoLock& aProofOfMapLock, TimeStamp aPreviousFrameTime,
|
const MutexAutoLock& aProofOfMapLock, TimeStamp aPreviousFrameTime,
|
||||||
TimeStamp aCurrentFrameTime, const AnimatedValue* aPreviousValue,
|
TimeStamp aCurrentFrameTime, const AnimatedValue* aPreviousValue,
|
||||||
nsTArray<PropertyAnimationGroup>& aPropertyAnimationGroups,
|
nsTArray<PropertyAnimationGroup>& aPropertyAnimationGroups,
|
||||||
nsTArray<RefPtr<RawServoAnimationValue>>& aAnimationValues /* out */) {
|
nsTArray<RefPtr<StyleAnimationValue>>& aAnimationValues /* out */) {
|
||||||
MOZ_ASSERT(!aPropertyAnimationGroups.IsEmpty(),
|
MOZ_ASSERT(!aPropertyAnimationGroups.IsEmpty(),
|
||||||
"Should be called with animation data");
|
"Should be called with animation data");
|
||||||
MOZ_ASSERT(aAnimationValues.IsEmpty(),
|
MOZ_ASSERT(aAnimationValues.IsEmpty(),
|
||||||
"Should be called with empty aAnimationValues");
|
"Should be called with empty aAnimationValues");
|
||||||
|
|
||||||
nsTArray<RefPtr<RawServoAnimationValue>> baseStyleOfDelayAnimations;
|
nsTArray<RefPtr<StyleAnimationValue>> baseStyleOfDelayAnimations;
|
||||||
nsTArray<RefPtr<RawServoAnimationValue>> nonAnimatingValues;
|
nsTArray<RefPtr<StyleAnimationValue>> nonAnimatingValues;
|
||||||
for (PropertyAnimationGroup& group : aPropertyAnimationGroups) {
|
for (PropertyAnimationGroup& group : aPropertyAnimationGroups) {
|
||||||
// Initialize animation value with base style.
|
// Initialize animation value with base style.
|
||||||
RefPtr<RawServoAnimationValue> currValue = group.mBaseStyle;
|
RefPtr<StyleAnimationValue> currValue = group.mBaseStyle;
|
||||||
|
|
||||||
CanSkipCompose canSkipCompose =
|
CanSkipCompose canSkipCompose =
|
||||||
aPreviousValue && aPropertyAnimationGroups.Length() == 1 &&
|
aPreviousValue && aPropertyAnimationGroups.Length() == 1 &&
|
||||||
|
|
@ -600,7 +600,7 @@ uint64_t AnimationHelper::GetNextCompositorAnimationsId() {
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Matrix4x4 AnimationHelper::ServoAnimationValueToMatrix4x4(
|
gfx::Matrix4x4 AnimationHelper::ServoAnimationValueToMatrix4x4(
|
||||||
const nsTArray<RefPtr<RawServoAnimationValue>>& aValues,
|
const nsTArray<RefPtr<StyleAnimationValue>>& aValues,
|
||||||
const TransformData& aTransformData, gfx::Path* aCachedMotionPath) {
|
const TransformData& aTransformData, gfx::Path* aCachedMotionPath) {
|
||||||
using nsStyleTransformMatrix::TransformReferenceBox;
|
using nsStyleTransformMatrix::TransformReferenceBox;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,9 +87,9 @@ class AnimationHelper {
|
||||||
* that it reduces each property group to a single output value:
|
* that it reduces each property group to a single output value:
|
||||||
*
|
*
|
||||||
* [
|
* [
|
||||||
* { rotate, RawServoAnimationValue },
|
* { rotate, StyleAnimationValue },
|
||||||
* { scale, RawServoAnimationValue },
|
* { scale, StyleAnimationValue },
|
||||||
* { transform, RawServoAnimationValue },
|
* { transform, StyleAnimationValue },
|
||||||
* ]
|
* ]
|
||||||
*
|
*
|
||||||
* For transform animations, the caller (SampleAnimations) will combine the
|
* For transform animations, the caller (SampleAnimations) will combine the
|
||||||
|
|
@ -100,7 +100,7 @@ class AnimationHelper {
|
||||||
const MutexAutoLock& aProofOfMapLock, TimeStamp aPreviousFrameTime,
|
const MutexAutoLock& aProofOfMapLock, TimeStamp aPreviousFrameTime,
|
||||||
TimeStamp aCurrentFrameTime, const AnimatedValue* aPreviousValue,
|
TimeStamp aCurrentFrameTime, const AnimatedValue* aPreviousValue,
|
||||||
nsTArray<PropertyAnimationGroup>& aPropertyAnimationGroups,
|
nsTArray<PropertyAnimationGroup>& aPropertyAnimationGroups,
|
||||||
nsTArray<RefPtr<RawServoAnimationValue>>& aAnimationValues);
|
nsTArray<RefPtr<StyleAnimationValue>>& aAnimationValues);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract organized animation data by property into an array of
|
* Extract organized animation data by property into an array of
|
||||||
|
|
@ -161,7 +161,7 @@ class AnimationHelper {
|
||||||
* (e.g. transform, translate etc.).
|
* (e.g. transform, translate etc.).
|
||||||
*/
|
*/
|
||||||
static gfx::Matrix4x4 ServoAnimationValueToMatrix4x4(
|
static gfx::Matrix4x4 ServoAnimationValueToMatrix4x4(
|
||||||
const nsTArray<RefPtr<RawServoAnimationValue>>& aValue,
|
const nsTArray<RefPtr<StyleAnimationValue>>& aValue,
|
||||||
const TransformData& aTransformData, gfx::Path* aCachedMotionPath);
|
const TransformData& aTransformData, gfx::Path* aCachedMotionPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ namespace layers {
|
||||||
|
|
||||||
struct PropertyAnimation {
|
struct PropertyAnimation {
|
||||||
struct SegmentData {
|
struct SegmentData {
|
||||||
RefPtr<RawServoAnimationValue> mStartValue;
|
RefPtr<StyleAnimationValue> mStartValue;
|
||||||
RefPtr<RawServoAnimationValue> mEndValue;
|
RefPtr<StyleAnimationValue> mEndValue;
|
||||||
Maybe<mozilla::StyleComputedTimingFunction> mFunction;
|
Maybe<mozilla::StyleComputedTimingFunction> mFunction;
|
||||||
float mStartPortion;
|
float mStartPortion;
|
||||||
float mEndPortion;
|
float mEndPortion;
|
||||||
|
|
@ -69,7 +69,7 @@ struct PropertyAnimationGroup {
|
||||||
nsCSSPropertyID mProperty;
|
nsCSSPropertyID mProperty;
|
||||||
|
|
||||||
nsTArray<PropertyAnimation> mAnimations;
|
nsTArray<PropertyAnimation> mAnimations;
|
||||||
RefPtr<RawServoAnimationValue> mBaseStyle;
|
RefPtr<StyleAnimationValue> mBaseStyle;
|
||||||
|
|
||||||
bool IsEmpty() const { return mAnimations.IsEmpty(); }
|
bool IsEmpty() const { return mAnimations.IsEmpty(); }
|
||||||
void Clear() {
|
void Clear() {
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ static ParentLayerRect GetClipRectForPartialPrerender(
|
||||||
void CompositorAnimationStorage::StoreAnimatedValue(
|
void CompositorAnimationStorage::StoreAnimatedValue(
|
||||||
nsCSSPropertyID aProperty, uint64_t aId,
|
nsCSSPropertyID aProperty, uint64_t aId,
|
||||||
const std::unique_ptr<AnimationStorageData>& aAnimationStorageData,
|
const std::unique_ptr<AnimationStorageData>& aAnimationStorageData,
|
||||||
const AutoTArray<RefPtr<RawServoAnimationValue>, 1>& aAnimationValues,
|
const AutoTArray<RefPtr<StyleAnimationValue>, 1>& aAnimationValues,
|
||||||
const MutexAutoLock& aProofOfMapLock, const RefPtr<APZSampler>& aApzSampler,
|
const MutexAutoLock& aProofOfMapLock, const RefPtr<APZSampler>& aApzSampler,
|
||||||
AnimatedValue* aAnimatedValueEntry,
|
AnimatedValue* aAnimatedValueEntry,
|
||||||
JankedAnimationMap& aJankedAnimationMap) {
|
JankedAnimationMap& aJankedAnimationMap) {
|
||||||
|
|
@ -310,7 +310,7 @@ bool CompositorAnimationStorage::SampleAnimations(
|
||||||
const nsCSSPropertyID lastPropertyAnimationGroupProperty =
|
const nsCSSPropertyID lastPropertyAnimationGroupProperty =
|
||||||
animationStorageData->mAnimation.LastElement().mProperty;
|
animationStorageData->mAnimation.LastElement().mProperty;
|
||||||
isAnimating = true;
|
isAnimating = true;
|
||||||
AutoTArray<RefPtr<RawServoAnimationValue>, 1> animationValues;
|
AutoTArray<RefPtr<StyleAnimationValue>, 1> animationValues;
|
||||||
AnimatedValue* previousValue = GetAnimatedValue(iter.first);
|
AnimatedValue* previousValue = GetAnimatedValue(iter.first);
|
||||||
AnimationHelper::SampleResult sampleResult =
|
AnimationHelper::SampleResult sampleResult =
|
||||||
AnimationHelper::SampleAnimationForEachNode(
|
AnimationHelper::SampleAnimationForEachNode(
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ class CompositorAnimationStorage final {
|
||||||
void StoreAnimatedValue(
|
void StoreAnimatedValue(
|
||||||
nsCSSPropertyID aProperty, uint64_t aId,
|
nsCSSPropertyID aProperty, uint64_t aId,
|
||||||
const std::unique_ptr<AnimationStorageData>& aAnimationStorageData,
|
const std::unique_ptr<AnimationStorageData>& aAnimationStorageData,
|
||||||
const AutoTArray<RefPtr<RawServoAnimationValue>, 1>& aAnimationValues,
|
const AutoTArray<RefPtr<StyleAnimationValue>, 1>& aAnimationValues,
|
||||||
const MutexAutoLock& aProofOfMapLock,
|
const MutexAutoLock& aProofOfMapLock,
|
||||||
const RefPtr<APZSampler>& aApzSampler, AnimatedValue* aAnimatedValueEntry,
|
const RefPtr<APZSampler>& aApzSampler, AnimatedValue* aAnimatedValueEntry,
|
||||||
JankedAnimationMap& aJankedAnimationMap);
|
JankedAnimationMap& aJankedAnimationMap);
|
||||||
|
|
|
||||||
|
|
@ -680,7 +680,7 @@ nsCSSPropertyID Gecko_ElementTransitions_PropertyAt(const Element* aElement,
|
||||||
: nsCSSPropertyID::eCSSProperty_UNKNOWN;
|
: nsCSSPropertyID::eCSSProperty_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RawServoAnimationValue* Gecko_ElementTransitions_EndValueAt(
|
const StyleAnimationValue* Gecko_ElementTransitions_EndValueAt(
|
||||||
const Element* aElement, size_t aIndex) {
|
const Element* aElement, size_t aIndex) {
|
||||||
CSSTransition* transition = GetCurrentTransitionAt(aElement, aIndex);
|
CSSTransition* transition = GetCurrentTransitionAt(aElement, aIndex);
|
||||||
return transition ? transition->ToValue().mServo.get() : nullptr;
|
return transition ? transition->ToValue().mServo.get() : nullptr;
|
||||||
|
|
@ -705,10 +705,10 @@ double Gecko_GetPositionInSegment(const AnimationPropertySegment* aSegment,
|
||||||
aSegment->mTimingFunction, positionInSegment, aBeforeFlag);
|
aSegment->mTimingFunction, positionInSegment, aBeforeFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
const RawServoAnimationValue* Gecko_AnimationGetBaseStyle(
|
const StyleAnimationValue* Gecko_AnimationGetBaseStyle(
|
||||||
const RawServoAnimationValueTable* aBaseStyles, nsCSSPropertyID aProperty) {
|
const RawServoAnimationValueTable* aBaseStyles, nsCSSPropertyID aProperty) {
|
||||||
auto base = reinterpret_cast<
|
auto base = reinterpret_cast<
|
||||||
const nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>*>(
|
const nsRefPtrHashtable<nsUint32HashKey, StyleAnimationValue>*>(
|
||||||
aBaseStyles);
|
aBaseStyles);
|
||||||
return base->GetWeak(aProperty);
|
return base->GetWeak(aProperty);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ size_t Gecko_ElementTransitions_Length(
|
||||||
nsCSSPropertyID Gecko_ElementTransitions_PropertyAt(
|
nsCSSPropertyID Gecko_ElementTransitions_PropertyAt(
|
||||||
const mozilla::dom::Element* aElementOrPseudo, size_t aIndex);
|
const mozilla::dom::Element* aElementOrPseudo, size_t aIndex);
|
||||||
|
|
||||||
const RawServoAnimationValue* Gecko_ElementTransitions_EndValueAt(
|
const mozilla::StyleAnimationValue* Gecko_ElementTransitions_EndValueAt(
|
||||||
const mozilla::dom::Element* aElementOrPseudo, size_t aIndex);
|
const mozilla::dom::Element* aElementOrPseudo, size_t aIndex);
|
||||||
|
|
||||||
double Gecko_GetProgressFromComputedTiming(const mozilla::ComputedTiming*);
|
double Gecko_GetProgressFromComputedTiming(const mozilla::ComputedTiming*);
|
||||||
|
|
@ -263,10 +263,10 @@ double Gecko_GetPositionInSegment(const mozilla::AnimationPropertySegment*,
|
||||||
|
|
||||||
// Get servo's AnimationValue for |aProperty| from the cached base style
|
// Get servo's AnimationValue for |aProperty| from the cached base style
|
||||||
// |aBaseStyles|.
|
// |aBaseStyles|.
|
||||||
// |aBaseStyles| is nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>.
|
// |aBaseStyles| is nsRefPtrHashtable<nsUint32HashKey, StyleAnimationValue>.
|
||||||
// We use RawServoAnimationValueTableBorrowed to avoid exposing
|
// We use RawServoAnimationValueTableBorrowed to avoid exposing
|
||||||
// nsRefPtrHashtable in FFI.
|
// nsRefPtrHashtable in FFI.
|
||||||
const RawServoAnimationValue* Gecko_AnimationGetBaseStyle(
|
const mozilla::StyleAnimationValue* Gecko_AnimationGetBaseStyle(
|
||||||
const RawServoAnimationValueTable* aBaseStyles, nsCSSPropertyID aProperty);
|
const RawServoAnimationValueTable* aBaseStyles, nsCSSPropertyID aProperty);
|
||||||
|
|
||||||
void Gecko_StyleTransition_SetUnsupportedProperty(
|
void Gecko_StyleTransition_SetUnsupportedProperty(
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ SERVO_ARC_TYPE(CssRules, ServoCssRules)
|
||||||
SERVO_ARC_TYPE(DeclarationBlock, RawServoDeclarationBlock)
|
SERVO_ARC_TYPE(DeclarationBlock, RawServoDeclarationBlock)
|
||||||
SERVO_ARC_TYPE(StyleRule, RawServoStyleRule)
|
SERVO_ARC_TYPE(StyleRule, RawServoStyleRule)
|
||||||
SERVO_ARC_TYPE(ImportRule, RawServoImportRule)
|
SERVO_ARC_TYPE(ImportRule, RawServoImportRule)
|
||||||
SERVO_ARC_TYPE(AnimationValue, RawServoAnimationValue)
|
|
||||||
SERVO_ARC_TYPE(Keyframe, RawServoKeyframe)
|
SERVO_ARC_TYPE(Keyframe, RawServoKeyframe)
|
||||||
SERVO_ARC_TYPE(KeyframesRule, RawServoKeyframesRule)
|
SERVO_ARC_TYPE(KeyframesRule, RawServoKeyframesRule)
|
||||||
SERVO_ARC_TYPE(LayerBlockRule, RawServoLayerBlockRule)
|
SERVO_ARC_TYPE(LayerBlockRule, RawServoLayerBlockRule)
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,7 @@ struct PropertyStyleAnimationValuePair;
|
||||||
struct PropertyValuePair;
|
struct PropertyValuePair;
|
||||||
struct StyleAnimation;
|
struct StyleAnimation;
|
||||||
struct StyleCssUrlData;
|
struct StyleCssUrlData;
|
||||||
|
struct StyleAnimationValue;
|
||||||
struct StyleStylesheetContents;
|
struct StyleStylesheetContents;
|
||||||
struct URLExtraData;
|
struct URLExtraData;
|
||||||
using ComputedKeyframeValues = nsTArray<PropertyStyleAnimationValuePair>;
|
using ComputedKeyframeValues = nsTArray<PropertyStyleAnimationValuePair>;
|
||||||
|
|
@ -154,6 +155,7 @@ class Element;
|
||||||
}; \
|
}; \
|
||||||
}
|
}
|
||||||
#include "mozilla/ServoArcTypeList.h"
|
#include "mozilla/ServoArcTypeList.h"
|
||||||
|
SERVO_ARC_TYPE(AnimationValue, mozilla::StyleAnimationValue)
|
||||||
SERVO_ARC_TYPE(ComputedStyle, mozilla::ComputedStyle)
|
SERVO_ARC_TYPE(ComputedStyle, mozilla::ComputedStyle)
|
||||||
SERVO_ARC_TYPE(CssUrlData, mozilla::StyleCssUrlData)
|
SERVO_ARC_TYPE(CssUrlData, mozilla::StyleCssUrlData)
|
||||||
SERVO_ARC_TYPE(StyleSheetContents, mozilla::StyleStylesheetContents)
|
SERVO_ARC_TYPE(StyleSheetContents, mozilla::StyleStylesheetContents)
|
||||||
|
|
|
||||||
|
|
@ -414,7 +414,6 @@ opaque-types = [
|
||||||
"mozilla::dom::TreeOrderedArray", # AutoTArray<>
|
"mozilla::dom::TreeOrderedArray", # AutoTArray<>
|
||||||
"gfxSize", # <- union { struct { T width; T height; }; T components[2] };
|
"gfxSize", # <- union { struct { T width; T height; }; T components[2] };
|
||||||
"gfxSize_Super", # Ditto.
|
"gfxSize_Super", # Ditto.
|
||||||
"mozilla::StyleAnimationValue",
|
|
||||||
"StyleAnimationValue", # pulls in a whole bunch of stuff we don't need in the bindings
|
"StyleAnimationValue", # pulls in a whole bunch of stuff we don't need in the bindings
|
||||||
"mozilla::dom::.*Callback", # Pulls in ErrorResult and other things that
|
"mozilla::dom::.*Callback", # Pulls in ErrorResult and other things that
|
||||||
# don't align properly on Linux 32-bit
|
# don't align properly on Linux 32-bit
|
||||||
|
|
@ -650,6 +649,7 @@ cbindgen-types = [
|
||||||
{ gecko = "StyleAuthorStyles", servo = "crate::gecko::data::AuthorStyles" },
|
{ gecko = "StyleAuthorStyles", servo = "crate::gecko::data::AuthorStyles" },
|
||||||
{ gecko = "StyleUseCounters", servo = "crate::use_counters::UseCounters" },
|
{ gecko = "StyleUseCounters", servo = "crate::use_counters::UseCounters" },
|
||||||
{ gecko = "StyleStylesheetContents", servo = "crate::stylesheets::StylesheetContents" },
|
{ gecko = "StyleStylesheetContents", servo = "crate::stylesheets::StylesheetContents" },
|
||||||
|
{ gecko = "StyleAnimationValue", servo = "crate::properties::animated_properties::AnimationValue" },
|
||||||
]
|
]
|
||||||
|
|
||||||
mapped-generic-types = [
|
mapped-generic-types = [
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace mozilla {
|
||||||
// this automatically from cbindgen.
|
// this automatically from cbindgen.
|
||||||
template struct StyleStrong<ComputedStyle>;
|
template struct StyleStrong<ComputedStyle>;
|
||||||
template struct StyleStrong<ServoCssRules>;
|
template struct StyleStrong<ServoCssRules>;
|
||||||
template struct StyleStrong<RawServoAnimationValue>;
|
template struct StyleStrong<StyleAnimationValue>;
|
||||||
template struct StyleStrong<RawServoDeclarationBlock>;
|
template struct StyleStrong<RawServoDeclarationBlock>;
|
||||||
template struct StyleStrong<StyleStylesheetContents>;
|
template struct StyleStrong<StyleStylesheetContents>;
|
||||||
template struct StyleStrong<RawServoKeyframe>;
|
template struct StyleStrong<RawServoKeyframe>;
|
||||||
|
|
|
||||||
|
|
@ -1090,7 +1090,7 @@ nsTArray<ComputedKeyframeValues> ServoStyleSet::GetComputedKeyframeValuesFor(
|
||||||
void ServoStyleSet::GetAnimationValues(
|
void ServoStyleSet::GetAnimationValues(
|
||||||
RawServoDeclarationBlock* aDeclarations, Element* aElement,
|
RawServoDeclarationBlock* aDeclarations, Element* aElement,
|
||||||
const ComputedStyle* aComputedStyle,
|
const ComputedStyle* aComputedStyle,
|
||||||
nsTArray<RefPtr<RawServoAnimationValue>>& aAnimationValues) {
|
nsTArray<RefPtr<StyleAnimationValue>>& aAnimationValues) {
|
||||||
// Servo_GetAnimationValues below won't handle ignoring existing element
|
// Servo_GetAnimationValues below won't handle ignoring existing element
|
||||||
// data for bfcached documents. (See comment in ResolveStyleLazily
|
// data for bfcached documents. (See comment in ResolveStyleLazily
|
||||||
// about these bfcache issues.)
|
// about these bfcache issues.)
|
||||||
|
|
@ -1108,13 +1108,13 @@ already_AddRefed<ComputedStyle> ServoStyleSet::GetBaseContextForElement(
|
||||||
already_AddRefed<ComputedStyle>
|
already_AddRefed<ComputedStyle>
|
||||||
ServoStyleSet::ResolveServoStyleByAddingAnimation(
|
ServoStyleSet::ResolveServoStyleByAddingAnimation(
|
||||||
Element* aElement, const ComputedStyle* aStyle,
|
Element* aElement, const ComputedStyle* aStyle,
|
||||||
RawServoAnimationValue* aAnimationValue) {
|
StyleAnimationValue* aAnimationValue) {
|
||||||
return Servo_StyleSet_GetComputedValuesByAddingAnimation(
|
return Servo_StyleSet_GetComputedValuesByAddingAnimation(
|
||||||
mRawData.get(), aElement, aStyle, &Snapshots(), aAnimationValue)
|
mRawData.get(), aElement, aStyle, &Snapshots(), aAnimationValue)
|
||||||
.Consume();
|
.Consume();
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<RawServoAnimationValue> ServoStyleSet::ComputeAnimationValue(
|
already_AddRefed<StyleAnimationValue> ServoStyleSet::ComputeAnimationValue(
|
||||||
Element* aElement, RawServoDeclarationBlock* aDeclarations,
|
Element* aElement, RawServoDeclarationBlock* aDeclarations,
|
||||||
const ComputedStyle* aStyle) {
|
const ComputedStyle* aStyle) {
|
||||||
return Servo_AnimationValue_Compute(aElement, aDeclarations, aStyle,
|
return Servo_AnimationValue_Compute(aElement, aDeclarations, aStyle,
|
||||||
|
|
|
||||||
|
|
@ -389,7 +389,7 @@ class ServoStyleSet {
|
||||||
void GetAnimationValues(
|
void GetAnimationValues(
|
||||||
RawServoDeclarationBlock* aDeclarations, dom::Element* aElement,
|
RawServoDeclarationBlock* aDeclarations, dom::Element* aElement,
|
||||||
const mozilla::ComputedStyle* aStyle,
|
const mozilla::ComputedStyle* aStyle,
|
||||||
nsTArray<RefPtr<RawServoAnimationValue>>& aAnimationValues);
|
nsTArray<RefPtr<StyleAnimationValue>>& aAnimationValues);
|
||||||
|
|
||||||
void AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray);
|
void AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray);
|
||||||
|
|
||||||
|
|
@ -418,7 +418,7 @@ class ServoStyleSet {
|
||||||
// Note: |aElement| should be the generated element if it is pseudo.
|
// Note: |aElement| should be the generated element if it is pseudo.
|
||||||
already_AddRefed<ComputedStyle> ResolveServoStyleByAddingAnimation(
|
already_AddRefed<ComputedStyle> ResolveServoStyleByAddingAnimation(
|
||||||
dom::Element* aElement, const ComputedStyle* aStyle,
|
dom::Element* aElement, const ComputedStyle* aStyle,
|
||||||
RawServoAnimationValue* aAnimationValue);
|
StyleAnimationValue* aAnimationValue);
|
||||||
/**
|
/**
|
||||||
* Resolve style for a given declaration block with/without the parent style.
|
* Resolve style for a given declaration block with/without the parent style.
|
||||||
* If the parent style is not specified, the document default computed values
|
* If the parent style is not specified, the document default computed values
|
||||||
|
|
@ -428,7 +428,7 @@ class ServoStyleSet {
|
||||||
const ComputedStyle* aParentOrNull,
|
const ComputedStyle* aParentOrNull,
|
||||||
const RawServoDeclarationBlock* aDeclarations);
|
const RawServoDeclarationBlock* aDeclarations);
|
||||||
|
|
||||||
already_AddRefed<RawServoAnimationValue> ComputeAnimationValue(
|
already_AddRefed<StyleAnimationValue> ComputeAnimationValue(
|
||||||
dom::Element* aElement, RawServoDeclarationBlock* aDeclaration,
|
dom::Element* aElement, RawServoDeclarationBlock* aDeclaration,
|
||||||
const mozilla::ComputedStyle* aStyle);
|
const mozilla::ComputedStyle* aStyle);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ AnimationValue AnimationValue::FromString(nsCSSPropertyID aProperty,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
already_AddRefed<RawServoAnimationValue> AnimationValue::FromAnimatable(
|
already_AddRefed<StyleAnimationValue> AnimationValue::FromAnimatable(
|
||||||
nsCSSPropertyID aProperty, const layers::Animatable& aAnimatable) {
|
nsCSSPropertyID aProperty, const layers::Animatable& aAnimatable) {
|
||||||
switch (aAnimatable.type()) {
|
switch (aAnimatable.type()) {
|
||||||
case layers::Animatable::Tnull_t:
|
case layers::Animatable::Tnull_t:
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ enum class PseudoStyleType : uint8_t;
|
||||||
struct PropertyStyleAnimationValuePair;
|
struct PropertyStyleAnimationValuePair;
|
||||||
|
|
||||||
struct AnimationValue {
|
struct AnimationValue {
|
||||||
explicit AnimationValue(const RefPtr<RawServoAnimationValue>& aValue)
|
explicit AnimationValue(const RefPtr<StyleAnimationValue>& aValue)
|
||||||
: mServo(aValue) {}
|
: mServo(aValue) {}
|
||||||
AnimationValue() = default;
|
AnimationValue() = default;
|
||||||
|
|
||||||
|
|
@ -105,15 +105,15 @@ struct AnimationValue {
|
||||||
const nsACString& aValue,
|
const nsACString& aValue,
|
||||||
dom::Element* aElement);
|
dom::Element* aElement);
|
||||||
|
|
||||||
// Create an already_AddRefed<RawServoAnimationValue> from a
|
// Create an already_AddRefed<StyleAnimationValue> from a
|
||||||
// layers::Animatable. Basically, this function should return AnimationValue,
|
// layers::Animatable. Basically, this function should return AnimationValue,
|
||||||
// but it seems the caller, AnimationHelper, only needs
|
// but it seems the caller, AnimationHelper, only needs
|
||||||
// RawServoAnimationValue, so we return its already_AddRefed<> to avoid
|
// StyleAnimationValue, so we return its already_AddRefed<> to avoid
|
||||||
// adding/removing a redundant ref-count.
|
// adding/removing a redundant ref-count.
|
||||||
static already_AddRefed<RawServoAnimationValue> FromAnimatable(
|
static already_AddRefed<StyleAnimationValue> FromAnimatable(
|
||||||
nsCSSPropertyID aProperty, const layers::Animatable& aAnimatable);
|
nsCSSPropertyID aProperty, const layers::Animatable& aAnimatable);
|
||||||
|
|
||||||
RefPtr<RawServoAnimationValue> mServo;
|
RefPtr<StyleAnimationValue> mServo;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::ostream& operator<<(std::ostream& aOut,
|
inline std::ostream& operator<<(std::ostream& aOut,
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
use crate::gecko::url::CssUrlData;
|
use crate::gecko::url::CssUrlData;
|
||||||
use crate::gecko_bindings::structs::{
|
use crate::gecko_bindings::structs::{
|
||||||
RawServoAnimationValue, RawServoContainerRule, RawServoCounterStyleRule,
|
RawServoContainerRule, RawServoCounterStyleRule, RawServoDeclarationBlock,
|
||||||
RawServoDeclarationBlock, RawServoFontFaceRule, RawServoFontFeatureValuesRule,
|
RawServoFontFaceRule, RawServoFontFeatureValuesRule, RawServoFontPaletteValuesRule,
|
||||||
RawServoFontPaletteValuesRule, RawServoImportRule, RawServoKeyframe, RawServoKeyframesRule,
|
RawServoImportRule, RawServoKeyframe, RawServoKeyframesRule, RawServoLayerBlockRule,
|
||||||
RawServoLayerBlockRule, RawServoLayerStatementRule, RawServoMediaList, RawServoMediaRule,
|
RawServoLayerStatementRule, RawServoMediaList, RawServoMediaRule, RawServoMozDocumentRule,
|
||||||
RawServoMozDocumentRule, RawServoNamespaceRule, RawServoPageRule, RawServoStyleRule,
|
RawServoNamespaceRule, RawServoPageRule, RawServoStyleRule, RawServoSupportsRule,
|
||||||
RawServoSupportsRule, ServoCssRules,
|
ServoCssRules,
|
||||||
};
|
};
|
||||||
use crate::gecko_bindings::sugar::ownership::HasArcFFI;
|
use crate::gecko_bindings::sugar::ownership::HasArcFFI;
|
||||||
use crate::media_queries::MediaList;
|
use crate::media_queries::MediaList;
|
||||||
|
|
@ -60,9 +60,6 @@ impl_arc_ffi!(Locked<StyleRule> => RawServoStyleRule
|
||||||
impl_arc_ffi!(Locked<ImportRule> => RawServoImportRule
|
impl_arc_ffi!(Locked<ImportRule> => RawServoImportRule
|
||||||
[Servo_ImportRule_AddRef, Servo_ImportRule_Release]);
|
[Servo_ImportRule_AddRef, Servo_ImportRule_Release]);
|
||||||
|
|
||||||
impl_arc_ffi!(AnimationValue => RawServoAnimationValue
|
|
||||||
[Servo_AnimationValue_AddRef, Servo_AnimationValue_Release]);
|
|
||||||
|
|
||||||
impl_arc_ffi!(Locked<Keyframe> => RawServoKeyframe
|
impl_arc_ffi!(Locked<Keyframe> => RawServoKeyframe
|
||||||
[Servo_Keyframe_AddRef, Servo_Keyframe_Release]);
|
[Servo_Keyframe_AddRef, Servo_Keyframe_Release]);
|
||||||
|
|
||||||
|
|
@ -137,3 +134,8 @@ impl_simple_arc_ffi!(
|
||||||
Servo_ComputedStyle_AddRef,
|
Servo_ComputedStyle_AddRef,
|
||||||
Servo_ComputedStyle_Release
|
Servo_ComputedStyle_Release
|
||||||
);
|
);
|
||||||
|
impl_simple_arc_ffi!(
|
||||||
|
AnimationValue,
|
||||||
|
Servo_AnimationValue_AddRef,
|
||||||
|
Servo_AnimationValue_Release
|
||||||
|
);
|
||||||
|
|
|
||||||
|
|
@ -825,14 +825,12 @@ impl<'le> GeckoElement<'le> {
|
||||||
let mut map = FxHashMap::with_capacity_and_hasher(collection_length, Default::default());
|
let mut map = FxHashMap::with_capacity_and_hasher(collection_length, Default::default());
|
||||||
|
|
||||||
for i in 0..collection_length {
|
for i in 0..collection_length {
|
||||||
let raw_end_value = unsafe { Gecko_ElementTransitions_EndValueAt(self.0, i).as_ref() };
|
let end_value = unsafe {
|
||||||
|
Arc::from_raw_addrefed(Gecko_ElementTransitions_EndValueAt(self.0, i))
|
||||||
let end_value = AnimationValue::arc_from_borrowed(&raw_end_value)
|
};
|
||||||
.expect("AnimationValue not found in ElementTransitions");
|
|
||||||
|
|
||||||
let property = end_value.id();
|
let property = end_value.id();
|
||||||
debug_assert!(!property.is_logical());
|
debug_assert!(!property.is_logical());
|
||||||
map.insert(property, end_value.clone_arc());
|
map.insert(property, end_value);
|
||||||
}
|
}
|
||||||
map
|
map
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use crate::gecko_bindings::{bindings, structs};
|
||||||
use crate::Atom;
|
use crate::Atom;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::Deref;
|
||||||
use std::{fmt, mem, ptr};
|
use std::{fmt, mem, ptr};
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
|
||||||
|
|
@ -40,18 +40,6 @@ impl<T: RefCounted> fmt::Debug for RefPtr<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A RefPtr that we know is uniquely owned.
|
|
||||||
///
|
|
||||||
/// This is basically Box<T>, with the additional guarantee that the box can be
|
|
||||||
/// safely interpreted as a RefPtr<T> (with refcount 1)
|
|
||||||
///
|
|
||||||
/// This is useful when you wish to create a refptr and mutate it temporarily,
|
|
||||||
/// while it is still uniquely owned.
|
|
||||||
pub struct UniqueRefPtr<T: RefCounted>(RefPtr<T>);
|
|
||||||
|
|
||||||
// There is no safe conversion from &T to RefPtr<T> (like Gecko has)
|
|
||||||
// because this lets you break UniqueRefPtr's guarantee
|
|
||||||
|
|
||||||
impl<T: RefCounted> RefPtr<T> {
|
impl<T: RefCounted> RefPtr<T> {
|
||||||
/// Create a new RefPtr from an already addrefed pointer obtained from FFI.
|
/// Create a new RefPtr from an already addrefed pointer obtained from FFI.
|
||||||
///
|
///
|
||||||
|
|
@ -59,7 +47,7 @@ impl<T: RefCounted> RefPtr<T> {
|
||||||
pub unsafe fn from_addrefed(ptr: *mut T) -> Self {
|
pub unsafe fn from_addrefed(ptr: *mut T) -> Self {
|
||||||
debug_assert!(!ptr.is_null());
|
debug_assert!(!ptr.is_null());
|
||||||
RefPtr {
|
RefPtr {
|
||||||
ptr: ptr,
|
ptr,
|
||||||
_marker: PhantomData,
|
_marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -125,23 +113,6 @@ impl<T: RefCounted> RefPtr<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: RefCounted> UniqueRefPtr<T> {
|
|
||||||
/// Create a unique refptr from an already addrefed pointer obtained from
|
|
||||||
/// FFI.
|
|
||||||
///
|
|
||||||
/// The refcount must be one.
|
|
||||||
///
|
|
||||||
/// The pointer must be valid and non null
|
|
||||||
pub unsafe fn from_addrefed(ptr: *mut T) -> Self {
|
|
||||||
UniqueRefPtr(RefPtr::from_addrefed(ptr))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert to a RefPtr so that it can be used.
|
|
||||||
pub fn get(self) -> RefPtr<T> {
|
|
||||||
self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: RefCounted> Deref for RefPtr<T> {
|
impl<T: RefCounted> Deref for RefPtr<T> {
|
||||||
type Target = T;
|
type Target = T;
|
||||||
fn deref(&self) -> &T {
|
fn deref(&self) -> &T {
|
||||||
|
|
@ -150,19 +121,6 @@ impl<T: RefCounted> Deref for RefPtr<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: RefCounted> Deref for UniqueRefPtr<T> {
|
|
||||||
type Target = T;
|
|
||||||
fn deref(&self) -> &T {
|
|
||||||
unsafe { &*self.0.ptr }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: RefCounted> DerefMut for UniqueRefPtr<T> {
|
|
||||||
fn deref_mut(&mut self) -> &mut T {
|
|
||||||
unsafe { &mut *self.0.ptr }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: RefCounted> structs::RefPtr<T> {
|
impl<T: RefCounted> structs::RefPtr<T> {
|
||||||
/// Produces a Rust-side RefPtr from an FFI RefPtr, bumping the refcount.
|
/// Produces a Rust-side RefPtr from an FFI RefPtr, bumping the refcount.
|
||||||
///
|
///
|
||||||
|
|
@ -226,24 +184,51 @@ impl<T: RefCounted> structs::RefPtr<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> structs::RefPtr<T> {
|
impl<T> structs::RefPtr<T> {
|
||||||
/// Sets the contents to an `Arc<T>`, releasing the old value in `self` if
|
/// Returns a new, null refptr.
|
||||||
/// necessary.
|
pub fn null() -> Self {
|
||||||
pub fn set_arc<U>(&mut self, other: Arc<U>)
|
Self {
|
||||||
|
mRawPtr: ptr::null_mut(),
|
||||||
|
_phantom_0: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new RefPtr from an arc.
|
||||||
|
pub fn from_arc(s: Arc<T>) -> Self {
|
||||||
|
Self {
|
||||||
|
mRawPtr: Arc::into_raw(s) as *mut _,
|
||||||
|
_phantom_0: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new RefPtr from an arc.
|
||||||
|
pub fn from_arc_ffi<U>(s: Arc<U>) -> Self
|
||||||
|
where
|
||||||
|
U: HasArcFFI<FFIType = T>,
|
||||||
|
{
|
||||||
|
Self {
|
||||||
|
mRawPtr: unsafe { mem::transmute(Arc::into_raw_offset(s)) },
|
||||||
|
_phantom_0: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the contents to an Arc<T>.
|
||||||
|
pub fn set_arc(&mut self, other: Arc<T>) {
|
||||||
|
unsafe {
|
||||||
|
if !self.mRawPtr.is_null() {
|
||||||
|
let _ = Arc::from_raw(self.mRawPtr);
|
||||||
|
}
|
||||||
|
self.mRawPtr = Arc::into_raw(other) as *mut _;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the contents to an Arc<U>.
|
||||||
|
pub fn set_arc_ffi<U>(&mut self, other: Arc<U>)
|
||||||
where
|
where
|
||||||
U: HasArcFFI<FFIType = T>,
|
U: HasArcFFI<FFIType = T>,
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
U::release_opt(self.mRawPtr.as_ref());
|
U::release_opt(self.mRawPtr.as_ref());
|
||||||
}
|
}
|
||||||
self.set_arc_leaky(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets the contents to an Arc<T>
|
|
||||||
/// will leak existing contents
|
|
||||||
pub fn set_arc_leaky<U>(&mut self, other: Arc<U>)
|
|
||||||
where
|
|
||||||
U: HasArcFFI<FFIType = T>,
|
|
||||||
{
|
|
||||||
*self = unsafe { mem::transmute(Arc::into_raw_offset(other)) };
|
*self = unsafe { mem::transmute(Arc::into_raw_offset(other)) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,4 +29,5 @@ servo_arc = {path = "../../components/servo_arc"}
|
||||||
smallvec = "1.0"
|
smallvec = "1.0"
|
||||||
style = {path = "../../components/style", features = ["gecko"]}
|
style = {path = "../../components/style", features = ["gecko"]}
|
||||||
style_traits = {path = "../../components/style_traits"}
|
style_traits = {path = "../../components/style_traits"}
|
||||||
|
thin-vec = { version = "0.2.1", features = ["gecko-ffi"] }
|
||||||
to_shmem = {path = "../../components/to_shmem"}
|
to_shmem = {path = "../../components/to_shmem"}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use dom::{DocumentState, ElementState};
|
||||||
use malloc_size_of::MallocSizeOfOps;
|
use malloc_size_of::MallocSizeOfOps;
|
||||||
use nsstring::{nsCString, nsString};
|
use nsstring::{nsCString, nsString};
|
||||||
use selectors::NthIndexCache;
|
use selectors::NthIndexCache;
|
||||||
use servo_arc::{Arc, ArcBorrow, RawOffsetArc};
|
use servo_arc::{Arc, ArcBorrow};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
|
@ -83,12 +83,11 @@ use style::gecko_bindings::structs::StyleSheet as DomStyleSheet;
|
||||||
use style::gecko_bindings::structs::URLExtraData;
|
use style::gecko_bindings::structs::URLExtraData;
|
||||||
use style::gecko_bindings::structs::{nsINode as RawGeckoNode, Element as RawGeckoElement};
|
use style::gecko_bindings::structs::{nsINode as RawGeckoNode, Element as RawGeckoElement};
|
||||||
use style::gecko_bindings::structs::{
|
use style::gecko_bindings::structs::{
|
||||||
RawServoAnimationValue, RawServoContainerRule, RawServoCounterStyleRule,
|
RawServoContainerRule, RawServoCounterStyleRule, RawServoDeclarationBlock,
|
||||||
RawServoDeclarationBlock, RawServoFontFaceRule, RawServoFontFeatureValuesRule,
|
RawServoFontFaceRule, RawServoFontFeatureValuesRule, RawServoFontPaletteValuesRule,
|
||||||
RawServoFontPaletteValuesRule, RawServoImportRule, RawServoKeyframe, RawServoKeyframesRule,
|
RawServoImportRule, RawServoKeyframe, RawServoKeyframesRule, RawServoLayerBlockRule,
|
||||||
RawServoLayerBlockRule, RawServoLayerStatementRule, RawServoMediaList, RawServoMediaRule,
|
RawServoLayerStatementRule, RawServoMediaList, RawServoMediaRule, RawServoMozDocumentRule,
|
||||||
RawServoMozDocumentRule, RawServoNamespaceRule, RawServoPageRule,
|
RawServoNamespaceRule, RawServoPageRule, RawServoSupportsRule, ServoCssRules,
|
||||||
RawServoSupportsRule, ServoCssRules,
|
|
||||||
};
|
};
|
||||||
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, Strong};
|
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, Strong};
|
||||||
use style::gecko_bindings::sugar::refptr::RefPtr;
|
use style::gecko_bindings::sugar::refptr::RefPtr;
|
||||||
|
|
@ -144,6 +143,7 @@ use style::values::specified::source_size_list::SourceSizeList;
|
||||||
use style::values::specified::{AbsoluteLength, NoCalcLength};
|
use style::values::specified::{AbsoluteLength, NoCalcLength};
|
||||||
use style::values::{specified, AtomIdent, CustomIdent, KeyframesName};
|
use style::values::{specified, AtomIdent, CustomIdent, KeyframesName};
|
||||||
use style_traits::{CssWriter, ParseError, ParsingMode, ToCss};
|
use style_traits::{CssWriter, ParseError, ParsingMode, ToCss};
|
||||||
|
use thin_vec::ThinVec;
|
||||||
use to_shmem::SharedMemoryBuilder;
|
use to_shmem::SharedMemoryBuilder;
|
||||||
|
|
||||||
trait ClosureHelper {
|
trait ClosureHelper {
|
||||||
|
|
@ -378,14 +378,12 @@ pub extern "C" fn Servo_MaybeGCRuleTree(raw_data: &PerDocumentStyleData) {
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValues_Interpolate(
|
pub extern "C" fn Servo_AnimationValues_Interpolate(
|
||||||
from: &RawServoAnimationValue,
|
from: &AnimationValue,
|
||||||
to: &RawServoAnimationValue,
|
to: &AnimationValue,
|
||||||
progress: f64,
|
progress: f64,
|
||||||
) -> Strong<RawServoAnimationValue> {
|
) -> Strong<AnimationValue> {
|
||||||
let from_value = AnimationValue::as_arc(&from);
|
if let Ok(value) = from.animate(to, Procedure::Interpolate { progress }) {
|
||||||
let to_value = AnimationValue::as_arc(&to);
|
Arc::new(value).into()
|
||||||
if let Ok(value) = from_value.animate(to_value, Procedure::Interpolate { progress }) {
|
|
||||||
Arc::new(value).into_strong()
|
|
||||||
} else {
|
} else {
|
||||||
Strong::null()
|
Strong::null()
|
||||||
}
|
}
|
||||||
|
|
@ -393,25 +391,16 @@ pub extern "C" fn Servo_AnimationValues_Interpolate(
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValues_IsInterpolable(
|
pub extern "C" fn Servo_AnimationValues_IsInterpolable(
|
||||||
from: &RawServoAnimationValue,
|
from: &AnimationValue,
|
||||||
to: &RawServoAnimationValue,
|
to: &AnimationValue,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let from_value = AnimationValue::as_arc(&from);
|
from.animate(to, Procedure::Interpolate { progress: 0.5 }).is_ok()
|
||||||
let to_value = AnimationValue::as_arc(&to);
|
|
||||||
from_value
|
|
||||||
.animate(to_value, Procedure::Interpolate { progress: 0.5 })
|
|
||||||
.is_ok()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValues_Add(
|
pub extern "C" fn Servo_AnimationValues_Add(a: &AnimationValue, b: &AnimationValue) -> Strong<AnimationValue> {
|
||||||
a: &RawServoAnimationValue,
|
if let Ok(value) = a.animate(b, Procedure::Add) {
|
||||||
b: &RawServoAnimationValue,
|
Arc::new(value).into()
|
||||||
) -> Strong<RawServoAnimationValue> {
|
|
||||||
let a_value = AnimationValue::as_arc(&a);
|
|
||||||
let b_value = AnimationValue::as_arc(&b);
|
|
||||||
if let Ok(value) = a_value.animate(b_value, Procedure::Add) {
|
|
||||||
Arc::new(value).into_strong()
|
|
||||||
} else {
|
} else {
|
||||||
Strong::null()
|
Strong::null()
|
||||||
}
|
}
|
||||||
|
|
@ -419,14 +408,12 @@ pub extern "C" fn Servo_AnimationValues_Add(
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValues_Accumulate(
|
pub extern "C" fn Servo_AnimationValues_Accumulate(
|
||||||
a: &RawServoAnimationValue,
|
a: &AnimationValue,
|
||||||
b: &RawServoAnimationValue,
|
b: &AnimationValue,
|
||||||
count: u64,
|
count: u64,
|
||||||
) -> Strong<RawServoAnimationValue> {
|
) -> Strong<AnimationValue> {
|
||||||
let a_value = AnimationValue::as_arc(&a);
|
if let Ok(value) = a.animate(b, Procedure::Accumulate { count }) {
|
||||||
let b_value = AnimationValue::as_arc(&b);
|
Arc::new(value).into()
|
||||||
if let Ok(value) = a_value.animate(b_value, Procedure::Accumulate { count }) {
|
|
||||||
Arc::new(value).into_strong()
|
|
||||||
} else {
|
} else {
|
||||||
Strong::null()
|
Strong::null()
|
||||||
}
|
}
|
||||||
|
|
@ -434,11 +421,10 @@ pub extern "C" fn Servo_AnimationValues_Accumulate(
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValues_GetZeroValue(
|
pub extern "C" fn Servo_AnimationValues_GetZeroValue(
|
||||||
value_to_match: &RawServoAnimationValue,
|
value_to_match: &AnimationValue,
|
||||||
) -> Strong<RawServoAnimationValue> {
|
) -> Strong<AnimationValue> {
|
||||||
let value_to_match = AnimationValue::as_arc(&value_to_match);
|
|
||||||
if let Ok(zero_value) = value_to_match.to_animated_zero() {
|
if let Ok(zero_value) = value_to_match.to_animated_zero() {
|
||||||
Arc::new(zero_value).into_strong()
|
Arc::new(zero_value).into()
|
||||||
} else {
|
} else {
|
||||||
Strong::null()
|
Strong::null()
|
||||||
}
|
}
|
||||||
|
|
@ -446,17 +432,12 @@ pub extern "C" fn Servo_AnimationValues_GetZeroValue(
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValues_ComputeDistance(
|
pub extern "C" fn Servo_AnimationValues_ComputeDistance(
|
||||||
from: &RawServoAnimationValue,
|
from: &AnimationValue,
|
||||||
to: &RawServoAnimationValue,
|
to: &AnimationValue,
|
||||||
) -> f64 {
|
) -> f64 {
|
||||||
let from_value = AnimationValue::as_arc(&from);
|
|
||||||
let to_value = AnimationValue::as_arc(&to);
|
|
||||||
// If compute_squared_distance() failed, this function will return negative value
|
// If compute_squared_distance() failed, this function will return negative value
|
||||||
// in order to check whether we support the specified paced animation values.
|
// in order to check whether we support the specified paced animation values.
|
||||||
from_value
|
from.compute_squared_distance(to).map_or(-1.0, |d| d.sqrt())
|
||||||
.compute_squared_distance(to_value)
|
|
||||||
.map(|d| d.sqrt())
|
|
||||||
.unwrap_or(-1.0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compute one of the endpoints for the interpolation interval, compositing it with the
|
/// Compute one of the endpoints for the interpolation interval, compositing it with the
|
||||||
|
|
@ -465,7 +446,7 @@ pub extern "C" fn Servo_AnimationValues_ComputeDistance(
|
||||||
/// It is the responsibility of the caller to ensure that |underlying_value| is provided
|
/// It is the responsibility of the caller to ensure that |underlying_value| is provided
|
||||||
/// when it will be used.
|
/// when it will be used.
|
||||||
fn composite_endpoint(
|
fn composite_endpoint(
|
||||||
endpoint_value: Option<&RawOffsetArc<AnimationValue>>,
|
endpoint_value: Option<&AnimationValue>,
|
||||||
composite: CompositeOperation,
|
composite: CompositeOperation,
|
||||||
underlying_value: Option<&AnimationValue>,
|
underlying_value: Option<&AnimationValue>,
|
||||||
) -> Option<AnimationValue> {
|
) -> Option<AnimationValue> {
|
||||||
|
|
@ -488,7 +469,7 @@ fn composite_endpoint(
|
||||||
/// Accumulate one of the endpoints of the animation interval.
|
/// Accumulate one of the endpoints of the animation interval.
|
||||||
/// A returned value of None means, "Just use endpoint_value as-is."
|
/// A returned value of None means, "Just use endpoint_value as-is."
|
||||||
fn accumulate_endpoint(
|
fn accumulate_endpoint(
|
||||||
endpoint_value: Option<&RawOffsetArc<AnimationValue>>,
|
endpoint_value: Option<&AnimationValue>,
|
||||||
composited_value: Option<AnimationValue>,
|
composited_value: Option<AnimationValue>,
|
||||||
last_value: &AnimationValue,
|
last_value: &AnimationValue,
|
||||||
current_iteration: u64,
|
current_iteration: u64,
|
||||||
|
|
@ -524,22 +505,8 @@ fn compose_animation_segment(
|
||||||
segment_progress: f64,
|
segment_progress: f64,
|
||||||
) -> AnimationValue {
|
) -> AnimationValue {
|
||||||
// Extract keyframe values.
|
// Extract keyframe values.
|
||||||
let raw_from_value;
|
let keyframe_from_value = unsafe {segment.mFromValue.mServo.mRawPtr.as_ref() };
|
||||||
let keyframe_from_value = if !segment.mFromValue.mServo.mRawPtr.is_null() {
|
let keyframe_to_value = unsafe { segment.mToValue.mServo.mRawPtr.as_ref() };
|
||||||
raw_from_value = unsafe { &*segment.mFromValue.mServo.mRawPtr };
|
|
||||||
Some(AnimationValue::as_arc(&raw_from_value))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let raw_to_value;
|
|
||||||
let keyframe_to_value = if !segment.mToValue.mServo.mRawPtr.is_null() {
|
|
||||||
raw_to_value = unsafe { &*segment.mToValue.mServo.mRawPtr };
|
|
||||||
Some(AnimationValue::as_arc(&raw_to_value))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut composited_from_value = composite_endpoint(
|
let mut composited_from_value = composite_endpoint(
|
||||||
keyframe_from_value,
|
keyframe_from_value,
|
||||||
segment.mFromComposite,
|
segment.mFromComposite,
|
||||||
|
|
@ -612,14 +579,12 @@ fn compose_animation_segment(
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_ComposeAnimationSegment(
|
pub extern "C" fn Servo_ComposeAnimationSegment(
|
||||||
segment: &structs::AnimationPropertySegment,
|
segment: &structs::AnimationPropertySegment,
|
||||||
underlying_value: Option<&RawServoAnimationValue>,
|
underlying_value: Option<&AnimationValue>,
|
||||||
last_value: Option<&RawServoAnimationValue>,
|
last_value: Option<&AnimationValue>,
|
||||||
iteration_composite: IterationCompositeOperation,
|
iteration_composite: IterationCompositeOperation,
|
||||||
progress: f64,
|
progress: f64,
|
||||||
current_iteration: u64,
|
current_iteration: u64,
|
||||||
) -> Strong<RawServoAnimationValue> {
|
) -> Strong<AnimationValue> {
|
||||||
let underlying_value = AnimationValue::arc_from_borrowed(&underlying_value).map(|v| &**v);
|
|
||||||
let last_value = AnimationValue::arc_from_borrowed(&last_value).map(|v| &**v);
|
|
||||||
let result = compose_animation_segment(
|
let result = compose_animation_segment(
|
||||||
segment,
|
segment,
|
||||||
underlying_value,
|
underlying_value,
|
||||||
|
|
@ -629,7 +594,7 @@ pub extern "C" fn Servo_ComposeAnimationSegment(
|
||||||
progress,
|
progress,
|
||||||
progress,
|
progress,
|
||||||
);
|
);
|
||||||
Arc::new(result).into_strong()
|
Arc::new(result).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
@ -667,13 +632,9 @@ pub extern "C" fn Servo_AnimationCompose(
|
||||||
// effect), or, if there is no current value, look up the cached base value
|
// effect), or, if there is no current value, look up the cached base value
|
||||||
// for this property.
|
// for this property.
|
||||||
let underlying_value = if need_underlying_value {
|
let underlying_value = if need_underlying_value {
|
||||||
let previous_composed_value = value_map.get(&property).cloned();
|
let previous_composed_value = value_map.get(&property).map(|v| &*v);
|
||||||
previous_composed_value.or_else(|| {
|
previous_composed_value.or_else(|| {
|
||||||
let raw_base_style =
|
unsafe { Gecko_AnimationGetBaseStyle(base_values, css_property).as_ref() }
|
||||||
unsafe { Gecko_AnimationGetBaseStyle(base_values, css_property).as_ref() };
|
|
||||||
AnimationValue::arc_from_borrowed(&raw_base_style)
|
|
||||||
.map(|v| &**v)
|
|
||||||
.cloned()
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
@ -684,14 +645,7 @@ pub extern "C" fn Servo_AnimationCompose(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let raw_last_value;
|
let last_value = unsafe { last_segment.mToValue.mServo.mRawPtr.as_ref() };
|
||||||
let last_value = if !last_segment.mToValue.mServo.mRawPtr.is_null() {
|
|
||||||
raw_last_value = unsafe { &*last_segment.mToValue.mServo.mRawPtr };
|
|
||||||
Some(&**AnimationValue::as_arc(&raw_last_value))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let progress = unsafe { Gecko_GetProgressFromComputedTiming(computed_timing) };
|
let progress = unsafe { Gecko_GetProgressFromComputedTiming(computed_timing) };
|
||||||
let position = if segment.mToKey == segment.mFromKey {
|
let position = if segment.mToKey == segment.mFromKey {
|
||||||
// Note: compose_animation_segment doesn't use this value
|
// Note: compose_animation_segment doesn't use this value
|
||||||
|
|
@ -703,7 +657,7 @@ pub extern "C" fn Servo_AnimationCompose(
|
||||||
|
|
||||||
let result = compose_animation_segment(
|
let result = compose_animation_segment(
|
||||||
segment,
|
segment,
|
||||||
underlying_value.as_ref(),
|
underlying_value,
|
||||||
last_value,
|
last_value,
|
||||||
iteration_composite,
|
iteration_composite,
|
||||||
computed_timing.mCurrentIteration,
|
computed_timing.mCurrentIteration,
|
||||||
|
|
@ -726,12 +680,12 @@ macro_rules! get_property_id_from_nscsspropertyid {
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValue_Serialize(
|
pub extern "C" fn Servo_AnimationValue_Serialize(
|
||||||
value: &RawServoAnimationValue,
|
value: &AnimationValue,
|
||||||
property: nsCSSPropertyID,
|
property: nsCSSPropertyID,
|
||||||
raw_data: &PerDocumentStyleData,
|
raw_data: &PerDocumentStyleData,
|
||||||
buffer: &mut nsACString,
|
buffer: &mut nsACString,
|
||||||
) {
|
) {
|
||||||
let uncomputed_value = AnimationValue::as_arc(&value).uncompute();
|
let uncomputed_value = value.uncompute();
|
||||||
let data = raw_data.borrow();
|
let data = raw_data.borrow();
|
||||||
let rv = PropertyDeclarationBlock::with_one(uncomputed_value, Importance::Normal)
|
let rv = PropertyDeclarationBlock::with_one(uncomputed_value, Importance::Normal)
|
||||||
.single_value_to_css(
|
.single_value_to_css(
|
||||||
|
|
@ -746,26 +700,20 @@ pub extern "C" fn Servo_AnimationValue_Serialize(
|
||||||
|
|
||||||
/// Debug: MOZ_DBG for AnimationValue.
|
/// Debug: MOZ_DBG for AnimationValue.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValue_Dump(
|
pub extern "C" fn Servo_AnimationValue_Dump(value: &AnimationValue, result: &mut nsACString) {
|
||||||
value: &RawServoAnimationValue,
|
|
||||||
result: &mut nsACString,
|
|
||||||
) {
|
|
||||||
let value = AnimationValue::as_arc(&value);
|
|
||||||
write!(result, "{:?}", value).unwrap();
|
write!(result, "{:?}", value).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValue_GetColor(
|
pub extern "C" fn Servo_AnimationValue_GetColor(
|
||||||
value: &RawServoAnimationValue,
|
value: &AnimationValue,
|
||||||
foreground_color: structs::nscolor,
|
foreground_color: structs::nscolor,
|
||||||
) -> structs::nscolor {
|
) -> structs::nscolor {
|
||||||
use style::gecko::values::{
|
use style::gecko::values::{
|
||||||
convert_absolute_color_to_nscolor, convert_nscolor_to_absolute_color,
|
convert_absolute_color_to_nscolor, convert_nscolor_to_absolute_color,
|
||||||
};
|
};
|
||||||
use style::values::computed::color::Color as ComputedColor;
|
use style::values::computed::color::Color as ComputedColor;
|
||||||
|
match *value {
|
||||||
let value = AnimationValue::as_arc(&value);
|
|
||||||
match **value {
|
|
||||||
AnimationValue::BackgroundColor(ref color) => {
|
AnimationValue::BackgroundColor(ref color) => {
|
||||||
let computed: ComputedColor = color.clone();
|
let computed: ComputedColor = color.clone();
|
||||||
let foreground_color = convert_nscolor_to_absolute_color(foreground_color);
|
let foreground_color = convert_nscolor_to_absolute_color(foreground_color);
|
||||||
|
|
@ -776,9 +724,8 @@ pub extern "C" fn Servo_AnimationValue_GetColor(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValue_IsCurrentColor(value: &RawServoAnimationValue) -> bool {
|
pub extern "C" fn Servo_AnimationValue_IsCurrentColor(value: &AnimationValue) -> bool {
|
||||||
let value = AnimationValue::as_arc(&value);
|
match *value {
|
||||||
match **value {
|
|
||||||
AnimationValue::BackgroundColor(ref color) => color.is_currentcolor(),
|
AnimationValue::BackgroundColor(ref color) => color.is_currentcolor(),
|
||||||
_ => {
|
_ => {
|
||||||
debug_assert!(false, "Other color properties are not supported yet");
|
debug_assert!(false, "Other color properties are not supported yet");
|
||||||
|
|
@ -788,9 +735,8 @@ pub extern "C" fn Servo_AnimationValue_IsCurrentColor(value: &RawServoAnimationV
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValue_GetOpacity(value: &RawServoAnimationValue) -> f32 {
|
pub extern "C" fn Servo_AnimationValue_GetOpacity(value: &AnimationValue) -> f32 {
|
||||||
let value = AnimationValue::as_arc(&value);
|
if let AnimationValue::Opacity(opacity) = *value {
|
||||||
if let AnimationValue::Opacity(opacity) = **value {
|
|
||||||
opacity
|
opacity
|
||||||
} else {
|
} else {
|
||||||
panic!("The AnimationValue should be Opacity");
|
panic!("The AnimationValue should be Opacity");
|
||||||
|
|
@ -798,15 +744,15 @@ pub extern "C" fn Servo_AnimationValue_GetOpacity(value: &RawServoAnimationValue
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValue_Opacity(opacity: f32) -> Strong<RawServoAnimationValue> {
|
pub extern "C" fn Servo_AnimationValue_Opacity(opacity: f32) -> Strong<AnimationValue> {
|
||||||
Arc::new(AnimationValue::Opacity(opacity)).into_strong()
|
Arc::new(AnimationValue::Opacity(opacity)).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValue_Color(
|
pub extern "C" fn Servo_AnimationValue_Color(
|
||||||
color_property: nsCSSPropertyID,
|
color_property: nsCSSPropertyID,
|
||||||
color: structs::nscolor,
|
color: structs::nscolor,
|
||||||
) -> Strong<RawServoAnimationValue> {
|
) -> Strong<AnimationValue> {
|
||||||
use style::gecko::values::convert_nscolor_to_absolute_color;
|
use style::gecko::values::convert_nscolor_to_absolute_color;
|
||||||
use style::values::animated::color::Color;
|
use style::values::animated::color::Color;
|
||||||
|
|
||||||
|
|
@ -817,171 +763,123 @@ pub extern "C" fn Servo_AnimationValue_Color(
|
||||||
|
|
||||||
match property {
|
match property {
|
||||||
LonghandId::BackgroundColor => {
|
LonghandId::BackgroundColor => {
|
||||||
Arc::new(AnimationValue::BackgroundColor(Color::Absolute(animated))).into_strong()
|
Arc::new(AnimationValue::BackgroundColor(Color::Absolute(animated))).into()
|
||||||
},
|
},
|
||||||
_ => panic!("Should be background-color property"),
|
_ => panic!("Should be background-color property"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_GetScale(
|
pub unsafe extern "C" fn Servo_AnimationValue_GetScale(value: &AnimationValue) -> *const computed::Scale {
|
||||||
value: &RawServoAnimationValue,
|
match *value {
|
||||||
) -> *const computed::Scale {
|
|
||||||
let value = AnimationValue::as_arc(&value);
|
|
||||||
match **value {
|
|
||||||
AnimationValue::Scale(ref value) => value,
|
AnimationValue::Scale(ref value) => value,
|
||||||
_ => unreachable!("Expected scale"),
|
_ => unreachable!("Expected scale"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_GetTranslate(
|
pub unsafe extern "C" fn Servo_AnimationValue_GetTranslate(value: &AnimationValue) -> *const computed::Translate {
|
||||||
value: &RawServoAnimationValue,
|
match *value {
|
||||||
) -> *const computed::Translate {
|
|
||||||
let value = AnimationValue::as_arc(&value);
|
|
||||||
match **value {
|
|
||||||
AnimationValue::Translate(ref value) => value,
|
AnimationValue::Translate(ref value) => value,
|
||||||
_ => unreachable!("Expected translate"),
|
_ => unreachable!("Expected translate"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_GetRotate(
|
pub unsafe extern "C" fn Servo_AnimationValue_GetRotate(value: &AnimationValue) -> *const computed::Rotate {
|
||||||
value: &RawServoAnimationValue,
|
match *value {
|
||||||
) -> *const computed::Rotate {
|
|
||||||
let value = AnimationValue::as_arc(&value);
|
|
||||||
match **value {
|
|
||||||
AnimationValue::Rotate(ref value) => value,
|
AnimationValue::Rotate(ref value) => value,
|
||||||
_ => unreachable!("Expected rotate"),
|
_ => unreachable!("Expected rotate"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_GetTransform(
|
pub unsafe extern "C" fn Servo_AnimationValue_GetTransform(value: &AnimationValue) -> *const computed::Transform {
|
||||||
value: &RawServoAnimationValue,
|
match *value {
|
||||||
) -> *const computed::Transform {
|
|
||||||
let value = AnimationValue::as_arc(&value);
|
|
||||||
match **value {
|
|
||||||
AnimationValue::Transform(ref value) => value,
|
AnimationValue::Transform(ref value) => value,
|
||||||
_ => unreachable!("Unsupported transform animation value"),
|
_ => unreachable!("Unsupported transform animation value"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_GetOffsetPath(
|
pub unsafe extern "C" fn Servo_AnimationValue_GetOffsetPath(value: &AnimationValue) -> *const computed::motion::OffsetPath {
|
||||||
value: &RawServoAnimationValue,
|
match *value {
|
||||||
) -> *const computed::motion::OffsetPath {
|
|
||||||
let value = AnimationValue::as_arc(&value);
|
|
||||||
match **value {
|
|
||||||
AnimationValue::OffsetPath(ref value) => value,
|
AnimationValue::OffsetPath(ref value) => value,
|
||||||
_ => unreachable!("Expected offset-path"),
|
_ => unreachable!("Expected offset-path"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_GetOffsetDistance(
|
pub unsafe extern "C" fn Servo_AnimationValue_GetOffsetDistance(value: &AnimationValue) -> *const computed::LengthPercentage {
|
||||||
value: &RawServoAnimationValue,
|
match *value {
|
||||||
) -> *const computed::LengthPercentage {
|
|
||||||
let value = AnimationValue::as_arc(&value);
|
|
||||||
match **value {
|
|
||||||
AnimationValue::OffsetDistance(ref value) => value,
|
AnimationValue::OffsetDistance(ref value) => value,
|
||||||
_ => unreachable!("Expected offset-distance"),
|
_ => unreachable!("Expected offset-distance"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_GetOffsetRotate(
|
pub unsafe extern "C" fn Servo_AnimationValue_GetOffsetRotate(value: &AnimationValue) -> *const computed::motion::OffsetRotate {
|
||||||
value: &RawServoAnimationValue,
|
match *value {
|
||||||
) -> *const computed::motion::OffsetRotate {
|
|
||||||
let value = AnimationValue::as_arc(&value);
|
|
||||||
match **value {
|
|
||||||
AnimationValue::OffsetRotate(ref value) => value,
|
AnimationValue::OffsetRotate(ref value) => value,
|
||||||
_ => unreachable!("Expected offset-rotate"),
|
_ => unreachable!("Expected offset-rotate"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_GetOffsetAnchor(
|
pub unsafe extern "C" fn Servo_AnimationValue_GetOffsetAnchor(value: &AnimationValue) -> *const computed::position::PositionOrAuto {
|
||||||
value: &RawServoAnimationValue,
|
match *value {
|
||||||
) -> *const computed::position::PositionOrAuto {
|
|
||||||
let value = AnimationValue::as_arc(&value);
|
|
||||||
match **value {
|
|
||||||
AnimationValue::OffsetAnchor(ref value) => value,
|
AnimationValue::OffsetAnchor(ref value) => value,
|
||||||
_ => unreachable!("Expected offset-anchor"),
|
_ => unreachable!("Expected offset-anchor"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_Rotate(
|
pub unsafe extern "C" fn Servo_AnimationValue_Rotate(r: &computed::Rotate) -> Strong<AnimationValue> {
|
||||||
r: &computed::Rotate,
|
Arc::new(AnimationValue::Rotate(r.clone())).into()
|
||||||
) -> Strong<RawServoAnimationValue> {
|
|
||||||
Arc::new(AnimationValue::Rotate(r.clone())).into_strong()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_Translate(
|
pub unsafe extern "C" fn Servo_AnimationValue_Translate(t: &computed::Translate) -> Strong<AnimationValue> {
|
||||||
t: &computed::Translate,
|
Arc::new(AnimationValue::Translate(t.clone())).into()
|
||||||
) -> Strong<RawServoAnimationValue> {
|
|
||||||
Arc::new(AnimationValue::Translate(t.clone())).into_strong()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_Scale(
|
pub unsafe extern "C" fn Servo_AnimationValue_Scale(s: &computed::Scale) -> Strong<AnimationValue> {
|
||||||
s: &computed::Scale,
|
Arc::new(AnimationValue::Scale(s.clone())).into()
|
||||||
) -> Strong<RawServoAnimationValue> {
|
|
||||||
Arc::new(AnimationValue::Scale(s.clone())).into_strong()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_Transform(
|
pub unsafe extern "C" fn Servo_AnimationValue_Transform(transform: &computed::Transform) -> Strong<AnimationValue> {
|
||||||
transform: &computed::Transform,
|
Arc::new(AnimationValue::Transform(transform.clone())).into()
|
||||||
) -> Strong<RawServoAnimationValue> {
|
|
||||||
Arc::new(AnimationValue::Transform(transform.clone())).into_strong()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_OffsetPath(
|
pub unsafe extern "C" fn Servo_AnimationValue_OffsetPath(p: &computed::motion::OffsetPath) -> Strong<AnimationValue> {
|
||||||
p: &computed::motion::OffsetPath,
|
Arc::new(AnimationValue::OffsetPath(p.clone())).into()
|
||||||
) -> Strong<RawServoAnimationValue> {
|
|
||||||
Arc::new(AnimationValue::OffsetPath(p.clone())).into_strong()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_OffsetDistance(
|
pub unsafe extern "C" fn Servo_AnimationValue_OffsetDistance(d: &computed::LengthPercentage) -> Strong<AnimationValue> {
|
||||||
d: &computed::length::LengthPercentage,
|
Arc::new(AnimationValue::OffsetDistance(d.clone())).into()
|
||||||
) -> Strong<RawServoAnimationValue> {
|
|
||||||
Arc::new(AnimationValue::OffsetDistance(d.clone())).into_strong()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_OffsetRotate(
|
pub unsafe extern "C" fn Servo_AnimationValue_OffsetRotate(r: &computed::motion::OffsetRotate) -> Strong<AnimationValue> {
|
||||||
r: &computed::motion::OffsetRotate,
|
Arc::new(AnimationValue::OffsetRotate(*r)).into()
|
||||||
) -> Strong<RawServoAnimationValue> {
|
|
||||||
Arc::new(AnimationValue::OffsetRotate(*r)).into_strong()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_AnimationValue_OffsetAnchor(
|
pub unsafe extern "C" fn Servo_AnimationValue_OffsetAnchor(p: &computed::position::PositionOrAuto) -> Strong<AnimationValue> {
|
||||||
p: &computed::position::PositionOrAuto,
|
Arc::new(AnimationValue::OffsetAnchor(p.clone())).into()
|
||||||
) -> Strong<RawServoAnimationValue> {
|
|
||||||
Arc::new(AnimationValue::OffsetAnchor(p.clone())).into_strong()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValue_DeepEqual(
|
pub extern "C" fn Servo_AnimationValue_DeepEqual(this: &AnimationValue, other: &AnimationValue) -> bool {
|
||||||
this: &RawServoAnimationValue,
|
this == other
|
||||||
other: &RawServoAnimationValue,
|
|
||||||
) -> bool {
|
|
||||||
let this_value = AnimationValue::as_arc(&this);
|
|
||||||
let other_value = AnimationValue::as_arc(&other);
|
|
||||||
this_value == other_value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValue_Uncompute(
|
pub extern "C" fn Servo_AnimationValue_Uncompute(value: &AnimationValue) -> Strong<RawServoDeclarationBlock> {
|
||||||
value: &RawServoAnimationValue,
|
|
||||||
) -> Strong<RawServoDeclarationBlock> {
|
|
||||||
let value = AnimationValue::as_arc(&value);
|
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
Arc::new(
|
Arc::new(
|
||||||
global_style_data
|
global_style_data
|
||||||
|
|
@ -1145,13 +1043,13 @@ pub unsafe extern "C" fn Servo_AnimationValueMap_Drop(value_map: *mut AnimationV
|
||||||
pub extern "C" fn Servo_AnimationValueMap_GetValue(
|
pub extern "C" fn Servo_AnimationValueMap_GetValue(
|
||||||
value_map: &AnimationValueMap,
|
value_map: &AnimationValueMap,
|
||||||
property_id: nsCSSPropertyID,
|
property_id: nsCSSPropertyID,
|
||||||
) -> Strong<RawServoAnimationValue> {
|
) -> Strong<AnimationValue> {
|
||||||
let property = match LonghandId::from_nscsspropertyid(property_id) {
|
let property = match LonghandId::from_nscsspropertyid(property_id) {
|
||||||
Ok(longhand) => longhand,
|
Ok(longhand) => longhand,
|
||||||
Err(()) => return Strong::null(),
|
Err(()) => return Strong::null(),
|
||||||
};
|
};
|
||||||
value_map.get(&property).map_or(Strong::null(), |value| {
|
value_map.get(&property).map_or(Strong::null(), |value| {
|
||||||
Arc::new(value.clone()).into_strong()
|
Arc::new(value.clone()).into()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1208,7 +1106,7 @@ pub extern "C" fn Servo_StyleSet_GetComputedValuesByAddingAnimation(
|
||||||
element: &RawGeckoElement,
|
element: &RawGeckoElement,
|
||||||
computed_values: &ComputedValues,
|
computed_values: &ComputedValues,
|
||||||
snapshots: *const ServoElementSnapshotTable,
|
snapshots: *const ServoElementSnapshotTable,
|
||||||
animation_value: &RawServoAnimationValue,
|
animation_value: &AnimationValue,
|
||||||
) -> Strong<ComputedValues> {
|
) -> Strong<ComputedValues> {
|
||||||
debug_assert!(!snapshots.is_null());
|
debug_assert!(!snapshots.is_null());
|
||||||
let rules = match computed_values.rules {
|
let rules = match computed_values.rules {
|
||||||
|
|
@ -1218,7 +1116,7 @@ pub extern "C" fn Servo_StyleSet_GetComputedValuesByAddingAnimation(
|
||||||
|
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
let guard = global_style_data.shared_lock.read();
|
let guard = global_style_data.shared_lock.read();
|
||||||
let uncomputed_value = AnimationValue::as_arc(&animation_value).uncompute();
|
let uncomputed_value = animation_value.uncompute();
|
||||||
let doc_data = raw_style_set.borrow();
|
let doc_data = raw_style_set.borrow();
|
||||||
|
|
||||||
let with_animations_rules = {
|
let with_animations_rules = {
|
||||||
|
|
@ -1263,13 +1161,13 @@ pub extern "C" fn Servo_StyleSet_GetComputedValuesByAddingAnimation(
|
||||||
pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(
|
pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(
|
||||||
computed_values: &ComputedValues,
|
computed_values: &ComputedValues,
|
||||||
property_id: nsCSSPropertyID,
|
property_id: nsCSSPropertyID,
|
||||||
) -> Strong<RawServoAnimationValue> {
|
) -> Strong<AnimationValue> {
|
||||||
let property = match LonghandId::from_nscsspropertyid(property_id) {
|
let property = match LonghandId::from_nscsspropertyid(property_id) {
|
||||||
Ok(longhand) => longhand,
|
Ok(longhand) => longhand,
|
||||||
Err(()) => return Strong::null(),
|
Err(()) => return Strong::null(),
|
||||||
};
|
};
|
||||||
match AnimationValue::from_computed_values(property, &computed_values) {
|
match AnimationValue::from_computed_values(property, &computed_values) {
|
||||||
Some(v) => Arc::new(v).into_strong(),
|
Some(v) => Arc::new(v).into(),
|
||||||
None => Strong::null(),
|
None => Strong::null(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4924,10 +4822,9 @@ pub unsafe extern "C" fn Servo_DeclarationBlock_SetProperty(
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_DeclarationBlock_SetPropertyToAnimationValue(
|
pub unsafe extern "C" fn Servo_DeclarationBlock_SetPropertyToAnimationValue(
|
||||||
declarations: &RawServoDeclarationBlock,
|
declarations: &RawServoDeclarationBlock,
|
||||||
animation_value: &RawServoAnimationValue,
|
animation_value: &AnimationValue,
|
||||||
before_change_closure: DeclarationBlockMutationClosure,
|
before_change_closure: DeclarationBlockMutationClosure,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let animation_value = AnimationValue::as_arc(&animation_value);
|
|
||||||
let non_custom_property_id = animation_value.id().into();
|
let non_custom_property_id = animation_value.id().into();
|
||||||
let mut source_declarations = SourcePropertyDeclaration::with_one(animation_value.uncompute());
|
let mut source_declarations = SourcePropertyDeclaration::with_one(animation_value.uncompute());
|
||||||
|
|
||||||
|
|
@ -6187,19 +6084,14 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(
|
||||||
seen.insert(property);
|
seen.insert(property);
|
||||||
|
|
||||||
// This is safe since we immediately write to the uninitialized values.
|
// This is safe since we immediately write to the uninitialized values.
|
||||||
unsafe { animation_values.set_len((property_index + 1) as u32) };
|
unsafe {
|
||||||
animation_values[property_index].mProperty = property.to_nscsspropertyid();
|
animation_values.set_len((property_index + 1) as u32);
|
||||||
match value {
|
ptr::write(&mut animation_values[property_index], structs::PropertyStyleAnimationValuePair {
|
||||||
Some(v) => {
|
mProperty: property.to_nscsspropertyid(),
|
||||||
animation_values[property_index]
|
mValue: structs::AnimationValue {
|
||||||
.mValue
|
mServo: value.map_or(structs::RefPtr::null(), |v| structs::RefPtr::from_arc(Arc::new(v))),
|
||||||
.mServo
|
|
||||||
.set_arc_leaky(Arc::new(v));
|
|
||||||
},
|
|
||||||
None => {
|
|
||||||
animation_values[property_index].mValue.mServo.mRawPtr =
|
|
||||||
ptr::null_mut();
|
|
||||||
},
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
property_index += 1;
|
property_index += 1;
|
||||||
};
|
};
|
||||||
|
|
@ -6235,7 +6127,7 @@ pub extern "C" fn Servo_GetAnimationValues(
|
||||||
element: &RawGeckoElement,
|
element: &RawGeckoElement,
|
||||||
style: &ComputedValues,
|
style: &ComputedValues,
|
||||||
raw_data: &PerDocumentStyleData,
|
raw_data: &PerDocumentStyleData,
|
||||||
animation_values: &mut nsTArray<structs::RefPtr<structs::RawServoAnimationValue>>,
|
animation_values: &mut ThinVec<structs::RefPtr<AnimationValue>>,
|
||||||
) {
|
) {
|
||||||
let data = raw_data.borrow();
|
let data = raw_data.borrow();
|
||||||
let element = GeckoElement(element);
|
let element = GeckoElement(element);
|
||||||
|
|
@ -6268,17 +6160,11 @@ pub extern "C" fn Servo_GetAnimationValues(
|
||||||
&default_values,
|
&default_values,
|
||||||
None, // SMIL has no extra custom properties.
|
None, // SMIL has no extra custom properties.
|
||||||
);
|
);
|
||||||
for (index, anim) in iter.enumerate() {
|
animation_values.extend(iter.map(|v| structs::RefPtr::from_arc(Arc::new(v))));
|
||||||
unsafe { animation_values.set_len((index + 1) as u32) };
|
|
||||||
animation_values[index].set_arc_leaky(Arc::new(anim));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValue_GetPropertyId(
|
pub extern "C" fn Servo_AnimationValue_GetPropertyId(value: &AnimationValue) -> nsCSSPropertyID {
|
||||||
value: &RawServoAnimationValue,
|
|
||||||
) -> nsCSSPropertyID {
|
|
||||||
let value = AnimationValue::as_arc(&value);
|
|
||||||
value.id().to_nscsspropertyid()
|
value.id().to_nscsspropertyid()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6288,7 +6174,7 @@ pub extern "C" fn Servo_AnimationValue_Compute(
|
||||||
declarations: &RawServoDeclarationBlock,
|
declarations: &RawServoDeclarationBlock,
|
||||||
style: &ComputedValues,
|
style: &ComputedValues,
|
||||||
raw_data: &PerDocumentStyleData,
|
raw_data: &PerDocumentStyleData,
|
||||||
) -> Strong<RawServoAnimationValue> {
|
) -> Strong<AnimationValue> {
|
||||||
let data = raw_data.borrow();
|
let data = raw_data.borrow();
|
||||||
|
|
||||||
let element = GeckoElement(element);
|
let element = GeckoElement(element);
|
||||||
|
|
@ -6327,7 +6213,7 @@ pub extern "C" fn Servo_AnimationValue_Compute(
|
||||||
None, // No extra custom properties for devtools.
|
None, // No extra custom properties for devtools.
|
||||||
default_values,
|
default_values,
|
||||||
);
|
);
|
||||||
animation.map_or(Strong::null(), |value| Arc::new(value).into_strong())
|
animation.map_or(Strong::null(), |value| Arc::new(value).into())
|
||||||
},
|
},
|
||||||
_ => Strong::null(),
|
_ => Strong::null(),
|
||||||
}
|
}
|
||||||
|
|
@ -6548,7 +6434,7 @@ pub unsafe extern "C" fn Servo_StyleSet_GetKeyframesForName(
|
||||||
id.to_nscsspropertyid(),
|
id.to_nscsspropertyid(),
|
||||||
);
|
);
|
||||||
|
|
||||||
(*pair).mServoDeclarationBlock.set_arc_leaky(Arc::new(
|
(*pair).mServoDeclarationBlock.set_arc_ffi(Arc::new(
|
||||||
global_style_data
|
global_style_data
|
||||||
.shared_lock
|
.shared_lock
|
||||||
.wrap(PropertyDeclarationBlock::with_one(
|
.wrap(PropertyDeclarationBlock::with_one(
|
||||||
|
|
@ -6571,7 +6457,7 @@ pub unsafe extern "C" fn Servo_StyleSet_GetKeyframesForName(
|
||||||
nsCSSPropertyID::eCSSPropertyExtra_variable,
|
nsCSSPropertyID::eCSSPropertyExtra_variable,
|
||||||
);
|
);
|
||||||
|
|
||||||
(*pair).mServoDeclarationBlock.set_arc_leaky(Arc::new(
|
(*pair).mServoDeclarationBlock.set_arc_ffi(Arc::new(
|
||||||
global_style_data.shared_lock.wrap(custom_properties),
|
global_style_data.shared_lock.wrap(custom_properties),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -6609,17 +6495,11 @@ pub unsafe extern "C" fn Servo_StyleSet_GetKeyframesForName(
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_StyleSet_GetFontFaceRules(
|
pub extern "C" fn Servo_StyleSet_GetFontFaceRules(
|
||||||
raw_data: &PerDocumentStyleData,
|
raw_data: &PerDocumentStyleData,
|
||||||
rules: &mut nsTArray<structs::nsFontFaceRuleContainer>,
|
rules: &mut ThinVec<structs::nsFontFaceRuleContainer>,
|
||||||
) {
|
) {
|
||||||
let data = raw_data.borrow();
|
let data = raw_data.borrow();
|
||||||
debug_assert_eq!(rules.len(), 0);
|
debug_assert_eq!(rules.len(), 0);
|
||||||
|
|
||||||
let len: u32 = data
|
|
||||||
.stylist
|
|
||||||
.iter_extra_data_origins()
|
|
||||||
.map(|(d, _)| d.font_faces.len() as u32)
|
|
||||||
.sum();
|
|
||||||
|
|
||||||
// Reversed iterator because Gecko expects rules to appear sorted
|
// Reversed iterator because Gecko expects rules to appear sorted
|
||||||
// UserAgent first, Author last.
|
// UserAgent first, Author last.
|
||||||
let font_face_iter = data
|
let font_face_iter = data
|
||||||
|
|
@ -6627,11 +6507,10 @@ pub extern "C" fn Servo_StyleSet_GetFontFaceRules(
|
||||||
.iter_extra_data_origins_rev()
|
.iter_extra_data_origins_rev()
|
||||||
.flat_map(|(d, o)| d.font_faces.iter().zip(iter::repeat(o)));
|
.flat_map(|(d, o)| d.font_faces.iter().zip(iter::repeat(o)));
|
||||||
|
|
||||||
unsafe { rules.set_len(len) };
|
rules.extend(font_face_iter.map(|(&(ref rule, _layer_id), origin)| structs::nsFontFaceRuleContainer {
|
||||||
for ((&(ref rule, _), origin), dest) in font_face_iter.zip(rules.iter_mut()) {
|
mRule: structs::RefPtr::from_arc_ffi(rule.clone()),
|
||||||
dest.mRule.set_arc_leaky(rule.clone());
|
mOrigin: origin,
|
||||||
dest.mOrigin = origin;
|
}))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX Ideally this should return a Option<&RawServoCounterStyleRule>,
|
// XXX Ideally this should return a Option<&RawServoCounterStyleRule>,
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ extern crate smallvec;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate style;
|
extern crate style;
|
||||||
extern crate style_traits;
|
extern crate style_traits;
|
||||||
|
extern crate thin_vec;
|
||||||
extern crate to_shmem;
|
extern crate to_shmem;
|
||||||
|
|
||||||
mod error_reporter;
|
mod error_reporter;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue