Bug 1345696 part 3 - Add FFI for nsCSSFontFaceRule. r=Manishearth draft
authorXidorn Quan <me@upsuper.org>
Fri, 24 Mar 2017 14:42:18 +1100
changeset 553417 bc4542e87a72d896fcfcf6c0cfc2093f9af718c1
parent 553416 48ed07a86666fd313786ca03818947b10ca7a2ce
child 553418 9ae6e65de6a28027730881f08a589167ef09a313
push id51629
push userxquan@mozilla.com
push dateThu, 30 Mar 2017 01:13:04 +0000
reviewersManishearth
bugs1345696
milestone55.0a1
Bug 1345696 part 3 - Add FFI for nsCSSFontFaceRule. r=Manishearth MozReview-Commit-ID: GV1CWwFihw7
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1575,16 +1575,32 @@ Gecko_LoadStyleSheet(css::Loader* aLoade
 }
 
 const nsMediaFeature*
 Gecko_GetMediaFeatures()
 {
   return nsMediaFeatures::features;
 }
 
+nsCSSFontFaceRule*
+Gecko_CSSFontFaceRule_Create()
+{
+  RefPtr<nsCSSFontFaceRule> rule = new nsCSSFontFaceRule(0, 0);
+  return rule.forget().take();
+}
+
+void
+Gecko_CSSFontFaceRule_GetCssText(const nsCSSFontFaceRule* aRule,
+                                 nsAString* aResult)
+{
+  aRule->GetCssText(*aResult);
+}
+
+NS_IMPL_FFI_REFCOUNTING(nsCSSFontFaceRule, CSSFontFaceRule);
+
 NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList);
 
 #define STYLE_STRUCT(name, checkdata_cb)                                      \
                                                                               \
 void                                                                          \
 Gecko_Construct_Default_nsStyle##name(nsStyle##name* ptr,                     \
                                       const nsPresContext* pres_context)      \
 {                                                                             \
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -38,16 +38,17 @@ namespace mozilla {
   namespace css {
     struct URLValue;
   };
   enum class UpdateAnimationsTasks : uint8_t;
 }
 using mozilla::FontFamilyList;
 using mozilla::FontFamilyType;
 using mozilla::ServoElementSnapshot;
+class nsCSSFontFaceRule;
 struct nsMediaFeature;
 struct nsStyleList;
 struct nsStyleImage;
 struct nsStyleGradientStop;
 class nsStyleGradient;
 class nsStyleCoord;
 struct nsStyleDisplay;
 
@@ -68,16 +69,23 @@ struct nsStyleDisplay;
   void Gecko_AddRef##name_##ArbitraryThread(ThreadSafe##name_##Holder* aPtr); \
   void Gecko_Release##name_##ArbitraryThread(ThreadSafe##name_##Holder* aPtr);
 #define NS_IMPL_HOLDER_FFI_REFCOUNTING(class_, name_)                         \
   void Gecko_AddRef##name_##ArbitraryThread(ThreadSafe##name_##Holder* aPtr)  \
   { NS_ADDREF(aPtr); }                                                        \
   void Gecko_Release##name_##ArbitraryThread(ThreadSafe##name_##Holder* aPtr) \
   { NS_RELEASE(aPtr); }                                                       \
 
+#define NS_DECL_FFI_REFCOUNTING(class_, name_)  \
+  void Gecko_##name_##_AddRef(class_* aPtr);    \
+  void Gecko_##name_##_Release(class_* aPtr);
+#define NS_IMPL_FFI_REFCOUNTING(class_, name_)                    \
+  void Gecko_##name_##_AddRef(class_* aPtr) { NS_ADDREF(aPtr); }  \
+  void Gecko_##name_##_Release(class_* aPtr) { NS_RELEASE(aPtr); }
+
 
 #define DEFINE_ARRAY_TYPE_FOR(type_)                                \
   struct nsTArrayBorrowed_##type_ {                                 \
     nsTArray<type_>* mArray;                                        \
     MOZ_IMPLICIT nsTArrayBorrowed_##type_(nsTArray<type_>* aArray)  \
       : mArray(aArray) {}                                           \
   }
 DEFINE_ARRAY_TYPE_FOR(uintptr_t);
@@ -378,16 +386,22 @@ NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSS
 bool Gecko_PropertyId_IsPrefEnabled(nsCSSPropertyID id);
 
 void Gecko_nsStyleFont_SetLang(nsStyleFont* font, nsIAtom* atom);
 void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont, const nsStyleFont* aSource);
 nscoord Gecko_nsStyleFont_GetBaseSize(const nsStyleFont* font, RawGeckoPresContextBorrowed pres_context);
 
 const nsMediaFeature* Gecko_GetMediaFeatures();
 
+// Font face rule
+// Creates and returns a new (already-addrefed) nsCSSFontFaceRule object.
+nsCSSFontFaceRule* Gecko_CSSFontFaceRule_Create();
+void Gecko_CSSFontFaceRule_GetCssText(const nsCSSFontFaceRule* rule, nsAString* result);
+NS_DECL_FFI_REFCOUNTING(nsCSSFontFaceRule, CSSFontFaceRule);
+
 // We use an int32_t here instead of a LookAndFeel::ColorID
 // because forward-declaring a nested enum/struct is impossible
 nscolor Gecko_GetLookAndFeelSystemColor(int32_t color_id,
                                         RawGeckoPresContextBorrowed pres_context);
 
 bool Gecko_MatchStringArgPseudo(RawGeckoElementBorrowed element,
                                 mozilla::CSSPseudoClassType type,
                                 const char16_t* ident,