Bug 1367293 - Get parent style from the target element. r=birtles
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 02 Jun 2017 09:38:22 +0900
changeset 361955 10c6f7837bbddcf060316a5ac9c8f89dff4e56f1
parent 361954 ebb95a9089b1154480fa96a0a17e1ac69086ab42
child 361956 a3470fcc5cc4c32081a49563f0fc60f83a8c30d3
push id31952
push usercbook@mozilla.com
push dateFri, 02 Jun 2017 12:17:25 +0000
treeherdermozilla-central@194c009d6295 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1367293
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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());
   }