From 1ef7b323acc0b9d6ed10227ba38fa5e84330d2a4 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Sat, 6 May 2017 11:46:47 +1000 Subject: [PATCH] Fix stylo issue after changing counter style names to nsIAtom. --- components/style/gecko_bindings/sugar/ns_css_value.rs | 5 +++++ components/style/gecko_string_cache/mod.rs | 8 ++++++++ components/style/properties/gecko.mako.rs | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/components/style/gecko_bindings/sugar/ns_css_value.rs b/components/style/gecko_bindings/sugar/ns_css_value.rs index a14ea0efb07..e2ff4ceab30 100644 --- a/components/style/gecko_bindings/sugar/ns_css_value.rs +++ b/components/style/gecko_bindings/sugar/ns_css_value.rs @@ -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); diff --git a/components/style/gecko_string_cache/mod.rs b/components/style/gecko_string_cache/mod.rs index 63ba6d7977c..741a4a3e534 100644 --- a/components/style/gecko_string_cache/mod.rs +++ b/components/style/gecko_string_cache/mod.rs @@ -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(); diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 69365b98082..f6fb7b95709 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -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 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 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()) }