Bug 1324700 - Add an FFI which returns computed values for a given declaration block with/without parent_style. r?heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sat, 15 Apr 2017 07:37:35 +0900
changeset 563188 6d0100ac6b70a469674f175bdedc593d5542049a
parent 563187 5d8cfde9328842826376d29b2afbb0970598ecc1
child 563189 fa32ddcb26af8aa79b8550479e4c2992831f53e3
push id54220
push userhikezoe@mozilla.com
push dateSat, 15 Apr 2017 04:25:00 +0000
reviewersheycam
bugs1324700
milestone55.0a1
Bug 1324700 - Add an FFI which returns computed values for a given declaration block with/without parent_style. r?heycam The function uses document's default computed values if the parent style is not specified. MozReview-Commit-ID: ICd3phAi0C6
layout/style/ServoBindingList.h
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -65,16 +65,21 @@ SERVO_BINDING_FUNC(Servo_StyleSet_FillKe
                    RawServoStyleSetBorrowed set,
                    const nsACString* property,
                    nsTimingFunctionBorrowed timing_function,
                    ServoComputedValuesBorrowed computed_values,
                    RawGeckoKeyframeListBorrowedMut keyframe_list)
 SERVO_BINDING_FUNC(Servo_StyleSet_GetFontFaceRules, void,
                    RawServoStyleSetBorrowed set,
                    RawGeckoFontFaceRuleListBorrowedMut list)
+SERVO_BINDING_FUNC(Servo_StyleSet_ResolveForDeclarations,
+                   ServoComputedValuesStrong,
+                   RawServoStyleSetBorrowed set,
+                   ServoComputedValuesBorrowedOrNull parent_style,
+                   RawServoDeclarationBlockBorrowed declarations)
 
 // CSSRuleList
 SERVO_BINDING_FUNC(Servo_CssRules_ListTypes, void,
                    ServoCssRulesBorrowed rules,
                    nsTArrayBorrowed_uintptr_t result)
 SERVO_BINDING_FUNC(Servo_CssRules_InsertRule, nsresult,
                    ServoCssRulesBorrowed rules,
                    RawServoStyleSheetBorrowed sheet, const nsACString* rule,
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -919,9 +919,19 @@ ServoStyleSet::ResolveStyleLazily(Elemen
 
 bool
 ServoStyleSet::AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray)
 {
   Servo_StyleSet_GetFontFaceRules(mRawSet.get(), &aArray);
   return true;
 }
 
+already_AddRefed<ServoComputedValues>
+ServoStyleSet::ResolveForDeclarations(
+  ServoComputedValuesBorrowedOrNull aParentOrNull,
+  RawServoDeclarationBlockBorrowed aDeclarations)
+{
+  return Servo_StyleSet_ResolveForDeclarations(mRawSet.get(),
+                                               aParentOrNull,
+                                               aDeclarations).Consume();
+}
+
 bool ServoStyleSet::sInServoTraversal = false;
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -292,16 +292,25 @@ public:
                                const ServoComputedValuesWithParent&
                                  aServoValues);
 
   bool AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray);
 
   already_AddRefed<ServoComputedValues>
   GetBaseComputedValuesForElement(dom::Element* aElement, nsIAtom* aPseudoTag);
 
+  /**
+   * Resolve style for a given declaration block with/without the parent style.
+   * If the parent style is not specified, the document default computed values
+   * is used.
+   */
+  already_AddRefed<ServoComputedValues>
+  ResolveForDeclarations(ServoComputedValuesBorrowedOrNull aParentOrNull,
+                         RawServoDeclarationBlockBorrowed aDeclarations);
+
 private:
   already_AddRefed<nsStyleContext> GetContext(already_AddRefed<ServoComputedValues>,
                                               nsStyleContext* aParentContext,
                                               nsIAtom* aPseudoTag,
                                               CSSPseudoElementType aPseudoType,
                                               dom::Element* aElementForAnimation);
 
   already_AddRefed<nsStyleContext> GetContext(nsIContent* aContent,