Bug 1349004 part 2 - Add ResolveServoStyle for get resolved servo's computed values. r=hiro draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Mon, 10 Apr 2017 15:10:55 +0900
changeset 559451 edae685da2271e729ffd66f408599e43eb9041b7
parent 559450 c35174346d2ba7a1d82115bf782634799f9b1d56
child 559452 a37ff71ea28f0e363cabf8c2a22be205cd7956fa
child 559454 b2ada2221fab35ec74604e5627289a34de1b9844
push id53097
push userbmo:mantaroh@gmail.com
push dateMon, 10 Apr 2017 06:12:11 +0000
reviewershiro
bugs1349004
milestone55.0a1
Bug 1349004 part 2 - Add ResolveServoStyle for get resolved servo's computed values. r=hiro MozReview-Commit-ID: 6RCv5YCDxWJ
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -864,16 +864,23 @@ ServoStyleSet::ResolveStyleLazily(Elemen
     computedValues =
       Servo_ResolveStyleLazily(aElement, aPseudoTag, mRawSet.get()).Consume();
   }
   sInServoTraversal = false;
 
   return computedValues.forget();
 }
 
+already_AddRefed<ServoComputedValues>
+ServoStyleSet::ResolveServoStyle(Element* aElement, nsIAtom* aPseudoTag)
+{
+  PreTraverseSync();
+  return ResolveStyleLazily(aElement, aPseudoTag);
+}
+
 bool
 ServoStyleSet::AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray)
 {
   Servo_StyleSet_GetFontFaceRules(mRawSet.get(), &aArray);
   return true;
 }
 
 bool ServoStyleSet::sInServoTraversal = false;
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -266,16 +266,24 @@ public:
   void RebuildData();
 
   /**
    * Resolve style for the given element, and return it as a
    * ServoComputedValues, not an nsStyleContext.
    */
   already_AddRefed<ServoComputedValues> ResolveServoStyleWithoutSyncUpData(dom::Element* aElement);
 
+  /**
+   * Resolve style for the given (pseudo-)element and pseudo information,
+   * and it will call PreTraverseSync() first.
+   */
+  already_AddRefed<ServoComputedValues>
+  ResolveServoStyle(dom::Element* aElement,
+                                       nsIAtom* aPseudoTag);
+
   bool FillKeyframesForName(const nsString& aName,
                             const nsTimingFunction& aTimingFunction,
                             const ServoComputedValues* aComputedValues,
                             nsTArray<Keyframe>& aKeyframes);
 
   nsTArray<ComputedKeyframeValues>
   GetComputedKeyframeValuesFor(const nsTArray<Keyframe>& aKeyframes,
                                dom::Element* aElement,