Skip to content

Commit

Permalink
Move DOM nodes into dom/base
Browse files Browse the repository at this point in the history
  • Loading branch information
pcwalton committed May 3, 2012
1 parent 8131d62 commit e089607
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
33 changes: 33 additions & 0 deletions src/servo/dom/base.rs
@@ -0,0 +1,33 @@
import dom::rcu::methods;
import gfx::geom::{au, size};
import layout::base::box;
import util::tree;

enum node_data = {
tree: tree::fields<node>,
kind: node_kind,

// Points to the primary box. Note that there may be multiple
// boxes per DOM node.
mut box: option<box>,
};

enum node_kind {
nk_div,
nk_img(size<au>)
}

type node = rcu::handle<node_data>;

impl of tree::tree for node {
fn tree_fields() -> tree::fields<node> {
ret self.get().tree;
}
}

fn new_node(+k: node_kind) -> node {
rcu::handle(node_data({tree: tree::empty(),
kind: k,
mut box: none}))
}

29 changes: 1 addition & 28 deletions src/servo/layout/base.rs
@@ -1,3 +1,4 @@
import dom::base::{nk_img, node_data, node_kind, node, new_node};
import dom::rcu;
import dom::rcu::methods;
import gfx::geom;
Expand All @@ -10,40 +11,12 @@ enum box = @{
mut bounds: geom::rect<au>
};

enum node_data = {
tree: tree::fields<node>,
kind: node_kind,

// Points to the primary box. Note that there may be multiple
// boxes per DOM node.
mut box: option<box>,
};

enum node_kind {
nk_div,
nk_img(size<au>)
}

type node = rcu::handle<node_data>;

impl of tree::tree for box {
fn tree_fields() -> tree::fields<box> {
ret self.tree;
}
}

impl of tree::tree for node {
fn tree_fields() -> tree::fields<node> {
ret self.get().tree;
}
}

fn new_node(+k: node_kind) -> node {
rcu::handle(node_data({tree: tree::empty(),
kind: k,
mut box: none}))
}

fn new_box(n: node) -> box {
box(@{tree: tree::empty(),
node: n,
Expand Down

0 comments on commit e089607

Please sign in to comment.