Bug 1420117 - Part 1: Add a ServoCSSParser::ParseCounterStyleName method. r?xidorn draft
authorCameron McCormack <cam@mcc.id.au>
Fri, 24 Nov 2017 15:52:26 +0800
changeset 706029 9c80b2874a56756389e7a511c0b409c3e6b5bd4b
parent 706028 d15e63b9d923bb30500e34b60c913f85b370a0b6
child 706030 4ad0c98f16c050ca28702eb038f7abd156b8bb13
push id91668
push userbmo:cam@mcc.id.au
push dateFri, 01 Dec 2017 02:05:28 +0000
reviewersxidorn
bugs1420117
milestone59.0a1
Bug 1420117 - Part 1: Add a ServoCSSParser::ParseCounterStyleName method. r?xidorn MozReview-Commit-ID: DAaUi5lLrFS
layout/style/ServoBindingList.h
layout/style/ServoCSSParser.cpp
layout/style/ServoCSSParser.h
--- 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