Auto merge of #16750 - upsuper:bug1362302, r=Manishearth

Use nsIAtom for counter style name

This is the Servo side change of [bug 1362302](https://bugzilla.mozilla.org/show_bug.cgi?id=1362302) which has been reviewed on Bugzilla.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16750)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-05-05 23:15:08 -05:00 committed by GitHub
commit 806f369a79
4 changed files with 19 additions and 2 deletions

View file

@ -1139,6 +1139,10 @@ extern "C" {
atom: *mut nsIAtom,
unit: nsCSSUnit);
}
extern "C" {
pub fn Gecko_CSSValue_SetAtomIdent(css_value: nsCSSValueBorrowedMut,
atom: *mut nsIAtom);
}
extern "C" {
pub fn Gecko_CSSValue_SetArray(css_value: nsCSSValueBorrowedMut,
len: i32);

View file

@ -134,6 +134,11 @@ impl nsCSSValue {
self.set_string_internal(s, nsCSSUnit::eCSSUnit_Ident)
}
/// Set to an atom identifier value
pub fn set_atom_ident(&mut self, s: Atom) {
unsafe { bindings::Gecko_CSSValue_SetAtomIdent(self, s.into_addrefed()) }
}
/// Set to a font format
pub fn set_font_format(&mut self, s: &str) {
self.set_string_internal(s, nsCSSUnit::eCSSUnit_Font_Format);

View file

@ -226,6 +226,14 @@ impl Atom {
}
}
/// Convert this atom into an addrefed nsIAtom pointer.
#[inline]
pub fn into_addrefed(self) -> *mut nsIAtom {
let ptr = self.as_ptr();
mem::forget(self);
ptr
}
/// Return whether two atoms are ASCII-case-insensitive matches
pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool {
let a = self.as_slice();

View file

@ -4152,7 +4152,7 @@ clip-path
let mut array = unsafe { &mut **self.gecko.mContents[i].mContent.mCounters.as_mut() };
array[0].set_string(&name);
// When we support <custom-ident> values for list-style-type this will need to be updated
array[1].set_ident(&style.to_css_string());
array[1].set_atom_ident(style.to_css_string().into());
}
ContentItem::Counters(name, sep, style) => {
unsafe {
@ -4163,7 +4163,7 @@ clip-path
array[0].set_string(&name);
array[1].set_string(&sep);
// When we support <custom-ident> values for list-style-type this will need to be updated
array[2].set_ident(&style.to_css_string());
array[2].set_atom_ident(style.to_css_string().into());
}
ContentItem::Url(url) => {
unsafe { bindings::Gecko_SetContentDataImage(&mut self.gecko.mContents[i], url.for_ffi()) }