auto merge of #1424 : pcwalton/servo/harden-layout, r=pcwalton

This changeset gets rid of the `FooView` phantom type in favor of a more brute force approach that just whitelists methods that layout is allowed to call. The set is surprisingly small now that layout isn't going to the DOM for much.

If this approach turns out not to scale, we can do something fancier, but I'd rather just have it be safe and secure first and then refactor later for programmer happiness.

r? @kmcallister
This commit is contained in:
bors-servo 2013-12-17 18:16:05 -08:00
commit 824c7ac613
103 changed files with 907 additions and 692 deletions

View file

@ -4,32 +4,33 @@
// High-level interface to CSS selector matching. // High-level interface to CSS selector matching.
use std::cell::Cell;
use std::comm;
use std::task;
use std::vec;
use std::rt;
use extra::arc::{Arc, RWArc};
use css::node_style::StyledNode; use css::node_style::StyledNode;
use layout::incremental; use layout::incremental;
use layout::util::LayoutDataAccess; use layout::util::LayoutDataAccess;
use layout::wrapper::LayoutNode;
use script::dom::node::{AbstractNode, LayoutView}; use extra::arc::{Arc, RWArc};
use std::cast;
use std::cell::Cell;
use std::comm;
use std::libc::uintptr_t;
use std::rt;
use std::task;
use std::vec;
use style::{TNode, Stylist, cascade}; use style::{TNode, Stylist, cascade};
pub trait MatchMethods { pub trait MatchMethods {
fn match_node(&self, stylist: &Stylist); fn match_node(&self, stylist: &Stylist);
fn match_subtree(&self, stylist: RWArc<Stylist>); fn match_subtree(&self, stylist: RWArc<Stylist>);
fn cascade_node(&self, parent: Option<AbstractNode<LayoutView>>); fn cascade_node(&self, parent: Option<LayoutNode>);
fn cascade_subtree(&self, parent: Option<AbstractNode<LayoutView>>); fn cascade_subtree(&self, parent: Option<LayoutNode>);
} }
impl MatchMethods for AbstractNode<LayoutView> { impl<'self> MatchMethods for LayoutNode<'self> {
fn match_node(&self, stylist: &Stylist) { fn match_node(&self, stylist: &Stylist) {
let applicable_declarations = do self.with_imm_element |element| { let applicable_declarations = do self.with_element |element| {
let style_attribute = match element.style_attribute { let style_attribute = match *element.style_attribute() {
None => None, None => None,
Some(ref style_attribute) => Some(style_attribute) Some(ref style_attribute) => Some(style_attribute)
}; };
@ -63,7 +64,20 @@ impl MatchMethods for AbstractNode<LayoutView> {
if nodes.len() > 0 { if nodes.len() > 0 {
let chan = chan.clone(); let chan = chan.clone();
let stylist = stylist.clone(); let stylist = stylist.clone();
do task::spawn_with((nodes, stylist)) |(nodes, stylist)| {
// FIXME(pcwalton): This transmute is to work around the fact that we have no
// mechanism for safe fork/join parallelism. If we had such a thing, then we could
// close over the lifetime-bounded `LayoutNode`. But we can't, so we force it with
// a transmute.
let evil: uintptr_t = unsafe {
cast::transmute(nodes)
};
do task::spawn_with((evil, stylist)) |(evil, stylist)| {
let nodes: ~[LayoutNode] = unsafe {
cast::transmute(evil)
};
let nodes = Cell::new(nodes); let nodes = Cell::new(nodes);
do stylist.read |stylist| { do stylist.read |stylist| {
for node in nodes.take().move_iter() { for node in nodes.take().move_iter() {
@ -80,7 +94,7 @@ impl MatchMethods for AbstractNode<LayoutView> {
} }
} }
fn cascade_node(&self, parent: Option<AbstractNode<LayoutView>>) { fn cascade_node(&self, parent: Option<LayoutNode>) {
let parent_style = match parent { let parent_style = match parent {
Some(ref parent) => Some(parent.style()), Some(ref parent) => Some(parent.style()),
None => None None => None
@ -111,7 +125,7 @@ impl MatchMethods for AbstractNode<LayoutView> {
} }
} }
fn cascade_subtree(&self, parent: Option<AbstractNode<LayoutView>>) { fn cascade_subtree(&self, parent: Option<LayoutNode>) {
self.cascade_node(parent); self.cascade_node(parent);
for kid in self.children() { for kid in self.children() {

View file

@ -6,10 +6,10 @@
use css::node_util::NodeUtil; use css::node_util::NodeUtil;
use layout::incremental::RestyleDamage; use layout::incremental::RestyleDamage;
use layout::wrapper::LayoutNode;
use extra::arc::Arc; use extra::arc::Arc;
use style::ComputedValues; use style::ComputedValues;
use script::dom::node::{AbstractNode, LayoutView};
/// Node mixin providing `style` method that returns a `NodeStyle` /// Node mixin providing `style` method that returns a `NodeStyle`
pub trait StyledNode { pub trait StyledNode {
@ -17,7 +17,7 @@ pub trait StyledNode {
fn restyle_damage(&self) -> RestyleDamage; fn restyle_damage(&self) -> RestyleDamage;
} }
impl StyledNode for AbstractNode<LayoutView> { impl<'self> StyledNode for LayoutNode<'self> {
#[inline] #[inline]
fn style<'a>(&'a self) -> &'a Arc<ComputedValues> { fn style<'a>(&'a self) -> &'a Arc<ComputedValues> {
self.get_css_select_results() self.get_css_select_results()

View file

@ -4,11 +4,11 @@
use layout::incremental::RestyleDamage; use layout::incremental::RestyleDamage;
use layout::util::LayoutDataAccess; use layout::util::LayoutDataAccess;
use layout::wrapper::LayoutNode;
use extra::arc::Arc; use extra::arc::Arc;
use std::cast; use std::cast;
use style::{ComputedValues, TNode}; use style::{ComputedValues, TNode};
use script::dom::node::{AbstractNode, LayoutView};
pub trait NodeUtil { pub trait NodeUtil {
fn get_css_select_results<'a>(&'a self) -> &'a Arc<ComputedValues>; fn get_css_select_results<'a>(&'a self) -> &'a Arc<ComputedValues>;
@ -18,7 +18,7 @@ pub trait NodeUtil {
fn set_restyle_damage(self, damage: RestyleDamage); fn set_restyle_damage(self, damage: RestyleDamage);
} }
impl NodeUtil for AbstractNode<LayoutView> { impl<'self> NodeUtil for LayoutNode<'self> {
/** /**
* Provides the computed style for the given node. If CSS selector * Provides the computed style for the given node. If CSS selector
* Returns the style results for the given node. If CSS selector * Returns the style results for the given node. If CSS selector

View file

@ -15,7 +15,6 @@ use gfx::display_list::{TextDisplayItemClass, TextDisplayItemFlags, ClipDisplayI
use gfx::display_list::{ClipDisplayItemClass}; use gfx::display_list::{ClipDisplayItemClass};
use gfx::font::{FontStyle, FontWeight300}; use gfx::font::{FontStyle, FontWeight300};
use gfx::text::text_run::TextRun; use gfx::text::text_run::TextRun;
use script::dom::node::{AbstractNode, LayoutView};
use servo_msg::constellation_msg::{FrameRectMsg, PipelineId, SubpageId}; use servo_msg::constellation_msg::{FrameRectMsg, PipelineId, SubpageId};
use servo_net::image::holder::ImageHolder; use servo_net::image::holder::ImageHolder;
use servo_net::local_image_cache::LocalImageCache; use servo_net::local_image_cache::LocalImageCache;
@ -40,6 +39,7 @@ use layout::flow::Flow;
use layout::flow; use layout::flow;
use layout::model::{MaybeAuto, specified}; use layout::model::{MaybeAuto, specified};
use layout::util::OpaqueNode; use layout::util::OpaqueNode;
use layout::wrapper::LayoutNode;
/// Boxes (`struct Box`) are the leaves of the layout tree. They cannot position themselves. In /// Boxes (`struct Box`) are the leaves of the layout tree. They cannot position themselves. In
/// general, boxes do not have a simple correspondence with CSS boxes in the specification: /// general, boxes do not have a simple correspondence with CSS boxes in the specification:
@ -116,12 +116,10 @@ impl ImageBoxInfo {
/// ///
/// FIXME(pcwalton): The fact that image boxes store the cache in the box makes little sense to /// FIXME(pcwalton): The fact that image boxes store the cache in the box makes little sense to
/// me. /// me.
pub fn new(node: &AbstractNode<LayoutView>, pub fn new(node: &LayoutNode, image_url: Url, local_image_cache: MutexArc<LocalImageCache>)
image_url: Url,
local_image_cache: MutexArc<LocalImageCache>)
-> ImageBoxInfo { -> ImageBoxInfo {
fn convert_length(node: &AbstractNode<LayoutView>, name: &str) -> Option<Au> { fn convert_length(node: &LayoutNode, name: &str) -> Option<Au> {
node.with_imm_element(|element| { node.with_element(|element| {
element.get_attr(None, name).and_then(|string| { element.get_attr(None, name).and_then(|string| {
let n: Option<int> = FromStr::from_str(string); let n: Option<int> = FromStr::from_str(string);
n n
@ -165,14 +163,12 @@ pub struct IframeBoxInfo {
impl IframeBoxInfo { impl IframeBoxInfo {
/// Creates the information specific to an iframe box. /// Creates the information specific to an iframe box.
pub fn new(node: &AbstractNode<LayoutView>) -> IframeBoxInfo { pub fn new(node: &LayoutNode) -> IframeBoxInfo {
node.with_imm_iframe_element(|iframe_element| { let (pipeline_id, subpage_id) = node.iframe_pipeline_and_subpage_ids();
let size = iframe_element.size.unwrap(); IframeBoxInfo {
IframeBoxInfo { pipeline_id: pipeline_id,
pipeline_id: size.pipeline_id, subpage_id: subpage_id,
subpage_id: size.subpage_id, }
}
})
} }
} }
@ -209,13 +205,11 @@ pub struct UnscannedTextBoxInfo {
impl UnscannedTextBoxInfo { impl UnscannedTextBoxInfo {
/// Creates a new instance of `UnscannedTextBoxInfo` from the given DOM node. /// Creates a new instance of `UnscannedTextBoxInfo` from the given DOM node.
pub fn new(node: &AbstractNode<LayoutView>) -> UnscannedTextBoxInfo { pub fn new(node: &LayoutNode) -> UnscannedTextBoxInfo {
node.with_imm_text(|text_node| { // FIXME(pcwalton): Don't copy text; atomically reference count it instead.
// FIXME(pcwalton): Don't copy text; atomically reference count it instead. UnscannedTextBoxInfo {
UnscannedTextBoxInfo { text: node.text(),
text: text_node.element.data.to_str(), }
}
})
} }
} }
@ -230,7 +224,7 @@ pub enum SplitBoxResult {
impl Box { impl Box {
/// Constructs a new `Box` instance. /// Constructs a new `Box` instance.
pub fn new(node: AbstractNode<LayoutView>, specific: SpecificBoxInfo) -> Box { pub fn new(node: LayoutNode, specific: SpecificBoxInfo) -> Box {
// Find the nearest ancestor element and take its style. (It should be either that node or // Find the nearest ancestor element and take its style. (It should be either that node or
// its immediate parent.) // its immediate parent.)
// //
@ -250,7 +244,7 @@ impl Box {
} }
Box { Box {
node: OpaqueNode::from_node(&node), node: OpaqueNode::from_layout_node(&node),
style: (*nearest_ancestor_element.style()).clone(), style: (*nearest_ancestor_element.style()).clone(),
position: Slot::init(Au::zero_rect()), position: Slot::init(Au::zero_rect()),
border: Slot::init(Zero::zero()), border: Slot::init(Zero::zero()),

View file

@ -30,11 +30,11 @@ use layout::flow::{Flow, FlowData, MutableFlowUtils};
use layout::inline::InlineFlow; use layout::inline::InlineFlow;
use layout::text::TextRunScanner; use layout::text::TextRunScanner;
use layout::util::LayoutDataAccess; use layout::util::LayoutDataAccess;
use layout::wrapper::{LayoutNode, PostorderNodeMutTraversal};
use script::dom::element::{HTMLIframeElementTypeId, HTMLImageElementTypeId}; use script::dom::element::{HTMLIframeElementTypeId, HTMLImageElementTypeId};
use script::dom::node::{AbstractNode, CommentNodeTypeId, DoctypeNodeTypeId}; use script::dom::node::{CommentNodeTypeId, DoctypeNodeTypeId, DocumentFragmentNodeTypeId};
use script::dom::node::{DocumentFragmentNodeTypeId, DocumentNodeTypeId, ElementNodeTypeId}; use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, TextNodeTypeId};
use script::dom::node::{LayoutView, PostorderNodeMutTraversal, TextNodeTypeId};
use servo_util::slot::Slot; use servo_util::slot::Slot;
use std::util; use std::util;
use style::computed_values::{display, float}; use style::computed_values::{display, float};
@ -198,13 +198,9 @@ impl<'self> FlowConstructor<'self> {
} }
/// Builds the `ImageBoxInfo` for the given image. This is out of line to guide inlining. /// Builds the `ImageBoxInfo` for the given image. This is out of line to guide inlining.
fn build_box_info_for_image(&mut self, node: AbstractNode<LayoutView>) -> Option<ImageBoxInfo> { fn build_box_info_for_image(&mut self, node: LayoutNode) -> Option<ImageBoxInfo> {
// FIXME(pcwalton): Don't copy URLs. // FIXME(pcwalton): Don't copy URLs.
let url = node.with_imm_image_element(|image_element| { match node.image_url() {
image_element.image.as_ref().map(|url| (*url).clone())
});
match url {
None => None, None => None,
Some(url) => { Some(url) => {
// FIXME(pcwalton): The fact that image boxes store the cache within them makes // FIXME(pcwalton): The fact that image boxes store the cache within them makes
@ -215,7 +211,7 @@ impl<'self> FlowConstructor<'self> {
} }
/// Builds a `Box` for the given node. /// Builds a `Box` for the given node.
fn build_box_for_node(&mut self, node: AbstractNode<LayoutView>) -> Box { fn build_box_for_node(&mut self, node: LayoutNode) -> Box {
let specific = match node.type_id() { let specific = match node.type_id() {
ElementNodeTypeId(HTMLImageElementTypeId) => { ElementNodeTypeId(HTMLImageElementTypeId) => {
match self.build_box_info_for_image(node) { match self.build_box_info_for_image(node) {
@ -235,10 +231,7 @@ impl<'self> FlowConstructor<'self> {
/// `#[inline(always)]` because this is performance critical and LLVM will not inline it /// `#[inline(always)]` because this is performance critical and LLVM will not inline it
/// otherwise. /// otherwise.
#[inline(always)] #[inline(always)]
fn flush_inline_boxes_to_flow(&mut self, fn flush_inline_boxes_to_flow(&mut self, boxes: ~[Box], flow: &mut ~Flow:, node: LayoutNode) {
boxes: ~[Box],
flow: &mut ~Flow:,
node: AbstractNode<LayoutView>) {
if boxes.len() > 0 { if boxes.len() > 0 {
let inline_base = FlowData::new(self.next_flow_id(), node); let inline_base = FlowData::new(self.next_flow_id(), node);
let mut inline_flow = ~InlineFlow::from_boxes(inline_base, boxes) as ~Flow:; let mut inline_flow = ~InlineFlow::from_boxes(inline_base, boxes) as ~Flow:;
@ -252,7 +245,7 @@ impl<'self> FlowConstructor<'self> {
fn flush_inline_boxes_to_flow_if_necessary(&mut self, fn flush_inline_boxes_to_flow_if_necessary(&mut self,
opt_boxes: &mut Option<~[Box]>, opt_boxes: &mut Option<~[Box]>,
flow: &mut ~Flow:, flow: &mut ~Flow:,
node: AbstractNode<LayoutView>) { node: LayoutNode) {
let opt_boxes = util::replace(opt_boxes, None); let opt_boxes = util::replace(opt_boxes, None);
if opt_boxes.len() > 0 { if opt_boxes.len() > 0 {
self.flush_inline_boxes_to_flow(opt_boxes.to_vec(), flow, node) self.flush_inline_boxes_to_flow(opt_boxes.to_vec(), flow, node)
@ -264,7 +257,7 @@ impl<'self> FlowConstructor<'self> {
/// whether {ib} splits needed to happen. /// whether {ib} splits needed to happen.
fn build_children_of_block_flow(&mut self, fn build_children_of_block_flow(&mut self,
flow: &mut ~Flow:, flow: &mut ~Flow:,
node: AbstractNode<LayoutView>) { node: LayoutNode) {
// Gather up boxes for the inline flows we might need to create. // Gather up boxes for the inline flows we might need to create.
let mut opt_boxes_for_inline_flow = None; let mut opt_boxes_for_inline_flow = None;
let mut first_box = true; let mut first_box = true;
@ -349,7 +342,7 @@ impl<'self> FlowConstructor<'self> {
/// Builds a flow for a node with `display: block`. This yields a `BlockFlow` with possibly /// Builds a flow for a node with `display: block`. This yields a `BlockFlow` with possibly
/// other `BlockFlow`s or `InlineFlow`s underneath it, depending on whether {ib} splits needed /// other `BlockFlow`s or `InlineFlow`s underneath it, depending on whether {ib} splits needed
/// to happen. /// to happen.
fn build_flow_for_block(&mut self, node: AbstractNode<LayoutView>) -> ~Flow: { fn build_flow_for_block(&mut self, node: LayoutNode) -> ~Flow: {
let base = FlowData::new(self.next_flow_id(), node); let base = FlowData::new(self.next_flow_id(), node);
let box = self.build_box_for_node(node); let box = self.build_box_for_node(node);
let mut flow = ~BlockFlow::from_box(base, box) as ~Flow:; let mut flow = ~BlockFlow::from_box(base, box) as ~Flow:;
@ -359,7 +352,7 @@ impl<'self> FlowConstructor<'self> {
/// Builds the flow for a node with `float: {left|right}`. This yields a float `BlockFlow` with /// Builds the flow for a node with `float: {left|right}`. This yields a float `BlockFlow` with
/// a `BlockFlow` underneath it. /// a `BlockFlow` underneath it.
fn build_flow_for_floated_block(&mut self, node: AbstractNode<LayoutView>, float_type: FloatType) fn build_flow_for_floated_block(&mut self, node: LayoutNode, float_type: FloatType)
-> ~Flow: { -> ~Flow: {
let base = FlowData::new(self.next_flow_id(), node); let base = FlowData::new(self.next_flow_id(), node);
let box = self.build_box_for_node(node); let box = self.build_box_for_node(node);
@ -371,7 +364,7 @@ impl<'self> FlowConstructor<'self> {
/// Concatenates the boxes of kids, adding in our own borders/padding/margins if necessary. /// Concatenates the boxes of kids, adding in our own borders/padding/margins if necessary.
/// Returns the `InlineBoxesConstructionResult`, if any. There will be no /// Returns the `InlineBoxesConstructionResult`, if any. There will be no
/// `InlineBoxesConstructionResult` if this node consisted entirely of ignorable whitespace. /// `InlineBoxesConstructionResult` if this node consisted entirely of ignorable whitespace.
fn build_boxes_for_nonreplaced_inline_content(&mut self, node: AbstractNode<LayoutView>) fn build_boxes_for_nonreplaced_inline_content(&mut self, node: LayoutNode)
-> ConstructionResult { -> ConstructionResult {
let mut opt_inline_block_splits = None; let mut opt_inline_block_splits = None;
let mut opt_box_accumulator = None; let mut opt_box_accumulator = None;
@ -437,8 +430,7 @@ impl<'self> FlowConstructor<'self> {
/// Creates an `InlineBoxesConstructionResult` for replaced content. Replaced content doesn't /// Creates an `InlineBoxesConstructionResult` for replaced content. Replaced content doesn't
/// render its children, so this just nukes a child's boxes and creates a `Box`. /// render its children, so this just nukes a child's boxes and creates a `Box`.
fn build_boxes_for_replaced_inline_content(&mut self, node: AbstractNode<LayoutView>) fn build_boxes_for_replaced_inline_content(&mut self, node: LayoutNode) -> ConstructionResult {
-> ConstructionResult {
for kid in node.children() { for kid in node.children() {
kid.set_flow_construction_result(NoConstructionResult) kid.set_flow_construction_result(NoConstructionResult)
} }
@ -454,7 +446,7 @@ impl<'self> FlowConstructor<'self> {
/// Builds one or more boxes for a node with `display: inline`. This yields an /// Builds one or more boxes for a node with `display: inline`. This yields an
/// `InlineBoxesConstructionResult`. /// `InlineBoxesConstructionResult`.
fn build_boxes_for_inline(&mut self, node: AbstractNode<LayoutView>) -> ConstructionResult { fn build_boxes_for_inline(&mut self, node: LayoutNode) -> ConstructionResult {
// Is this node replaced content? // Is this node replaced content?
if !node.is_replaced_content() { if !node.is_replaced_content() {
// Go to a path that concatenates our kids' boxes. // Go to a path that concatenates our kids' boxes.
@ -470,7 +462,7 @@ impl<'self> PostorderNodeMutTraversal for FlowConstructor<'self> {
// `#[inline(always)]` because this is always called from the traversal function and for some // `#[inline(always)]` because this is always called from the traversal function and for some
// reason LLVM's inlining heuristics go awry here. // reason LLVM's inlining heuristics go awry here.
#[inline(always)] #[inline(always)]
fn process(&mut self, node: AbstractNode<LayoutView>) -> bool { fn process(&mut self, node: LayoutNode) -> bool {
// Get the `display` property for this node, and determine whether this node is floated. // Get the `display` property for this node, and determine whether this node is floated.
let (display, float) = match node.type_id() { let (display, float) = match node.type_id() {
ElementNodeTypeId(_) => { ElementNodeTypeId(_) => {
@ -534,13 +526,9 @@ trait NodeUtils {
/// Replaces the flow construction result in a node with `NoConstructionResult` and returns the /// Replaces the flow construction result in a node with `NoConstructionResult` and returns the
/// old value. /// old value.
fn swap_out_construction_result(self) -> ConstructionResult; fn swap_out_construction_result(self) -> ConstructionResult;
/// Returns true if this node consists entirely of ignorable whitespace and false otherwise.
/// Ignorable whitespace is defined as whitespace that would be removed per CSS 2.1 § 16.6.1.
fn is_ignorable_whitespace(self) -> bool;
} }
impl NodeUtils for AbstractNode<LayoutView> { impl<'self> NodeUtils for LayoutNode<'self> {
fn is_replaced_content(self) -> bool { fn is_replaced_content(self) -> bool {
match self.type_id() { match self.type_id() {
TextNodeTypeId | TextNodeTypeId |
@ -570,10 +558,6 @@ impl NodeUtils for AbstractNode<LayoutView> {
None => fail!("no layout data"), None => fail!("no layout data"),
} }
} }
fn is_ignorable_whitespace(self) -> bool {
self.is_text() && self.with_imm_text(|text| text.element.data.is_whitespace())
}
} }
/// Strips ignorable whitespace from the start of a list of boxes. /// Strips ignorable whitespace from the start of a list of boxes.

View file

@ -5,8 +5,7 @@
//! Code for managing the layout data in the DOM. //! Code for managing the layout data in the DOM.
use layout::util::{LayoutData, LayoutDataAccess}; use layout::util::{LayoutData, LayoutDataAccess};
use layout::wrapper::LayoutNode;
use script::dom::node::{AbstractNode, LayoutView};
/// Functionality useful for querying the layout-specific data on DOM nodes. /// Functionality useful for querying the layout-specific data on DOM nodes.
pub trait LayoutAuxMethods { pub trait LayoutAuxMethods {
@ -14,7 +13,7 @@ pub trait LayoutAuxMethods {
fn initialize_style_for_subtree(self); fn initialize_style_for_subtree(self);
} }
impl LayoutAuxMethods for AbstractNode<LayoutView> { impl<'self> LayoutAuxMethods for LayoutNode<'self> {
/// Resets layout data and styles for the node. /// Resets layout data and styles for the node.
/// ///
/// FIXME(pcwalton): Do this as part of box building instead of in a traversal. /// FIXME(pcwalton): Do this as part of box building instead of in a traversal.

View file

@ -33,13 +33,13 @@ use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData};
use layout::float_context::{FloatContext, Invalid}; use layout::float_context::{FloatContext, Invalid};
use layout::incremental::RestyleDamage; use layout::incremental::RestyleDamage;
use layout::inline::InlineFlow; use layout::inline::InlineFlow;
use layout::wrapper::LayoutNode;
use extra::dlist::{DList, DListIterator, MutDListIterator}; use extra::dlist::{DList, DListIterator, MutDListIterator};
use extra::container::Deque; use extra::container::Deque;
use geom::point::Point2D; use geom::point::Point2D;
use geom::rect::Rect; use geom::rect::Rect;
use gfx::display_list::{ClipDisplayItemClass, DisplayList}; use gfx::display_list::{ClipDisplayItemClass, DisplayList};
use script::dom::node::{AbstractNode, LayoutView};
use servo_util::geometry::Au; use servo_util::geometry::Au;
use std::cast; use std::cast;
use std::cell::Cell; use std::cell::Cell;
@ -382,7 +382,6 @@ impl FlowFlags {
/// FIXME: We need a naming convention for pseudo-inheritance like this. How about /// FIXME: We need a naming convention for pseudo-inheritance like this. How about
/// `CommonFlowInfo`? /// `CommonFlowInfo`?
pub struct FlowData { pub struct FlowData {
node: AbstractNode<LayoutView>,
restyle_damage: RestyleDamage, restyle_damage: RestyleDamage,
/// The children of this flow. /// The children of this flow.
@ -433,10 +432,9 @@ impl Iterator<@Box> for BoxIterator {
impl FlowData { impl FlowData {
#[inline] #[inline]
pub fn new(id: int, node: AbstractNode<LayoutView>) -> FlowData { pub fn new(id: int, node: LayoutNode) -> FlowData {
let style = node.style(); let style = node.style();
FlowData { FlowData {
node: node,
restyle_damage: node.restyle_damage(), restyle_damage: node.restyle_damage(),
children: DList::new(), children: DList::new(),

View file

@ -441,10 +441,11 @@ pub struct InlineFlow {
// these ranges are disjoint, and are the result of inline layout. // these ranges are disjoint, and are the result of inline layout.
// also some metadata used for positioning lines // also some metadata used for positioning lines
lines: ~[LineBox], lines: ~[LineBox],
// vec of ranges into boxes that represent elements. These ranges // vec of ranges into boxes that represent elements. These ranges
// must be well-nested, and are only related to the content of // must be well-nested, and are only related to the content of
// boxes (not lines). Ranges are only kept for non-leaf elements. // boxes (not lines). Ranges are only kept for non-leaf elements.
elems: ElementMapping elems: ElementMapping,
} }
impl InlineFlow { impl InlineFlow {

View file

@ -17,6 +17,7 @@ use layout::flow::{PostorderFlowTraversal};
use layout::flow; use layout::flow;
use layout::incremental::{RestyleDamage}; use layout::incremental::{RestyleDamage};
use layout::util::{LayoutData, LayoutDataAccess, OpaqueNode}; use layout::util::{LayoutData, LayoutDataAccess, OpaqueNode};
use layout::wrapper::LayoutNode;
use extra::arc::{Arc, RWArc, MutexArc}; use extra::arc::{Arc, RWArc, MutexArc};
use geom::point::Point2D; use geom::point::Point2D;
@ -28,7 +29,7 @@ use gfx::opts::Opts;
use gfx::render_task::{RenderMsg, RenderChan, RenderLayer}; use gfx::render_task::{RenderMsg, RenderChan, RenderLayer};
use gfx::{render_task, color}; use gfx::{render_task, color};
use script::dom::event::ReflowEvent; use script::dom::event::ReflowEvent;
use script::dom::node::{AbstractNode, LayoutDataRef, LayoutView, ElementNodeTypeId}; use script::dom::node::{AbstractNode, ElementNodeTypeId, LayoutDataRef};
use script::dom::element::{HTMLBodyElementTypeId, HTMLHtmlElementTypeId}; use script::dom::element::{HTMLBodyElementTypeId, HTMLHtmlElementTypeId};
use script::layout_interface::{AddStylesheetMsg, ContentBoxQuery}; use script::layout_interface::{AddStylesheetMsg, ContentBoxQuery};
use script::layout_interface::{ContentBoxesQuery, ContentBoxesResponse, ExitNowMsg, LayoutQuery}; use script::layout_interface::{ContentBoxesQuery, ContentBoxesResponse, ExitNowMsg, LayoutQuery};
@ -358,8 +359,7 @@ impl LayoutTask {
/// is intertwined with selector matching, making it difficult to compare directly. It is /// is intertwined with selector matching, making it difficult to compare directly. It is
/// marked `#[inline(never)]` to aid benchmarking in sampling profilers. /// marked `#[inline(never)]` to aid benchmarking in sampling profilers.
#[inline(never)] #[inline(never)]
fn construct_flow_tree(&self, layout_context: &mut LayoutContext, node: AbstractNode<LayoutView>) fn construct_flow_tree(&self, layout_context: &mut LayoutContext, node: LayoutNode) -> ~Flow: {
-> ~Flow: {
node.traverse_postorder_mut(&mut FlowConstructor::init(layout_context)); node.traverse_postorder_mut(&mut FlowConstructor::init(layout_context));
let result = match *node.mutate_layout_data().ptr { let result = match *node.mutate_layout_data().ptr {
@ -401,7 +401,7 @@ impl LayoutTask {
/// The high-level routine that performs layout tasks. /// The high-level routine that performs layout tasks.
fn handle_reflow(&mut self, data: &Reflow) { fn handle_reflow(&mut self, data: &Reflow) {
// FIXME: Isolate this transmutation into a "bridge" module. // FIXME: Isolate this transmutation into a "bridge" module.
let node: &AbstractNode<LayoutView> = unsafe { let node: &LayoutNode = unsafe {
transmute(&data.document_root) transmute(&data.document_root)
}; };
@ -534,7 +534,7 @@ impl LayoutTask {
// The neat thing here is that in order to answer the following two queries we only // The neat thing here is that in order to answer the following two queries we only
// need to compare nodes for equality. Thus we can safely work only with `OpaqueNode`. // need to compare nodes for equality. Thus we can safely work only with `OpaqueNode`.
ContentBoxQuery(node, reply_chan) => { ContentBoxQuery(node, reply_chan) => {
let node = OpaqueNode::from_node(&node); let node = OpaqueNode::from_script_node(&node);
fn union_boxes_for_node<'a>( fn union_boxes_for_node<'a>(
accumulator: &mut Option<Rect<Au>>, accumulator: &mut Option<Rect<Au>>,
@ -557,7 +557,7 @@ impl LayoutTask {
reply_chan.send(ContentBoxResponse(rect.unwrap_or(Au::zero_rect()))) reply_chan.send(ContentBoxResponse(rect.unwrap_or(Au::zero_rect())))
} }
ContentBoxesQuery(node, reply_chan) => { ContentBoxesQuery(node, reply_chan) => {
let node = OpaqueNode::from_node(&node); let node = OpaqueNode::from_script_node(&node);
fn add_boxes_for_node<'a>( fn add_boxes_for_node<'a>(
accumulator: &mut ~[Rect<Au>], accumulator: &mut ~[Rect<Au>],
@ -608,8 +608,8 @@ impl LayoutTask {
// incremental flow construction could create this. Paranoid validation // incremental flow construction could create this. Paranoid validation
// against the set of valid nodes should occur in the script task to // against the set of valid nodes should occur in the script task to
// ensure that this is a valid address instead of transmuting here. // ensure that this is a valid address instead of transmuting here.
let node: AbstractNode<LayoutView> = unsafe { let node: AbstractNode = unsafe {
item.base().extra.to_node() item.base().extra.to_script_node()
}; };
let resp = Some(HitTestResponse(node)); let resp = Some(HitTestResponse(node));
return resp; return resp;

View file

@ -3,15 +3,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Text layout. //! Text layout.
use extra::arc::Arc;
use layout::box::{Box, ScannedTextBox, ScannedTextBoxInfo, UnscannedTextBox}; use layout::box::{Box, ScannedTextBox, ScannedTextBoxInfo, UnscannedTextBox};
use layout::context::LayoutContext; use layout::context::LayoutContext;
use layout::flow::Flow; use layout::flow::Flow;
use extra::arc::Arc;
use gfx::text::text_run::TextRun; use gfx::text::text_run::TextRun;
use gfx::text::util::{CompressWhitespaceNewline, transform_text}; use gfx::text::util::{CompressWhitespaceNewline, transform_text};
use std::vec;
use servo_util::range::Range; use servo_util::range::Range;
use std::vec;
/// A stack-allocated object for scanning an inline flow into `TextRun`-containing `TextBox`es. /// A stack-allocated object for scanning an inline flow into `TextRun`-containing `TextBox`es.
struct TextRunScanner { struct TextRunScanner {

View file

@ -4,9 +4,10 @@
use layout::box::Box; use layout::box::Box;
use layout::construct::{ConstructionResult, NoConstructionResult}; use layout::construct::{ConstructionResult, NoConstructionResult};
use layout::wrapper::LayoutNode;
use extra::arc::Arc; use extra::arc::Arc;
use script::dom::node::{AbstractNode, LayoutView}; use script::dom::node::AbstractNode;
use servo_util::range::Range; use servo_util::range::Range;
use servo_util::slot::{MutSlotRef, SlotRef}; use servo_util::slot::{MutSlotRef, SlotRef};
use std::cast; use std::cast;
@ -163,23 +164,23 @@ pub trait LayoutDataAccess {
fn mutate_layout_data<'a>(&'a self) -> MutSlotRef<'a,Option<~LayoutData>>; fn mutate_layout_data<'a>(&'a self) -> MutSlotRef<'a,Option<~LayoutData>>;
} }
impl LayoutDataAccess for AbstractNode<LayoutView> { impl<'self> LayoutDataAccess for LayoutNode<'self> {
#[inline(always)] #[inline(always)]
unsafe fn borrow_layout_data_unchecked<'a>(&'a self) -> &'a Option<~LayoutData> { unsafe fn borrow_layout_data_unchecked<'a>(&'a self) -> &'a Option<~LayoutData> {
cast::transmute(self.node().layout_data.borrow_unchecked()) cast::transmute(self.get().layout_data.borrow_unchecked())
} }
#[inline(always)] #[inline(always)]
fn borrow_layout_data<'a>(&'a self) -> SlotRef<'a,Option<~LayoutData>> { fn borrow_layout_data<'a>(&'a self) -> SlotRef<'a,Option<~LayoutData>> {
unsafe { unsafe {
cast::transmute(self.node().layout_data.borrow()) cast::transmute(self.get().layout_data.borrow())
} }
} }
#[inline(always)] #[inline(always)]
fn mutate_layout_data<'a>(&'a self) -> MutSlotRef<'a,Option<~LayoutData>> { fn mutate_layout_data<'a>(&'a self) -> MutSlotRef<'a,Option<~LayoutData>> {
unsafe { unsafe {
cast::transmute(self.node().layout_data.mutate()) cast::transmute(self.get().layout_data.mutate())
} }
} }
} }
@ -193,25 +194,24 @@ impl LayoutDataAccess for AbstractNode<LayoutView> {
#[deriving(Clone, Eq)] #[deriving(Clone, Eq)]
pub struct OpaqueNode(uintptr_t); pub struct OpaqueNode(uintptr_t);
impl<T> Equiv<AbstractNode<T>> for OpaqueNode {
fn equiv(&self, node: &AbstractNode<T>) -> bool {
unsafe {
**self == cast::transmute_copy::<AbstractNode<T>,uintptr_t>(node)
}
}
}
impl OpaqueNode { impl OpaqueNode {
/// Converts a DOM node to an `OpaqueNode`. /// Converts a DOM node (layout view) to an `OpaqueNode`.
pub fn from_node<T>(node: &AbstractNode<T>) -> OpaqueNode { pub fn from_layout_node(node: &LayoutNode) -> OpaqueNode {
unsafe { unsafe {
OpaqueNode(cast::transmute_copy(node)) OpaqueNode(cast::transmute_copy(node))
} }
} }
/// Unsafely converts an `OpaqueNode` to a DOM node. Use this only if you absolutely know what /// Converts a DOM node (script view) to an `OpaqueNode`.
/// you're doing. pub fn from_script_node(node: &AbstractNode) -> OpaqueNode {
pub unsafe fn to_node<T>(&self) -> AbstractNode<T> { unsafe {
OpaqueNode(cast::transmute_copy(node))
}
}
/// Unsafely converts an `OpaqueNode` to a DOM node (script view). Use this only if you
/// absolutely know what you're doing.
pub unsafe fn to_script_node(&self) -> AbstractNode {
cast::transmute(**self) cast::transmute(**self)
} }

View file

@ -0,0 +1,397 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A safe wrapper for DOM nodes that prevents layout from mutating the DOM, from letting DOM nodes
//! escape, and from generally doing anything that it isn't supposed to. This is accomplished via
//! a simple whitelist of allowed operations.
//!
//! As a security wrapper is only as good as its whitelist, be careful when adding operations to
//! this list. The cardinal rules are:
//!
//! (1) Layout is not allowed to mutate the DOM.
//!
//! (2) Layout is not allowed to see anything with `Abstract` in the name, because it could hang
//! onto these objects and cause use-after-free.
use extra::url::Url;
use script::dom::element::{Element, HTMLAreaElementTypeId, HTMLAnchorElementTypeId};
use script::dom::element::{HTMLLinkElementTypeId};
use script::dom::htmliframeelement::HTMLIFrameElement;
use script::dom::htmlimageelement::HTMLImageElement;
use script::dom::node::{AbstractNode, DocumentNodeTypeId, ElementNodeTypeId, Node, NodeTypeId};
use script::dom::text::Text;
use servo_msg::constellation_msg::{PipelineId, SubpageId};
use std::cast;
use style::{PropertyDeclarationBlock, TElement, TNode};
/// A wrapper so that layout can access only the methods that it should have access to. Layout must
/// only ever see these and must never see instances of `AbstractNode`.
#[deriving(Clone, Eq)]
pub struct LayoutNode<'self> {
/// The wrapped node.
priv node: AbstractNode,
/// Being chained to a value prevents `LayoutNode`s from escaping.
priv chain: &'self (),
}
impl<'self> LayoutNode<'self> {
/// Creates a new layout node, scoped to the given closure.
pub unsafe fn with_layout_node<R>(node: AbstractNode, f: &fn<'a>(LayoutNode<'a>) -> R) -> R {
let heavy_iron_ball = ();
f(LayoutNode {
node: node,
chain: &heavy_iron_ball,
})
}
/// Creates a new layout node with the same lifetime as this layout node.
unsafe fn new_with_this_lifetime(&self, node: AbstractNode) -> LayoutNode<'self> {
LayoutNode {
node: node,
chain: self.chain,
}
}
/// Returns the interior of this node as a `Node`. This is highly unsafe for layout to call
/// and as such is marked `unsafe`.
pub unsafe fn get<'a>(&'a self) -> &'a Node {
cast::transmute(self.node.node())
}
/// Returns the first child of this node.
pub fn first_child(&self) -> Option<LayoutNode<'self>> {
unsafe {
self.node.first_child().map(|node| self.new_with_this_lifetime(node))
}
}
/// Returns the first child of this node.
pub fn last_child(&self) -> Option<LayoutNode<'self>> {
unsafe {
self.node.last_child().map(|node| self.new_with_this_lifetime(node))
}
}
/// Iterates over this node and all its descendants, in preorder.
///
/// FIXME(pcwalton): Terribly inefficient. We should use parallelism.
pub fn traverse_preorder(&self) -> LayoutTreeIterator<'self> {
let mut nodes = ~[];
gather_layout_nodes(self, &mut nodes, false);
LayoutTreeIterator::new(nodes)
}
/// Returns an iterator over this node's children.
pub fn children(&self) -> LayoutNodeChildrenIterator<'self> {
LayoutNodeChildrenIterator {
current_node: self.first_child(),
}
}
/// Returns the type ID of this node. Fails if this node is borrowed mutably.
pub fn type_id(&self) -> NodeTypeId {
self.node.type_id()
}
/// If this is an image element, returns its URL. If this is not an image element, fails.
///
/// FIXME(pcwalton): Don't copy URLs.
pub fn image_url(&self) -> Option<Url> {
unsafe {
self.with_image_element(|image_element| {
image_element.image.as_ref().map(|url| (*url).clone())
})
}
}
/// Downcasts this node to an image element and calls the given closure.
///
/// FIXME(pcwalton): RAII.
unsafe fn with_image_element<R>(self, f: &fn(&HTMLImageElement) -> R) -> R {
if !self.node.is_image_element() {
fail!(~"node is not an image element");
}
self.node.transmute(f)
}
/// If this node is an iframe element, returns its pipeline and subpage IDs. If this node is
/// not an iframe element, fails.
pub fn iframe_pipeline_and_subpage_ids(&self) -> (PipelineId, SubpageId) {
unsafe {
self.with_iframe_element(|iframe_element| {
let size = iframe_element.size.unwrap();
(size.pipeline_id, size.subpage_id)
})
}
}
/// Downcasts this node to an iframe element and calls the given closure.
///
/// FIXME(pcwalton): RAII.
unsafe fn with_iframe_element<R>(self, f: &fn(&HTMLIFrameElement) -> R) -> R {
if !self.node.is_iframe_element() {
fail!(~"node is not an iframe element");
}
self.node.transmute(f)
}
/// Returns true if this node is a text node or false otherwise.
#[inline]
pub fn is_text(self) -> bool {
self.node.is_text()
}
/// Returns true if this node consists entirely of ignorable whitespace and false otherwise.
/// Ignorable whitespace is defined as whitespace that would be removed per CSS 2.1 § 16.6.1.
pub fn is_ignorable_whitespace(&self) -> bool {
unsafe {
self.is_text() && self.with_text(|text| text.element.data.is_whitespace())
}
}
/// If this is a text node, copies out the text. If this is not a text node, fails.
///
/// FIXME(pcwalton): Don't copy text. Atomically reference count instead.
pub fn text(&self) -> ~str {
unsafe {
self.with_text(|text| text.element.data.to_str())
}
}
/// Downcasts this node to a text node and calls the given closure.
///
/// FIXME(pcwalton): RAII.
unsafe fn with_text<R>(self, f: &fn(&Text) -> R) -> R {
self.node.with_imm_text(f)
}
/// Dumps this node tree, for debugging.
pub fn dump(&self) {
self.node.dump()
}
/// Returns a string that describes this node, for debugging.
pub fn debug_str(&self) -> ~str {
self.node.debug_str()
}
/// Traverses the tree in postorder.
///
/// TODO(pcwalton): Offer a parallel version with a compatible API.
pub fn traverse_postorder<T:PostorderNodeTraversal>(self, traversal: &T) -> bool {
if traversal.should_prune(self) {
return true
}
let mut opt_kid = self.first_child();
loop {
match opt_kid {
None => break,
Some(kid) => {
if !kid.traverse_postorder(traversal) {
return false
}
opt_kid = kid.next_sibling()
}
}
}
traversal.process(self)
}
/// Traverses the tree in postorder.
///
/// TODO(pcwalton): Offer a parallel version with a compatible API.
pub fn traverse_postorder_mut<T:PostorderNodeMutTraversal>(mut self, traversal: &mut T)
-> bool {
if traversal.should_prune(self) {
return true
}
let mut opt_kid = self.first_child();
loop {
match opt_kid {
None => break,
Some(kid) => {
if !kid.traverse_postorder_mut(traversal) {
return false
}
opt_kid = kid.next_sibling()
}
}
}
traversal.process(self)
}
}
impl<'self> TNode<LayoutElement<'self>> for LayoutNode<'self> {
fn parent_node(&self) -> Option<LayoutNode<'self>> {
unsafe {
self.node.node().parent_node.map(|node| self.new_with_this_lifetime(node))
}
}
fn prev_sibling(&self) -> Option<LayoutNode<'self>> {
unsafe {
self.node.node().prev_sibling.map(|node| self.new_with_this_lifetime(node))
}
}
fn next_sibling(&self) -> Option<LayoutNode<'self>> {
unsafe {
self.node.node().next_sibling.map(|node| self.new_with_this_lifetime(node))
}
}
fn is_element(&self) -> bool {
match self.node.type_id() {
ElementNodeTypeId(*) => true,
_ => false
}
}
fn is_document(&self) -> bool {
match self.node.type_id() {
DocumentNodeTypeId(*) => true,
_ => false
}
}
/// If this is an element, accesses the element data. Fails if this is not an element node.
#[inline]
fn with_element<R>(&self, f: &fn(&LayoutElement<'self>) -> R) -> R {
self.node.with_imm_element(|element| {
// FIXME(pcwalton): Workaround until Rust gets multiple lifetime parameters on
// implementations.
unsafe {
f(&LayoutElement {
element: cast::transmute_region(element),
})
}
})
}
}
pub struct LayoutNodeChildrenIterator<'self> {
priv current_node: Option<LayoutNode<'self>>,
}
impl<'self> Iterator<LayoutNode<'self>> for LayoutNodeChildrenIterator<'self> {
fn next(&mut self) -> Option<LayoutNode<'self>> {
let node = self.current_node;
self.current_node = do self.current_node.and_then |node| {
node.next_sibling()
};
node
}
}
// FIXME: Do this without precomputing a vector of refs.
// Easy for preorder; harder for postorder.
//
// FIXME(pcwalton): Parallelism! Eventually this should just be nuked.
pub struct LayoutTreeIterator<'self> {
priv nodes: ~[LayoutNode<'self>],
priv index: uint,
}
impl<'self> LayoutTreeIterator<'self> {
fn new(nodes: ~[LayoutNode<'self>]) -> LayoutTreeIterator<'self> {
LayoutTreeIterator {
nodes: nodes,
index: 0,
}
}
}
impl<'self> Iterator<LayoutNode<'self>> for LayoutTreeIterator<'self> {
fn next(&mut self) -> Option<LayoutNode<'self>> {
if self.index >= self.nodes.len() {
None
} else {
let v = self.nodes[self.index].clone();
self.index += 1;
Some(v)
}
}
}
/// FIXME(pcwalton): This is super inefficient.
fn gather_layout_nodes<'a>(cur: &LayoutNode<'a>, refs: &mut ~[LayoutNode<'a>], postorder: bool) {
if !postorder {
refs.push(cur.clone());
}
for kid in cur.children() {
gather_layout_nodes(&kid, refs, postorder)
}
if postorder {
refs.push(cur.clone());
}
}
/// A bottom-up, parallelizable traversal.
pub trait PostorderNodeTraversal {
/// The operation to perform. Return true to continue or false to stop.
fn process<'a>(&'a self, node: LayoutNode<'a>) -> bool;
/// Returns true if this node should be pruned. If this returns true, we skip the operation
/// entirely and do not process any descendant nodes. This is called *before* child nodes are
/// visited. The default implementation never prunes any nodes.
fn should_prune<'a>(&'a self, _node: LayoutNode<'a>) -> bool {
false
}
}
/// A bottom-up, parallelizable traversal.
pub trait PostorderNodeMutTraversal {
/// The operation to perform. Return true to continue or false to stop.
fn process<'a>(&'a mut self, node: LayoutNode<'a>) -> bool;
/// Returns true if this node should be pruned. If this returns true, we skip the operation
/// entirely and do not process any descendant nodes. This is called *before* child nodes are
/// visited. The default implementation never prunes any nodes.
fn should_prune<'a>(&'a self, _node: LayoutNode<'a>) -> bool {
false
}
}
/// A wrapper around elements that ensures layout can only ever access safe properties.
pub struct LayoutElement<'self> {
priv element: &'self Element,
}
impl<'self> LayoutElement<'self> {
pub fn style_attribute(&self) -> &'self Option<PropertyDeclarationBlock> {
&self.element.style_attribute
}
}
impl<'self> TElement for LayoutElement<'self> {
fn get_local_name<'a>(&'a self) -> &'a str {
self.element.tag_name.as_slice()
}
fn get_namespace_url<'a>(&'a self) -> &'a str {
self.element.namespace.to_str().unwrap_or("")
}
fn get_attr(&self, ns_url: Option<~str>, name: &str) -> Option<~str> {
self.element.get_attr(ns_url, name)
}
fn get_link(&self) -> Option<~str> {
// FIXME: This is HTML only.
match self.element.node.type_id {
// http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#
// selector-link
ElementNodeTypeId(HTMLAnchorElementTypeId) |
ElementNodeTypeId(HTMLAreaElementTypeId) |
ElementNodeTypeId(HTMLLinkElementTypeId) => self.get_attr(None, "href"),
_ => None,
}
}
}

View file

@ -88,6 +88,7 @@ pub mod layout {
pub mod text; pub mod text;
pub mod util; pub mod util;
pub mod incremental; pub mod incremental;
pub mod wrapper;
mod extra; mod extra;
} }

View file

@ -5,18 +5,17 @@
use dom::attr::Attr; use dom::attr::Attr;
use dom::bindings::codegen::AttrListBinding; use dom::bindings::codegen::AttrListBinding;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::node::{AbstractNode, ScriptView}; use dom::node::{AbstractNode};
use dom::window::Window; use dom::window::Window;
pub struct AttrList { pub struct AttrList {
reflector_: Reflector, reflector_: Reflector,
window: @mut Window, window: @mut Window,
owner: AbstractNode<ScriptView> owner: AbstractNode,
} }
impl AttrList { impl AttrList {
pub fn new_inherited(window: @mut Window, pub fn new_inherited(window: @mut Window, elem: AbstractNode) -> AttrList {
elem: AbstractNode<ScriptView>) -> AttrList {
AttrList { AttrList {
reflector_: Reflector::new(), reflector_: Reflector::new(),
window: window, window: window,
@ -24,7 +23,7 @@ impl AttrList {
} }
} }
pub fn new(window: @mut Window, elem: AbstractNode<ScriptView>) -> @mut AttrList { pub fn new(window: @mut Window, elem: AbstractNode) -> @mut AttrList {
reflect_dom_object(@mut AttrList::new_inherited(window, elem), reflect_dom_object(@mut AttrList::new_inherited(window, elem),
window, AttrListBinding::Wrap) window, AttrListBinding::Wrap)
} }

View file

@ -121,7 +121,7 @@ DOMInterfaces = {
}], }],
'CharacterData': { 'CharacterData': {
'nativeType': 'AbstractNode<ScriptView>', 'nativeType': 'AbstractNode',
'concreteType': 'CharacterData', 'concreteType': 'CharacterData',
'pointerType': '' 'pointerType': ''
}, },
@ -182,7 +182,7 @@ DOMInterfaces = {
}], }],
'Element': { 'Element': {
'nativeType': 'AbstractNode<ScriptView>', 'nativeType': 'AbstractNode',
'pointerType': '', 'pointerType': '',
'needsAbstract': ['getClientRects', 'getBoundingClientRect', 'setAttribute', 'setAttributeNS', 'id', 'attributes'] 'needsAbstract': ['getClientRects', 'getBoundingClientRect', 'setAttribute', 'setAttributeNS', 'id', 'attributes']
}, },
@ -239,7 +239,7 @@ DOMInterfaces = {
}, },
'HTMLFormElement': { 'HTMLFormElement': {
'nativeType': 'AbstractNode<ScriptView>', 'nativeType': 'AbstractNode',
'pointerType': '', 'pointerType': '',
'register': False 'register': False
}, },
@ -302,8 +302,8 @@ DOMInterfaces = {
}, },
'Node': { 'Node': {
'nativeType': 'AbstractNode<ScriptView>', 'nativeType': 'AbstractNode',
'concreteType': 'Node<ScriptView>', 'concreteType': 'Node',
'pointerType': '', 'pointerType': '',
'needsAbstract': [ 'needsAbstract': [
'appendChild', 'appendChild',
@ -574,7 +574,7 @@ def addExternalIface(iface, nativeType=None, headerFile=None, pointerType=None):
def addHTMLElement(element, concrete=None, needsAbstract=[]): def addHTMLElement(element, concrete=None, needsAbstract=[]):
DOMInterfaces[element] = { DOMInterfaces[element] = {
'nativeType': 'AbstractNode<ScriptView>', 'nativeType': 'AbstractNode',
'pointerType': '', 'pointerType': '',
'concreteType': concrete if concrete else element, 'concreteType': concrete if concrete else element,
'customTrace': 'trace', 'customTrace': 'trace',

View file

@ -5161,7 +5161,7 @@ class CGBindingRoot(CGThing):
'dom::bindings::proxyhandler', 'dom::bindings::proxyhandler',
'dom::bindings::proxyhandler::*', 'dom::bindings::proxyhandler::*',
'dom::document::AbstractDocument', 'dom::document::AbstractDocument',
'dom::node::{AbstractNode, ScriptView}', 'dom::node::AbstractNode',
'dom::eventtarget::AbstractEventTarget', 'dom::eventtarget::AbstractEventTarget',
'dom::event::AbstractEvent', 'dom::event::AbstractEvent',
'servo_util::vec::zip_copies', 'servo_util::vec::zip_copies',

View file

@ -4,14 +4,14 @@
use dom::bindings::utils::{Reflectable, Reflector, Traceable}; use dom::bindings::utils::{Reflectable, Reflector, Traceable};
use dom::types::*; use dom::types::*;
use dom::node::{AbstractNode, ScriptView}; use dom::node::AbstractNode;
use std::cast; use std::cast;
use std::libc; use std::libc;
use std::ptr; use std::ptr;
use js::jsapi::{JSTracer, JSTRACE_OBJECT, JS_CallTracer}; use js::jsapi::{JSTracer, JSTRACE_OBJECT, JS_CallTracer};
impl Reflectable for AbstractNode<ScriptView> { impl Reflectable for AbstractNode {
fn reflector<'a>(&'a self) -> &'a Reflector { fn reflector<'a>(&'a self) -> &'a Reflector {
self.node().reflector() self.node().reflector()
} }
@ -21,10 +21,10 @@ impl Reflectable for AbstractNode<ScriptView> {
} }
} }
impl Traceable for Node<ScriptView> { impl Traceable for Node {
fn trace(&self, tracer: *mut JSTracer) { fn trace(&self, tracer: *mut JSTracer) {
#[fixed_stack_segment] #[fixed_stack_segment]
fn trace_node(tracer: *mut JSTracer, node: Option<AbstractNode<ScriptView>>, name: &str) { fn trace_node(tracer: *mut JSTracer, node: Option<AbstractNode>, name: &str) {
if node.is_none() { if node.is_none() {
return; return;
} }

View file

@ -7,10 +7,10 @@
use dom::bindings::utils::{DOMString, ErrorResult, Fallible}; use dom::bindings::utils::{DOMString, ErrorResult, Fallible};
use dom::bindings::utils::{Reflectable, Reflector}; use dom::bindings::utils::{Reflectable, Reflector};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::node::{Node, NodeTypeId, ScriptView}; use dom::node::{Node, NodeTypeId};
pub struct CharacterData { pub struct CharacterData {
node: Node<ScriptView>, node: Node,
data: ~str data: ~str
} }

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::CommentBinding;
use dom::bindings::utils::{DOMString, Fallible}; use dom::bindings::utils::{DOMString, Fallible};
use dom::characterdata::CharacterData; use dom::characterdata::CharacterData;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::node::{AbstractNode, ScriptView, CommentNodeTypeId, Node}; use dom::node::{AbstractNode, CommentNodeTypeId, Node};
use dom::window::Window; use dom::window::Window;
/// An HTML comment. /// An HTML comment.
@ -21,12 +21,12 @@ impl Comment {
} }
} }
pub fn new(text: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(text: ~str, document: AbstractDocument) -> AbstractNode {
let node = Comment::new_inherited(text, document); let node = Comment::new_inherited(text, document);
Node::reflect_node(@mut node, document, CommentBinding::Wrap) Node::reflect_node(@mut node, document, CommentBinding::Wrap)
} }
pub fn Constructor(owner: @mut Window, data: DOMString) -> Fallible<AbstractNode<ScriptView>> { pub fn Constructor(owner: @mut Window, data: DOMString) -> Fallible<AbstractNode> {
Ok(Comment::new(data, owner.Document())) Ok(Comment::new(data, owner.Document()))
} }
} }

View file

@ -15,7 +15,7 @@ use dom::event::{AbstractEvent, Event};
use dom::htmlcollection::HTMLCollection; use dom::htmlcollection::HTMLCollection;
use dom::htmldocument::HTMLDocument; use dom::htmldocument::HTMLDocument;
use dom::mouseevent::MouseEvent; use dom::mouseevent::MouseEvent;
use dom::node::{AbstractNode, ScriptView, Node, ElementNodeTypeId, DocumentNodeTypeId}; use dom::node::{AbstractNode, Node, ElementNodeTypeId, DocumentNodeTypeId};
use dom::text::Text; use dom::text::Text;
use dom::uievent::UIEvent; use dom::uievent::UIEvent;
use dom::window::Window; use dom::window::Window;
@ -29,7 +29,6 @@ use std::cast;
use std::hashmap::HashMap; use std::hashmap::HashMap;
use std::str::eq_slice; use std::str::eq_slice;
use std::unstable::raw::Box; use std::unstable::raw::Box;
use style::{TElement, TNode};
#[deriving(Eq)] #[deriving(Eq)]
pub enum DocumentTypeId { pub enum DocumentTypeId {
@ -87,12 +86,12 @@ pub enum DocumentType {
} }
pub struct Document { pub struct Document {
node: Node<ScriptView>, node: Node,
reflector_: Reflector, reflector_: Reflector,
window: @mut Window, window: @mut Window,
doctype: DocumentType, doctype: DocumentType,
title: ~str, title: ~str,
idmap: HashMap<DOMString, AbstractNode<ScriptView>> idmap: HashMap<DOMString, AbstractNode>
} }
impl Document { impl Document {
@ -161,7 +160,7 @@ impl Reflectable for Document {
} }
impl Document { impl Document {
pub fn GetDocumentElement(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetDocumentElement(&self) -> Option<AbstractNode> {
do self.node.children().find |c| { do self.node.children().find |c| {
c.is_element() c.is_element()
} }
@ -183,7 +182,7 @@ impl Document {
HTMLCollection::new(self.window, ~[]) HTMLCollection::new(self.window, ~[])
} }
pub fn GetElementById(&self, id: DOMString) -> Option<AbstractNode<ScriptView>> { pub fn GetElementById(&self, id: DOMString) -> Option<AbstractNode> {
// TODO: "in tree order, within the context object's tree" // TODO: "in tree order, within the context object's tree"
// http://dom.spec.whatwg.org/#dom-document-getelementbyid. // http://dom.spec.whatwg.org/#dom-document-getelementbyid.
match self.idmap.find_equiv(&id) { match self.idmap.find_equiv(&id) {
@ -192,7 +191,8 @@ impl Document {
} }
} }
pub fn CreateElement(&self, abstract_self: AbstractDocument, local_name: DOMString) -> Fallible<AbstractNode<ScriptView>> { pub fn CreateElement(&self, abstract_self: AbstractDocument, local_name: DOMString)
-> Fallible<AbstractNode> {
if xml_name_type(local_name) == InvalidXMLName { if xml_name_type(local_name) == InvalidXMLName {
debug!("Not a valid element name"); debug!("Not a valid element name");
return Err(InvalidCharacter); return Err(InvalidCharacter);
@ -201,15 +201,16 @@ impl Document {
Ok(build_element_from_tag(local_name, abstract_self)) Ok(build_element_from_tag(local_name, abstract_self))
} }
pub fn CreateDocumentFragment(&self, abstract_self: AbstractDocument) -> AbstractNode<ScriptView> { pub fn CreateDocumentFragment(&self, abstract_self: AbstractDocument) -> AbstractNode {
DocumentFragment::new(abstract_self) DocumentFragment::new(abstract_self)
} }
pub fn CreateTextNode(&self, abstract_self: AbstractDocument, data: DOMString) -> AbstractNode<ScriptView> { pub fn CreateTextNode(&self, abstract_self: AbstractDocument, data: DOMString)
-> AbstractNode {
Text::new(data, abstract_self) Text::new(data, abstract_self)
} }
pub fn CreateComment(&self, abstract_self: AbstractDocument, data: DOMString) -> AbstractNode<ScriptView> { pub fn CreateComment(&self, abstract_self: AbstractDocument, data: DOMString) -> AbstractNode {
Comment::new(data, abstract_self) Comment::new(data, abstract_self)
} }
@ -330,15 +331,15 @@ impl Document {
self.window.wait_until_safe_to_modify_dom(); self.window.wait_until_safe_to_modify_dom();
} }
pub fn register_nodes_with_id(&mut self, root: &AbstractNode<ScriptView>) { pub fn register_nodes_with_id(&mut self, root: &AbstractNode) {
foreach_ided_elements(root, |id: &DOMString, abstract_node: &AbstractNode<ScriptView>| { foreach_ided_elements(root, |id: &DOMString, abstract_node: &AbstractNode| {
// TODO: "in tree order, within the context object's tree" // TODO: "in tree order, within the context object's tree"
// http://dom.spec.whatwg.org/#dom-document-getelementbyid. // http://dom.spec.whatwg.org/#dom-document-getelementbyid.
self.idmap.find_or_insert(id.clone(), *abstract_node); self.idmap.find_or_insert(id.clone(), *abstract_node);
}); });
} }
pub fn unregister_nodes_with_id(&mut self, root: &AbstractNode<ScriptView>) { pub fn unregister_nodes_with_id(&mut self, root: &AbstractNode) {
foreach_ided_elements(root, |id: &DOMString, _| { foreach_ided_elements(root, |id: &DOMString, _| {
// TODO: "in tree order, within the context object's tree" // TODO: "in tree order, within the context object's tree"
// http://dom.spec.whatwg.org/#dom-document-getelementbyid. // http://dom.spec.whatwg.org/#dom-document-getelementbyid.
@ -347,7 +348,7 @@ impl Document {
} }
pub fn update_idmap(&mut self, pub fn update_idmap(&mut self,
abstract_self: AbstractNode<ScriptView>, abstract_self: AbstractNode,
new_id: DOMString, new_id: DOMString,
old_id: Option<DOMString>) { old_id: Option<DOMString>) {
// remove old ids if the old ones are not same as the new one. // remove old ids if the old ones are not same as the new one.
@ -359,19 +360,17 @@ impl Document {
} }
// TODO: support the case if multiple elements which haves same id are in the same document. // TODO: support the case if multiple elements which haves same id are in the same document.
self.idmap.mangle(new_id, abstract_self, self.idmap.mangle(new_id, abstract_self, |_, new_node: AbstractNode| -> AbstractNode {
|_, new_node: AbstractNode<ScriptView>| -> AbstractNode<ScriptView> {
new_node new_node
}, },
|_, old_node: &mut AbstractNode<ScriptView>, new_node: AbstractNode<ScriptView>| { |_, old_node: &mut AbstractNode, new_node: AbstractNode| {
*old_node = new_node; *old_node = new_node;
}); });
} }
} }
#[inline(always)] #[inline(always)]
fn foreach_ided_elements(root: &AbstractNode<ScriptView>, fn foreach_ided_elements(root: &AbstractNode, callback: &fn(&DOMString, &AbstractNode)) {
callback: &fn(&DOMString, &AbstractNode<ScriptView>)) {
for node in root.traverse_preorder() { for node in root.traverse_preorder() {
if !node.is_element() { if !node.is_element() {
continue; continue;

View file

@ -5,12 +5,11 @@
use dom::bindings::codegen::DocumentFragmentBinding; use dom::bindings::codegen::DocumentFragmentBinding;
use dom::bindings::utils::Fallible; use dom::bindings::utils::Fallible;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::node::{ScriptView, Node, DocumentFragmentNodeTypeId}; use dom::node::{AbstractNode, DocumentFragmentNodeTypeId, Node};
use dom::node::{AbstractNode};
use dom::window::Window; use dom::window::Window;
pub struct DocumentFragment { pub struct DocumentFragment {
node: Node<ScriptView>, node: Node,
} }
impl DocumentFragment { impl DocumentFragment {
@ -21,14 +20,14 @@ impl DocumentFragment {
} }
} }
pub fn new(document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(document: AbstractDocument) -> AbstractNode {
let node = DocumentFragment::new_inherited(document); let node = DocumentFragment::new_inherited(document);
Node::reflect_node(@mut node, document, DocumentFragmentBinding::Wrap) Node::reflect_node(@mut node, document, DocumentFragmentBinding::Wrap)
} }
} }
impl DocumentFragment { impl DocumentFragment {
pub fn Constructor(owner: @mut Window) -> Fallible<AbstractNode<ScriptView>> { pub fn Constructor(owner: @mut Window) -> Fallible<AbstractNode> {
Ok(DocumentFragment::new(owner.Document())) Ok(DocumentFragment::new(owner.Document()))
} }
} }

View file

@ -5,11 +5,11 @@
use dom::bindings::codegen::DocumentTypeBinding; use dom::bindings::codegen::DocumentTypeBinding;
use dom::bindings::utils::DOMString; use dom::bindings::utils::DOMString;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::node::{AbstractNode, ScriptView, Node, DoctypeNodeTypeId}; use dom::node::{AbstractNode, Node, DoctypeNodeTypeId};
/// The `DOCTYPE` tag. /// The `DOCTYPE` tag.
pub struct DocumentType { pub struct DocumentType {
node: Node<ScriptView>, node: Node,
name: DOMString, name: DOMString,
public_id: DOMString, public_id: DOMString,
system_id: DOMString, system_id: DOMString,
@ -36,7 +36,8 @@ impl DocumentType {
public_id: Option<~str>, public_id: Option<~str>,
system_id: Option<~str>, system_id: Option<~str>,
force_quirks: bool, force_quirks: bool,
document: AbstractDocument) -> AbstractNode<ScriptView> { document: AbstractDocument)
-> AbstractNode {
let documenttype = DocumentType::new_inherited(name, let documenttype = DocumentType::new_inherited(name,
public_id, public_id,
system_id, system_id,

View file

@ -4,6 +4,7 @@
//! Element nodes. //! Element nodes.
use dom::attr::Attr;
use dom::attrlist::AttrList; use dom::attrlist::AttrList;
use dom::bindings::utils::{Reflectable, DOMString, ErrorResult, Fallible, Reflector}; use dom::bindings::utils::{Reflectable, DOMString, ErrorResult, Fallible, Reflector};
use dom::bindings::utils::{null_str_as_empty, NamespaceError}; use dom::bindings::utils::{null_str_as_empty, NamespaceError};
@ -12,15 +13,13 @@ use dom::htmlcollection::HTMLCollection;
use dom::clientrect::ClientRect; use dom::clientrect::ClientRect;
use dom::clientrectlist::ClientRectList; use dom::clientrectlist::ClientRectList;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::node::{ElementNodeTypeId, Node, ScriptView, AbstractNode}; use dom::node::{AbstractNode, ElementNodeTypeId, Node};
use dom::attr:: Attr;
use dom::document; use dom::document;
use dom::namespace; use dom::namespace;
use dom::namespace::Namespace; use dom::namespace::Namespace;
use layout_interface::{ContentBoxQuery, ContentBoxResponse, ContentBoxesQuery}; use layout_interface::{ContentBoxQuery, ContentBoxResponse, ContentBoxesQuery};
use layout_interface::{ContentBoxesResponse, ContentChangedDocumentDamage}; use layout_interface::{ContentBoxesResponse, ContentChangedDocumentDamage};
use layout_interface::{MatchSelectorsDocumentDamage}; use layout_interface::{MatchSelectorsDocumentDamage};
use style::{TElement, TNode};
use style; use style;
use std::comm; use std::comm;
@ -29,7 +28,7 @@ use std::str::{eq, eq_slice};
use std::ascii::StrAsciiExt; use std::ascii::StrAsciiExt;
pub struct Element { pub struct Element {
node: Node<ScriptView>, node: Node,
tag_name: ~str, // TODO: This should be an atom, not a ~str. tag_name: ~str, // TODO: This should be an atom, not a ~str.
namespace: Namespace, namespace: Namespace,
attrs: HashMap<~str, ~[@mut Attr]>, attrs: HashMap<~str, ~[@mut Attr]>,
@ -125,31 +124,6 @@ pub enum ElementTypeId {
// Element methods // Element methods
// //
impl TElement for Element {
fn get_local_name<'a>(&'a self) -> &'a str {
self.tag_name.as_slice()
}
fn get_namespace_url<'a>(&'a self) -> &'a str {
self.namespace.to_str().unwrap_or("")
}
fn get_attr(&self, ns_url: Option<~str>, name: &str) -> Option<~str> {
self.get_attribute(ns_url, name).map(|attr| attr.value.clone())
}
fn get_link(&self) -> Option<~str>{
// FIXME: This is HTML only.
match self.node.type_id {
// http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#selector-link
ElementNodeTypeId(HTMLAnchorElementTypeId) |
ElementNodeTypeId(HTMLAreaElementTypeId) |
ElementNodeTypeId(HTMLLinkElementTypeId)
=> self.get_attr(None, "href"),
_ => None,
}
}
}
impl<'self> Element { impl<'self> Element {
pub fn new_inherited(type_id: ElementTypeId, tag_name: ~str, namespace: Namespace, document: AbstractDocument) -> Element { pub fn new_inherited(type_id: ElementTypeId, tag_name: ~str, namespace: Namespace, document: AbstractDocument) -> Element {
@ -187,15 +161,18 @@ impl<'self> Element {
}) })
} }
pub fn set_attr(&mut self, // FIXME(pcwalton): This is kind of confusingly named relative to the above...
abstract_self: AbstractNode<ScriptView>, pub fn get_attr(&self, ns_url: Option<~str>, name: &str) -> Option<~str> {
name: DOMString, self.get_attribute(ns_url, name).map(|attr| attr.value.clone())
value: DOMString) -> ErrorResult { }
pub fn set_attr(&mut self, abstract_self: AbstractNode, name: DOMString, value: DOMString)
-> ErrorResult {
self.set_attribute(abstract_self, namespace::Null, name, value) self.set_attribute(abstract_self, namespace::Null, name, value)
} }
pub fn set_attribute(&mut self, pub fn set_attribute(&mut self,
abstract_self: AbstractNode<ScriptView>, abstract_self: AbstractNode,
namespace: Namespace, namespace: Namespace,
raw_name: DOMString, raw_name: DOMString,
value: DOMString) -> ErrorResult { value: DOMString) -> ErrorResult {
@ -260,7 +237,7 @@ impl<'self> Element {
} }
fn after_set_attr(&mut self, fn after_set_attr(&mut self,
abstract_self: AbstractNode<ScriptView>, abstract_self: AbstractNode,
local_name: DOMString, local_name: DOMString,
value: DOMString, value: DOMString,
old_value: Option<DOMString>) { old_value: Option<DOMString>) {
@ -309,18 +286,18 @@ impl Element {
self.tag_name.to_ascii_upper() self.tag_name.to_ascii_upper()
} }
pub fn Id(&self, _abstract_self: AbstractNode<ScriptView>) -> DOMString { pub fn Id(&self, _abstract_self: AbstractNode) -> DOMString {
match self.get_attr(None, "id") { match self.get_attr(None, "id") {
Some(x) => x, Some(x) => x,
None => ~"" None => ~""
} }
} }
pub fn SetId(&mut self, abstract_self: AbstractNode<ScriptView>, id: DOMString) { pub fn SetId(&mut self, abstract_self: AbstractNode, id: DOMString) {
self.set_attribute(abstract_self, namespace::Null, ~"id", id); self.set_attribute(abstract_self, namespace::Null, ~"id", id);
} }
pub fn Attributes(&mut self, abstract_self: AbstractNode<ScriptView>) -> @mut AttrList { pub fn Attributes(&mut self, abstract_self: AbstractNode) -> @mut AttrList {
match self.attr_list { match self.attr_list {
None => { None => {
let window = self.node.owner_doc().document().window; let window = self.node.owner_doc().document().window;
@ -341,16 +318,14 @@ impl Element {
.map(|attr| attr.value.clone()) .map(|attr| attr.value.clone())
} }
pub fn SetAttribute(&mut self, pub fn SetAttribute(&mut self, abstract_self: AbstractNode, name: DOMString, value: DOMString)
abstract_self: AbstractNode<ScriptView>, -> ErrorResult {
name: DOMString,
value: DOMString) -> ErrorResult {
self.set_attr(abstract_self, name, value); self.set_attr(abstract_self, name, value);
Ok(()) Ok(())
} }
pub fn SetAttributeNS(&mut self, pub fn SetAttributeNS(&mut self,
abstract_self: AbstractNode<ScriptView>, abstract_self: AbstractNode,
namespace_url: Option<DOMString>, namespace_url: Option<DOMString>,
name: DOMString, name: DOMString,
value: DOMString) -> ErrorResult { value: DOMString) -> ErrorResult {
@ -409,7 +384,7 @@ impl Element {
pub fn MozRequestPointerLock(&self) { pub fn MozRequestPointerLock(&self) {
} }
pub fn GetClientRects(&self, abstract_self: AbstractNode<ScriptView>) -> @mut ClientRectList { pub fn GetClientRects(&self, abstract_self: AbstractNode) -> @mut ClientRectList {
let win = self.node.owner_doc().document().window; let win = self.node.owner_doc().document().window;
let node = abstract_self; let node = abstract_self;
assert!(node.is_element()); assert!(node.is_element());
@ -431,7 +406,7 @@ impl Element {
ClientRectList::new(win, rects) ClientRectList::new(win, rects)
} }
pub fn GetBoundingClientRect(&self, abstract_self: AbstractNode<ScriptView>) -> @mut ClientRect { pub fn GetBoundingClientRect(&self, abstract_self: AbstractNode) -> @mut ClientRect {
let win = self.node.owner_doc().document().window; let win = self.node.owner_doc().document().window;
let node = abstract_self; let node = abstract_self;
assert!(node.is_element()); assert!(node.is_element());
@ -509,7 +484,7 @@ impl Element {
Ok(()) Ok(())
} }
pub fn QuerySelector(&self, _selectors: DOMString) -> Fallible<Option<AbstractNode<ScriptView>>> { pub fn QuerySelector(&self, _selectors: DOMString) -> Fallible<Option<AbstractNode>> {
Ok(None) Ok(None)
} }
} }

View file

@ -8,7 +8,7 @@ use dom::bindings::codegen::EventListenerBinding::EventListener;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::event::AbstractEvent; use dom::event::AbstractEvent;
use dom::eventdispatcher::dispatch_event; use dom::eventdispatcher::dispatch_event;
use dom::node::{AbstractNode, ScriptView}; use dom::node::AbstractNode;
use dom::window::Window; use dom::window::Window;
use std::cast; use std::cast;
@ -50,7 +50,7 @@ impl AbstractEventTarget {
} }
} }
pub fn from_node(node: AbstractNode<ScriptView>) -> AbstractEventTarget { pub fn from_node(node: AbstractNode) -> AbstractEventTarget {
unsafe { unsafe {
cast::transmute(node) cast::transmute(node)
} }

View file

@ -6,7 +6,7 @@ use dom::bindings::utils::{Fallible, Reflectable, Reflector, reflect_dom_object}
use dom::bindings::utils::DOMString; use dom::bindings::utils::DOMString;
use dom::bindings::codegen::FormDataBinding; use dom::bindings::codegen::FormDataBinding;
use dom::blob::Blob; use dom::blob::Blob;
use dom::node::{AbstractNode, ScriptView}; use dom::node::AbstractNode;
use dom::window::Window; use dom::window::Window;
use std::hashmap::HashMap; use std::hashmap::HashMap;
@ -20,11 +20,11 @@ pub struct FormData {
data: HashMap<~str, FormDatum>, data: HashMap<~str, FormDatum>,
reflector_: Reflector, reflector_: Reflector,
window: @mut Window, window: @mut Window,
form: Option<AbstractNode<ScriptView>> form: Option<AbstractNode>
} }
impl FormData { impl FormData {
pub fn new_inherited(form: Option<AbstractNode<ScriptView>>, window: @mut Window) -> FormData { pub fn new_inherited(form: Option<AbstractNode>, window: @mut Window) -> FormData {
FormData { FormData {
data: HashMap::new(), data: HashMap::new(),
reflector_: Reflector::new(), reflector_: Reflector::new(),
@ -33,12 +33,12 @@ impl FormData {
} }
} }
pub fn new(form: Option<AbstractNode<ScriptView>>, window: @mut Window) -> @mut FormData { pub fn new(form: Option<AbstractNode>, window: @mut Window) -> @mut FormData {
reflect_dom_object(@mut FormData::new_inherited(form, window), window, FormDataBinding::Wrap) reflect_dom_object(@mut FormData::new_inherited(form, window), window, FormDataBinding::Wrap)
} }
pub fn Constructor(window: @mut Window, pub fn Constructor(window: @mut Window, form: Option<AbstractNode>)
form: Option<AbstractNode<ScriptView>>) -> Fallible<@mut FormData> { -> Fallible<@mut FormData> {
Ok(FormData::new(form, window)) Ok(FormData::new(form, window))
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLAnchorElementTypeId; use dom::element::HTMLAnchorElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLAnchorElement { pub struct HTMLAnchorElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLAnchorElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLAnchorElement::new_inherited(localName, document); let element = HTMLAnchorElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLAnchorElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLAnchorElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLAppletElementTypeId; use dom::element::HTMLAppletElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLAppletElement { pub struct HTMLAppletElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLAppletElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLAppletElement::new_inherited(localName, document); let element = HTMLAppletElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLAppletElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLAppletElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLAreaElementTypeId; use dom::element::HTMLAreaElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLAreaElement { pub struct HTMLAreaElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLAreaElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLAreaElement::new_inherited(localName, document); let element = HTMLAreaElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLAreaElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLAreaElementBinding::Wrap)
} }

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLAudioElementBinding;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLAudioElementTypeId; use dom::element::HTMLAudioElementTypeId;
use dom::htmlmediaelement::HTMLMediaElement; use dom::htmlmediaelement::HTMLMediaElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLAudioElement { pub struct HTMLAudioElement {
htmlmediaelement: HTMLMediaElement htmlmediaelement: HTMLMediaElement
@ -19,7 +19,7 @@ impl HTMLAudioElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLAudioElement::new_inherited(localName, document); let element = HTMLAudioElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLAudioElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLAudioElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLBaseElementTypeId; use dom::element::HTMLBaseElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLBaseElement { pub struct HTMLBaseElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLBaseElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLBaseElement::new_inherited(localName, document); let element = HTMLBaseElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLBaseElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLBaseElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLBodyElementTypeId; use dom::element::HTMLBodyElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLBodyElement { pub struct HTMLBodyElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLBodyElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLBodyElement::new_inherited(localName, document); let element = HTMLBodyElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLBodyElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLBodyElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLBRElementTypeId; use dom::element::HTMLBRElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLBRElement { pub struct HTMLBRElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLBRElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLBRElement::new_inherited(localName, document); let element = HTMLBRElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLBRElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLBRElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLButtonElementTypeId; use dom::element::HTMLButtonElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
use dom::validitystate::ValidityState; use dom::validitystate::ValidityState;
pub struct HTMLButtonElement { pub struct HTMLButtonElement {
@ -21,7 +21,7 @@ impl HTMLButtonElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLButtonElement::new_inherited(localName, document); let element = HTMLButtonElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLButtonElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLButtonElementBinding::Wrap)
} }
@ -44,7 +44,7 @@ impl HTMLButtonElement {
Ok(()) Ok(())
} }
pub fn GetForm(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetForm(&self) -> Option<AbstractNode> {
None None
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLCanvasElementTypeId; use dom::element::HTMLCanvasElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLCanvasElement { pub struct HTMLCanvasElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLCanvasElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLCanvasElement::new_inherited(localName, document); let element = HTMLCanvasElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLCanvasElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLCanvasElementBinding::Wrap)
} }

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::HTMLCollectionBinding; use dom::bindings::codegen::HTMLCollectionBinding;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::utils::{DOMString, Fallible}; use dom::bindings::utils::{DOMString, Fallible};
use dom::node::{AbstractNode, ScriptView}; use dom::node::AbstractNode;
use dom::window::Window; use dom::window::Window;
use js::jsapi::{JSObject, JSContext}; use js::jsapi::{JSObject, JSContext};
@ -13,14 +13,13 @@ use js::jsapi::{JSObject, JSContext};
use std::ptr; use std::ptr;
pub struct HTMLCollection { pub struct HTMLCollection {
elements: ~[AbstractNode<ScriptView>], elements: ~[AbstractNode],
reflector_: Reflector, reflector_: Reflector,
window: @mut Window, window: @mut Window,
} }
impl HTMLCollection { impl HTMLCollection {
pub fn new_inherited(window: @mut Window, pub fn new_inherited(window: @mut Window, elements: ~[AbstractNode]) -> HTMLCollection {
elements: ~[AbstractNode<ScriptView>]) -> HTMLCollection {
HTMLCollection { HTMLCollection {
elements: elements, elements: elements,
reflector_: Reflector::new(), reflector_: Reflector::new(),
@ -28,8 +27,7 @@ impl HTMLCollection {
} }
} }
pub fn new(window: @mut Window, pub fn new(window: @mut Window, elements: ~[AbstractNode]) -> @mut HTMLCollection {
elements: ~[AbstractNode<ScriptView>]) -> @mut HTMLCollection {
reflect_dom_object(@mut HTMLCollection::new_inherited(window, elements), reflect_dom_object(@mut HTMLCollection::new_inherited(window, elements),
window, HTMLCollectionBinding::Wrap) window, HTMLCollectionBinding::Wrap)
} }
@ -38,7 +36,7 @@ impl HTMLCollection {
self.elements.len() as u32 self.elements.len() as u32
} }
pub fn Item(&self, index: u32) -> Option<AbstractNode<ScriptView>> { pub fn Item(&self, index: u32) -> Option<AbstractNode> {
if index < self.Length() { if index < self.Length() {
Some(self.elements[index]) Some(self.elements[index])
} else { } else {
@ -50,7 +48,7 @@ impl HTMLCollection {
Ok(ptr::null()) Ok(ptr::null())
} }
pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<AbstractNode<ScriptView>> { pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<AbstractNode> {
*found = true; *found = true;
self.Item(index) self.Item(index)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLDataElementTypeId; use dom::element::HTMLDataElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLDataElement { pub struct HTMLDataElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLDataElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLDataElement::new_inherited(localName, document); let element = HTMLDataElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLDataElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLDataElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::document::AbstractDocument;
use dom::element::HTMLDataListElementTypeId; use dom::element::HTMLDataListElementTypeId;
use dom::htmlcollection::HTMLCollection; use dom::htmlcollection::HTMLCollection;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLDataListElement { pub struct HTMLDataListElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLDataListElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLDataListElement::new_inherited(localName, document); let element = HTMLDataListElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLDataListElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLDataListElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::ErrorResult;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLDirectoryElementTypeId; use dom::element::HTMLDirectoryElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLDirectoryElement { pub struct HTMLDirectoryElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLDirectoryElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLDirectoryElement::new_inherited(localName, document); let element = HTMLDirectoryElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLDirectoryElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLDirectoryElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLDivElementTypeId; use dom::element::HTMLDivElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLDivElement { pub struct HTMLDivElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLDivElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLDivElement::new_inherited(localName, document); let element = HTMLDivElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLDivElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLDivElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLDListElementTypeId; use dom::element::HTMLDListElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLDListElement { pub struct HTMLDListElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLDListElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLDListElement::new_inherited(localName, document); let element = HTMLDListElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLDListElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLDListElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{Reflectable, Reflector, Traceable};
use dom::document::{AbstractDocument, Document, HTML}; use dom::document::{AbstractDocument, Document, HTML};
use dom::element::HTMLHeadElementTypeId; use dom::element::HTMLHeadElementTypeId;
use dom::htmlcollection::HTMLCollection; use dom::htmlcollection::HTMLCollection;
use dom::node::{AbstractNode, ScriptView, ElementNodeTypeId}; use dom::node::{AbstractNode, ElementNodeTypeId};
use dom::window::Window; use dom::window::Window;
use js::jsapi::JSTracer; use js::jsapi::JSTracer;
@ -32,7 +32,7 @@ impl HTMLDocument {
} }
impl HTMLDocument { impl HTMLDocument {
pub fn GetHead(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetHead(&self) -> Option<AbstractNode> {
match self.parent.GetDocumentElement() { match self.parent.GetDocumentElement() {
None => None, None => None,
Some(root) => root.traverse_preorder().find(|child| { Some(root) => root.traverse_preorder().find(|child| {

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLElementBinding;
use dom::bindings::utils::{DOMString, ErrorResult, Fallible}; use dom::bindings::utils::{DOMString, ErrorResult, Fallible};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::{Element, ElementTypeId, HTMLElementTypeId}; use dom::element::{Element, ElementTypeId, HTMLElementTypeId};
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
use js::jsapi::{JSContext, JSVal}; use js::jsapi::{JSContext, JSVal};
use js::JSVAL_NULL; use js::JSVAL_NULL;
use dom::namespace; use dom::namespace;
@ -22,7 +22,7 @@ impl HTMLElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLElement::new_inherited(HTMLElementTypeId, localName, document); let element = HTMLElement::new_inherited(HTMLElementTypeId, localName, document);
Node::reflect_node(@mut element, document, HTMLElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLElementBinding::Wrap)
} }
@ -133,7 +133,7 @@ impl HTMLElement {
pub fn SetClassName(&self, _class: DOMString) { pub fn SetClassName(&self, _class: DOMString) {
} }
pub fn GetOffsetParent(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetOffsetParent(&self) -> Option<AbstractNode> {
None None
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLEmbedElementTypeId; use dom::element::HTMLEmbedElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLEmbedElement { pub struct HTMLEmbedElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLEmbedElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLEmbedElement::new_inherited(localName, document); let element = HTMLEmbedElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLEmbedElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLEmbedElementBinding::Wrap)
} }

View file

@ -8,7 +8,7 @@ use dom::document::AbstractDocument;
use dom::element::HTMLFieldSetElementTypeId; use dom::element::HTMLFieldSetElementTypeId;
use dom::htmlcollection::HTMLCollection; use dom::htmlcollection::HTMLCollection;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
use dom::validitystate::ValidityState; use dom::validitystate::ValidityState;
pub struct HTMLFieldSetElement { pub struct HTMLFieldSetElement {
@ -22,7 +22,7 @@ impl HTMLFieldSetElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLFieldSetElement::new_inherited(localName, document); let element = HTMLFieldSetElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLFieldSetElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLFieldSetElementBinding::Wrap)
} }
@ -37,7 +37,7 @@ impl HTMLFieldSetElement {
Ok(()) Ok(())
} }
pub fn GetForm(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetForm(&self) -> Option<AbstractNode> {
None None
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLFontElementTypeId; use dom::element::HTMLFontElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLFontElement { pub struct HTMLFontElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLFontElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLFontElement::new_inherited(localName, document); let element = HTMLFontElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLFontElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLFontElementBinding::Wrap)
} }

View file

@ -8,7 +8,7 @@ use dom::document::AbstractDocument;
use dom::element::HTMLFormElementTypeId; use dom::element::HTMLFormElementTypeId;
use dom::htmlcollection::HTMLCollection; use dom::htmlcollection::HTMLCollection;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLFormElement { pub struct HTMLFormElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -21,7 +21,7 @@ impl HTMLFormElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLFormElement::new_inherited(localName, document); let element = HTMLFormElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLFormElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLFormElementBinding::Wrap)
} }
@ -120,7 +120,7 @@ impl HTMLFormElement {
false false
} }
pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> AbstractNode<ScriptView> { pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> AbstractNode {
fail!("Not implemented.") fail!("Not implemented.")
} }
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLFrameElementTypeId; use dom::element::HTMLFrameElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
use dom::windowproxy::WindowProxy; use dom::windowproxy::WindowProxy;
pub struct HTMLFrameElement { pub struct HTMLFrameElement {
@ -21,7 +21,7 @@ impl HTMLFrameElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLFrameElement::new_inherited(localName, document); let element = HTMLFrameElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLFrameElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLFrameElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLFrameSetElementTypeId; use dom::element::HTMLFrameSetElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLFrameSetElement { pub struct HTMLFrameSetElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLFrameSetElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLFrameSetElement::new_inherited(localName, document); let element = HTMLFrameSetElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLFrameSetElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLFrameSetElementBinding::Wrap)
} }

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLHeadElementBinding;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLHeadElementTypeId; use dom::element::HTMLHeadElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLHeadElement { pub struct HTMLHeadElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -19,7 +19,7 @@ impl HTMLHeadElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLHeadElement::new_inherited(localName, document); let element = HTMLHeadElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLHeadElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLHeadElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::DOMString;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLHeadingElementTypeId; use dom::element::HTMLHeadingElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub enum HeadingLevel { pub enum HeadingLevel {
Heading1, Heading1,
@ -31,7 +31,7 @@ impl HTMLHeadingElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument, level: HeadingLevel) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument, level: HeadingLevel) -> AbstractNode {
let element = HTMLHeadingElement::new_inherited(localName, document, level); let element = HTMLHeadingElement::new_inherited(localName, document, level);
Node::reflect_node(@mut element, document, HTMLHeadingElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLHeadingElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLHRElementTypeId; use dom::element::HTMLHRElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLHRElement { pub struct HTMLHRElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLHRElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLHRElement::new_inherited(localName, document); let element = HTMLHRElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLHRElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLHRElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLHtmlElementTypeId; use dom::element::HTMLHtmlElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLHtmlElement { pub struct HTMLHtmlElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLHtmlElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLHtmlElement::new_inherited(localName, document); let element = HTMLHtmlElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLHtmlElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLHtmlElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLIframeElementTypeId; use dom::element::HTMLIframeElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
use dom::windowproxy::WindowProxy; use dom::windowproxy::WindowProxy;
use extra::url::Url; use extra::url::Url;
@ -52,7 +52,7 @@ impl HTMLIFrameElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLIFrameElement::new_inherited(localName, document); let element = HTMLIFrameElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLIFrameElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLIFrameElementBinding::Wrap)
} }
@ -83,14 +83,14 @@ impl HTMLIFrameElement {
Ok(()) Ok(())
} }
pub fn Sandbox(&self, _abstract_self: AbstractNode<ScriptView>) -> DOMString { pub fn Sandbox(&self, _abstract_self: AbstractNode) -> DOMString {
match self.htmlelement.element.GetAttribute(~"sandbox") { match self.htmlelement.element.GetAttribute(~"sandbox") {
Some(s) => s.to_owned(), Some(s) => s.to_owned(),
None => ~"", None => ~"",
} }
} }
pub fn SetSandbox(&mut self, abstract_self: AbstractNode<ScriptView>, sandbox: DOMString) { pub fn SetSandbox(&mut self, abstract_self: AbstractNode, sandbox: DOMString) {
self.htmlelement.element.SetAttribute(abstract_self, ~"sandbox", sandbox); self.htmlelement.element.SetAttribute(abstract_self, ~"sandbox", sandbox);
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLImageElementTypeId; use dom::element::HTMLImageElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
use extra::url::Url; use extra::url::Url;
use servo_util::geometry::to_px; use servo_util::geometry::to_px;
use layout_interface::{ContentBoxQuery, ContentBoxResponse}; use layout_interface::{ContentBoxQuery, ContentBoxResponse};
@ -29,7 +29,7 @@ impl HTMLImageElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLImageElement::new_inherited(localName, document); let element = HTMLImageElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLImageElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLImageElementBinding::Wrap)
} }
@ -74,13 +74,11 @@ impl HTMLImageElement {
Ok(()) Ok(())
} }
pub fn Src(&self, _abstract_self: AbstractNode<ScriptView>) -> DOMString { pub fn Src(&self, _abstract_self: AbstractNode) -> DOMString {
~"" ~""
} }
pub fn SetSrc(&mut self, pub fn SetSrc(&mut self, abstract_self: AbstractNode, src: DOMString) -> ErrorResult {
abstract_self: AbstractNode<ScriptView>,
src: DOMString) -> ErrorResult {
let node = &mut self.htmlelement.element; let node = &mut self.htmlelement.element;
node.set_attr(abstract_self, ~"src", src.clone()); node.set_attr(abstract_self, ~"src", src.clone());
Ok(()) Ok(())
@ -110,7 +108,7 @@ impl HTMLImageElement {
Ok(()) Ok(())
} }
pub fn Width(&self, abstract_self: AbstractNode<ScriptView>) -> u32 { pub fn Width(&self, abstract_self: AbstractNode) -> u32 {
let node = &self.htmlelement.element.node; let node = &self.htmlelement.element.node;
let page = node.owner_doc().document().window.page; let page = node.owner_doc().document().window.page;
let (port, chan) = stream(); let (port, chan) = stream();
@ -121,15 +119,13 @@ impl HTMLImageElement {
} }
} }
pub fn SetWidth(&mut self, pub fn SetWidth(&mut self, abstract_self: AbstractNode, width: u32) -> ErrorResult {
abstract_self: AbstractNode<ScriptView>,
width: u32) -> ErrorResult {
let node = &mut self.htmlelement.element; let node = &mut self.htmlelement.element;
node.set_attr(abstract_self, ~"width", width.to_str()); node.set_attr(abstract_self, ~"width", width.to_str());
Ok(()) Ok(())
} }
pub fn Height(&self, abstract_self: AbstractNode<ScriptView>) -> u32 { pub fn Height(&self, abstract_self: AbstractNode) -> u32 {
let node = &self.htmlelement.element.node; let node = &self.htmlelement.element.node;
let page = node.owner_doc().document().window.page; let page = node.owner_doc().document().window.page;
let (port, chan) = stream(); let (port, chan) = stream();
@ -140,9 +136,7 @@ impl HTMLImageElement {
} }
} }
pub fn SetHeight(&mut self, pub fn SetHeight(&mut self, abstract_self: AbstractNode, height: u32) -> ErrorResult {
abstract_self: AbstractNode<ScriptView>,
height: u32) -> ErrorResult {
let node = &mut self.htmlelement.element; let node = &mut self.htmlelement.element;
node.set_attr(abstract_self, ~"height", height.to_str()); node.set_attr(abstract_self, ~"height", height.to_str());
Ok(()) Ok(())

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult, Fallible};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLInputElementTypeId; use dom::element::HTMLInputElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLInputElement { pub struct HTMLInputElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLInputElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLInputElement::new_inherited(localName, document); let element = HTMLInputElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLInputElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLInputElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::DOMString;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLLabelElementTypeId; use dom::element::HTMLLabelElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLLabelElement { pub struct HTMLLabelElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLLabelElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLLabelElement::new_inherited(localName, document); let element = HTMLLabelElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLLabelElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLLabelElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLLegendElementTypeId; use dom::element::HTMLLegendElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLLegendElement { pub struct HTMLLegendElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLLegendElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLLegendElement::new_inherited(localName, document); let element = HTMLLegendElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLLegendElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLLegendElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLLIElementTypeId; use dom::element::HTMLLIElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLLIElement { pub struct HTMLLIElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLLIElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLLIElement::new_inherited(localName, document); let element = HTMLLIElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLLIElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLLIElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLLinkElementTypeId; use dom::element::HTMLLinkElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLLinkElement { pub struct HTMLLinkElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLLinkElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLLinkElement::new_inherited(localName, document); let element = HTMLLinkElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLLinkElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLLinkElementBinding::Wrap)
} }

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLMainElementBinding;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLMainElementTypeId; use dom::element::HTMLMainElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLMainElement { pub struct HTMLMainElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -19,7 +19,7 @@ impl HTMLMainElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLMainElement::new_inherited(localName, document); let element = HTMLMainElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLMainElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLMainElementBinding::Wrap)
} }

View file

@ -8,7 +8,7 @@ use dom::htmlcollection::HTMLCollection;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLMapElementTypeId; use dom::element::HTMLMapElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLMapElement { pub struct HTMLMapElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -21,7 +21,7 @@ impl HTMLMapElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLMapElement::new_inherited(localName, document); let element = HTMLMapElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLMapElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLMapElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLMetaElementTypeId; use dom::element::HTMLMetaElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLMetaElement { pub struct HTMLMetaElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLMetaElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLMetaElement::new_inherited(localName, document); let element = HTMLMetaElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLMetaElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLMetaElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::ErrorResult;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLMeterElementTypeId; use dom::element::HTMLMeterElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLMeterElement { pub struct HTMLMeterElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLMeterElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLMeterElement::new_inherited(localName, document); let element = HTMLMeterElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLMeterElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLMeterElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLModElementTypeId; use dom::element::HTMLModElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLModElement { pub struct HTMLModElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLModElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLModElement::new_inherited(localName, document); let element = HTMLModElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLModElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLModElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLObjectElementTypeId; use dom::element::HTMLObjectElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
use dom::validitystate::ValidityState; use dom::validitystate::ValidityState;
use dom::windowproxy::WindowProxy; use dom::windowproxy::WindowProxy;
@ -22,7 +22,7 @@ impl HTMLObjectElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLObjectElement::new_inherited(localName, document); let element = HTMLObjectElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLObjectElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLObjectElementBinding::Wrap)
} }
@ -61,7 +61,7 @@ impl HTMLObjectElement {
Ok(()) Ok(())
} }
pub fn GetForm(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetForm(&self) -> Option<AbstractNode> {
None None
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLOListElementTypeId; use dom::element::HTMLOListElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLOListElement { pub struct HTMLOListElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLOListElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLOListElement::new_inherited(localName, document); let element = HTMLOListElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLOListElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLOListElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLOptGroupElementTypeId; use dom::element::HTMLOptGroupElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLOptGroupElement { pub struct HTMLOptGroupElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLOptGroupElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLOptGroupElement::new_inherited(localName, document); let element = HTMLOptGroupElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLOptGroupElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLOptGroupElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLOptionElementTypeId; use dom::element::HTMLOptionElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLOptionElement { pub struct HTMLOptionElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLOptionElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLOptionElement::new_inherited(localName, document); let element = HTMLOptionElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLOptionElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLOptionElementBinding::Wrap)
} }
@ -35,7 +35,7 @@ impl HTMLOptionElement {
Ok(()) Ok(())
} }
pub fn GetForm(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetForm(&self) -> Option<AbstractNode> {
None None
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLOutputElementTypeId; use dom::element::HTMLOutputElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
use dom::validitystate::ValidityState; use dom::validitystate::ValidityState;
pub struct HTMLOutputElement { pub struct HTMLOutputElement {
@ -21,14 +21,14 @@ impl HTMLOutputElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLOutputElement::new_inherited(localName, document); let element = HTMLOutputElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLOutputElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLOutputElementBinding::Wrap)
} }
} }
impl HTMLOutputElement { impl HTMLOutputElement {
pub fn GetForm(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetForm(&self) -> Option<AbstractNode> {
None None
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLParagraphElementTypeId; use dom::element::HTMLParagraphElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLParagraphElement { pub struct HTMLParagraphElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLParagraphElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLParagraphElement::new_inherited(localName, document); let element = HTMLParagraphElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLParagraphElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLParagraphElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLParamElementTypeId; use dom::element::HTMLParamElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLParamElement { pub struct HTMLParamElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLParamElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLParamElement::new_inherited(localName, document); let element = HTMLParamElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLParamElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLParamElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLPreElementTypeId; use dom::element::HTMLPreElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLPreElement { pub struct HTMLPreElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLPreElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLPreElement::new_inherited(localName, document); let element = HTMLPreElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLPreElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLPreElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{ErrorResult, Fallible};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLProgressElementTypeId; use dom::element::HTMLProgressElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLProgressElement { pub struct HTMLProgressElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLProgressElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLProgressElement::new_inherited(localName, document); let element = HTMLProgressElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLProgressElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLProgressElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLQuoteElementTypeId; use dom::element::HTMLQuoteElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLQuoteElement { pub struct HTMLQuoteElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLQuoteElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLQuoteElement::new_inherited(localName, document); let element = HTMLQuoteElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLQuoteElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLQuoteElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLScriptElementTypeId; use dom::element::HTMLScriptElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
use style::TElement; use style::TElement;
pub struct HTMLScriptElement { pub struct HTMLScriptElement {
@ -21,7 +21,7 @@ impl HTMLScriptElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLScriptElement::new_inherited(localName, document); let element = HTMLScriptElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLScriptElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLScriptElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLSelectElementTypeId; use dom::element::HTMLSelectElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
use dom::validitystate::ValidityState; use dom::validitystate::ValidityState;
pub struct HTMLSelectElement { pub struct HTMLSelectElement {
@ -21,7 +21,7 @@ impl HTMLSelectElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLSelectElement::new_inherited(localName, document); let element = HTMLSelectElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLSelectElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLSelectElementBinding::Wrap)
} }
@ -44,7 +44,7 @@ impl HTMLSelectElement {
Ok(()) Ok(())
} }
pub fn GetForm(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetForm(&self) -> Option<AbstractNode> {
None None
} }
@ -92,19 +92,19 @@ impl HTMLSelectElement {
Ok(()) Ok(())
} }
pub fn Item(&self, _index: u32) -> Option<AbstractNode<ScriptView>> { pub fn Item(&self, _index: u32) -> Option<AbstractNode> {
None None
} }
pub fn NamedItem(&self, _name: DOMString) -> Option<AbstractNode<ScriptView>> { pub fn NamedItem(&self, _name: DOMString) -> Option<AbstractNode> {
None None
} }
pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<AbstractNode<ScriptView>> { pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<AbstractNode> {
None None
} }
pub fn IndexedSetter(&mut self, _index: u32, _option: Option<AbstractNode<ScriptView>>) -> ErrorResult { pub fn IndexedSetter(&mut self, _index: u32, _option: Option<AbstractNode>) -> ErrorResult {
Ok(()) Ok(())
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLSourceElementTypeId; use dom::element::HTMLSourceElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLSourceElement { pub struct HTMLSourceElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLSourceElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLSourceElement::new_inherited(localName, document); let element = HTMLSourceElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLSourceElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLSourceElementBinding::Wrap)
} }

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLSpanElementBinding;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLSpanElementTypeId; use dom::element::HTMLSpanElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLSpanElement { pub struct HTMLSpanElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -19,7 +19,7 @@ impl HTMLSpanElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLSpanElement::new_inherited(localName, document); let element = HTMLSpanElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLSpanElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLSpanElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLStyleElementTypeId; use dom::element::HTMLStyleElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLStyleElement { pub struct HTMLStyleElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLStyleElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLStyleElement::new_inherited(localName, document); let element = HTMLStyleElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLStyleElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLStyleElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLTableCaptionElementTypeId; use dom::element::HTMLTableCaptionElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLTableCaptionElement { pub struct HTMLTableCaptionElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLTableCaptionElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLTableCaptionElement::new_inherited(localName, document); let element = HTMLTableCaptionElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTableCaptionElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLTableCaptionElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLTableColElementTypeId; use dom::element::HTMLTableColElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLTableColElement { pub struct HTMLTableColElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLTableColElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLTableColElement::new_inherited(localName, document); let element = HTMLTableColElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTableColElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLTableColElementBinding::Wrap)
} }

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLTableDataCellElementBinding;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLTableDataCellElementTypeId; use dom::element::HTMLTableDataCellElementTypeId;
use dom::htmltablecellelement::HTMLTableCellElement; use dom::htmltablecellelement::HTMLTableCellElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLTableDataCellElement { pub struct HTMLTableDataCellElement {
htmltablecellelement: HTMLTableCellElement, htmltablecellelement: HTMLTableCellElement,
@ -19,7 +19,7 @@ impl HTMLTableDataCellElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLTableDataCellElement::new_inherited(localName, document); let element = HTMLTableDataCellElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTableDataCellElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLTableDataCellElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLTableElementTypeId; use dom::element::HTMLTableElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLTableElement { pub struct HTMLTableElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLTableElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLTableElement::new_inherited(localName, document); let element = HTMLTableElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTableElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLTableElementBinding::Wrap)
} }

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLTableHeaderCellElementBinding;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLTableHeaderCellElementTypeId; use dom::element::HTMLTableHeaderCellElementTypeId;
use dom::htmltablecellelement::HTMLTableCellElement; use dom::htmltablecellelement::HTMLTableCellElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLTableHeaderCellElement { pub struct HTMLTableHeaderCellElement {
htmltablecellelement: HTMLTableCellElement, htmltablecellelement: HTMLTableCellElement,
@ -19,7 +19,7 @@ impl HTMLTableHeaderCellElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLTableHeaderCellElement::new_inherited(localName, document); let element = HTMLTableHeaderCellElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTableHeaderCellElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLTableHeaderCellElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLTableRowElementTypeId; use dom::element::HTMLTableRowElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLTableRowElement { pub struct HTMLTableRowElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLTableRowElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLTableRowElement::new_inherited(localName, document); let element = HTMLTableRowElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTableRowElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLTableRowElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLTableSectionElementTypeId; use dom::element::HTMLTableSectionElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLTableSectionElement { pub struct HTMLTableSectionElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLTableSectionElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLTableSectionElement::new_inherited(localName, document); let element = HTMLTableSectionElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTableSectionElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLTableSectionElementBinding::Wrap)
} }

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLTemplateElementBinding;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLTemplateElementTypeId; use dom::element::HTMLTemplateElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLTemplateElement { pub struct HTMLTemplateElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -19,7 +19,7 @@ impl HTMLTemplateElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLTemplateElement::new_inherited(localName, document); let element = HTMLTemplateElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTemplateElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLTemplateElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult, Fallible};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLTextAreaElementTypeId; use dom::element::HTMLTextAreaElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLTextAreaElement { pub struct HTMLTextAreaElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLTextAreaElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLTextAreaElement::new_inherited(localName, document); let element = HTMLTextAreaElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTextAreaElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLTextAreaElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLTimeElementTypeId; use dom::element::HTMLTimeElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLTimeElement { pub struct HTMLTimeElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLTimeElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLTimeElement::new_inherited(localName, document); let element = HTMLTimeElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTimeElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLTimeElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLTitleElementTypeId; use dom::element::HTMLTitleElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLTitleElement { pub struct HTMLTitleElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLTitleElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLTitleElement::new_inherited(localName, document); let element = HTMLTitleElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTitleElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLTitleElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLTrackElementTypeId; use dom::element::HTMLTrackElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLTrackElement { pub struct HTMLTrackElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -20,7 +20,7 @@ impl HTMLTrackElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLTrackElement::new_inherited(localName, document); let element = HTMLTrackElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTrackElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLTrackElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLUListElementTypeId; use dom::element::HTMLUListElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLUListElement { pub struct HTMLUListElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -20,7 +20,7 @@ impl HTMLUListElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLUListElement::new_inherited(localName, document); let element = HTMLUListElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLUListElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLUListElementBinding::Wrap)
} }

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLUnknownElementBinding;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLUnknownElementTypeId; use dom::element::HTMLUnknownElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLUnknownElement { pub struct HTMLUnknownElement {
htmlelement: HTMLElement htmlelement: HTMLElement
@ -19,7 +19,7 @@ impl HTMLUnknownElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLUnknownElement::new_inherited(localName, document); let element = HTMLUnknownElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLUnknownElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLUnknownElementBinding::Wrap)
} }

View file

@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLVideoElementTypeId; use dom::element::HTMLVideoElementTypeId;
use dom::htmlmediaelement::HTMLMediaElement; use dom::htmlmediaelement::HTMLMediaElement;
use dom::node::{AbstractNode, Node, ScriptView}; use dom::node::{AbstractNode, Node};
pub struct HTMLVideoElement { pub struct HTMLVideoElement {
htmlmediaelement: HTMLMediaElement htmlmediaelement: HTMLMediaElement
@ -20,7 +20,7 @@ impl HTMLVideoElement {
} }
} }
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
let element = HTMLVideoElement::new_inherited(localName, document); let element = HTMLVideoElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLVideoElementBinding::Wrap) Node::reflect_node(@mut element, document, HTMLVideoElementBinding::Wrap)
} }

View file

@ -14,9 +14,9 @@ use dom::documenttype::DocumentType;
use dom::element::{Element, ElementTypeId, HTMLImageElementTypeId, HTMLIframeElementTypeId}; use dom::element::{Element, ElementTypeId, HTMLImageElementTypeId, HTMLIframeElementTypeId};
use dom::element::{HTMLAnchorElementTypeId, HTMLStyleElementTypeId}; use dom::element::{HTMLAnchorElementTypeId, HTMLStyleElementTypeId};
use dom::eventtarget::{AbstractEventTarget, EventTarget, NodeTypeId}; use dom::eventtarget::{AbstractEventTarget, EventTarget, NodeTypeId};
use dom::nodelist::{NodeList};
use dom::htmlimageelement::HTMLImageElement;
use dom::htmliframeelement::HTMLIFrameElement; use dom::htmliframeelement::HTMLIFrameElement;
use dom::htmlimageelement::HTMLImageElement;
use dom::nodelist::{NodeList};
use dom::text::Text; use dom::text::Text;
use js::jsapi::{JSObject, JSContext}; use js::jsapi::{JSObject, JSContext};
@ -25,65 +25,44 @@ use std::cast::transmute;
use std::cast; use std::cast;
use std::unstable::raw::Box; use std::unstable::raw::Box;
use std::util; use std::util;
use style::TNode;
// //
// The basic Node structure // The basic Node structure
// //
/// A phantom type representing the script task's view of this node. Script is able to mutate
/// nodes but may not access layout data.
#[deriving(Eq)]
pub struct ScriptView;
/// A phantom type representing the layout task's view of the node. Layout is not allowed to mutate
/// nodes but may access layout data.
#[deriving(Eq)]
pub struct LayoutView;
// We shouldn't need Eq for ScriptView and LayoutView; see Rust #7671.
/// This is what a Node looks like if you do not know what kind of node it is. To unpack it, use /// This is what a Node looks like if you do not know what kind of node it is. To unpack it, use
/// downcast(). /// downcast().
/// ///
/// FIXME: This should be replaced with a trait once they can inherit from structs. /// FIXME: This should be replaced with a trait once they can inherit from structs.
#[deriving(Eq)] #[deriving(Eq)]
pub struct AbstractNode<View> { pub struct AbstractNode {
priv obj: *mut Box<Node<View>>, priv obj: *mut Box<Node>,
}
pub struct AbstractNodeChildrenIterator<View> {
priv current_node: Option<AbstractNode<View>>,
} }
/// An HTML node. /// An HTML node.
/// pub struct Node {
/// `View` describes extra data associated with this node that this task has access to. For
/// the script task, this is the unit type `()`. For the layout task, this is
/// `LayoutData`.
pub struct Node<View> {
/// The JavaScript reflector for this node. /// The JavaScript reflector for this node.
eventtarget: EventTarget, eventtarget: EventTarget,
/// The type of node that this is. /// The type of node that this is.
type_id: NodeTypeId, type_id: NodeTypeId,
abstract: Option<AbstractNode<View>>, abstract: Option<AbstractNode>,
/// The parent of this node. /// The parent of this node.
parent_node: Option<AbstractNode<View>>, parent_node: Option<AbstractNode>,
/// The first child of this node. /// The first child of this node.
first_child: Option<AbstractNode<View>>, first_child: Option<AbstractNode>,
/// The last child of this node. /// The last child of this node.
last_child: Option<AbstractNode<View>>, last_child: Option<AbstractNode>,
/// The next sibling of this node. /// The next sibling of this node.
next_sibling: Option<AbstractNode<View>>, next_sibling: Option<AbstractNode>,
/// The previous sibling of this node. /// The previous sibling of this node.
prev_sibling: Option<AbstractNode<View>>, prev_sibling: Option<AbstractNode>,
/// The document that this node belongs to. /// The document that this node belongs to.
priv owner_doc: Option<AbstractDocument>, priv owner_doc: Option<AbstractDocument>,
@ -119,10 +98,10 @@ impl NodeFlags {
bitfield!(NodeFlags, is_in_doc, set_is_in_doc, 0x01) bitfield!(NodeFlags, is_in_doc, set_is_in_doc, 0x01)
#[unsafe_destructor] #[unsafe_destructor]
impl<T> Drop for Node<T> { impl Drop for Node {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
let this: &mut Node<ScriptView> = cast::transmute(self); let this: &mut Node = cast::transmute(self);
this.reap_layout_data() this.reap_layout_data()
} }
} }
@ -204,68 +183,53 @@ pub enum NodeTypeId {
TextNodeTypeId, TextNodeTypeId,
} }
impl<View> Clone for AbstractNode<View> { impl Clone for AbstractNode {
fn clone(&self) -> AbstractNode<View> { fn clone(&self) -> AbstractNode {
*self *self
} }
} }
impl<View> TNode<Element> for AbstractNode<View> { impl AbstractNode {
fn parent_node(&self) -> Option<AbstractNode<View>> { pub fn node<'a>(&'a self) -> &'a Node {
unsafe {
&(*self.obj).data
}
}
pub fn mut_node<'a>(&'a self) -> &'a mut Node {
unsafe {
&mut (*self.obj).data
}
}
pub fn parent_node(&self) -> Option<AbstractNode> {
self.node().parent_node self.node().parent_node
} }
fn prev_sibling(&self) -> Option<AbstractNode<View>> { pub fn first_child(&self) -> Option<AbstractNode> {
self.node().prev_sibling self.node().first_child
}
fn next_sibling(&self) -> Option<AbstractNode<View>> {
self.node().next_sibling
} }
fn is_element(&self) -> bool { pub fn last_child(&self) -> Option<AbstractNode> {
self.node().last_child
}
pub fn is_element(&self) -> bool {
match self.type_id() { match self.type_id() {
ElementNodeTypeId(*) => true, ElementNodeTypeId(*) => true,
_ => false _ => false
} }
} }
fn is_document(&self) -> bool { pub fn is_document(&self) -> bool {
match self.type_id() { match self.type_id() {
DocumentNodeTypeId(*) => true, DocumentNodeTypeId(*) => true,
_ => false _ => false
} }
} }
#[inline]
fn with_element<R>(&self, f: &fn(&Element) -> R) -> R {
self.with_imm_element(f)
}
} }
impl<View> AbstractNode<View> { impl<'self> AbstractNode {
pub fn node<'a>(&'a self) -> &'a Node<View> {
unsafe {
&(*self.obj).data
}
}
pub fn mut_node<'a>(&'a self) -> &'a mut Node<View> {
unsafe {
&mut (*self.obj).data
}
}
pub fn first_child(&self) -> Option<AbstractNode<View>> {
self.node().first_child
}
pub fn last_child(&self) -> Option<AbstractNode<View>> {
self.node().last_child
}
}
impl<'self, View> AbstractNode<View> {
// Unsafe accessors // Unsafe accessors
pub unsafe fn as_cacheable_wrapper(&self) -> @mut Reflectable { pub unsafe fn as_cacheable_wrapper(&self) -> @mut Reflectable {
@ -283,20 +247,22 @@ impl<'self, View> AbstractNode<View> {
/// Allow consumers to recreate an AbstractNode from the raw boxed type. /// Allow consumers to recreate an AbstractNode from the raw boxed type.
/// Must only be used in situations where the boxed type is in the inheritance /// Must only be used in situations where the boxed type is in the inheritance
/// chain for nodes. /// chain for nodes.
pub fn from_box<T>(ptr: *mut Box<T>) -> AbstractNode<View> { ///
/// FIXME(pcwalton): Mark unsafe?
pub fn from_box<T>(ptr: *mut Box<T>) -> AbstractNode {
AbstractNode { AbstractNode {
obj: ptr as *mut Box<Node<View>> obj: ptr as *mut Box<Node>
} }
} }
/// Allow consumers to upcast from derived classes. /// Allow consumers to upcast from derived classes.
pub fn from_document(doc: AbstractDocument) -> AbstractNode<View> { pub fn from_document(doc: AbstractDocument) -> AbstractNode {
unsafe { unsafe {
cast::transmute(doc) cast::transmute(doc)
} }
} }
pub fn from_eventtarget(target: AbstractEventTarget) -> AbstractNode<View> { pub fn from_eventtarget(target: AbstractEventTarget) -> AbstractNode {
assert!(target.is_node()); assert!(target.is_node());
unsafe { unsafe {
cast::transmute(target) cast::transmute(target)
@ -311,12 +277,12 @@ impl<'self, View> AbstractNode<View> {
} }
/// Returns the previous sibling of this node. Fails if this node is borrowed mutably. /// Returns the previous sibling of this node. Fails if this node is borrowed mutably.
pub fn prev_sibling(self) -> Option<AbstractNode<View>> { pub fn prev_sibling(self) -> Option<AbstractNode> {
self.node().prev_sibling self.node().prev_sibling
} }
/// Returns the next sibling of this node. Fails if this node is borrowed mutably. /// Returns the next sibling of this node. Fails if this node is borrowed mutably.
pub fn next_sibling(self) -> Option<AbstractNode<View>> { pub fn next_sibling(self) -> Option<AbstractNode> {
self.node().next_sibling self.node().next_sibling
} }
@ -326,7 +292,7 @@ impl<'self, View> AbstractNode<View> {
pub fn transmute<T, R>(self, f: &fn(&T) -> R) -> R { pub fn transmute<T, R>(self, f: &fn(&T) -> R) -> R {
unsafe { unsafe {
let node_box: *mut Box<Node<View>> = transmute(self.obj); let node_box: *mut Box<Node> = transmute(self.obj);
let node = &mut (*node_box).data; let node = &mut (*node_box).data;
let old = node.abstract; let old = node.abstract;
node.abstract = Some(self); node.abstract = Some(self);
@ -339,7 +305,7 @@ impl<'self, View> AbstractNode<View> {
pub fn transmute_mut<T, R>(self, f: &fn(&mut T) -> R) -> R { pub fn transmute_mut<T, R>(self, f: &fn(&mut T) -> R) -> R {
unsafe { unsafe {
let node_box: *mut Box<Node<View>> = transmute(self.obj); let node_box: *mut Box<Node> = transmute(self.obj);
let node = &mut (*node_box).data; let node = &mut (*node_box).data;
let old = node.abstract; let old = node.abstract;
node.abstract = Some(self); node.abstract = Some(self);
@ -446,13 +412,6 @@ impl<'self, View> AbstractNode<View> {
} }
} }
pub fn with_imm_image_element<R>(self, f: &fn(&HTMLImageElement) -> R) -> R {
if !self.is_image_element() {
fail!(~"node is not an image element");
}
self.transmute(f)
}
pub fn with_mut_image_element<R>(self, f: &fn(&mut HTMLImageElement) -> R) -> R { pub fn with_mut_image_element<R>(self, f: &fn(&mut HTMLImageElement) -> R) -> R {
if !self.is_image_element() { if !self.is_image_element() {
fail!(~"node is not an image element"); fail!(~"node is not an image element");
@ -464,13 +423,6 @@ impl<'self, View> AbstractNode<View> {
self.type_id() == ElementNodeTypeId(HTMLIframeElementTypeId) self.type_id() == ElementNodeTypeId(HTMLIframeElementTypeId)
} }
pub fn with_imm_iframe_element<R>(self, f: &fn(&HTMLIFrameElement) -> R) -> R {
if !self.is_iframe_element() {
fail!(~"node is not an iframe element");
}
self.transmute(f)
}
pub fn with_mut_iframe_element<R>(self, f: &fn(&mut HTMLIFrameElement) -> R) -> R { pub fn with_mut_iframe_element<R>(self, f: &fn(&mut HTMLIFrameElement) -> R) -> R {
if !self.is_iframe_element() { if !self.is_iframe_element() {
fail!(~"node is not an iframe element"); fail!(~"node is not an iframe element");
@ -486,11 +438,11 @@ impl<'self, View> AbstractNode<View> {
self.type_id() == ElementNodeTypeId(HTMLAnchorElementTypeId) self.type_id() == ElementNodeTypeId(HTMLAnchorElementTypeId)
} }
pub unsafe fn raw_object(self) -> *mut Box<Node<View>> { pub unsafe fn raw_object(self) -> *mut Box<Node> {
self.obj self.obj
} }
pub fn from_raw(raw: *mut Box<Node<View>>) -> AbstractNode<View> { pub fn from_raw(raw: *mut Box<Node>) -> AbstractNode {
AbstractNode { AbstractNode {
obj: raw obj: raw
} }
@ -530,7 +482,7 @@ impl<'self, View> AbstractNode<View> {
self.first_child().is_none() self.first_child().is_none()
} }
pub fn children(&self) -> AbstractNodeChildrenIterator<View> { pub fn children(&self) -> AbstractNodeChildrenIterator {
self.node().children() self.node().children()
} }
@ -539,12 +491,12 @@ impl<'self, View> AbstractNode<View> {
} }
} }
impl AbstractNode<ScriptView> { impl AbstractNode {
pub fn AppendChild(self, node: AbstractNode<ScriptView>) -> Fallible<AbstractNode<ScriptView>> { pub fn AppendChild(self, node: AbstractNode) -> Fallible<AbstractNode> {
self.node().AppendChild(self, node) self.node().AppendChild(self, node)
} }
pub fn RemoveChild(self, node: AbstractNode<ScriptView>) -> Fallible<AbstractNode<ScriptView>> { pub fn RemoveChild(self, node: AbstractNode) -> Fallible<AbstractNode> {
self.node().RemoveChild(self, node) self.node().RemoveChild(self, node)
} }
@ -577,9 +529,7 @@ impl AbstractNode<ScriptView> {
/// Adds a new child to the end of this node's list of children. /// Adds a new child to the end of this node's list of children.
/// ///
/// Fails unless `new_child` is disconnected from the tree. /// Fails unless `new_child` is disconnected from the tree.
fn add_child(&self, fn add_child(&self, new_child: AbstractNode, before: Option<AbstractNode>) {
new_child: AbstractNode<ScriptView>,
before: Option<AbstractNode<ScriptView>>) {
let this_node = self.mut_node(); let this_node = self.mut_node();
let new_child_node = new_child.mut_node(); let new_child_node = new_child.mut_node();
assert!(new_child_node.parent_node.is_none()); assert!(new_child_node.parent_node.is_none());
@ -626,7 +576,7 @@ impl AbstractNode<ScriptView> {
/// Removes the given child from this node's list of children. /// Removes the given child from this node's list of children.
/// ///
/// Fails unless `child` is a child of this node. (FIXME: This is not yet checked.) /// Fails unless `child` is a child of this node. (FIXME: This is not yet checked.)
fn remove_child(&self, child: AbstractNode<ScriptView>) { fn remove_child(&self, child: AbstractNode) {
let this_node = self.mut_node(); let this_node = self.mut_node();
let child_node = child.mut_node(); let child_node = child.mut_node();
assert!(child_node.parent_node.is_some()); assert!(child_node.parent_node.is_some());
@ -656,27 +606,27 @@ impl AbstractNode<ScriptView> {
// Low-level pointer stitching wrappers // Low-level pointer stitching wrappers
// //
fn set_parent_node(&self, new_parent_node: Option<AbstractNode<ScriptView>>) { fn set_parent_node(&self, new_parent_node: Option<AbstractNode>) {
let node = self.mut_node(); let node = self.mut_node();
node.set_parent_node(new_parent_node) node.set_parent_node(new_parent_node)
} }
fn set_first_child(&self, new_first_child: Option<AbstractNode<ScriptView>>) { fn set_first_child(&self, new_first_child: Option<AbstractNode>) {
let node = self.mut_node(); let node = self.mut_node();
node.set_first_child(new_first_child) node.set_first_child(new_first_child)
} }
fn set_last_child(&self, new_last_child: Option<AbstractNode<ScriptView>>) { fn set_last_child(&self, new_last_child: Option<AbstractNode>) {
let node = self.mut_node(); let node = self.mut_node();
node.set_last_child(new_last_child) node.set_last_child(new_last_child)
} }
fn set_prev_sibling(&self, new_prev_sibling: Option<AbstractNode<ScriptView>>) { fn set_prev_sibling(&self, new_prev_sibling: Option<AbstractNode>) {
let node = self.mut_node(); let node = self.mut_node();
node.set_prev_sibling(new_prev_sibling) node.set_prev_sibling(new_prev_sibling)
} }
fn set_next_sibling(&self, new_next_sibling: Option<AbstractNode<ScriptView>>) { fn set_next_sibling(&self, new_next_sibling: Option<AbstractNode>) {
let node = self.mut_node(); let node = self.mut_node();
node.set_next_sibling(new_next_sibling) node.set_next_sibling(new_next_sibling)
} }
@ -686,8 +636,12 @@ impl AbstractNode<ScriptView> {
// Iteration and traversal // Iteration and traversal
// //
impl<View> Iterator<AbstractNode<View>> for AbstractNodeChildrenIterator<View> { pub struct AbstractNodeChildrenIterator {
fn next(&mut self) -> Option<AbstractNode<View>> { priv current_node: Option<AbstractNode>,
}
impl Iterator<AbstractNode> for AbstractNodeChildrenIterator {
fn next(&mut self) -> Option<AbstractNode> {
let node = self.current_node; let node = self.current_node;
self.current_node = do self.current_node.and_then |node| { self.current_node = do self.current_node.and_then |node| {
node.next_sibling() node.next_sibling()
@ -696,12 +650,12 @@ impl<View> Iterator<AbstractNode<View>> for AbstractNodeChildrenIterator<View> {
} }
} }
pub struct AncestorIterator<View> { pub struct AncestorIterator {
priv current: Option<AbstractNode<View>>, priv current: Option<AbstractNode>,
} }
impl<View> Iterator<AbstractNode<View>> for AncestorIterator<View> { impl Iterator<AbstractNode> for AncestorIterator {
fn next(&mut self) -> Option<AbstractNode<View>> { fn next(&mut self) -> Option<AbstractNode> {
if self.current.is_none() { if self.current.is_none() {
return None; return None;
} }
@ -715,13 +669,13 @@ impl<View> Iterator<AbstractNode<View>> for AncestorIterator<View> {
// FIXME: Do this without precomputing a vector of refs. // FIXME: Do this without precomputing a vector of refs.
// Easy for preorder; harder for postorder. // Easy for preorder; harder for postorder.
pub struct TreeIterator<View> { pub struct TreeIterator {
priv nodes: ~[AbstractNode<View>], priv nodes: ~[AbstractNode],
priv index: uint, priv index: uint,
} }
impl<View> TreeIterator<View> { impl TreeIterator {
fn new(nodes: ~[AbstractNode<View>]) -> TreeIterator<View> { fn new(nodes: ~[AbstractNode]) -> TreeIterator {
TreeIterator { TreeIterator {
nodes: nodes, nodes: nodes,
index: 0, index: 0,
@ -729,8 +683,8 @@ impl<View> TreeIterator<View> {
} }
} }
impl<View> Iterator<AbstractNode<View>> for TreeIterator<View> { impl Iterator<AbstractNode> for TreeIterator {
fn next(&mut self) -> Option<AbstractNode<View>> { fn next(&mut self) -> Option<AbstractNode> {
if self.index >= self.nodes.len() { if self.index >= self.nodes.len() {
None None
} else { } else {
@ -741,42 +695,42 @@ impl<View> Iterator<AbstractNode<View>> for TreeIterator<View> {
} }
} }
fn gather<View>(cur: &AbstractNode<View>, refs: &mut ~[AbstractNode<View>], postorder: bool) { fn gather_abstract_nodes(cur: &AbstractNode, refs: &mut ~[AbstractNode], postorder: bool) {
if !postorder { if !postorder {
refs.push(cur.clone()); refs.push(cur.clone());
} }
for kid in cur.children() { for kid in cur.children() {
gather(&kid, refs, postorder) gather_abstract_nodes(&kid, refs, postorder)
} }
if postorder { if postorder {
refs.push(cur.clone()); refs.push(cur.clone());
} }
} }
impl<View> AbstractNode<View> { impl AbstractNode {
/// Iterates over all ancestors of this node. /// Iterates over all ancestors of this node.
pub fn ancestors(&self) -> AncestorIterator<View> { pub fn ancestors(&self) -> AncestorIterator {
AncestorIterator { AncestorIterator {
current: self.parent_node(), current: self.parent_node(),
} }
} }
/// Iterates over this node and all its descendants, in preorder. /// Iterates over this node and all its descendants, in preorder.
pub fn traverse_preorder(&self) -> TreeIterator<View> { pub fn traverse_preorder(&self) -> TreeIterator {
let mut nodes = ~[]; let mut nodes = ~[];
gather(self, &mut nodes, false); gather_abstract_nodes(self, &mut nodes, false);
TreeIterator::new(nodes) TreeIterator::new(nodes)
} }
/// Iterates over this node and all its descendants, in postorder. /// Iterates over this node and all its descendants, in postorder.
pub fn sequential_traverse_postorder(&self) -> TreeIterator<View> { pub fn sequential_traverse_postorder(&self) -> TreeIterator {
let mut nodes = ~[]; let mut nodes = ~[];
gather(self, &mut nodes, true); gather_abstract_nodes(self, &mut nodes, true);
TreeIterator::new(nodes) TreeIterator::new(nodes)
} }
} }
impl<View> Node<View> { impl Node {
pub fn owner_doc(&self) -> AbstractDocument { pub fn owner_doc(&self) -> AbstractDocument {
self.owner_doc.unwrap() self.owner_doc.unwrap()
} }
@ -785,19 +739,17 @@ impl<View> Node<View> {
self.owner_doc = Some(document); self.owner_doc = Some(document);
} }
pub fn children(&self) -> AbstractNodeChildrenIterator<View> { pub fn children(&self) -> AbstractNodeChildrenIterator {
AbstractNodeChildrenIterator { AbstractNodeChildrenIterator {
current_node: self.first_child, current_node: self.first_child,
} }
} }
}
impl Node<ScriptView> {
pub fn reflect_node<N: Reflectable> pub fn reflect_node<N: Reflectable>
(node: @mut N, (node: @mut N,
document: AbstractDocument, document: AbstractDocument,
wrap_fn: extern "Rust" fn(*JSContext, *JSObject, @mut N) -> *JSObject) wrap_fn: extern "Rust" fn(*JSContext, *JSObject, @mut N) -> *JSObject)
-> AbstractNode<ScriptView> { -> AbstractNode {
assert!(node.reflector().get_jsobject().is_null()); assert!(node.reflector().get_jsobject().is_null());
let node = reflect_dom_object(node, document.document().window, wrap_fn); let node = reflect_dom_object(node, document.document().window, wrap_fn);
assert!(node.reflector().get_jsobject().is_not_null()); assert!(node.reflector().get_jsobject().is_not_null());
@ -807,15 +759,15 @@ impl Node<ScriptView> {
} }
} }
pub fn new_inherited(type_id: NodeTypeId, doc: AbstractDocument) -> Node<ScriptView> { pub fn new_inherited(type_id: NodeTypeId, doc: AbstractDocument) -> Node {
Node::new_(type_id, Some(doc)) Node::new_(type_id, Some(doc))
} }
pub fn new_without_doc(type_id: NodeTypeId) -> Node<ScriptView> { pub fn new_without_doc(type_id: NodeTypeId) -> Node {
Node::new_(type_id, None) Node::new_(type_id, None)
} }
fn new_(type_id: NodeTypeId, doc: Option<AbstractDocument>) -> Node<ScriptView> { fn new_(type_id: NodeTypeId, doc: Option<AbstractDocument>) -> Node {
Node { Node {
eventtarget: EventTarget::new_inherited(NodeTypeId), eventtarget: EventTarget::new_inherited(NodeTypeId),
type_id: type_id, type_id: type_id,
@ -845,9 +797,7 @@ impl Node<ScriptView> {
(*js_window).data.page.reap_dead_layout_data(layout_data) (*js_window).data.page.reap_dead_layout_data(layout_data)
} }
} }
}
impl Node<ScriptView> {
// http://dom.spec.whatwg.org/#dom-node-nodetype // http://dom.spec.whatwg.org/#dom-node-nodetype
pub fn NodeType(&self) -> u16 { pub fn NodeType(&self) -> u16 {
match self.type_id { match self.type_id {
@ -860,7 +810,7 @@ impl Node<ScriptView> {
} }
} }
pub fn NodeName(&self, abstract_self: AbstractNode<ScriptView>) -> DOMString { pub fn NodeName(&self, abstract_self: AbstractNode) -> DOMString {
match self.type_id { match self.type_id {
ElementNodeTypeId(*) => { ElementNodeTypeId(*) => {
do abstract_self.with_imm_element |element| { do abstract_self.with_imm_element |element| {
@ -894,11 +844,11 @@ impl Node<ScriptView> {
} }
} }
pub fn GetParentNode(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetParentNode(&self) -> Option<AbstractNode> {
self.parent_node self.parent_node
} }
pub fn GetParentElement(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetParentElement(&self) -> Option<AbstractNode> {
self.parent_node.filtered(|parent| parent.is_element()) self.parent_node.filtered(|parent| parent.is_element())
} }
@ -906,23 +856,23 @@ impl Node<ScriptView> {
self.first_child.is_some() self.first_child.is_some()
} }
pub fn GetFirstChild(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetFirstChild(&self) -> Option<AbstractNode> {
self.first_child self.first_child
} }
pub fn GetLastChild(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetLastChild(&self) -> Option<AbstractNode> {
self.last_child self.last_child
} }
pub fn GetPreviousSibling(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetPreviousSibling(&self) -> Option<AbstractNode> {
self.prev_sibling self.prev_sibling
} }
pub fn GetNextSibling(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetNextSibling(&self) -> Option<AbstractNode> {
self.next_sibling self.next_sibling
} }
pub fn GetNodeValue(&self, abstract_self: AbstractNode<ScriptView>) -> Option<DOMString> { pub fn GetNodeValue(&self, abstract_self: AbstractNode) -> Option<DOMString> {
match self.type_id { match self.type_id {
// ProcessingInstruction // ProcessingInstruction
CommentNodeTypeId | TextNodeTypeId => { CommentNodeTypeId | TextNodeTypeId => {
@ -936,11 +886,12 @@ impl Node<ScriptView> {
} }
} }
pub fn SetNodeValue(&mut self, _abstract_self: AbstractNode<ScriptView>, _val: Option<DOMString>) -> ErrorResult { pub fn SetNodeValue(&mut self, _abstract_self: AbstractNode, _val: Option<DOMString>)
-> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetTextContent(&self, abstract_self: AbstractNode<ScriptView>) -> Option<DOMString> { pub fn GetTextContent(&self, abstract_self: AbstractNode) -> Option<DOMString> {
match self.type_id { match self.type_id {
DocumentFragmentNodeTypeId | ElementNodeTypeId(*) => { DocumentFragmentNodeTypeId | ElementNodeTypeId(*) => {
let mut content = ~""; let mut content = ~"";
@ -964,7 +915,7 @@ impl Node<ScriptView> {
} }
} }
pub fn ChildNodes(&mut self, abstract_self: AbstractNode<ScriptView>) -> @mut NodeList { pub fn ChildNodes(&mut self, abstract_self: AbstractNode) -> @mut NodeList {
match self.child_list { match self.child_list {
None => { None => {
let window = self.owner_doc().document().window; let window = self.owner_doc().document().window;
@ -977,7 +928,7 @@ impl Node<ScriptView> {
} }
// http://dom.spec.whatwg.org/#concept-node-adopt // http://dom.spec.whatwg.org/#concept-node-adopt
fn adopt(node: AbstractNode<ScriptView>, document: AbstractDocument) { fn adopt(node: AbstractNode, document: AbstractDocument) {
// Step 1. // Step 1.
match node.parent_node() { match node.parent_node() {
Some(parent) => Node::remove(node, parent, false), Some(parent) => Node::remove(node, parent, false),
@ -996,11 +947,9 @@ impl Node<ScriptView> {
} }
// http://dom.spec.whatwg.org/#concept-node-pre-insert // http://dom.spec.whatwg.org/#concept-node-pre-insert
fn pre_insert(node: AbstractNode<ScriptView>, fn pre_insert(node: AbstractNode, parent: AbstractNode, child: Option<AbstractNode>)
parent: AbstractNode<ScriptView>, -> Fallible<AbstractNode> {
child: Option<AbstractNode<ScriptView>>) -> Fallible<AbstractNode<ScriptView>> { fn is_inclusive_ancestor_of(node: AbstractNode, parent: AbstractNode) -> bool {
fn is_inclusive_ancestor_of(node: AbstractNode<ScriptView>,
parent: AbstractNode<ScriptView>) -> bool {
node == parent || parent.ancestors().any(|ancestor| ancestor == node) node == parent || parent.ancestors().any(|ancestor| ancestor == node)
} }
@ -1060,7 +1009,7 @@ impl Node<ScriptView> {
// Step 6. // Step 6.
match parent.type_id() { match parent.type_id() {
DocumentNodeTypeId(_) => { DocumentNodeTypeId(_) => {
fn inclusively_followed_by_doctype(child: Option<AbstractNode<ScriptView>>) -> bool{ fn inclusively_followed_by_doctype(child: Option<AbstractNode>) -> bool{
match child { match child {
Some(child) if child.is_doctype() => true, Some(child) if child.is_doctype() => true,
Some(child) => { Some(child) => {
@ -1159,9 +1108,9 @@ impl Node<ScriptView> {
} }
// http://dom.spec.whatwg.org/#concept-node-insert // http://dom.spec.whatwg.org/#concept-node-insert
fn insert(node: AbstractNode<ScriptView>, fn insert(node: AbstractNode,
parent: AbstractNode<ScriptView>, parent: AbstractNode,
child: Option<AbstractNode<ScriptView>>, child: Option<AbstractNode>,
suppress_observers: bool) { suppress_observers: bool) {
// XXX assert owner_doc // XXX assert owner_doc
// Step 1-3: ranges. // Step 1-3: ranges.
@ -1198,8 +1147,7 @@ impl Node<ScriptView> {
} }
// http://dom.spec.whatwg.org/#concept-node-replace-all // http://dom.spec.whatwg.org/#concept-node-replace-all
pub fn replace_all(node: Option<AbstractNode<ScriptView>>, pub fn replace_all(node: Option<AbstractNode>, parent: AbstractNode) {
parent: AbstractNode<ScriptView>) {
// Step 1. // Step 1.
match node { match node {
Some(node) => Node::adopt(node, parent.node().owner_doc()), Some(node) => Node::adopt(node, parent.node().owner_doc()),
@ -1207,7 +1155,7 @@ impl Node<ScriptView> {
} }
// Step 2. // Step 2.
let removedNodes: ~[AbstractNode<ScriptView>] = parent.children().collect(); let removedNodes: ~[AbstractNode] = parent.children().collect();
// Step 3. // Step 3.
let addedNodes = match node { let addedNodes = match node {
@ -1241,8 +1189,7 @@ impl Node<ScriptView> {
} }
// http://dom.spec.whatwg.org/#concept-node-pre-remove // http://dom.spec.whatwg.org/#concept-node-pre-remove
fn pre_remove(child: AbstractNode<ScriptView>, fn pre_remove(child: AbstractNode, parent: AbstractNode) -> Fallible<AbstractNode> {
parent: AbstractNode<ScriptView>) -> Fallible<AbstractNode<ScriptView>> {
// Step 1. // Step 1.
if child.parent_node() != Some(parent) { if child.parent_node() != Some(parent) {
return Err(NotFound); return Err(NotFound);
@ -1256,9 +1203,7 @@ impl Node<ScriptView> {
} }
// http://dom.spec.whatwg.org/#concept-node-remove // http://dom.spec.whatwg.org/#concept-node-remove
fn remove(node: AbstractNode<ScriptView>, fn remove(node: AbstractNode, parent: AbstractNode, suppress_observers: bool) {
parent: AbstractNode<ScriptView>,
suppress_observers: bool) {
assert!(node.parent_node() == Some(parent)); assert!(node.parent_node() == Some(parent));
// Step 1-5: ranges. // Step 1-5: ranges.
@ -1273,9 +1218,8 @@ impl Node<ScriptView> {
} }
} }
pub fn SetTextContent(&mut self, pub fn SetTextContent(&mut self, abstract_self: AbstractNode, value: Option<DOMString>)
abstract_self: AbstractNode<ScriptView>, -> ErrorResult {
value: Option<DOMString>) -> ErrorResult {
let value = null_str_as_empty(&value); let value = null_str_as_empty(&value);
match self.type_id { match self.type_id {
DocumentFragmentNodeTypeId | ElementNodeTypeId(*) => { DocumentFragmentNodeTypeId | ElementNodeTypeId(*) => {
@ -1305,9 +1249,8 @@ impl Node<ScriptView> {
Ok(()) Ok(())
} }
pub fn InsertBefore(&self, pub fn InsertBefore(&self, node: AbstractNode, child: Option<AbstractNode>)
node: AbstractNode<ScriptView>, -> Fallible<AbstractNode> {
child: Option<AbstractNode<ScriptView>>) -> Fallible<AbstractNode<ScriptView>> {
Node::pre_insert(node, node, child) Node::pre_insert(node, node, child)
} }
@ -1316,38 +1259,37 @@ impl Node<ScriptView> {
document.document().wait_until_safe_to_modify_dom(); document.document().wait_until_safe_to_modify_dom();
} }
pub fn AppendChild(&self, pub fn AppendChild(&self, abstract_self: AbstractNode, node: AbstractNode)
abstract_self: AbstractNode<ScriptView>, -> Fallible<AbstractNode> {
node: AbstractNode<ScriptView>) -> Fallible<AbstractNode<ScriptView>> {
Node::pre_insert(node, abstract_self, None) Node::pre_insert(node, abstract_self, None)
} }
pub fn ReplaceChild(&mut self, _node: AbstractNode<ScriptView>, _child: AbstractNode<ScriptView>) -> Fallible<AbstractNode<ScriptView>> { pub fn ReplaceChild(&mut self, _node: AbstractNode, _child: AbstractNode)
-> Fallible<AbstractNode> {
fail!("stub") fail!("stub")
} }
pub fn RemoveChild(&self, pub fn RemoveChild(&self, abstract_self: AbstractNode, node: AbstractNode)
abstract_self: AbstractNode<ScriptView>, -> Fallible<AbstractNode> {
node: AbstractNode<ScriptView>) -> Fallible<AbstractNode<ScriptView>> {
Node::pre_remove(node, abstract_self) Node::pre_remove(node, abstract_self)
} }
pub fn Normalize(&mut self) { pub fn Normalize(&mut self) {
} }
pub fn CloneNode(&self, _deep: bool) -> Fallible<AbstractNode<ScriptView>> { pub fn CloneNode(&self, _deep: bool) -> Fallible<AbstractNode> {
fail!("stub") fail!("stub")
} }
pub fn IsEqualNode(&self, _node: Option<AbstractNode<ScriptView>>) -> bool { pub fn IsEqualNode(&self, _node: Option<AbstractNode>) -> bool {
false false
} }
pub fn CompareDocumentPosition(&self, _other: AbstractNode<ScriptView>) -> u16 { pub fn CompareDocumentPosition(&self, _other: AbstractNode) -> u16 {
0 0
} }
pub fn Contains(&self, _other: Option<AbstractNode<ScriptView>>) -> bool { pub fn Contains(&self, _other: Option<AbstractNode>) -> bool {
false false
} }
@ -1384,38 +1326,38 @@ impl Node<ScriptView> {
// Low-level pointer stitching // Low-level pointer stitching
// //
pub fn set_parent_node(&mut self, new_parent_node: Option<AbstractNode<ScriptView>>) { pub fn set_parent_node(&mut self, new_parent_node: Option<AbstractNode>) {
let doc = self.owner_doc(); let doc = self.owner_doc();
doc.document().wait_until_safe_to_modify_dom(); doc.document().wait_until_safe_to_modify_dom();
self.parent_node = new_parent_node self.parent_node = new_parent_node
} }
pub fn set_first_child(&mut self, new_first_child: Option<AbstractNode<ScriptView>>) { pub fn set_first_child(&mut self, new_first_child: Option<AbstractNode>) {
let doc = self.owner_doc(); let doc = self.owner_doc();
doc.document().wait_until_safe_to_modify_dom(); doc.document().wait_until_safe_to_modify_dom();
self.first_child = new_first_child self.first_child = new_first_child
} }
pub fn set_last_child(&mut self, new_last_child: Option<AbstractNode<ScriptView>>) { pub fn set_last_child(&mut self, new_last_child: Option<AbstractNode>) {
let doc = self.owner_doc(); let doc = self.owner_doc();
doc.document().wait_until_safe_to_modify_dom(); doc.document().wait_until_safe_to_modify_dom();
self.last_child = new_last_child self.last_child = new_last_child
} }
pub fn set_prev_sibling(&mut self, new_prev_sibling: Option<AbstractNode<ScriptView>>) { pub fn set_prev_sibling(&mut self, new_prev_sibling: Option<AbstractNode>) {
let doc = self.owner_doc(); let doc = self.owner_doc();
doc.document().wait_until_safe_to_modify_dom(); doc.document().wait_until_safe_to_modify_dom();
self.prev_sibling = new_prev_sibling self.prev_sibling = new_prev_sibling
} }
pub fn set_next_sibling(&mut self, new_next_sibling: Option<AbstractNode<ScriptView>>) { pub fn set_next_sibling(&mut self, new_next_sibling: Option<AbstractNode>) {
let doc = self.owner_doc(); let doc = self.owner_doc();
doc.document().wait_until_safe_to_modify_dom(); doc.document().wait_until_safe_to_modify_dom();
self.next_sibling = new_next_sibling self.next_sibling = new_next_sibling
} }
} }
impl Reflectable for Node<ScriptView> { impl Reflectable for Node {
fn reflector<'a>(&'a self) -> &'a Reflector { fn reflector<'a>(&'a self) -> &'a Reflector {
self.eventtarget.reflector() self.eventtarget.reflector()
} }
@ -1425,80 +1367,3 @@ impl Reflectable for Node<ScriptView> {
} }
} }
/// A bottom-up, parallelizable traversal.
pub trait PostorderNodeTraversal {
/// The operation to perform. Return true to continue or false to stop.
fn process(&self, node: AbstractNode<LayoutView>) -> bool;
/// Returns true if this node should be pruned. If this returns true, we skip the operation
/// entirely and do not process any descendant nodes. This is called *before* child nodes are
/// visited. The default implementation never prunes any nodes.
fn should_prune(&self, _node: AbstractNode<LayoutView>) -> bool {
false
}
}
/// A bottom-up, parallelizable traversal.
pub trait PostorderNodeMutTraversal {
/// The operation to perform. Return true to continue or false to stop.
fn process(&mut self, node: AbstractNode<LayoutView>) -> bool;
/// Returns true if this node should be pruned. If this returns true, we skip the operation
/// entirely and do not process any descendant nodes. This is called *before* child nodes are
/// visited. The default implementation never prunes any nodes.
fn should_prune(&self, _node: AbstractNode<LayoutView>) -> bool {
false
}
}
impl AbstractNode<LayoutView> {
/// Traverses the tree in postorder.
///
/// TODO(pcwalton): Offer a parallel version with a compatible API.
pub fn traverse_postorder<T:PostorderNodeTraversal>(self, traversal: &T) -> bool {
if traversal.should_prune(self) {
return true
}
let mut opt_kid = self.first_child();
loop {
match opt_kid {
None => break,
Some(kid) => {
if !kid.traverse_postorder(traversal) {
return false
}
opt_kid = kid.next_sibling()
}
}
}
traversal.process(self)
}
/// Traverses the tree in postorder.
///
/// TODO(pcwalton): Offer a parallel version with a compatible API.
pub fn traverse_postorder_mut<T:PostorderNodeMutTraversal>(mut self, traversal: &mut T) -> bool {
if traversal.should_prune(self) {
return true
}
let mut opt_kid = self.first_child();
loop {
match opt_kid {
None => break,
Some(kid) => {
if !kid.traverse_postorder_mut(traversal) {
return false
}
opt_kid = kid.next_sibling()
}
}
}
traversal.process(self)
}
}

View file

@ -4,12 +4,12 @@
use dom::bindings::codegen::NodeListBinding; use dom::bindings::codegen::NodeListBinding;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::node::{AbstractNode, ScriptView}; use dom::node::AbstractNode;
use dom::window::Window; use dom::window::Window;
enum NodeListType { enum NodeListType {
Simple(~[AbstractNode<ScriptView>]), Simple(~[AbstractNode]),
Children(AbstractNode<ScriptView>) Children(AbstractNode)
} }
pub struct NodeList { pub struct NodeList {
@ -34,11 +34,11 @@ impl NodeList {
window, NodeListBinding::Wrap) window, NodeListBinding::Wrap)
} }
pub fn new_simple_list(window: @mut Window, elements: ~[AbstractNode<ScriptView>]) -> @mut NodeList { pub fn new_simple_list(window: @mut Window, elements: ~[AbstractNode]) -> @mut NodeList {
NodeList::new(window, Simple(elements)) NodeList::new(window, Simple(elements))
} }
pub fn new_child_list(window: @mut Window, node: AbstractNode<ScriptView>) -> @mut NodeList { pub fn new_child_list(window: @mut Window, node: AbstractNode) -> @mut NodeList {
NodeList::new(window, Children(node)) NodeList::new(window, Children(node))
} }
@ -49,7 +49,7 @@ impl NodeList {
} }
} }
pub fn Item(&self, index: u32) -> Option<AbstractNode<ScriptView>> { pub fn Item(&self, index: u32) -> Option<AbstractNode> {
match self.list_type { match self.list_type {
_ if index >= self.Length() => None, _ if index >= self.Length() => None,
Simple(ref elems) => Some(elems[index]), Simple(ref elems) => Some(elems[index]),
@ -57,7 +57,7 @@ impl NodeList {
} }
} }
pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<AbstractNode<ScriptView>> { pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<AbstractNode> {
let item = self.Item(index); let item = self.Item(index);
*found = item.is_some(); *found = item.is_some();
item item

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::TextBinding;
use dom::bindings::utils::{DOMString, Fallible}; use dom::bindings::utils::{DOMString, Fallible};
use dom::characterdata::CharacterData; use dom::characterdata::CharacterData;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::node::{AbstractNode, ScriptView, Node, TextNodeTypeId}; use dom::node::{AbstractNode, Node, TextNodeTypeId};
use dom::window::Window; use dom::window::Window;
/// An HTML text node. /// An HTML text node.
@ -21,16 +21,16 @@ impl Text {
} }
} }
pub fn new(text: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn new(text: ~str, document: AbstractDocument) -> AbstractNode {
let node = Text::new_inherited(text, document); let node = Text::new_inherited(text, document);
Node::reflect_node(@mut node, document, TextBinding::Wrap) Node::reflect_node(@mut node, document, TextBinding::Wrap)
} }
pub fn Constructor(owner: @mut Window, text: DOMString) -> Fallible<AbstractNode<ScriptView>> { pub fn Constructor(owner: @mut Window, text: DOMString) -> Fallible<AbstractNode> {
Ok(Text::new(text.clone(), owner.Document())) Ok(Text::new(text.clone(), owner.Document()))
} }
pub fn SplitText(&self, _offset: u32) -> Fallible<AbstractNode<ScriptView>> { pub fn SplitText(&self, _offset: u32) -> Fallible<AbstractNode> {
fail!("unimplemented") fail!("unimplemented")
} }

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::UIEventBinding; use dom::bindings::codegen::UIEventBinding;
use dom::bindings::utils::{DOMString, Fallible}; use dom::bindings::utils::{DOMString, Fallible};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::node::{AbstractNode, ScriptView}; use dom::node::AbstractNode;
use dom::event::{AbstractEvent, Event, EventTypeId, UIEventTypeId}; use dom::event::{AbstractEvent, Event, EventTypeId, UIEventTypeId};
use dom::window::Window; use dom::window::Window;
use dom::windowproxy::WindowProxy; use dom::windowproxy::WindowProxy;
@ -85,7 +85,7 @@ impl UIEvent {
0 0
} }
pub fn GetRangeParent(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetRangeParent(&self) -> Option<AbstractNode> {
//TODO //TODO
None None
} }

View file

@ -8,7 +8,7 @@ use dom::bindings::utils::{trace_option, trace_reflector};
use dom::bindings::utils::DOMString; use dom::bindings::utils::DOMString;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::eventtarget::{EventTarget, WindowTypeId}; use dom::eventtarget::{EventTarget, WindowTypeId};
use dom::node::{AbstractNode, ScriptView}; use dom::node::AbstractNode;
use dom::location::Location; use dom::location::Location;
use dom::navigator::Navigator; use dom::navigator::Navigator;
@ -114,7 +114,7 @@ impl Window {
pub fn Blur(&self) { pub fn Blur(&self) {
} }
pub fn GetFrameElement(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetFrameElement(&self) -> Option<AbstractNode> {
None None
} }

View file

@ -9,7 +9,7 @@ use dom::htmlheadingelement::{Heading1, Heading2, Heading3, Heading4, Heading5,
use dom::htmliframeelement::IFrameSize; use dom::htmliframeelement::IFrameSize;
use dom::htmlformelement::HTMLFormElement; use dom::htmlformelement::HTMLFormElement;
use dom::namespace; use dom::namespace;
use dom::node::{AbstractNode, ElementNodeTypeId, ScriptView}; use dom::node::{AbstractNode, ElementNodeTypeId};
use dom::types::*; use dom::types::*;
use html::cssparse::{InlineProvenance, StylesheetProvenance, UrlProvenance, spawn_css_parser}; use html::cssparse::{InlineProvenance, StylesheetProvenance, UrlProvenance, spawn_css_parser};
use script_task::page_from_context; use script_task::page_from_context;
@ -77,11 +77,11 @@ trait NodeWrapping {
unsafe fn from_hubbub_node(n: hubbub::NodeDataPtr) -> Self; unsafe fn from_hubbub_node(n: hubbub::NodeDataPtr) -> Self;
} }
impl NodeWrapping for AbstractNode<ScriptView> { impl NodeWrapping for AbstractNode {
unsafe fn to_hubbub_node(self) -> hubbub::NodeDataPtr { unsafe fn to_hubbub_node(self) -> hubbub::NodeDataPtr {
cast::transmute(self) cast::transmute(self)
} }
unsafe fn from_hubbub_node(n: hubbub::NodeDataPtr) -> AbstractNode<ScriptView> { unsafe fn from_hubbub_node(n: hubbub::NodeDataPtr) -> AbstractNode {
cast::transmute(n) cast::transmute(n)
} }
} }
@ -159,7 +159,7 @@ fn js_script_listener(to_parent: SharedChan<HtmlDiscoveryMessage>,
// Silly macros to handle constructing DOM nodes. This produces bad code and should be optimized // Silly macros to handle constructing DOM nodes. This produces bad code and should be optimized
// via atomization (issue #85). // via atomization (issue #85).
pub fn build_element_from_tag(tag: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn build_element_from_tag(tag: ~str, document: AbstractDocument) -> AbstractNode {
// TODO (Issue #85): use atoms // TODO (Issue #85): use atoms
handle_element!(document, tag, "a", HTMLAnchorElement); handle_element!(document, tag, "a", HTMLAnchorElement);
handle_element!(document, tag, "applet", HTMLAppletElement); handle_element!(document, tag, "applet", HTMLAppletElement);
@ -299,7 +299,7 @@ pub fn parse_html(cx: *JSContext,
let mut parser = hubbub::Parser("UTF-8", false); let mut parser = hubbub::Parser("UTF-8", false);
debug!("created parser"); debug!("created parser");
let document_node = AbstractNode::<ScriptView>::from_document(document); let document_node = AbstractNode::from_document(document);
parser.set_document_node(unsafe { document_node.to_hubbub_node() }); parser.set_document_node(unsafe { document_node.to_hubbub_node() });
parser.enable_scripting(true); parser.enable_scripting(true);
parser.enable_styling(true); parser.enable_styling(true);
@ -415,8 +415,8 @@ pub fn parse_html(cx: *JSContext,
append_child: |parent: hubbub::NodeDataPtr, child: hubbub::NodeDataPtr| { append_child: |parent: hubbub::NodeDataPtr, child: hubbub::NodeDataPtr| {
unsafe { unsafe {
debug!("append child {:x} {:x}", parent, child); debug!("append child {:x} {:x}", parent, child);
let parent: AbstractNode<ScriptView> = NodeWrapping::from_hubbub_node(parent); let parent: AbstractNode = NodeWrapping::from_hubbub_node(parent);
let child: AbstractNode<ScriptView> = NodeWrapping::from_hubbub_node(child); let child: AbstractNode = NodeWrapping::from_hubbub_node(child);
parent.AppendChild(child); parent.AppendChild(child);
} }
child child
@ -460,7 +460,7 @@ pub fn parse_html(cx: *JSContext,
}, },
complete_script: |script| { complete_script: |script| {
unsafe { unsafe {
let scriptnode: AbstractNode<ScriptView> = NodeWrapping::from_hubbub_node(script); let scriptnode: AbstractNode = NodeWrapping::from_hubbub_node(script);
do scriptnode.with_imm_element |script| { do scriptnode.with_imm_element |script| {
match script.get_attr(None, "src") { match script.get_attr(None, "src") {
Some(src) => { Some(src) => {
@ -489,7 +489,7 @@ pub fn parse_html(cx: *JSContext,
complete_style: |style| { complete_style: |style| {
// We've reached the end of a <style> so we can submit all the text to the parser. // We've reached the end of a <style> so we can submit all the text to the parser.
unsafe { unsafe {
let style: AbstractNode<ScriptView> = NodeWrapping::from_hubbub_node(style); let style: AbstractNode = NodeWrapping::from_hubbub_node(style);
let url = FromStr::from_str("http://example.com/"); // FIXME let url = FromStr::from_str("http://example.com/"); // FIXME
let url_cell = Cell::new(url); let url_cell = Cell::new(url);

Some files were not shown because too many files have changed in this diff Show more