Bug 1420117 - Part 1: Add a ServoCSSParser::ParseCounterStyleName method. r?xidorn
MozReview-Commit-ID: DAaUi5lLrFS
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -750,15 +750,17 @@ SERVO_BINDING_FUNC(Servo_ParseIntersecti
nsCSSRect* result);
// Returning false means the parsed transform contains relative lengths or
// 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);
// 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/ServoCSSParser.cpp
+++ b/layout/style/ServoCSSParser.cpp
@@ -27,8 +27,16 @@ ServoCSSParser::ComputeColor(ServoStyleS
}
/* static */ bool
ServoCSSParser::ParseIntersectionObserverRootMargin(const nsAString& aValue,
nsCSSRect* aResult)
{
return Servo_ParseIntersectionObserverRootMargin(&aValue, aResult);
}
+
+/* static */ already_AddRefed<nsAtom>
+ServoCSSParser::ParseCounterStyleName(const nsAString& aValue)
+{
+ NS_ConvertUTF16toUTF8 value(aValue);
+ nsAtom* atom = Servo_ParseCounterStyleName(&value);
+ return already_AddRefed<nsAtom>(atom);
+}
--- a/layout/style/ServoCSSParser.h
+++ b/layout/style/ServoCSSParser.h
@@ -44,13 +44,22 @@ public:
* property.
*
* @param aValue The rootMargin value.
* @param aResult The nsCSSRect object to write the result into.
* @return Whether the value was successfully parsed.
*/
static bool ParseIntersectionObserverRootMargin(const nsAString& aValue,
nsCSSRect* aResult);
+
+ /**
+ * 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);
};
} // namespace mozilla
#endif // mozilla_ServoCSSParser_h