Bug 1336891 - stylo: Implement custom property value getter. r=emilio
MozReview-Commit-ID: AfAJtNJyCSO
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -536,16 +536,21 @@ SERVO_BINDING_FUNC(Servo_StyleSet_GetBas
const mozilla::ServoElementSnapshotTable* snapshots,
mozilla::CSSPseudoElementType pseudo_type)
// For canvas font.
SERVO_BINDING_FUNC(Servo_SerializeFontValueForCanvas, void,
RawServoDeclarationBlockBorrowed declarations,
nsAString* buffer)
+// Get custom property value.
+SERVO_BINDING_FUNC(Servo_GetCustomProperty, bool,
+ ServoComputedValuesBorrowed computed_values,
+ const nsAString* name, nsAString* value)
+
// Style-struct management.
#define STYLE_STRUCT(name, checkdata_cb) \
struct nsStyle##name; \
SERVO_BINDING_FUNC(Servo_GetStyle##name, const nsStyle##name*, \
ServoComputedValuesBorrowedOrNull computed_values)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -6908,22 +6908,24 @@ MarkComputedStyleMapDirty(const char* aP
static_cast<nsComputedStyleMap*>(aData)->MarkDirty();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetCustomProperty(const nsAString& aPropertyName)
{
MOZ_ASSERT(nsCSSProps::IsCustomPropertyName(aPropertyName));
- const nsStyleVariables* variables = StyleVariables();
-
nsString variableValue;
const nsAString& name = Substring(aPropertyName,
CSS_CUSTOM_NAME_PREFIX_LENGTH);
- if (!variables->mVariables.Get(name, variableValue)) {
+ bool present = mStyleContext->IsServo()
+ ? Servo_GetCustomProperty(mStyleContext->ComputedValues(),
+ &name, &variableValue)
+ : StyleVariables()->mVariables.Get(name, variableValue);
+ if (!present) {
return nullptr;
}
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetString(variableValue);
return val.forget();
}