aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/style/gecko_bindings/sugar/ns_com_ptr.rs14
-rw-r--r--components/style/properties/gecko.mako.rs41
2 files changed, 36 insertions, 19 deletions
diff --git a/components/style/gecko_bindings/sugar/ns_com_ptr.rs b/components/style/gecko_bindings/sugar/ns_com_ptr.rs
index 488dc862608..f50eda02c3d 100644
--- a/components/style/gecko_bindings/sugar/ns_com_ptr.rs
+++ b/components/style/gecko_bindings/sugar/ns_com_ptr.rs
@@ -13,6 +13,13 @@ impl<T> nsCOMPtr<T> {
pub fn raw<U>(&self) -> *mut T {
self.mRawPtr
}
+
+ /// Set this pointer from an addrefed raw pointer.
+ /// It leaks the old pointer.
+ #[inline]
+ pub unsafe fn set_raw_from_addrefed<U>(&mut self, ptr: *mut T) {
+ self.mRawPtr = ptr;
+ }
}
#[cfg(not(feature = "gecko_debug"))]
@@ -22,4 +29,11 @@ impl nsCOMPtr {
pub fn raw<T>(&self) -> *mut T {
self._base.mRawPtr as *mut _
}
+
+ /// Set this pointer from an addrefed raw pointer.
+ /// It leaks the old pointer.
+ #[inline]
+ pub unsafe fn set_raw_from_addrefed<T>(&mut self, ptr: *mut T) {
+ self._base.mRawPtr = ptr as *mut _;
+ }
}
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index 28ab764c463..618675b111d 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -4212,7 +4212,9 @@ clip-path
use properties::longhands::content::computed_value::T;
use properties::longhands::content::computed_value::ContentItem;
use values::generics::CounterStyleOrNone;
- use gecko_bindings::structs::nsCSSValue;
+ use gecko_bindings::structs::nsIAtom;
+ use gecko_bindings::structs::nsStyleContentData;
+ use gecko_bindings::structs::nsStyleContentType;
use gecko_bindings::structs::nsStyleContentType::*;
use gecko_bindings::bindings::Gecko_ClearAndResizeStyleContents;
@@ -4226,11 +4228,23 @@ clip-path
ptr
}
- fn set_counter_style(style: CounterStyleOrNone, dest: &mut nsCSSValue) {
- dest.set_atom_ident(match style {
+ fn set_counter_function(data: &mut nsStyleContentData,
+ content_type: nsStyleContentType,
+ name: &str, sep: &str, style: CounterStyleOrNone) {
+ debug_assert!(content_type == eStyleContentType_Counter ||
+ content_type == eStyleContentType_Counters);
+ let counter_func = unsafe {
+ bindings::Gecko_SetCounterFunction(data, content_type).as_mut().unwrap()
+ };
+ counter_func.mIdent.assign_utf8(name);
+ if content_type == eStyleContentType_Counters {
+ counter_func.mSeparator.assign_utf8(sep);
+ }
+ let ptr = match style {
CounterStyleOrNone::None_ => atom!("none"),
CounterStyleOrNone::Name(name) => name.0,
- });
+ }.into_addrefed();
+ unsafe { counter_func.mCounterStyleName.set_raw_from_addrefed::<nsIAtom>(ptr); }
}
match v {
@@ -4293,23 +4307,12 @@ clip-path
ContentItem::NoCloseQuote
=> self.gecko.mContents[i].mType = eStyleContentType_NoCloseQuote,
ContentItem::Counter(name, style) => {
- unsafe {
- bindings::Gecko_SetContentDataArray(&mut self.gecko.mContents[i],
- eStyleContentType_Counter, 2)
- }
- let mut array = unsafe { &mut **self.gecko.mContents[i].mContent.mCounters.as_mut() };
- array[0].set_string(&name);
- set_counter_style(style, &mut array[1]);
+ set_counter_function(&mut self.gecko.mContents[i],
+ eStyleContentType_Counter, &name, "", style);
}
ContentItem::Counters(name, sep, style) => {
- unsafe {
- bindings::Gecko_SetContentDataArray(&mut self.gecko.mContents[i],
- eStyleContentType_Counters, 3)
- }
- let mut array = unsafe { &mut **self.gecko.mContents[i].mContent.mCounters.as_mut() };
- array[0].set_string(&name);
- array[1].set_string(&sep);
- set_counter_style(style, &mut array[2]);
+ set_counter_function(&mut self.gecko.mContents[i],
+ eStyleContentType_Counters, &name, &sep, style);
}
ContentItem::Url(ref url) => {
unsafe {