Bug 1420117 - Part 3: Add a ServoCSSParser::ParseCounterStyleDescriptor method. r?xidorn
MozReview-Commit-ID: LHBZ4j1Ji9R
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -752,15 +752,20 @@ SERVO_BINDING_FUNC(Servo_ParseIntersecti
// percentage value, so we cannot compute the matrix. In this case, we keep
// |result| and |contains_3d_transform| as-is.
SERVO_BINDING_FUNC(Servo_ParseTransformIntoMatrix, bool,
const nsAString* value,
bool* contains_3d_transform,
RawGeckoGfxMatrix4x4* result);
SERVO_BINDING_FUNC(Servo_ParseCounterStyleName, nsAtom*,
const nsACString* value);
+SERVO_BINDING_FUNC(Servo_ParseCounterStyleDescriptor, bool,
+ nsCSSCounterDesc aDescriptor,
+ const nsACString* aValue,
+ RawGeckoURLExtraData* aURLExtraData,
+ nsCSSValue* aResult);
// AddRef / Release functions
#define SERVO_ARC_TYPE(name_, type_) \
SERVO_BINDING_FUNC(Servo_##name_##_AddRef, void, type_##Borrowed) \
SERVO_BINDING_FUNC(Servo_##name_##_Release, void, type_##Borrowed)
#include "mozilla/ServoArcTypeList.h"
#undef SERVO_ARC_TYPE
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -512,16 +512,17 @@ structs-types = [
"ServoElementSnapshot",
"ServoElementSnapshotTable",
"ServoStyleSetSizes",
"SheetParsingMode",
"StyleBasicShapeType",
"StyleShapeSource",
"StyleTransition",
"gfxFontFeatureValueSet",
+ "nsCSSCounterDesc",
"nsCSSCounterStyleRule",
"nsCSSFontFaceRule",
"nsCSSKeyword",
"nsCSSPropertyID",
"nsCSSPropertyIDSet",
"nsCSSRect",
"nsCSSShadowArray",
"nsCSSUnit",
--- a/layout/style/ServoCSSParser.cpp
+++ b/layout/style/ServoCSSParser.cpp
@@ -35,8 +35,19 @@ ServoCSSParser::ParseIntersectionObserve
/* static */ already_AddRefed<nsAtom>
ServoCSSParser::ParseCounterStyleName(const nsAString& aValue)
{
NS_ConvertUTF16toUTF8 value(aValue);
nsAtom* atom = Servo_ParseCounterStyleName(&value);
return already_AddRefed<nsAtom>(atom);
}
+
+/* static */ bool
+ServoCSSParser::ParseCounterStyleDescriptor(nsCSSCounterDesc aDescriptor,
+ const nsAString& aValue,
+ URLExtraData* aURLExtraData,
+ nsCSSValue& aResult)
+{
+ NS_ConvertUTF16toUTF8 value(aValue);
+ return Servo_ParseCounterStyleDescriptor(aDescriptor, &value, aURLExtraData,
+ &aResult);
+}
--- a/layout/style/ServoCSSParser.h
+++ b/layout/style/ServoCSSParser.h
@@ -53,13 +53,29 @@ public:
/**
* Parses a @counter-style name.
*
* @param aValue The name to parse.
* @return The name as an atom, lowercased if a built-in counter style name,
* or nullptr if parsing failed or if the name was invalid (like "inherit").
*/
static already_AddRefed<nsAtom> ParseCounterStyleName(const nsAString& aValue);
+
+ /**
+ * Parses a @counter-style descriptor.
+ *
+ * @param aDescriptor The descriptor to parse.
+ * @param aValue The value of the descriptor.
+ * @param aURLExtraData URL data for parsing. This would be used for
+ * image value URL resolution.
+ * @param aResult The nsCSSValue to store the result in.
+ * @return Whether parsing succeeded.
+ */
+ static bool
+ ParseCounterStyleDescriptor(nsCSSCounterDesc aDescriptor,
+ const nsAString& aValue,
+ URLExtraData* aURLExtraData,
+ nsCSSValue& aResult);
};
} // namespace mozilla
#endif // mozilla_ServoCSSParser_h