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
--- 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,