Bug 1339629 Part 3: Servo-side define and call Gecko CounterStyle and FontFaceRule clone functions.
MozReview-Commit-ID: GNbXKFjR1Wb
--- a/servo/components/style/gecko/generated/bindings.rs
+++ b/servo/components/style/gecko/generated/bindings.rs
@@ -1315,30 +1315,38 @@ extern "C" {
pub fn Gecko_CSSKeywordString(keyword: nsCSSKeyword, len: *mut u32)
-> *const ::std::os::raw::c_char;
}
extern "C" {
pub fn Gecko_CSSFontFaceRule_Create(line: u32, column: u32)
-> *mut nsCSSFontFaceRule;
}
extern "C" {
+ pub fn Gecko_CSSFontFaceRule_Clone(rule: *const nsCSSFontFaceRule)
+ -> *mut nsCSSFontFaceRule;
+}
+extern "C" {
pub fn Gecko_CSSFontFaceRule_GetCssText(rule: *const nsCSSFontFaceRule,
result: *mut nsAString);
}
extern "C" {
pub fn Gecko_CSSFontFaceRule_AddRef(aPtr: *mut nsCSSFontFaceRule);
}
extern "C" {
pub fn Gecko_CSSFontFaceRule_Release(aPtr: *mut nsCSSFontFaceRule);
}
extern "C" {
pub fn Gecko_CSSCounterStyle_Create(name: *mut nsIAtom)
-> *mut nsCSSCounterStyleRule;
}
extern "C" {
+ pub fn Gecko_CSSCounterStyle_Clone(rule: *const nsCSSCounterStyleRule)
+ -> *mut nsCSSCounterStyleRule;
+}
+extern "C" {
pub fn Gecko_CSSCounterStyle_GetCssText(rule:
*const nsCSSCounterStyleRule,
result: *mut nsAString);
}
extern "C" {
pub fn Gecko_CSSCounterStyleRule_AddRef(aPtr: *mut nsCSSCounterStyleRule);
}
extern "C" {
--- a/servo/components/style/gecko/rules.rs
+++ b/servo/components/style/gecko/rules.rs
@@ -144,16 +144,28 @@ impl ToNsCssValue for FontDisplay {
FontDisplay::Block => structs::NS_FONT_DISPLAY_BLOCK,
FontDisplay::Swap => structs::NS_FONT_DISPLAY_SWAP,
FontDisplay::Fallback => structs::NS_FONT_DISPLAY_FALLBACK,
FontDisplay::Optional => structs::NS_FONT_DISPLAY_OPTIONAL,
} as i32)
}
}
+impl FontFaceRule {
+ /// Ask Gecko to deep clone the nsCSSFontFaceRule, and then construct
+ /// a FontFaceRule object from it.
+ pub fn deep_clone_from_gecko(&self) -> FontFaceRule {
+ let result = unsafe {
+ UniqueRefPtr::from_addrefed(
+ bindings::Gecko_CSSFontFaceRule_Clone(self.get()))
+ };
+ result.get()
+ }
+}
+
impl From<FontFaceRuleData> for FontFaceRule {
fn from(data: FontFaceRuleData) -> FontFaceRule {
let mut result = unsafe {
UniqueRefPtr::from_addrefed(bindings::Gecko_CSSFontFaceRule_Create(
data.source_location.line as u32, data.source_location.column as u32
))
};
data.set_descriptors(&mut result.mDecl.mDescriptors);
@@ -170,16 +182,28 @@ impl ToCssWithGuard for FontFaceRule {
}
write!(dest, "{}", css_text)
}
}
/// A @counter-style rule
pub type CounterStyleRule = RefPtr<nsCSSCounterStyleRule>;
+impl CounterStyleRule {
+ /// Ask Gecko to deep clone the nsCSSCounterStyleRule, and then construct
+ /// a CounterStyleRule object from it.
+ pub fn deep_clone_from_gecko(&self) -> CounterStyleRule {
+ let result = unsafe {
+ UniqueRefPtr::from_addrefed(
+ bindings::Gecko_CSSCounterStyle_Clone(self.get()))
+ };
+ result.get()
+ }
+}
+
impl From<counter_style::CounterStyleRuleData> for CounterStyleRule {
fn from(data: counter_style::CounterStyleRuleData) -> CounterStyleRule {
let mut result = unsafe {
UniqueRefPtr::from_addrefed(
bindings::Gecko_CSSCounterStyle_Create(data.name().0.as_ptr()))
};
data.set_descriptors(&mut result.mValues);
result.get()
--- a/servo/components/style/stylesheets.rs
+++ b/servo/components/style/stylesheets.rs
@@ -500,21 +500,23 @@ impl CssRule {
},
CssRule::Media(ref arc) => {
let rule = arc.read_with(&guard);
CssRule::Media(Arc::new(
lock.wrap(rule.deep_clone_with_lock(lock))))
},
CssRule::FontFace(ref arc) => {
let rule = arc.read_with(&guard);
- CssRule::FontFace(Arc::new(lock.wrap(rule.clone())))
+ CssRule::FontFace(Arc::new(lock.wrap(
+ rule.deep_clone_from_gecko())))
},
CssRule::CounterStyle(ref arc) => {
let rule = arc.read_with(&guard);
- CssRule::CounterStyle(Arc::new(lock.wrap(rule.clone())))
+ CssRule::CounterStyle(Arc::new(lock.wrap(
+ rule.deep_clone_from_gecko())))
},
CssRule::Viewport(ref arc) => {
let rule = arc.read_with(&guard);
CssRule::Viewport(Arc::new(lock.wrap(rule.clone())))
},
CssRule::Keyframes(ref arc) => {
let rule = arc.read_with(&guard);
CssRule::Keyframes(Arc::new(