mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Use the new struct in stylo.
This commit is contained in:
parent
f3a694a7b4
commit
737733eaae
2 changed files with 36 additions and 19 deletions
|
@ -13,6 +13,13 @@ impl<T> nsCOMPtr<T> {
|
||||||
pub fn raw<U>(&self) -> *mut T {
|
pub fn raw<U>(&self) -> *mut T {
|
||||||
self.mRawPtr
|
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"))]
|
#[cfg(not(feature = "gecko_debug"))]
|
||||||
|
@ -22,4 +29,11 @@ impl nsCOMPtr {
|
||||||
pub fn raw<T>(&self) -> *mut T {
|
pub fn raw<T>(&self) -> *mut T {
|
||||||
self._base.mRawPtr as *mut _
|
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 _;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4212,7 +4212,9 @@ clip-path
|
||||||
use properties::longhands::content::computed_value::T;
|
use properties::longhands::content::computed_value::T;
|
||||||
use properties::longhands::content::computed_value::ContentItem;
|
use properties::longhands::content::computed_value::ContentItem;
|
||||||
use values::generics::CounterStyleOrNone;
|
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::structs::nsStyleContentType::*;
|
||||||
use gecko_bindings::bindings::Gecko_ClearAndResizeStyleContents;
|
use gecko_bindings::bindings::Gecko_ClearAndResizeStyleContents;
|
||||||
|
|
||||||
|
@ -4226,11 +4228,23 @@ clip-path
|
||||||
ptr
|
ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_counter_style(style: CounterStyleOrNone, dest: &mut nsCSSValue) {
|
fn set_counter_function(data: &mut nsStyleContentData,
|
||||||
dest.set_atom_ident(match style {
|
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::None_ => atom!("none"),
|
||||||
CounterStyleOrNone::Name(name) => name.0,
|
CounterStyleOrNone::Name(name) => name.0,
|
||||||
});
|
}.into_addrefed();
|
||||||
|
unsafe { counter_func.mCounterStyleName.set_raw_from_addrefed::<nsIAtom>(ptr); }
|
||||||
}
|
}
|
||||||
|
|
||||||
match v {
|
match v {
|
||||||
|
@ -4293,23 +4307,12 @@ clip-path
|
||||||
ContentItem::NoCloseQuote
|
ContentItem::NoCloseQuote
|
||||||
=> self.gecko.mContents[i].mType = eStyleContentType_NoCloseQuote,
|
=> self.gecko.mContents[i].mType = eStyleContentType_NoCloseQuote,
|
||||||
ContentItem::Counter(name, style) => {
|
ContentItem::Counter(name, style) => {
|
||||||
unsafe {
|
set_counter_function(&mut self.gecko.mContents[i],
|
||||||
bindings::Gecko_SetContentDataArray(&mut self.gecko.mContents[i],
|
eStyleContentType_Counter, &name, "", style);
|
||||||
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]);
|
|
||||||
}
|
}
|
||||||
ContentItem::Counters(name, sep, style) => {
|
ContentItem::Counters(name, sep, style) => {
|
||||||
unsafe {
|
set_counter_function(&mut self.gecko.mContents[i],
|
||||||
bindings::Gecko_SetContentDataArray(&mut self.gecko.mContents[i],
|
eStyleContentType_Counters, &name, &sep, style);
|
||||||
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]);
|
|
||||||
}
|
}
|
||||||
ContentItem::Url(ref url) => {
|
ContentItem::Url(ref url) => {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue