Make Arc helpers into methods

This commit is contained in:
Manish Goregaokar 2016-08-23 16:34:37 +05:30
parent 92c3961743
commit 9f6b772bbb
No known key found for this signature in database
GPG key ID: 3BBF4D3E2EF79F98
5 changed files with 110 additions and 120 deletions

View file

@ -25,7 +25,7 @@ use gecko_bindings::bindings::{Gecko_LocalName, Gecko_Namespace, Gecko_NodeIsEle
use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
use gecko_bindings::structs::{NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO, NODE_IS_DIRTY_FOR_SERVO};
use gecko_bindings::structs::{nsIAtom, nsChangeHint, nsStyleContext};
use gecko_bindings::sugar::refptr::HasArcFFI;
use gecko_bindings::sugar::refptr::FFIArcHelpers;
use gecko_string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
use glue::GeckoDeclarationBlock;
use libc::uintptr_t;
@ -109,7 +109,7 @@ impl TRestyleDamage for GeckoRestyleDamage {
fn compute(source: &nsStyleContext,
new_style: &Arc<ComputedValues>) -> Self {
let context = source as *const nsStyleContext as *mut nsStyleContext;
let hint = unsafe { Gecko_CalcStyleDifference(context, ComputedValues::to_borrowed(new_style)) };
let hint = unsafe { Gecko_CalcStyleDifference(context, new_style.as_borrowed()) };
GeckoRestyleDamage(hint)
}
@ -474,11 +474,8 @@ impl<'le> TElement for GeckoElement<'le> {
if declarations.is_null() {
None
} else {
let opt_ptr = GeckoDeclarationBlock::with(declarations, |declarations| {
// Use a raw pointer to extend the lifetime
declarations.declarations.as_ref().map(|r| r as *const Arc<_>)
});
opt_ptr.map(|ptr| unsafe { &*ptr })
let declarations = declarations.as_arc::<GeckoDeclarationBlock>();
declarations.declarations.as_ref().map(|r| r as *const Arc<_>).map(|ptr| unsafe { &*ptr })
}
}