From aaf7ca9322b10466da6847c33db707c2245262fc Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Fri, 24 Nov 2017 15:52:26 +0800 Subject: [PATCH] Bug 1420117 - Part 1: Add a ServoCSSParser::ParseCounterStyleName method. r=xidorn MozReview-Commit-ID: DAaUi5lLrFS --HG-- extra : rebase_source : 5b53cbfc9a1286e7ece3a62fb20b536de28a73d6 --- layout/style/ServoBindingList.h | 2 ++ layout/style/ServoCSSParser.cpp | 8 ++++++++ layout/style/ServoCSSParser.h | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/layout/style/ServoBindingList.h b/layout/style/ServoBindingList.h index 55121d15a73e..e4113bf9654a 100644 --- a/layout/style/ServoBindingList.h +++ b/layout/style/ServoBindingList.h @@ -755,6 +755,8 @@ 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_) \ diff --git a/layout/style/ServoCSSParser.cpp b/layout/style/ServoCSSParser.cpp index c8c33cc448cf..84dfaf877111 100644 --- a/layout/style/ServoCSSParser.cpp +++ b/layout/style/ServoCSSParser.cpp @@ -32,3 +32,11 @@ ServoCSSParser::ParseIntersectionObserverRootMargin(const nsAString& aValue, { return Servo_ParseIntersectionObserverRootMargin(&aValue, aResult); } + +/* static */ already_AddRefed +ServoCSSParser::ParseCounterStyleName(const nsAString& aValue) +{ + NS_ConvertUTF16toUTF8 value(aValue); + nsAtom* atom = Servo_ParseCounterStyleName(&value); + return already_AddRefed(atom); +} diff --git a/layout/style/ServoCSSParser.h b/layout/style/ServoCSSParser.h index 08db2958166b..31b54d801cf3 100644 --- a/layout/style/ServoCSSParser.h +++ b/layout/style/ServoCSSParser.h @@ -49,6 +49,15 @@ public: */ 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 ParseCounterStyleName(const nsAString& aValue); }; } // namespace mozilla