Bug 1381389 - Append PropertyValuePair objects on Gecko side so they are initialized correctly; r=hiro

Without this mValue may end up looking like a valid nsCSSValue object and bad
things will happen when we try to clone it.

We could just assign mem::zeroed() to mValue but this array hacking on the Servo
side is already pretty nasty and mSimulateComputeValuesFailure would still
remain unassigned (and if we did try to assign it on the Servo side we'd need to
only assign it in debug builds). Unless this proves performance-critical, it's
probably best to just do this on the Gecko side.

MozReview-Commit-ID: 75nFsflhZUM

--HG--
extra : rebase_source : 0e5d94a7f6fdb6768983ba440a3ea69d65cbffbf
This commit is contained in:
Brian Birtles 2017-07-20 14:38:54 +09:00
Родитель 25469a7ddc
Коммит 267881f1f1
6 изменённых файлов: 25 добавлений и 0 удалений

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

@ -25,6 +25,8 @@ enum class CompositeOperation : uint8_t;
*/
struct PropertyValuePair
{
explicit PropertyValuePair(nsCSSPropertyID aProperty)
: mProperty(aProperty) { }
PropertyValuePair(nsCSSPropertyID aProperty, nsCSSValue&& aValue)
: mProperty(aProperty), mValue(Move(aValue)) { }
PropertyValuePair(nsCSSPropertyID aProperty,

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

@ -195,6 +195,7 @@ function treatAsSafeArgument(entry, varName, csuName)
["Gecko_GetOrCreateKeyframeAtStart", "aKeyframes", null],
["Gecko_GetOrCreateInitialKeyframe", "aKeyframes", null],
["Gecko_GetOrCreateFinalKeyframe", "aKeyframes", null],
["Gecko_AppendPropertyValuePair", "aProperties", null],
["Gecko_SetStyleCoordCalcValue", null, null],
["Gecko_StyleClipPath_SetURLValue", "aClip", null],
["Gecko_nsStyleFilter_SetURLValue", "aEffects", null],

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

@ -34,6 +34,7 @@ class StyleChildrenIterator;
struct AnimationPropertySegment;
struct ComputedTiming;
struct Keyframe;
struct PropertyValuePair;
struct PropertyStyleAnimationValuePair;
using ComputedKeyframeValues = nsTArray<PropertyStyleAnimationValuePair>;
} // namespace mozilla
@ -61,6 +62,7 @@ typedef nsXBLBinding RawGeckoXBLBinding;
typedef mozilla::URLExtraData RawGeckoURLExtraData;
typedef nsTArray<RefPtr<RawServoAnimationValue>> RawGeckoServoAnimationValueList;
typedef nsTArray<mozilla::Keyframe> RawGeckoKeyframeList;
typedef nsTArray<mozilla::PropertyValuePair> RawGeckoPropertyValuePairList;
typedef nsTArray<mozilla::ComputedKeyframeValues> RawGeckoComputedKeyframeValuesList;
typedef nsStyleAutoArray<mozilla::StyleAnimation> RawGeckoStyleAnimationList;
typedef nsTArray<nsFontFaceRuleContainer> RawGeckoFontFaceRuleList;
@ -158,6 +160,8 @@ DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoServoAnimationValueList)
DECL_BORROWED_REF_TYPE_FOR(RawGeckoServoAnimationValueList)
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoKeyframeList)
DECL_BORROWED_REF_TYPE_FOR(RawGeckoKeyframeList)
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoPropertyValuePairList)
DECL_BORROWED_REF_TYPE_FOR(RawGeckoPropertyValuePairList)
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoComputedKeyframeValuesList)
DECL_BORROWED_REF_TYPE_FOR(RawGeckoStyleAnimationList)
DECL_BORROWED_MUT_REF_TYPE_FOR(nsTimingFunction)

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

@ -1892,6 +1892,14 @@ Gecko_GetOrCreateFinalKeyframe(nsTArray<Keyframe>* aKeyframes,
KeyframeInsertPosition::LastForOffset);
}
PropertyValuePair*
Gecko_AppendPropertyValuePair(nsTArray<PropertyValuePair>* aProperties,
nsCSSPropertyID aProperty)
{
MOZ_ASSERT(aProperties);
return aProperties->AppendElement(PropertyValuePair {aProperty});
}
void
Gecko_ResetStyleCoord(nsStyleUnit* aUnit, nsStyleUnion* aValue)
{

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

@ -476,6 +476,13 @@ mozilla::Keyframe* Gecko_GetOrCreateFinalKeyframe(
RawGeckoKeyframeListBorrowedMut keyframes,
const nsTimingFunction* timingFunction);
// Appends and returns a new PropertyValuePair to |aProperties| initialized with
// its mProperty member set to |aProperty| and all other members initialized to
// their default values.
mozilla::PropertyValuePair* Gecko_AppendPropertyValuePair(
RawGeckoPropertyValuePairListBorrowedMut aProperties,
nsCSSPropertyID aProperty);
// Clean up pointer-based coordinates
void Gecko_ResetStyleCoord(nsStyleUnit* unit, nsStyleUnion* value);

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

@ -368,6 +368,7 @@ structs-types = [
"RawGeckoDocument",
"RawGeckoElement",
"RawGeckoKeyframeList",
"RawGeckoPropertyValuePairList",
"RawGeckoComputedKeyframeValuesList",
"RawGeckoFontFaceRuleList",
"RawGeckoNode",
@ -397,6 +398,7 @@ structs-types = [
"GeckoFontMetrics",
"IterationCompositeOperation",
"Keyframe",
"PropertyValuePair",
"ServoBundledURI",
"ServoElementSnapshot",
"ServoElementSnapshotTable",
@ -511,6 +513,7 @@ servo-borrow-types = [
"RawGeckoComputedTiming",
"RawGeckoCSSPropertyIDList",
"RawGeckoKeyframeList",
"RawGeckoPropertyValuePairList",
"RawGeckoComputedKeyframeValuesList",
"RawGeckoFontFaceRuleList",
"RawGeckoServoStyleRuleList",