Auto merge of #9284 - bholley:bootstrap_stylo, r=SimonSapin

Add Partial Implementation of style DOM traits for Gecko, and some basic glue to let Gecko call into Servo

The wrapper stuff is partially-complete, modulo some unimplemented methods. The glue code is just a toy for now. Regardless, I think it's worth getting some of this stuff in-tree to minimize breakage.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9284)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-01-19 14:19:10 +05:30
commit 77d3fbcca3
11 changed files with 700 additions and 21 deletions

View file

@ -275,14 +275,6 @@ impl<'ln> TNode<'ln> for ServoLayoutNode<'ln> {
self.node.next_sibling_ref().map(|node| self.new_with_this_lifetime(&node))
}
}
fn style(&self) -> Ref<Arc<ComputedValues>> {
Ref::map(self.borrow_data().unwrap(), |data| data.style.as_ref().unwrap())
}
fn unstyle(self) {
self.mutate_data().unwrap().style = None;
}
}
impl<'ln> LayoutNode<'ln> for ServoLayoutNode<'ln> {
@ -300,7 +292,7 @@ impl<'ln> LayoutNode<'ln> for ServoLayoutNode<'ln> {
unsafe fn borrow_layout_data_unchecked(&self) -> Option<*const PrivateLayoutData> {
self.get_jsmanaged().get_style_and_layout_data().map(|opaque| {
let container: NonOpaqueStyleAndLayoutData = transmute(opaque.ptr);
let container = *opaque.ptr as NonOpaqueStyleAndLayoutData;
&(*(*container).as_unsafe_cell().get()) as *const PrivateLayoutData
})
}
@ -308,7 +300,7 @@ impl<'ln> LayoutNode<'ln> for ServoLayoutNode<'ln> {
fn borrow_layout_data(&self) -> Option<Ref<PrivateLayoutData>> {
unsafe {
self.get_jsmanaged().get_style_and_layout_data().map(|opaque| {
let container: NonOpaqueStyleAndLayoutData = transmute(opaque.ptr);
let container = *opaque.ptr as NonOpaqueStyleAndLayoutData;
(*container).borrow()
})
}
@ -317,7 +309,7 @@ impl<'ln> LayoutNode<'ln> for ServoLayoutNode<'ln> {
fn mutate_layout_data(&self) -> Option<RefMut<PrivateLayoutData>> {
unsafe {
self.get_jsmanaged().get_style_and_layout_data().map(|opaque| {
let container: NonOpaqueStyleAndLayoutData = transmute(opaque.ptr);
let container = *opaque.ptr as NonOpaqueStyleAndLayoutData;
(*container).borrow_mut()
})
}

View file

@ -160,10 +160,14 @@ pub trait TNode<'ln> : Sized + Copy + Clone {
/// Returns the style results for the given node. If CSS selector matching
/// has not yet been performed, fails.
fn style(&self) -> Ref<Arc<ComputedValues>>;
fn style(&self) -> Ref<Arc<ComputedValues>> {
Ref::map(self.borrow_data().unwrap(), |data| data.style.as_ref().unwrap())
}
/// Removes the style from this node.
fn unstyle(self);
fn unstyle(self) {
self.mutate_data().unwrap().style = None;
}
}
pub trait TDocument<'ld> : Sized + Copy + Clone {

View file

@ -4,6 +4,7 @@
#![feature(box_syntax)]
#![feature(box_patterns)]
#![feature(cell_extras)]
#![feature(concat_idents)]
#![feature(core_intrinsics)]
#![feature(custom_attribute)]

View file

@ -115,10 +115,6 @@ pub trait DomTraversalContext<'ln, N: TNode<'ln>> {
fn process_postorder(&self, node: N);
}
/// FIXME(bholley): I added this now to demonstrate the usefulness of the new design.
/// This is currently unused, but will be used shortly.
#[allow(dead_code)]
pub struct StandaloneStyleContext<'a> {
pub shared: &'a SharedStyleContext,
cached_local_style_context: Rc<LocalStyleContext>,
@ -138,7 +134,6 @@ impl<'a> StyleContext<'a> for StandaloneStyleContext<'a> {
}
}
#[allow(dead_code)]
pub struct RecalcStyleOnly<'lc> {
context: StandaloneStyleContext<'lc>,
root: OpaqueNode,