mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Relax the requirement of Atom::with.
This commit is contained in:
parent
9354e90afc
commit
0667287bf6
4 changed files with 4 additions and 4 deletions
|
@ -47,7 +47,7 @@ pub fn each_class<F, T>(item: T,
|
||||||
let length = getter(item, &mut class, &mut list);
|
let length = getter(item, &mut class, &mut list);
|
||||||
match length {
|
match length {
|
||||||
0 => {}
|
0 => {}
|
||||||
1 => Atom::with(class, &mut callback),
|
1 => Atom::with(class, callback),
|
||||||
n => {
|
n => {
|
||||||
let classes = slice::from_raw_parts(list, n as usize);
|
let classes = slice::from_raw_parts(list, n as usize);
|
||||||
for c in classes {
|
for c in classes {
|
||||||
|
|
|
@ -198,7 +198,7 @@ impl fmt::Display for WeakAtom {
|
||||||
|
|
||||||
impl Atom {
|
impl Atom {
|
||||||
/// Execute a callback with the atom represented by `ptr`.
|
/// Execute a callback with the atom represented by `ptr`.
|
||||||
pub unsafe fn with<F, R: 'static>(ptr: *mut nsIAtom, callback: &mut F) -> R where F: FnMut(&Atom) -> R {
|
pub unsafe fn with<F, R>(ptr: *mut nsIAtom, callback: F) -> R where F: FnOnce(&Atom) -> R {
|
||||||
let atom = Atom(WeakAtom::new(ptr));
|
let atom = Atom(WeakAtom::new(ptr));
|
||||||
let ret = callback(&atom);
|
let ret = callback(&atom);
|
||||||
mem::forget(atom);
|
mem::forget(atom);
|
||||||
|
|
|
@ -721,7 +721,7 @@ ${helpers.single_keyword_system("font-variant-caps",
|
||||||
// XXXManishearth handle quirks mode
|
// XXXManishearth handle quirks mode
|
||||||
|
|
||||||
let ref gecko_font = cx.style().get_font().gecko();
|
let ref gecko_font = cx.style().get_font().gecko();
|
||||||
let base_size = unsafe { Atom::with(gecko_font.mLanguage.raw::<nsIAtom>(), &mut |atom| {
|
let base_size = unsafe { Atom::with(gecko_font.mLanguage.raw::<nsIAtom>(), |atom| {
|
||||||
cx.font_metrics_provider.get_size(atom, gecko_font.mGenericID).0
|
cx.font_metrics_provider.get_size(atom, gecko_font.mGenericID).0
|
||||||
}) };
|
}) };
|
||||||
|
|
||||||
|
|
|
@ -2411,7 +2411,7 @@ pub extern "C" fn Servo_StyleSet_ResolveForDeclarations(raw_data: RawServoStyleS
|
||||||
pub extern "C" fn Servo_StyleSet_MightHaveAttributeDependency(raw_data: RawServoStyleSetBorrowed,
|
pub extern "C" fn Servo_StyleSet_MightHaveAttributeDependency(raw_data: RawServoStyleSetBorrowed,
|
||||||
local_name: *mut nsIAtom) -> bool {
|
local_name: *mut nsIAtom) -> bool {
|
||||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||||
unsafe { Atom::with(local_name, &mut |atom| data.stylist.might_have_attribute_dependency(atom)) }
|
unsafe { Atom::with(local_name, |atom| data.stylist.might_have_attribute_dependency(atom)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue