Bug 1367523 Part 2: Gecko-side implement the CounterStyle and FontFaceRule clone functions. draft
authorBrad Werth <bwerth@mozilla.com>
Mon, 22 May 2017 17:21:09 -0700
changeset 591085 daaa9619f0cfce9663c2950bec29642fddec75b0
parent 590997 6491fb29e7fcc9e02cc179ae2856f426a3552385
child 591086 dfd88426eb6de1aa239a9f09d9c42b001d9d0a4b
push id62952
push userbwerth@mozilla.com
push dateThu, 08 Jun 2017 16:52:26 +0000
bugs1367523
milestone55.0a1
Bug 1367523 Part 2: Gecko-side implement the CounterStyle and FontFaceRule clone functions. MozReview-Commit-ID: HHGgItSdyZ5
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -2319,16 +2319,23 @@ Gecko_CSSKeywordString(nsCSSKeyword aKey
 
 nsCSSFontFaceRule*
 Gecko_CSSFontFaceRule_Create(uint32_t aLine, uint32_t aColumn)
 {
   RefPtr<nsCSSFontFaceRule> rule = new nsCSSFontFaceRule(aLine, aColumn);
   return rule.forget().take();
 }
 
+nsCSSFontFaceRule*
+Gecko_CSSFontFaceRule_Clone(const nsCSSFontFaceRule* aRule)
+{
+  RefPtr<css::Rule> rule = aRule->Clone();
+  return static_cast<nsCSSFontFaceRule*>(rule.forget().take());
+}
+
 void
 Gecko_CSSFontFaceRule_GetCssText(const nsCSSFontFaceRule* aRule,
                                  nsAString* aResult)
 {
   // GetCSSText serializes nsCSSValues, which have a heap write
   // hazard when dealing with color values (nsCSSKeywords::AddRefTable)
   // We only serialize on the main thread; assert to convince the analysis
   // and prevent accidentally calling this elsewhere
@@ -2365,16 +2372,23 @@ NS_IMPL_FFI_REFCOUNTING(nsCSSFontFaceRul
 
 nsCSSCounterStyleRule*
 Gecko_CSSCounterStyle_Create(nsIAtom* aName)
 {
   RefPtr<nsCSSCounterStyleRule> rule = new nsCSSCounterStyleRule(aName, 0, 0);
   return rule.forget().take();
 }
 
+nsCSSCounterStyleRule*
+Gecko_CSSCounterStyle_Clone(const nsCSSCounterStyleRule* aRule)
+{
+  RefPtr<css::Rule> rule = aRule->Clone();
+  return static_cast<nsCSSCounterStyleRule*>(rule.forget().take());
+}
+
 void
 Gecko_CSSCounterStyle_GetCssText(const nsCSSCounterStyleRule* aRule,
                                  nsAString* aResult)
 {
   MOZ_ASSERT(NS_IsMainThread());
   aRule->GetCssText(*aResult);
 }
 
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -545,22 +545,24 @@ void AssertIsMainThreadOrServoLangFontPr
 
 const nsMediaFeature* Gecko_GetMediaFeatures();
 nsCSSKeyword Gecko_LookupCSSKeyword(const uint8_t* string, uint32_t len);
 const char* Gecko_CSSKeywordString(nsCSSKeyword keyword, uint32_t* len);
 
 // Font face rule
 // Creates and returns a new (already-addrefed) nsCSSFontFaceRule object.
 nsCSSFontFaceRule* Gecko_CSSFontFaceRule_Create(uint32_t line, uint32_t column);
+nsCSSFontFaceRule* Gecko_CSSFontFaceRule_Clone(const nsCSSFontFaceRule* rule);
 void Gecko_CSSFontFaceRule_GetCssText(const nsCSSFontFaceRule* rule, nsAString* result);
 NS_DECL_FFI_REFCOUNTING(nsCSSFontFaceRule, CSSFontFaceRule);
 
 // Counter style rule
 // Creates and returns a new (already-addrefed) nsCSSCounterStyleRule object.
 nsCSSCounterStyleRule* Gecko_CSSCounterStyle_Create(nsIAtom* name);
+nsCSSCounterStyleRule* Gecko_CSSCounterStyle_Clone(const nsCSSCounterStyleRule* rule);
 void Gecko_CSSCounterStyle_GetCssText(const nsCSSCounterStyleRule* rule, nsAString* result);
 NS_DECL_FFI_REFCOUNTING(nsCSSCounterStyleRule, CSSCounterStyleRule);
 
 RawGeckoElementBorrowedOrNull Gecko_GetBody(RawGeckoPresContextBorrowed pres_context);
 
 // 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,