Bug 1367293 - Get parent style from the target element. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 02 Jun 2017 09:38:22 +0900
changeset 588045 9be37aca18cdf17c6fcb5e5177904c0a42d39dc2
parent 588044 6b8cde612394ab13f8ee2ca6e3a180cb1515764e
child 588046 6fc04d4db113cfea2624848285058c491fb61462
push id61886
push userhikezoe@mozilla.com
push dateFri, 02 Jun 2017 02:26:43 +0000
reviewersbirtles
bugs1367293
milestone55.0a1
Bug 1367293 - Get parent style from the target element. r?birtles We can get the parent style from element tree in servo side. The parent style has been already restyled. E.g.; When we get target element style with nsComputedDOMStyle::GetStyleContext, the function flushes styles so that the parent style has also restyled. When we call Servo_GetComputedKeyframeValues, it's called from a SequentialTask, that means all elements have been already restyled. Unfortunately we can't assert that the parent style is not stale to check the parent element has no dirty descendant bit since Servo_GetComputedKeyframeValues is called in a SequantialTask that is processed before post traversal, that means elements still have the dirty bit to update nsStyleContext in the post traversal. MozReview-Commit-ID: AC2ZRyzk3eu
layout/style/ServoBindingList.h
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
layout/style/StyleAnimationValue.cpp
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -200,18 +200,18 @@ SERVO_BINDING_FUNC(Servo_ParseProperty,
                    mozilla::ParsingMode parsing_mode,
                    nsCompatibility quirks_mode)
 SERVO_BINDING_FUNC(Servo_ParseEasing, bool,
                    const nsAString* easing,
                    RawGeckoURLExtraData* data,
                    nsTimingFunctionBorrowedMut output)
 SERVO_BINDING_FUNC(Servo_GetComputedKeyframeValues, void,
                    RawGeckoKeyframeListBorrowed keyframes,
+                   RawGeckoElementBorrowed element,
                    ServoComputedValuesBorrowed style,
-                   ServoComputedValuesBorrowedOrNull parent_style,
                    RawServoStyleSetBorrowed set,
                    RawGeckoComputedKeyframeValuesListBorrowedMut result)
 SERVO_BINDING_FUNC(Servo_AnimationValueMap_Push, void,
                    RawServoAnimationValueMapBorrowedMut,
                    nsCSSPropertyID property,
                    RawServoAnimationValueBorrowed value)
 SERVO_BINDING_FUNC(Servo_ComputedValues_ExtractAnimationValue,
                    RawServoAnimationValueStrong,
@@ -250,19 +250,19 @@ SERVO_BINDING_FUNC(Servo_AnimationValue_
 SERVO_BINDING_FUNC(Servo_AnimationValue_DeepEqual, bool,
                    RawServoAnimationValueBorrowed,
                    RawServoAnimationValueBorrowed)
 SERVO_BINDING_FUNC(Servo_AnimationValue_Uncompute,
                    RawServoDeclarationBlockStrong,
                    RawServoAnimationValueBorrowed value)
 SERVO_BINDING_FUNC(Servo_AnimationValue_Compute,
                    RawServoAnimationValueStrong,
+                   RawGeckoElementBorrowed element,
                    RawServoDeclarationBlockBorrowed declarations,
                    ServoComputedValuesBorrowed style,
-                   ServoComputedValuesBorrowedOrNull parent_style,
                    RawServoStyleSetBorrowed raw_data)
 
 // Style attribute
 SERVO_BINDING_FUNC(Servo_ParseStyleAttribute, RawServoDeclarationBlockStrong,
                    const nsACString* data,
                    RawGeckoURLExtraData* extra_data,
                    nsCompatibility quirks_mode)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_CreateEmpty,
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -1015,27 +1015,27 @@ ServoStyleSet::GetKeyframesForName(const
                                             &aTimingFunction,
                                             aComputedValues,
                                             &aKeyframes);
 }
 
 nsTArray<ComputedKeyframeValues>
 ServoStyleSet::GetComputedKeyframeValuesFor(
   const nsTArray<Keyframe>& aKeyframes,
-  dom::Element* aElement,
+  Element* aElement,
   const ServoComputedValuesWithParent& aServoValues)
 {
   nsTArray<ComputedKeyframeValues> result(aKeyframes.Length());
 
   // Construct each nsTArray<PropertyStyleAnimationValuePair> here.
   result.AppendElements(aKeyframes.Length());
 
   Servo_GetComputedKeyframeValues(&aKeyframes,
+                                  aElement,
                                   aServoValues.mCurrentStyle,
-                                  aServoValues.mParentStyle,
                                   mRawSet.get(),
                                   &result);
   return result;
 }
 
 already_AddRefed<ServoComputedValues>
 ServoStyleSet::GetBaseComputedValuesForElement(Element* aElement,
                                                CSSPseudoElementType aPseudoType)
@@ -1043,22 +1043,23 @@ ServoStyleSet::GetBaseComputedValuesForE
   return Servo_StyleSet_GetBaseComputedValuesForElement(mRawSet.get(),
                                                         aElement,
                                                         &Snapshots(),
                                                         aPseudoType).Consume();
 }
 
 already_AddRefed<RawServoAnimationValue>
 ServoStyleSet::ComputeAnimationValue(
+  Element* aElement,
   RawServoDeclarationBlock* aDeclarations,
   const ServoComputedValuesWithParent& aComputedValues)
 {
-  return Servo_AnimationValue_Compute(aDeclarations,
+  return Servo_AnimationValue_Compute(aElement,
+                                      aDeclarations,
                                       aComputedValues.mCurrentStyle,
-                                      aComputedValues.mParentStyle,
                                       mRawSet.get()).Consume();
 }
 
 bool
 ServoStyleSet::EnsureUniqueInnerOnCSSSheets()
 {
   AutoTArray<StyleSheet*, 32> queue;
   for (auto& entryArray : mSheets) {
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -373,17 +373,18 @@ public:
    * If the parent style is not specified, the document default computed values
    * is used.
    */
   already_AddRefed<ServoComputedValues>
   ResolveForDeclarations(ServoComputedValuesBorrowedOrNull aParentOrNull,
                          RawServoDeclarationBlockBorrowed aDeclarations);
 
   already_AddRefed<RawServoAnimationValue>
-  ComputeAnimationValue(RawServoDeclarationBlock* aDeclaration,
+  ComputeAnimationValue(dom::Element* aElement,
+                        RawServoDeclarationBlock* aDeclaration,
                         const ServoComputedValuesWithParent& aComputedValues);
 
   void AppendTask(PostTraversalTask aTask)
   {
     MOZ_ASSERT(IsInServoTraversal());
 
     // We currently only use PostTraversalTasks while the Servo font metrics
     // mutex is locked.  If we need to use them in other situations during
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -5383,17 +5383,19 @@ AnimationValue::FromString(nsCSSProperty
     const ServoComputedValuesWithParent styles = {
       styleContext->StyleSource().AsServoComputedValues(),
       parentContext ? parentContext->StyleSource().AsServoComputedValues()
                     : nullptr
     };
 
     result.mServo = presContext->StyleSet()
                                ->AsServo()
-                               ->ComputeAnimationValue(declarations, styles);
+                               ->ComputeAnimationValue(aElement,
+                                                       declarations,
+                                                       styles);
     return result;
   }
 
   if (!StyleAnimationValue::ComputeValue(aProperty, aElement, styleContext,
                                          aValue, false /* |aUseSVGMode| */,
                                          result.mGecko)) {
     MOZ_ASSERT(result.IsNull());
   }