Bug 1420117 - Part 3: Add a ServoCSSParser::ParseCounterStyleDescriptor method. r?xidorn draft
authorCameron McCormack <cam@mcc.id.au>
Fri, 24 Nov 2017 17:26:41 +0800
changeset 706031 7e04248781392dd3f4365828bdf9d11ffc93ed37
parent 706030 4ad0c98f16c050ca28702eb038f7abd156b8bb13
child 706032 006489b0dc4c5b1e0b6ad9d31792ea465e507579
push id91668
push userbmo:cam@mcc.id.au
push dateFri, 01 Dec 2017 02:05:28 +0000
reviewersxidorn
bugs1420117
milestone59.0a1
Bug 1420117 - Part 3: Add a ServoCSSParser::ParseCounterStyleDescriptor method. r?xidorn MozReview-Commit-ID: LHBZ4j1Ji9R
layout/style/ServoBindingList.h
layout/style/ServoBindings.toml
layout/style/ServoCSSParser.cpp
layout/style/ServoCSSParser.h
--- 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