diff --git a/src/components/main/css/matching.rs b/src/components/main/css/matching.rs index 6de245e3d60..4ca64a8a138 100644 --- a/src/components/main/css/matching.rs +++ b/src/components/main/css/matching.rs @@ -15,20 +15,20 @@ use css::node_style::StyledNode; use layout::incremental; use layout::util::LayoutDataAccess; -use script::dom::node::{AbstractNode, LayoutView}; +use script::dom::node::LayoutNode; use style::{TNode, Stylist, cascade}; pub trait MatchMethods { fn match_node(&self, stylist: &Stylist); fn match_subtree(&self, stylist: RWArc); - fn cascade_node(&self, parent: Option>); - fn cascade_subtree(&self, parent: Option>); + fn cascade_node(&self, parent: Option); + fn cascade_subtree(&self, parent: Option); } -impl MatchMethods for AbstractNode { +impl MatchMethods for LayoutNode { 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 { None => None, Some(ref style_attribute) => Some(style_attribute) @@ -80,7 +80,7 @@ impl MatchMethods for AbstractNode { } } - fn cascade_node(&self, parent: Option>) { + fn cascade_node(&self, parent: Option) { let parent_style = match parent { Some(ref parent) => Some(parent.style()), None => None @@ -111,7 +111,7 @@ impl MatchMethods for AbstractNode { } } - fn cascade_subtree(&self, parent: Option>) { + fn cascade_subtree(&self, parent: Option) { self.cascade_node(parent); for kid in self.children() { diff --git a/src/components/main/css/node_style.rs b/src/components/main/css/node_style.rs index af9b927e171..6e2abaa81d1 100644 --- a/src/components/main/css/node_style.rs +++ b/src/components/main/css/node_style.rs @@ -9,7 +9,7 @@ use layout::incremental::RestyleDamage; use extra::arc::Arc; use style::ComputedValues; -use script::dom::node::{AbstractNode, LayoutView}; +use script::dom::node::LayoutNode; /// Node mixin providing `style` method that returns a `NodeStyle` pub trait StyledNode { @@ -17,7 +17,7 @@ pub trait StyledNode { fn restyle_damage(&self) -> RestyleDamage; } -impl StyledNode for AbstractNode { +impl StyledNode for LayoutNode { #[inline] fn style<'a>(&'a self) -> &'a Arc { self.get_css_select_results() diff --git a/src/components/main/css/node_util.rs b/src/components/main/css/node_util.rs index b5d8e790c00..3b24f85e9de 100644 --- a/src/components/main/css/node_util.rs +++ b/src/components/main/css/node_util.rs @@ -8,7 +8,7 @@ use layout::util::LayoutDataAccess; use extra::arc::Arc; use std::cast; use style::{ComputedValues, TNode}; -use script::dom::node::{AbstractNode, LayoutView}; +use script::dom::node::LayoutNode; pub trait NodeUtil { fn get_css_select_results<'a>(&'a self) -> &'a Arc; @@ -18,7 +18,7 @@ pub trait NodeUtil { fn set_restyle_damage(self, damage: RestyleDamage); } -impl NodeUtil for AbstractNode { +impl NodeUtil for LayoutNode { /** * Provides the computed style for the given node. If CSS selector * Returns the style results for the given node. If CSS selector diff --git a/src/components/main/layout/box.rs b/src/components/main/layout/box.rs index 9c341f12028..99d72aeec04 100644 --- a/src/components/main/layout/box.rs +++ b/src/components/main/layout/box.rs @@ -15,7 +15,7 @@ use gfx::display_list::{TextDisplayItemClass, TextDisplayItemFlags, ClipDisplayI use gfx::display_list::{ClipDisplayItemClass}; use gfx::font::{FontStyle, FontWeight300}; use gfx::text::text_run::TextRun; -use script::dom::node::{AbstractNode, LayoutView}; +use script::dom::node::LayoutNode; use servo_msg::constellation_msg::{FrameRectMsg, PipelineId, SubpageId}; use servo_net::image::holder::ImageHolder; use servo_net::local_image_cache::LocalImageCache; @@ -116,12 +116,10 @@ impl ImageBoxInfo { /// /// FIXME(pcwalton): The fact that image boxes store the cache in the box makes little sense to /// me. - pub fn new(node: &AbstractNode, - image_url: Url, - local_image_cache: MutexArc) + pub fn new(node: &LayoutNode, image_url: Url, local_image_cache: MutexArc) -> ImageBoxInfo { - fn convert_length(node: &AbstractNode, name: &str) -> Option { - node.with_imm_element(|element| { + fn convert_length(node: &LayoutNode, name: &str) -> Option { + node.with_element(|element| { element.get_attr(None, name).and_then(|string| { let n: Option = FromStr::from_str(string); n @@ -165,8 +163,8 @@ pub struct IframeBoxInfo { impl IframeBoxInfo { /// Creates the information specific to an iframe box. - pub fn new(node: &AbstractNode) -> IframeBoxInfo { - node.with_imm_iframe_element(|iframe_element| { + pub fn new(node: &LayoutNode) -> IframeBoxInfo { + node.with_iframe_element(|iframe_element| { let size = iframe_element.size.unwrap(); IframeBoxInfo { pipeline_id: size.pipeline_id, @@ -209,8 +207,8 @@ pub struct UnscannedTextBoxInfo { impl UnscannedTextBoxInfo { /// Creates a new instance of `UnscannedTextBoxInfo` from the given DOM node. - pub fn new(node: &AbstractNode) -> UnscannedTextBoxInfo { - node.with_imm_text(|text_node| { + pub fn new(node: &LayoutNode) -> UnscannedTextBoxInfo { + node.with_text(|text_node| { // FIXME(pcwalton): Don't copy text; atomically reference count it instead. UnscannedTextBoxInfo { text: text_node.element.data.to_str(), @@ -230,7 +228,7 @@ pub enum SplitBoxResult { impl Box { /// Constructs a new `Box` instance. - pub fn new(node: AbstractNode, 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 // its immediate parent.) // @@ -250,7 +248,7 @@ impl Box { } Box { - node: OpaqueNode::from_node(&node), + node: OpaqueNode::from_layout_node(&node), style: (*nearest_ancestor_element.style()).clone(), position: Slot::init(Au::zero_rect()), border: Slot::init(Zero::zero()), diff --git a/src/components/main/layout/construct.rs b/src/components/main/layout/construct.rs index 42764b9fe60..cc9478aca56 100644 --- a/src/components/main/layout/construct.rs +++ b/src/components/main/layout/construct.rs @@ -32,9 +32,9 @@ use layout::text::TextRunScanner; use layout::util::LayoutDataAccess; use script::dom::element::{HTMLIframeElementTypeId, HTMLImageElementTypeId}; -use script::dom::node::{AbstractNode, CommentNodeTypeId, DoctypeNodeTypeId}; -use script::dom::node::{DocumentFragmentNodeTypeId, DocumentNodeTypeId, ElementNodeTypeId}; -use script::dom::node::{LayoutView, PostorderNodeMutTraversal, TextNodeTypeId}; +use script::dom::node::{CommentNodeTypeId, DoctypeNodeTypeId, DocumentFragmentNodeTypeId}; +use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, LayoutNode}; +use script::dom::node::{PostorderNodeMutTraversal, TextNodeTypeId}; use servo_util::slot::Slot; use std::util; use style::computed_values::{display, float}; @@ -198,9 +198,9 @@ impl<'self> FlowConstructor<'self> { } /// 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) -> Option { + fn build_box_info_for_image(&mut self, node: LayoutNode) -> Option { // FIXME(pcwalton): Don't copy URLs. - let url = node.with_imm_image_element(|image_element| { + let url = node.with_image_element(|image_element| { image_element.image.as_ref().map(|url| (*url).clone()) }); @@ -215,7 +215,7 @@ impl<'self> FlowConstructor<'self> { } /// Builds a `Box` for the given node. - fn build_box_for_node(&mut self, node: AbstractNode) -> Box { + fn build_box_for_node(&mut self, node: LayoutNode) -> Box { let specific = match node.type_id() { ElementNodeTypeId(HTMLImageElementTypeId) => { match self.build_box_info_for_image(node) { @@ -235,10 +235,7 @@ impl<'self> FlowConstructor<'self> { /// `#[inline(always)]` because this is performance critical and LLVM will not inline it /// otherwise. #[inline(always)] - fn flush_inline_boxes_to_flow(&mut self, - boxes: ~[Box], - flow: &mut ~Flow:, - node: AbstractNode) { + fn flush_inline_boxes_to_flow(&mut self, boxes: ~[Box], flow: &mut ~Flow:, node: LayoutNode) { if boxes.len() > 0 { let inline_base = FlowData::new(self.next_flow_id(), node); let mut inline_flow = ~InlineFlow::from_boxes(inline_base, boxes) as ~Flow:; @@ -252,7 +249,7 @@ impl<'self> FlowConstructor<'self> { fn flush_inline_boxes_to_flow_if_necessary(&mut self, opt_boxes: &mut Option<~[Box]>, flow: &mut ~Flow:, - node: AbstractNode) { + node: LayoutNode) { let opt_boxes = util::replace(opt_boxes, None); if opt_boxes.len() > 0 { self.flush_inline_boxes_to_flow(opt_boxes.to_vec(), flow, node) @@ -264,7 +261,7 @@ impl<'self> FlowConstructor<'self> { /// whether {ib} splits needed to happen. fn build_children_of_block_flow(&mut self, flow: &mut ~Flow:, - node: AbstractNode) { + node: LayoutNode) { // Gather up boxes for the inline flows we might need to create. let mut opt_boxes_for_inline_flow = None; let mut first_box = true; @@ -349,7 +346,7 @@ impl<'self> FlowConstructor<'self> { /// 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 /// to happen. - fn build_flow_for_block(&mut self, node: AbstractNode) -> ~Flow: { + fn build_flow_for_block(&mut self, node: LayoutNode) -> ~Flow: { let base = FlowData::new(self.next_flow_id(), node); let box = self.build_box_for_node(node); let mut flow = ~BlockFlow::from_box(base, box) as ~Flow:; @@ -359,7 +356,7 @@ impl<'self> FlowConstructor<'self> { /// Builds the flow for a node with `float: {left|right}`. This yields a float `BlockFlow` with /// a `BlockFlow` underneath it. - fn build_flow_for_floated_block(&mut self, node: AbstractNode, float_type: FloatType) + fn build_flow_for_floated_block(&mut self, node: LayoutNode, float_type: FloatType) -> ~Flow: { let base = FlowData::new(self.next_flow_id(), node); let box = self.build_box_for_node(node); @@ -371,7 +368,7 @@ impl<'self> FlowConstructor<'self> { /// Concatenates the boxes of kids, adding in our own borders/padding/margins if necessary. /// Returns the `InlineBoxesConstructionResult`, if any. There will be no /// `InlineBoxesConstructionResult` if this node consisted entirely of ignorable whitespace. - fn build_boxes_for_nonreplaced_inline_content(&mut self, node: AbstractNode) + fn build_boxes_for_nonreplaced_inline_content(&mut self, node: LayoutNode) -> ConstructionResult { let mut opt_inline_block_splits = None; let mut opt_box_accumulator = None; @@ -437,8 +434,7 @@ impl<'self> FlowConstructor<'self> { /// 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`. - fn build_boxes_for_replaced_inline_content(&mut self, node: AbstractNode) - -> ConstructionResult { + fn build_boxes_for_replaced_inline_content(&mut self, node: LayoutNode) -> ConstructionResult { for kid in node.children() { kid.set_flow_construction_result(NoConstructionResult) } @@ -454,7 +450,7 @@ impl<'self> FlowConstructor<'self> { /// Builds one or more boxes for a node with `display: inline`. This yields an /// `InlineBoxesConstructionResult`. - fn build_boxes_for_inline(&mut self, node: AbstractNode) -> ConstructionResult { + fn build_boxes_for_inline(&mut self, node: LayoutNode) -> ConstructionResult { // Is this node replaced content? if !node.is_replaced_content() { // Go to a path that concatenates our kids' boxes. @@ -470,7 +466,7 @@ impl<'self> PostorderNodeMutTraversal for FlowConstructor<'self> { // `#[inline(always)]` because this is always called from the traversal function and for some // reason LLVM's inlining heuristics go awry here. #[inline(always)] - fn process(&mut self, node: AbstractNode) -> bool { + fn process(&mut self, node: LayoutNode) -> bool { // Get the `display` property for this node, and determine whether this node is floated. let (display, float) = match node.type_id() { ElementNodeTypeId(_) => { @@ -540,7 +536,7 @@ trait NodeUtils { fn is_ignorable_whitespace(self) -> bool; } -impl NodeUtils for AbstractNode { +impl NodeUtils for LayoutNode { fn is_replaced_content(self) -> bool { match self.type_id() { TextNodeTypeId | @@ -572,7 +568,7 @@ impl NodeUtils for AbstractNode { } fn is_ignorable_whitespace(self) -> bool { - self.is_text() && self.with_imm_text(|text| text.element.data.is_whitespace()) + self.is_text() && self.with_text(|text| text.element.data.is_whitespace()) } } diff --git a/src/components/main/layout/extra.rs b/src/components/main/layout/extra.rs index 8b6a8c46478..7bc4847f5d3 100644 --- a/src/components/main/layout/extra.rs +++ b/src/components/main/layout/extra.rs @@ -6,7 +6,7 @@ use layout::util::{LayoutData, LayoutDataAccess}; -use script::dom::node::{AbstractNode, LayoutView}; +use script::dom::node::LayoutNode; /// Functionality useful for querying the layout-specific data on DOM nodes. pub trait LayoutAuxMethods { @@ -14,7 +14,7 @@ pub trait LayoutAuxMethods { fn initialize_style_for_subtree(self); } -impl LayoutAuxMethods for AbstractNode { +impl LayoutAuxMethods for LayoutNode { /// Resets layout data and styles for the node. /// /// FIXME(pcwalton): Do this as part of box building instead of in a traversal. diff --git a/src/components/main/layout/flow.rs b/src/components/main/layout/flow.rs index 4b612286b30..4062e13a30c 100644 --- a/src/components/main/layout/flow.rs +++ b/src/components/main/layout/flow.rs @@ -39,7 +39,7 @@ use extra::container::Deque; use geom::point::Point2D; use geom::rect::Rect; use gfx::display_list::{ClipDisplayItemClass, DisplayList}; -use script::dom::node::{AbstractNode, LayoutView}; +use script::dom::node::LayoutNode; use servo_util::geometry::Au; use std::cast; use std::cell::Cell; @@ -382,7 +382,6 @@ impl FlowFlags { /// FIXME: We need a naming convention for pseudo-inheritance like this. How about /// `CommonFlowInfo`? pub struct FlowData { - node: AbstractNode, restyle_damage: RestyleDamage, /// The children of this flow. @@ -433,10 +432,9 @@ impl Iterator<@Box> for BoxIterator { impl FlowData { #[inline] - pub fn new(id: int, node: AbstractNode) -> FlowData { + pub fn new(id: int, node: LayoutNode) -> FlowData { let style = node.style(); FlowData { - node: node, restyle_damage: node.restyle_damage(), children: DList::new(), diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs index 74070b6a6f8..2d83e0f1a6a 100644 --- a/src/components/main/layout/layout_task.rs +++ b/src/components/main/layout/layout_task.rs @@ -28,7 +28,7 @@ use gfx::opts::Opts; use gfx::render_task::{RenderMsg, RenderChan, RenderLayer}; use gfx::{render_task, color}; use script::dom::event::ReflowEvent; -use script::dom::node::{AbstractNode, LayoutDataRef, LayoutView, ElementNodeTypeId}; +use script::dom::node::{AbstractNode, ElementNodeTypeId, LayoutDataRef, LayoutNode}; use script::dom::element::{HTMLBodyElementTypeId, HTMLHtmlElementTypeId}; use script::layout_interface::{AddStylesheetMsg, ContentBoxQuery}; use script::layout_interface::{ContentBoxesQuery, ContentBoxesResponse, ExitNowMsg, LayoutQuery}; @@ -358,8 +358,7 @@ impl LayoutTask { /// is intertwined with selector matching, making it difficult to compare directly. It is /// marked `#[inline(never)]` to aid benchmarking in sampling profilers. #[inline(never)] - fn construct_flow_tree(&self, layout_context: &mut LayoutContext, node: AbstractNode) - -> ~Flow: { + fn construct_flow_tree(&self, layout_context: &mut LayoutContext, node: LayoutNode) -> ~Flow: { node.traverse_postorder_mut(&mut FlowConstructor::init(layout_context)); let result = match *node.mutate_layout_data().ptr { @@ -401,7 +400,7 @@ impl LayoutTask { /// The high-level routine that performs layout tasks. fn handle_reflow(&mut self, data: &Reflow) { // FIXME: Isolate this transmutation into a "bridge" module. - let node: &AbstractNode = unsafe { + let node: &LayoutNode = unsafe { transmute(&data.document_root) }; @@ -534,7 +533,7 @@ impl LayoutTask { // 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`. ContentBoxQuery(node, reply_chan) => { - let node = OpaqueNode::from_node(&node); + let node = OpaqueNode::from_script_node(&node); fn union_boxes_for_node<'a>( accumulator: &mut Option>, @@ -557,7 +556,7 @@ impl LayoutTask { reply_chan.send(ContentBoxResponse(rect.unwrap_or(Au::zero_rect()))) } ContentBoxesQuery(node, reply_chan) => { - let node = OpaqueNode::from_node(&node); + let node = OpaqueNode::from_script_node(&node); fn add_boxes_for_node<'a>( accumulator: &mut ~[Rect], @@ -608,8 +607,8 @@ impl LayoutTask { // incremental flow construction could create this. Paranoid validation // against the set of valid nodes should occur in the script task to // ensure that this is a valid address instead of transmuting here. - let node: AbstractNode = unsafe { - item.base().extra.to_node() + let node: AbstractNode = unsafe { + item.base().extra.to_script_node() }; let resp = Some(HitTestResponse(node)); return resp; diff --git a/src/components/main/layout/util.rs b/src/components/main/layout/util.rs index 66681135b52..4621578e481 100644 --- a/src/components/main/layout/util.rs +++ b/src/components/main/layout/util.rs @@ -6,7 +6,7 @@ use layout::box::Box; use layout::construct::{ConstructionResult, NoConstructionResult}; use extra::arc::Arc; -use script::dom::node::{AbstractNode, LayoutView}; +use script::dom::node::{AbstractNode, LayoutNode}; use servo_util::range::Range; use servo_util::slot::{MutSlotRef, SlotRef}; use std::cast; @@ -163,23 +163,23 @@ pub trait LayoutDataAccess { fn mutate_layout_data<'a>(&'a self) -> MutSlotRef<'a,Option<~LayoutData>>; } -impl LayoutDataAccess for AbstractNode { +impl LayoutDataAccess for LayoutNode { #[inline(always)] 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)] fn borrow_layout_data<'a>(&'a self) -> SlotRef<'a,Option<~LayoutData>> { unsafe { - cast::transmute(self.node().layout_data.borrow()) + cast::transmute(self.get().layout_data.borrow()) } } #[inline(always)] fn mutate_layout_data<'a>(&'a self) -> MutSlotRef<'a,Option<~LayoutData>> { unsafe { - cast::transmute(self.node().layout_data.mutate()) + cast::transmute(self.get().layout_data.mutate()) } } } @@ -193,25 +193,24 @@ impl LayoutDataAccess for AbstractNode { #[deriving(Clone, Eq)] pub struct OpaqueNode(uintptr_t); -impl Equiv> for OpaqueNode { - fn equiv(&self, node: &AbstractNode) -> bool { - unsafe { - **self == cast::transmute_copy::,uintptr_t>(node) - } - } -} - impl OpaqueNode { - /// Converts a DOM node to an `OpaqueNode`. - pub fn from_node(node: &AbstractNode) -> OpaqueNode { + /// Converts a DOM node (layout view) to an `OpaqueNode`. + pub fn from_layout_node(node: &LayoutNode) -> OpaqueNode { unsafe { OpaqueNode(cast::transmute_copy(node)) } } - /// Unsafely converts an `OpaqueNode` to a DOM node. Use this only if you absolutely know what - /// you're doing. - pub unsafe fn to_node(&self) -> AbstractNode { + /// Converts a DOM node (script view) to an `OpaqueNode`. + pub fn from_script_node(node: &AbstractNode) -> OpaqueNode { + 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) } diff --git a/src/components/script/dom/attrlist.rs b/src/components/script/dom/attrlist.rs index 48f74be69d5..450a6830e8b 100644 --- a/src/components/script/dom/attrlist.rs +++ b/src/components/script/dom/attrlist.rs @@ -5,18 +5,17 @@ use dom::attr::Attr; use dom::bindings::codegen::AttrListBinding; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; -use dom::node::{AbstractNode, ScriptView}; +use dom::node::{AbstractNode}; use dom::window::Window; pub struct AttrList { reflector_: Reflector, window: @mut Window, - owner: AbstractNode + owner: AbstractNode, } impl AttrList { - pub fn new_inherited(window: @mut Window, - elem: AbstractNode) -> AttrList { + pub fn new_inherited(window: @mut Window, elem: AbstractNode) -> AttrList { AttrList { reflector_: Reflector::new(), window: window, @@ -24,7 +23,7 @@ impl AttrList { } } - pub fn new(window: @mut Window, elem: AbstractNode) -> @mut AttrList { + pub fn new(window: @mut Window, elem: AbstractNode) -> @mut AttrList { reflect_dom_object(@mut AttrList::new_inherited(window, elem), window, AttrListBinding::Wrap) } diff --git a/src/components/script/dom/bindings/codegen/Bindings.conf b/src/components/script/dom/bindings/codegen/Bindings.conf index 18665606bba..daeae22bb31 100644 --- a/src/components/script/dom/bindings/codegen/Bindings.conf +++ b/src/components/script/dom/bindings/codegen/Bindings.conf @@ -121,7 +121,7 @@ DOMInterfaces = { }], 'CharacterData': { - 'nativeType': 'AbstractNode', + 'nativeType': 'AbstractNode', 'concreteType': 'CharacterData', 'pointerType': '' }, @@ -182,7 +182,7 @@ DOMInterfaces = { }], 'Element': { - 'nativeType': 'AbstractNode', + 'nativeType': 'AbstractNode', 'pointerType': '', 'needsAbstract': ['getClientRects', 'getBoundingClientRect', 'setAttribute', 'setAttributeNS', 'id', 'attributes'] }, @@ -239,7 +239,7 @@ DOMInterfaces = { }, 'HTMLFormElement': { - 'nativeType': 'AbstractNode', + 'nativeType': 'AbstractNode', 'pointerType': '', 'register': False }, @@ -302,7 +302,7 @@ DOMInterfaces = { }, 'Node': { - 'nativeType': 'AbstractNode', + 'nativeType': 'AbstractNode', 'concreteType': 'Node', 'pointerType': '', 'needsAbstract': [ @@ -574,7 +574,7 @@ def addExternalIface(iface, nativeType=None, headerFile=None, pointerType=None): def addHTMLElement(element, concrete=None, needsAbstract=[]): DOMInterfaces[element] = { - 'nativeType': 'AbstractNode', + 'nativeType': 'AbstractNode', 'pointerType': '', 'concreteType': concrete if concrete else element, 'customTrace': 'trace', diff --git a/src/components/script/dom/bindings/node.rs b/src/components/script/dom/bindings/node.rs index 6a009a9bac4..a3b18c278f7 100644 --- a/src/components/script/dom/bindings/node.rs +++ b/src/components/script/dom/bindings/node.rs @@ -11,7 +11,7 @@ use std::libc; use std::ptr; use js::jsapi::{JSTracer, JSTRACE_OBJECT, JS_CallTracer}; -impl Reflectable for AbstractNode { +impl Reflectable for AbstractNode { fn reflector<'a>(&'a self) -> &'a Reflector { self.node().reflector() } @@ -24,7 +24,7 @@ impl Reflectable for AbstractNode { impl Traceable for Node { fn trace(&self, tracer: *mut JSTracer) { #[fixed_stack_segment] - fn trace_node(tracer: *mut JSTracer, node: Option>, name: &str) { + fn trace_node(tracer: *mut JSTracer, node: Option, name: &str) { if node.is_none() { return; } diff --git a/src/components/script/dom/comment.rs b/src/components/script/dom/comment.rs index bae0ba0f66b..1d42d28b97f 100644 --- a/src/components/script/dom/comment.rs +++ b/src/components/script/dom/comment.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::CommentBinding; use dom::bindings::utils::{DOMString, Fallible}; use dom::characterdata::CharacterData; use dom::document::AbstractDocument; -use dom::node::{AbstractNode, ScriptView, CommentNodeTypeId, Node}; +use dom::node::{AbstractNode, CommentNodeTypeId, Node}; use dom::window::Window; /// An HTML comment. @@ -21,12 +21,12 @@ impl Comment { } } - pub fn new(text: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(text: ~str, document: AbstractDocument) -> AbstractNode { let node = Comment::new_inherited(text, document); Node::reflect_node(@mut node, document, CommentBinding::Wrap) } - pub fn Constructor(owner: @mut Window, data: DOMString) -> Fallible> { + pub fn Constructor(owner: @mut Window, data: DOMString) -> Fallible { Ok(Comment::new(data, owner.Document())) } } diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index cd3bb578507..d6ed1a05b1f 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -92,7 +92,7 @@ pub struct Document { window: @mut Window, doctype: DocumentType, title: ~str, - idmap: HashMap> + idmap: HashMap } impl Document { @@ -161,7 +161,7 @@ impl Reflectable for Document { } impl Document { - pub fn GetDocumentElement(&self) -> Option> { + pub fn GetDocumentElement(&self) -> Option { do self.node.children().find |c| { c.is_element() } @@ -183,7 +183,7 @@ impl Document { HTMLCollection::new(self.window, ~[]) } - pub fn GetElementById(&self, id: DOMString) -> Option> { + pub fn GetElementById(&self, id: DOMString) -> Option { // TODO: "in tree order, within the context object's tree" // http://dom.spec.whatwg.org/#dom-document-getelementbyid. match self.idmap.find_equiv(&id) { @@ -192,7 +192,8 @@ impl Document { } } - pub fn CreateElement(&self, abstract_self: AbstractDocument, local_name: DOMString) -> Fallible> { + pub fn CreateElement(&self, abstract_self: AbstractDocument, local_name: DOMString) + -> Fallible { if xml_name_type(local_name) == InvalidXMLName { debug!("Not a valid element name"); return Err(InvalidCharacter); @@ -201,15 +202,16 @@ impl Document { Ok(build_element_from_tag(local_name, abstract_self)) } - pub fn CreateDocumentFragment(&self, abstract_self: AbstractDocument) -> AbstractNode { + pub fn CreateDocumentFragment(&self, abstract_self: AbstractDocument) -> AbstractNode { DocumentFragment::new(abstract_self) } - pub fn CreateTextNode(&self, abstract_self: AbstractDocument, data: DOMString) -> AbstractNode { + pub fn CreateTextNode(&self, abstract_self: AbstractDocument, data: DOMString) + -> AbstractNode { Text::new(data, abstract_self) } - pub fn CreateComment(&self, abstract_self: AbstractDocument, data: DOMString) -> AbstractNode { + pub fn CreateComment(&self, abstract_self: AbstractDocument, data: DOMString) -> AbstractNode { Comment::new(data, abstract_self) } @@ -330,15 +332,15 @@ impl Document { self.window.wait_until_safe_to_modify_dom(); } - pub fn register_nodes_with_id(&mut self, root: &AbstractNode) { - foreach_ided_elements(root, |id: &DOMString, abstract_node: &AbstractNode| { + pub fn register_nodes_with_id(&mut self, root: &AbstractNode) { + foreach_ided_elements(root, |id: &DOMString, abstract_node: &AbstractNode| { // TODO: "in tree order, within the context object's tree" // http://dom.spec.whatwg.org/#dom-document-getelementbyid. self.idmap.find_or_insert(id.clone(), *abstract_node); }); } - pub fn unregister_nodes_with_id(&mut self, root: &AbstractNode) { + pub fn unregister_nodes_with_id(&mut self, root: &AbstractNode) { foreach_ided_elements(root, |id: &DOMString, _| { // TODO: "in tree order, within the context object's tree" // http://dom.spec.whatwg.org/#dom-document-getelementbyid. @@ -347,7 +349,7 @@ impl Document { } pub fn update_idmap(&mut self, - abstract_self: AbstractNode, + abstract_self: AbstractNode, new_id: DOMString, old_id: Option) { // remove old ids if the old ones are not same as the new one. @@ -359,19 +361,17 @@ impl Document { } // TODO: support the case if multiple elements which haves same id are in the same document. - self.idmap.mangle(new_id, abstract_self, - |_, new_node: AbstractNode| -> AbstractNode { + self.idmap.mangle(new_id, abstract_self, |_, new_node: AbstractNode| -> AbstractNode { new_node }, - |_, old_node: &mut AbstractNode, new_node: AbstractNode| { + |_, old_node: &mut AbstractNode, new_node: AbstractNode| { *old_node = new_node; }); } } #[inline(always)] -fn foreach_ided_elements(root: &AbstractNode, - callback: &fn(&DOMString, &AbstractNode)) { +fn foreach_ided_elements(root: &AbstractNode, callback: &fn(&DOMString, &AbstractNode)) { for node in root.traverse_preorder() { if !node.is_element() { continue; diff --git a/src/components/script/dom/documentfragment.rs b/src/components/script/dom/documentfragment.rs index 1f4e6a35113..fdee1c68aca 100644 --- a/src/components/script/dom/documentfragment.rs +++ b/src/components/script/dom/documentfragment.rs @@ -21,14 +21,14 @@ impl DocumentFragment { } } - pub fn new(document: AbstractDocument) -> AbstractNode { + pub fn new(document: AbstractDocument) -> AbstractNode { let node = DocumentFragment::new_inherited(document); Node::reflect_node(@mut node, document, DocumentFragmentBinding::Wrap) } } impl DocumentFragment { - pub fn Constructor(owner: @mut Window) -> Fallible> { + pub fn Constructor(owner: @mut Window) -> Fallible { Ok(DocumentFragment::new(owner.Document())) } } diff --git a/src/components/script/dom/documenttype.rs b/src/components/script/dom/documenttype.rs index 9c4d6a750fa..a15db60e415 100644 --- a/src/components/script/dom/documenttype.rs +++ b/src/components/script/dom/documenttype.rs @@ -36,7 +36,8 @@ impl DocumentType { public_id: Option<~str>, system_id: Option<~str>, force_quirks: bool, - document: AbstractDocument) -> AbstractNode { + document: AbstractDocument) + -> AbstractNode { let documenttype = DocumentType::new_inherited(name, public_id, system_id, diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs index 001cd3e34f9..d214614f45e 100644 --- a/src/components/script/dom/element.rs +++ b/src/components/script/dom/element.rs @@ -187,15 +187,13 @@ impl<'self> Element { }) } - pub fn set_attr(&mut self, - abstract_self: AbstractNode, - name: DOMString, - 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) } pub fn set_attribute(&mut self, - abstract_self: AbstractNode, + abstract_self: AbstractNode, namespace: Namespace, raw_name: DOMString, value: DOMString) -> ErrorResult { @@ -260,7 +258,7 @@ impl<'self> Element { } fn after_set_attr(&mut self, - abstract_self: AbstractNode, + abstract_self: AbstractNode, local_name: DOMString, value: DOMString, old_value: Option) { @@ -309,18 +307,18 @@ impl Element { self.tag_name.to_ascii_upper() } - pub fn Id(&self, _abstract_self: AbstractNode) -> DOMString { + pub fn Id(&self, _abstract_self: AbstractNode) -> DOMString { match self.get_attr(None, "id") { Some(x) => x, None => ~"" } } - pub fn SetId(&mut self, abstract_self: AbstractNode, id: DOMString) { + pub fn SetId(&mut self, abstract_self: AbstractNode, id: DOMString) { self.set_attribute(abstract_self, namespace::Null, ~"id", id); } - pub fn Attributes(&mut self, abstract_self: AbstractNode) -> @mut AttrList { + pub fn Attributes(&mut self, abstract_self: AbstractNode) -> @mut AttrList { match self.attr_list { None => { let window = self.node.owner_doc().document().window; @@ -341,16 +339,14 @@ impl Element { .map(|attr| attr.value.clone()) } - pub fn SetAttribute(&mut self, - abstract_self: AbstractNode, - name: DOMString, - value: DOMString) -> ErrorResult { + pub fn SetAttribute(&mut self, abstract_self: AbstractNode, name: DOMString, value: DOMString) + -> ErrorResult { self.set_attr(abstract_self, name, value); Ok(()) } pub fn SetAttributeNS(&mut self, - abstract_self: AbstractNode, + abstract_self: AbstractNode, namespace_url: Option, name: DOMString, value: DOMString) -> ErrorResult { @@ -409,7 +405,7 @@ impl Element { pub fn MozRequestPointerLock(&self) { } - pub fn GetClientRects(&self, abstract_self: AbstractNode) -> @mut ClientRectList { + pub fn GetClientRects(&self, abstract_self: AbstractNode) -> @mut ClientRectList { let win = self.node.owner_doc().document().window; let node = abstract_self; assert!(node.is_element()); @@ -431,7 +427,7 @@ impl Element { ClientRectList::new(win, rects) } - pub fn GetBoundingClientRect(&self, abstract_self: AbstractNode) -> @mut ClientRect { + pub fn GetBoundingClientRect(&self, abstract_self: AbstractNode) -> @mut ClientRect { let win = self.node.owner_doc().document().window; let node = abstract_self; assert!(node.is_element()); @@ -509,7 +505,7 @@ impl Element { Ok(()) } - pub fn QuerySelector(&self, _selectors: DOMString) -> Fallible>> { + pub fn QuerySelector(&self, _selectors: DOMString) -> Fallible> { Ok(None) } } diff --git a/src/components/script/dom/eventtarget.rs b/src/components/script/dom/eventtarget.rs index a47d780b3bf..d3768ed656e 100644 --- a/src/components/script/dom/eventtarget.rs +++ b/src/components/script/dom/eventtarget.rs @@ -8,7 +8,7 @@ use dom::bindings::codegen::EventListenerBinding::EventListener; use dom::document::AbstractDocument; use dom::event::AbstractEvent; use dom::eventdispatcher::dispatch_event; -use dom::node::{AbstractNode, ScriptView}; +use dom::node::AbstractNode; use dom::window::Window; use std::cast; @@ -50,7 +50,7 @@ impl AbstractEventTarget { } } - pub fn from_node(node: AbstractNode) -> AbstractEventTarget { + pub fn from_node(node: AbstractNode) -> AbstractEventTarget { unsafe { cast::transmute(node) } diff --git a/src/components/script/dom/formdata.rs b/src/components/script/dom/formdata.rs index 1ee68db74fb..3722fb3e9ca 100644 --- a/src/components/script/dom/formdata.rs +++ b/src/components/script/dom/formdata.rs @@ -6,7 +6,7 @@ use dom::bindings::utils::{Fallible, Reflectable, Reflector, reflect_dom_object} use dom::bindings::utils::DOMString; use dom::bindings::codegen::FormDataBinding; use dom::blob::Blob; -use dom::node::{AbstractNode, ScriptView}; +use dom::node::AbstractNode; use dom::window::Window; use std::hashmap::HashMap; @@ -20,11 +20,11 @@ pub struct FormData { data: HashMap<~str, FormDatum>, reflector_: Reflector, window: @mut Window, - form: Option> + form: Option } impl FormData { - pub fn new_inherited(form: Option>, window: @mut Window) -> FormData { + pub fn new_inherited(form: Option, window: @mut Window) -> FormData { FormData { data: HashMap::new(), reflector_: Reflector::new(), @@ -33,12 +33,12 @@ impl FormData { } } - pub fn new(form: Option>, window: @mut Window) -> @mut FormData { + pub fn new(form: Option, window: @mut Window) -> @mut FormData { reflect_dom_object(@mut FormData::new_inherited(form, window), window, FormDataBinding::Wrap) } - pub fn Constructor(window: @mut Window, - form: Option>) -> Fallible<@mut FormData> { + pub fn Constructor(window: @mut Window, form: Option) + -> Fallible<@mut FormData> { Ok(FormData::new(form, window)) } diff --git a/src/components/script/dom/htmlanchorelement.rs b/src/components/script/dom/htmlanchorelement.rs index 17f3db7bb67..db1d68472d2 100644 --- a/src/components/script/dom/htmlanchorelement.rs +++ b/src/components/script/dom/htmlanchorelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLAnchorElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLAnchorElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLAnchorElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLAnchorElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLAnchorElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlappletelement.rs b/src/components/script/dom/htmlappletelement.rs index e21460eeae3..5d5a9f5df5d 100644 --- a/src/components/script/dom/htmlappletelement.rs +++ b/src/components/script/dom/htmlappletelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLAppletElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLAppletElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLAppletElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLAppletElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLAppletElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlareaelement.rs b/src/components/script/dom/htmlareaelement.rs index 13df0e4fe49..cb088d52542 100644 --- a/src/components/script/dom/htmlareaelement.rs +++ b/src/components/script/dom/htmlareaelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLAreaElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLAreaElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLAreaElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLAreaElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLAreaElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlaudioelement.rs b/src/components/script/dom/htmlaudioelement.rs index 6ece4235c7c..45f2e9af340 100644 --- a/src/components/script/dom/htmlaudioelement.rs +++ b/src/components/script/dom/htmlaudioelement.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLAudioElementBinding; use dom::document::AbstractDocument; use dom::element::HTMLAudioElementTypeId; use dom::htmlmediaelement::HTMLMediaElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLAudioElement { htmlmediaelement: HTMLMediaElement @@ -19,7 +19,7 @@ impl HTMLAudioElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLAudioElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLAudioElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlbaseelement.rs b/src/components/script/dom/htmlbaseelement.rs index 97970b1128d..10d07f226c5 100644 --- a/src/components/script/dom/htmlbaseelement.rs +++ b/src/components/script/dom/htmlbaseelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLBaseElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLBaseElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLBaseElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLBaseElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLBaseElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlbodyelement.rs b/src/components/script/dom/htmlbodyelement.rs index 10d5ebb3dab..944d09ce3b2 100644 --- a/src/components/script/dom/htmlbodyelement.rs +++ b/src/components/script/dom/htmlbodyelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLBodyElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLBodyElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLBodyElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLBodyElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLBodyElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlbrelement.rs b/src/components/script/dom/htmlbrelement.rs index 6fe7748467c..51e04f07d58 100644 --- a/src/components/script/dom/htmlbrelement.rs +++ b/src/components/script/dom/htmlbrelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLBRElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLBRElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLBRElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLBRElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLBRElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlbuttonelement.rs b/src/components/script/dom/htmlbuttonelement.rs index 963d9524cee..95b162acaa6 100644 --- a/src/components/script/dom/htmlbuttonelement.rs +++ b/src/components/script/dom/htmlbuttonelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLButtonElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; use dom::validitystate::ValidityState; pub struct HTMLButtonElement { @@ -21,7 +21,7 @@ impl HTMLButtonElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLButtonElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLButtonElementBinding::Wrap) } @@ -44,7 +44,7 @@ impl HTMLButtonElement { Ok(()) } - pub fn GetForm(&self) -> Option> { + pub fn GetForm(&self) -> Option { None } diff --git a/src/components/script/dom/htmlcanvaselement.rs b/src/components/script/dom/htmlcanvaselement.rs index 4c789163d72..086c859447a 100644 --- a/src/components/script/dom/htmlcanvaselement.rs +++ b/src/components/script/dom/htmlcanvaselement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLCanvasElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLCanvasElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLCanvasElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLCanvasElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLCanvasElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlcollection.rs b/src/components/script/dom/htmlcollection.rs index 204c1a23501..f374d5bd70e 100644 --- a/src/components/script/dom/htmlcollection.rs +++ b/src/components/script/dom/htmlcollection.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::HTMLCollectionBinding; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{DOMString, Fallible}; -use dom::node::{AbstractNode, ScriptView}; +use dom::node::AbstractNode; use dom::window::Window; use js::jsapi::{JSObject, JSContext}; @@ -13,14 +13,13 @@ use js::jsapi::{JSObject, JSContext}; use std::ptr; pub struct HTMLCollection { - elements: ~[AbstractNode], + elements: ~[AbstractNode], reflector_: Reflector, window: @mut Window, } impl HTMLCollection { - pub fn new_inherited(window: @mut Window, - elements: ~[AbstractNode]) -> HTMLCollection { + pub fn new_inherited(window: @mut Window, elements: ~[AbstractNode]) -> HTMLCollection { HTMLCollection { elements: elements, reflector_: Reflector::new(), @@ -28,8 +27,7 @@ impl HTMLCollection { } } - pub fn new(window: @mut Window, - elements: ~[AbstractNode]) -> @mut HTMLCollection { + pub fn new(window: @mut Window, elements: ~[AbstractNode]) -> @mut HTMLCollection { reflect_dom_object(@mut HTMLCollection::new_inherited(window, elements), window, HTMLCollectionBinding::Wrap) } @@ -38,7 +36,7 @@ impl HTMLCollection { self.elements.len() as u32 } - pub fn Item(&self, index: u32) -> Option> { + pub fn Item(&self, index: u32) -> Option { if index < self.Length() { Some(self.elements[index]) } else { @@ -50,7 +48,7 @@ impl HTMLCollection { Ok(ptr::null()) } - pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { + pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option { *found = true; self.Item(index) } diff --git a/src/components/script/dom/htmldataelement.rs b/src/components/script/dom/htmldataelement.rs index 98c24c28e2e..7a4f7795a9f 100644 --- a/src/components/script/dom/htmldataelement.rs +++ b/src/components/script/dom/htmldataelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLDataElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLDataElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLDataElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLDataElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLDataElementBinding::Wrap) } diff --git a/src/components/script/dom/htmldatalistelement.rs b/src/components/script/dom/htmldatalistelement.rs index 9f5bfce6b37..2cc31b6b428 100644 --- a/src/components/script/dom/htmldatalistelement.rs +++ b/src/components/script/dom/htmldatalistelement.rs @@ -7,7 +7,7 @@ use dom::document::AbstractDocument; use dom::element::HTMLDataListElementTypeId; use dom::htmlcollection::HTMLCollection; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLDataListElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLDataListElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLDataListElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLDataListElementBinding::Wrap) } diff --git a/src/components/script/dom/htmldirectoryelement.rs b/src/components/script/dom/htmldirectoryelement.rs index fb63cecfaf9..026e8883055 100644 --- a/src/components/script/dom/htmldirectoryelement.rs +++ b/src/components/script/dom/htmldirectoryelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::ErrorResult; use dom::document::AbstractDocument; use dom::element::HTMLDirectoryElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLDirectoryElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLDirectoryElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLDirectoryElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLDirectoryElementBinding::Wrap) } diff --git a/src/components/script/dom/htmldivelement.rs b/src/components/script/dom/htmldivelement.rs index fd148438fdf..0d32034dcf6 100644 --- a/src/components/script/dom/htmldivelement.rs +++ b/src/components/script/dom/htmldivelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLDivElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLDivElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLDivElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLDivElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLDivElementBinding::Wrap) } diff --git a/src/components/script/dom/htmldlistelement.rs b/src/components/script/dom/htmldlistelement.rs index 4310b55b609..3bfff50575a 100644 --- a/src/components/script/dom/htmldlistelement.rs +++ b/src/components/script/dom/htmldlistelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLDListElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLDListElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLDListElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLDListElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLDListElementBinding::Wrap) } diff --git a/src/components/script/dom/htmldocument.rs b/src/components/script/dom/htmldocument.rs index 16bf7f8b569..6fb84620ab0 100644 --- a/src/components/script/dom/htmldocument.rs +++ b/src/components/script/dom/htmldocument.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{Reflectable, Reflector, Traceable}; use dom::document::{AbstractDocument, Document, HTML}; use dom::element::HTMLHeadElementTypeId; use dom::htmlcollection::HTMLCollection; -use dom::node::{AbstractNode, ScriptView, ElementNodeTypeId}; +use dom::node::{AbstractNode, ElementNodeTypeId}; use dom::window::Window; use js::jsapi::JSTracer; @@ -32,7 +32,7 @@ impl HTMLDocument { } impl HTMLDocument { - pub fn GetHead(&self) -> Option> { + pub fn GetHead(&self) -> Option { match self.parent.GetDocumentElement() { None => None, Some(root) => root.traverse_preorder().find(|child| { diff --git a/src/components/script/dom/htmlelement.rs b/src/components/script/dom/htmlelement.rs index 6a79ee11864..f8703298926 100644 --- a/src/components/script/dom/htmlelement.rs +++ b/src/components/script/dom/htmlelement.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLElementBinding; use dom::bindings::utils::{DOMString, ErrorResult, Fallible}; use dom::document::AbstractDocument; use dom::element::{Element, ElementTypeId, HTMLElementTypeId}; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; use js::jsapi::{JSContext, JSVal}; use js::JSVAL_NULL; use dom::namespace; @@ -22,7 +22,7 @@ impl HTMLElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLElement::new_inherited(HTMLElementTypeId, localName, document); Node::reflect_node(@mut element, document, HTMLElementBinding::Wrap) } @@ -133,7 +133,7 @@ impl HTMLElement { pub fn SetClassName(&self, _class: DOMString) { } - pub fn GetOffsetParent(&self) -> Option> { + pub fn GetOffsetParent(&self) -> Option { None } diff --git a/src/components/script/dom/htmlembedelement.rs b/src/components/script/dom/htmlembedelement.rs index 9319680bfc0..b387aa51800 100644 --- a/src/components/script/dom/htmlembedelement.rs +++ b/src/components/script/dom/htmlembedelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLEmbedElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLEmbedElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLEmbedElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLEmbedElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLEmbedElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlfieldsetelement.rs b/src/components/script/dom/htmlfieldsetelement.rs index 9eb4a3be627..f63a56fe723 100644 --- a/src/components/script/dom/htmlfieldsetelement.rs +++ b/src/components/script/dom/htmlfieldsetelement.rs @@ -8,7 +8,7 @@ use dom::document::AbstractDocument; use dom::element::HTMLFieldSetElementTypeId; use dom::htmlcollection::HTMLCollection; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; use dom::validitystate::ValidityState; pub struct HTMLFieldSetElement { @@ -22,7 +22,7 @@ impl HTMLFieldSetElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLFieldSetElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLFieldSetElementBinding::Wrap) } @@ -37,7 +37,7 @@ impl HTMLFieldSetElement { Ok(()) } - pub fn GetForm(&self) -> Option> { + pub fn GetForm(&self) -> Option { None } diff --git a/src/components/script/dom/htmlfontelement.rs b/src/components/script/dom/htmlfontelement.rs index 22526ec9bc9..dc9924b102b 100644 --- a/src/components/script/dom/htmlfontelement.rs +++ b/src/components/script/dom/htmlfontelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLFontElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLFontElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLFontElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLFontElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLFontElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlformelement.rs b/src/components/script/dom/htmlformelement.rs index d312816def9..4382c863169 100644 --- a/src/components/script/dom/htmlformelement.rs +++ b/src/components/script/dom/htmlformelement.rs @@ -8,7 +8,7 @@ use dom::document::AbstractDocument; use dom::element::HTMLFormElementTypeId; use dom::htmlcollection::HTMLCollection; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLFormElement { htmlelement: HTMLElement @@ -21,7 +21,7 @@ impl HTMLFormElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLFormElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLFormElementBinding::Wrap) } @@ -120,7 +120,7 @@ impl HTMLFormElement { false } - pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> AbstractNode { + pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> AbstractNode { fail!("Not implemented.") } } diff --git a/src/components/script/dom/htmlframeelement.rs b/src/components/script/dom/htmlframeelement.rs index b63333f55fe..c8daf679ccc 100644 --- a/src/components/script/dom/htmlframeelement.rs +++ b/src/components/script/dom/htmlframeelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLFrameElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; use dom::windowproxy::WindowProxy; pub struct HTMLFrameElement { @@ -21,7 +21,7 @@ impl HTMLFrameElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLFrameElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLFrameElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlframesetelement.rs b/src/components/script/dom/htmlframesetelement.rs index 9a569b4d18d..60aa03d4e94 100644 --- a/src/components/script/dom/htmlframesetelement.rs +++ b/src/components/script/dom/htmlframesetelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLFrameSetElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLFrameSetElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLFrameSetElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLFrameSetElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLFrameSetElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlheadelement.rs b/src/components/script/dom/htmlheadelement.rs index cd2a046cba9..d480504aeab 100644 --- a/src/components/script/dom/htmlheadelement.rs +++ b/src/components/script/dom/htmlheadelement.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLHeadElementBinding; use dom::document::AbstractDocument; use dom::element::HTMLHeadElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLHeadElement { htmlelement: HTMLElement @@ -19,7 +19,7 @@ impl HTMLHeadElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLHeadElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLHeadElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlheadingelement.rs b/src/components/script/dom/htmlheadingelement.rs index aa1a4b6a96a..284982c6852 100644 --- a/src/components/script/dom/htmlheadingelement.rs +++ b/src/components/script/dom/htmlheadingelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::DOMString; use dom::document::AbstractDocument; use dom::element::HTMLHeadingElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub enum HeadingLevel { Heading1, @@ -31,7 +31,7 @@ impl HTMLHeadingElement { } } - pub fn new(localName: ~str, document: AbstractDocument, level: HeadingLevel) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument, level: HeadingLevel) -> AbstractNode { let element = HTMLHeadingElement::new_inherited(localName, document, level); Node::reflect_node(@mut element, document, HTMLHeadingElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlhrelement.rs b/src/components/script/dom/htmlhrelement.rs index a3897d3ffb5..274e82be2ff 100644 --- a/src/components/script/dom/htmlhrelement.rs +++ b/src/components/script/dom/htmlhrelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLHRElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLHRElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLHRElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLHRElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLHRElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlhtmlelement.rs b/src/components/script/dom/htmlhtmlelement.rs index b445e08a64e..685f01b6bbd 100644 --- a/src/components/script/dom/htmlhtmlelement.rs +++ b/src/components/script/dom/htmlhtmlelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLHtmlElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLHtmlElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLHtmlElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLHtmlElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLHtmlElementBinding::Wrap) } diff --git a/src/components/script/dom/htmliframeelement.rs b/src/components/script/dom/htmliframeelement.rs index d1579164f41..b41dd2c773e 100644 --- a/src/components/script/dom/htmliframeelement.rs +++ b/src/components/script/dom/htmliframeelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLIframeElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; use dom::windowproxy::WindowProxy; use extra::url::Url; @@ -52,7 +52,7 @@ impl HTMLIFrameElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLIFrameElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLIFrameElementBinding::Wrap) } @@ -83,14 +83,14 @@ impl HTMLIFrameElement { Ok(()) } - pub fn Sandbox(&self, _abstract_self: AbstractNode) -> DOMString { + pub fn Sandbox(&self, _abstract_self: AbstractNode) -> DOMString { match self.htmlelement.element.GetAttribute(~"sandbox") { Some(s) => s.to_owned(), None => ~"", } } - pub fn SetSandbox(&mut self, abstract_self: AbstractNode, sandbox: DOMString) { + pub fn SetSandbox(&mut self, abstract_self: AbstractNode, sandbox: DOMString) { self.htmlelement.element.SetAttribute(abstract_self, ~"sandbox", sandbox); } diff --git a/src/components/script/dom/htmlimageelement.rs b/src/components/script/dom/htmlimageelement.rs index 6e8192a2349..d4f8479abe7 100644 --- a/src/components/script/dom/htmlimageelement.rs +++ b/src/components/script/dom/htmlimageelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLImageElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; use extra::url::Url; use servo_util::geometry::to_px; use layout_interface::{ContentBoxQuery, ContentBoxResponse}; @@ -29,7 +29,7 @@ impl HTMLImageElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLImageElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLImageElementBinding::Wrap) } @@ -74,13 +74,11 @@ impl HTMLImageElement { Ok(()) } - pub fn Src(&self, _abstract_self: AbstractNode) -> DOMString { + pub fn Src(&self, _abstract_self: AbstractNode) -> DOMString { ~"" } - pub fn SetSrc(&mut self, - abstract_self: AbstractNode, - src: DOMString) -> ErrorResult { + pub fn SetSrc(&mut self, abstract_self: AbstractNode, src: DOMString) -> ErrorResult { let node = &mut self.htmlelement.element; node.set_attr(abstract_self, ~"src", src.clone()); Ok(()) @@ -110,7 +108,7 @@ impl HTMLImageElement { Ok(()) } - pub fn Width(&self, abstract_self: AbstractNode) -> u32 { + pub fn Width(&self, abstract_self: AbstractNode) -> u32 { let node = &self.htmlelement.element.node; let page = node.owner_doc().document().window.page; let (port, chan) = stream(); @@ -121,15 +119,13 @@ impl HTMLImageElement { } } - pub fn SetWidth(&mut self, - abstract_self: AbstractNode, - width: u32) -> ErrorResult { + pub fn SetWidth(&mut self, abstract_self: AbstractNode, width: u32) -> ErrorResult { let node = &mut self.htmlelement.element; node.set_attr(abstract_self, ~"width", width.to_str()); Ok(()) } - pub fn Height(&self, abstract_self: AbstractNode) -> u32 { + pub fn Height(&self, abstract_self: AbstractNode) -> u32 { let node = &self.htmlelement.element.node; let page = node.owner_doc().document().window.page; let (port, chan) = stream(); @@ -140,9 +136,7 @@ impl HTMLImageElement { } } - pub fn SetHeight(&mut self, - abstract_self: AbstractNode, - height: u32) -> ErrorResult { + pub fn SetHeight(&mut self, abstract_self: AbstractNode, height: u32) -> ErrorResult { let node = &mut self.htmlelement.element; node.set_attr(abstract_self, ~"height", height.to_str()); Ok(()) diff --git a/src/components/script/dom/htmlinputelement.rs b/src/components/script/dom/htmlinputelement.rs index 6dac0543645..6505fdc62b5 100644 --- a/src/components/script/dom/htmlinputelement.rs +++ b/src/components/script/dom/htmlinputelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult, Fallible}; use dom::document::AbstractDocument; use dom::element::HTMLInputElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLInputElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLInputElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLInputElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLInputElementBinding::Wrap) } diff --git a/src/components/script/dom/htmllabelelement.rs b/src/components/script/dom/htmllabelelement.rs index b1e9dffe81a..cfba2f43256 100644 --- a/src/components/script/dom/htmllabelelement.rs +++ b/src/components/script/dom/htmllabelelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::DOMString; use dom::document::AbstractDocument; use dom::element::HTMLLabelElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLLabelElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLLabelElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLLabelElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLLabelElementBinding::Wrap) } diff --git a/src/components/script/dom/htmllegendelement.rs b/src/components/script/dom/htmllegendelement.rs index a5893cfd224..11e0409c022 100644 --- a/src/components/script/dom/htmllegendelement.rs +++ b/src/components/script/dom/htmllegendelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLLegendElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLLegendElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLLegendElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLLegendElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLLegendElementBinding::Wrap) } diff --git a/src/components/script/dom/htmllielement.rs b/src/components/script/dom/htmllielement.rs index 67643b2daab..28ce96b2392 100644 --- a/src/components/script/dom/htmllielement.rs +++ b/src/components/script/dom/htmllielement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLLIElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLLIElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLLIElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLLIElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLLIElementBinding::Wrap) } diff --git a/src/components/script/dom/htmllinkelement.rs b/src/components/script/dom/htmllinkelement.rs index ce740b3394b..905ca7109d4 100644 --- a/src/components/script/dom/htmllinkelement.rs +++ b/src/components/script/dom/htmllinkelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLLinkElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLLinkElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLLinkElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLLinkElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLLinkElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlmainelement.rs b/src/components/script/dom/htmlmainelement.rs index cbcd68d17b7..a310f139660 100644 --- a/src/components/script/dom/htmlmainelement.rs +++ b/src/components/script/dom/htmlmainelement.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLMainElementBinding; use dom::document::AbstractDocument; use dom::element::HTMLMainElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLMainElement { htmlelement: HTMLElement @@ -19,7 +19,7 @@ impl HTMLMainElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLMainElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLMainElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlmapelement.rs b/src/components/script/dom/htmlmapelement.rs index 1a05862b61e..fc6bbc444c5 100644 --- a/src/components/script/dom/htmlmapelement.rs +++ b/src/components/script/dom/htmlmapelement.rs @@ -8,7 +8,7 @@ use dom::htmlcollection::HTMLCollection; use dom::document::AbstractDocument; use dom::element::HTMLMapElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLMapElement { htmlelement: HTMLElement @@ -21,7 +21,7 @@ impl HTMLMapElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLMapElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLMapElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlmetaelement.rs b/src/components/script/dom/htmlmetaelement.rs index f6dee84c73d..e57d3d6b595 100644 --- a/src/components/script/dom/htmlmetaelement.rs +++ b/src/components/script/dom/htmlmetaelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLMetaElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLMetaElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLMetaElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLMetaElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLMetaElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlmeterelement.rs b/src/components/script/dom/htmlmeterelement.rs index ea039682f51..30067b1d0e9 100644 --- a/src/components/script/dom/htmlmeterelement.rs +++ b/src/components/script/dom/htmlmeterelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::ErrorResult; use dom::document::AbstractDocument; use dom::element::HTMLMeterElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLMeterElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLMeterElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLMeterElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLMeterElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlmodelement.rs b/src/components/script/dom/htmlmodelement.rs index 3e6365334b7..b1357875f17 100644 --- a/src/components/script/dom/htmlmodelement.rs +++ b/src/components/script/dom/htmlmodelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLModElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLModElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLModElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLModElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLModElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlobjectelement.rs b/src/components/script/dom/htmlobjectelement.rs index a44d05b81ff..eb4375be216 100644 --- a/src/components/script/dom/htmlobjectelement.rs +++ b/src/components/script/dom/htmlobjectelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLObjectElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; use dom::validitystate::ValidityState; use dom::windowproxy::WindowProxy; @@ -22,7 +22,7 @@ impl HTMLObjectElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLObjectElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLObjectElementBinding::Wrap) } @@ -61,7 +61,7 @@ impl HTMLObjectElement { Ok(()) } - pub fn GetForm(&self) -> Option> { + pub fn GetForm(&self) -> Option { None } diff --git a/src/components/script/dom/htmlolistelement.rs b/src/components/script/dom/htmlolistelement.rs index ed38eb0e871..9946f51ba3d 100644 --- a/src/components/script/dom/htmlolistelement.rs +++ b/src/components/script/dom/htmlolistelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLOListElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLOListElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLOListElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLOListElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLOListElementBinding::Wrap) } diff --git a/src/components/script/dom/htmloptgroupelement.rs b/src/components/script/dom/htmloptgroupelement.rs index 0e9e3588ee7..8c1d4c3922c 100644 --- a/src/components/script/dom/htmloptgroupelement.rs +++ b/src/components/script/dom/htmloptgroupelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLOptGroupElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLOptGroupElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLOptGroupElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLOptGroupElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLOptGroupElementBinding::Wrap) } diff --git a/src/components/script/dom/htmloptionelement.rs b/src/components/script/dom/htmloptionelement.rs index 3d46580a080..6beb2ba3c18 100644 --- a/src/components/script/dom/htmloptionelement.rs +++ b/src/components/script/dom/htmloptionelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLOptionElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLOptionElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLOptionElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLOptionElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLOptionElementBinding::Wrap) } @@ -35,7 +35,7 @@ impl HTMLOptionElement { Ok(()) } - pub fn GetForm(&self) -> Option> { + pub fn GetForm(&self) -> Option { None } diff --git a/src/components/script/dom/htmloutputelement.rs b/src/components/script/dom/htmloutputelement.rs index 13063193792..26b399af8b3 100644 --- a/src/components/script/dom/htmloutputelement.rs +++ b/src/components/script/dom/htmloutputelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLOutputElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; use dom::validitystate::ValidityState; pub struct HTMLOutputElement { @@ -21,14 +21,14 @@ impl HTMLOutputElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLOutputElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLOutputElementBinding::Wrap) } } impl HTMLOutputElement { - pub fn GetForm(&self) -> Option> { + pub fn GetForm(&self) -> Option { None } diff --git a/src/components/script/dom/htmlparagraphelement.rs b/src/components/script/dom/htmlparagraphelement.rs index 36ef329b9fd..3fdc422cced 100644 --- a/src/components/script/dom/htmlparagraphelement.rs +++ b/src/components/script/dom/htmlparagraphelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLParagraphElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLParagraphElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLParagraphElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLParagraphElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLParagraphElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlparamelement.rs b/src/components/script/dom/htmlparamelement.rs index 423cf6d913b..80e1696fa4e 100644 --- a/src/components/script/dom/htmlparamelement.rs +++ b/src/components/script/dom/htmlparamelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLParamElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLParamElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLParamElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLParamElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLParamElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlpreelement.rs b/src/components/script/dom/htmlpreelement.rs index 2c736fd7d8e..2fb9752d096 100644 --- a/src/components/script/dom/htmlpreelement.rs +++ b/src/components/script/dom/htmlpreelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLPreElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLPreElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLPreElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLPreElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLPreElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlprogresselement.rs b/src/components/script/dom/htmlprogresselement.rs index 7f7c13d6318..b3f8f49a152 100644 --- a/src/components/script/dom/htmlprogresselement.rs +++ b/src/components/script/dom/htmlprogresselement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{ErrorResult, Fallible}; use dom::document::AbstractDocument; use dom::element::HTMLProgressElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLProgressElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLProgressElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLProgressElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLProgressElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlquoteelement.rs b/src/components/script/dom/htmlquoteelement.rs index dfef4b1a97b..82992c73006 100644 --- a/src/components/script/dom/htmlquoteelement.rs +++ b/src/components/script/dom/htmlquoteelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLQuoteElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLQuoteElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLQuoteElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLQuoteElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLQuoteElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlscriptelement.rs b/src/components/script/dom/htmlscriptelement.rs index 37b49fbd1ac..50f923e7718 100644 --- a/src/components/script/dom/htmlscriptelement.rs +++ b/src/components/script/dom/htmlscriptelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLScriptElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; use style::TElement; pub struct HTMLScriptElement { @@ -21,7 +21,7 @@ impl HTMLScriptElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLScriptElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLScriptElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlselectelement.rs b/src/components/script/dom/htmlselectelement.rs index 98ea62a144c..ffdee692bee 100644 --- a/src/components/script/dom/htmlselectelement.rs +++ b/src/components/script/dom/htmlselectelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLSelectElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; use dom::validitystate::ValidityState; pub struct HTMLSelectElement { @@ -21,7 +21,7 @@ impl HTMLSelectElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLSelectElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLSelectElementBinding::Wrap) } @@ -44,7 +44,7 @@ impl HTMLSelectElement { Ok(()) } - pub fn GetForm(&self) -> Option> { + pub fn GetForm(&self) -> Option { None } @@ -92,19 +92,19 @@ impl HTMLSelectElement { Ok(()) } - pub fn Item(&self, _index: u32) -> Option> { + pub fn Item(&self, _index: u32) -> Option { None } - pub fn NamedItem(&self, _name: DOMString) -> Option> { + pub fn NamedItem(&self, _name: DOMString) -> Option { None } - pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option> { + pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option { None } - pub fn IndexedSetter(&mut self, _index: u32, _option: Option>) -> ErrorResult { + pub fn IndexedSetter(&mut self, _index: u32, _option: Option) -> ErrorResult { Ok(()) } diff --git a/src/components/script/dom/htmlsourceelement.rs b/src/components/script/dom/htmlsourceelement.rs index 54a83b35d0a..ba5701e7cc1 100644 --- a/src/components/script/dom/htmlsourceelement.rs +++ b/src/components/script/dom/htmlsourceelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLSourceElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLSourceElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLSourceElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLSourceElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLSourceElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlspanelement.rs b/src/components/script/dom/htmlspanelement.rs index f1678043a62..b63e5fc9626 100644 --- a/src/components/script/dom/htmlspanelement.rs +++ b/src/components/script/dom/htmlspanelement.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLSpanElementBinding; use dom::document::AbstractDocument; use dom::element::HTMLSpanElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLSpanElement { htmlelement: HTMLElement @@ -19,7 +19,7 @@ impl HTMLSpanElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLSpanElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLSpanElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlstyleelement.rs b/src/components/script/dom/htmlstyleelement.rs index 8e8fefaabe4..b43d75d0321 100644 --- a/src/components/script/dom/htmlstyleelement.rs +++ b/src/components/script/dom/htmlstyleelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLStyleElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLStyleElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLStyleElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLStyleElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLStyleElementBinding::Wrap) } diff --git a/src/components/script/dom/htmltablecaptionelement.rs b/src/components/script/dom/htmltablecaptionelement.rs index 0e538fe5049..5f3c6edc2f7 100644 --- a/src/components/script/dom/htmltablecaptionelement.rs +++ b/src/components/script/dom/htmltablecaptionelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLTableCaptionElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLTableCaptionElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLTableCaptionElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLTableCaptionElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLTableCaptionElementBinding::Wrap) } diff --git a/src/components/script/dom/htmltablecolelement.rs b/src/components/script/dom/htmltablecolelement.rs index a50850181b1..c640c852140 100644 --- a/src/components/script/dom/htmltablecolelement.rs +++ b/src/components/script/dom/htmltablecolelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLTableColElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLTableColElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLTableColElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLTableColElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLTableColElementBinding::Wrap) } diff --git a/src/components/script/dom/htmltabledatacellelement.rs b/src/components/script/dom/htmltabledatacellelement.rs index 4b3dda09745..52ee1d24d64 100644 --- a/src/components/script/dom/htmltabledatacellelement.rs +++ b/src/components/script/dom/htmltabledatacellelement.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLTableDataCellElementBinding; use dom::document::AbstractDocument; use dom::element::HTMLTableDataCellElementTypeId; use dom::htmltablecellelement::HTMLTableCellElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLTableDataCellElement { htmltablecellelement: HTMLTableCellElement, @@ -19,7 +19,7 @@ impl HTMLTableDataCellElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLTableDataCellElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLTableDataCellElementBinding::Wrap) } diff --git a/src/components/script/dom/htmltableelement.rs b/src/components/script/dom/htmltableelement.rs index 2ecb39d92e9..9c5b639cf7b 100644 --- a/src/components/script/dom/htmltableelement.rs +++ b/src/components/script/dom/htmltableelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLTableElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLTableElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLTableElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLTableElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLTableElementBinding::Wrap) } diff --git a/src/components/script/dom/htmltableheadercellelement.rs b/src/components/script/dom/htmltableheadercellelement.rs index 59a9d596aea..20cddcc9dc1 100644 --- a/src/components/script/dom/htmltableheadercellelement.rs +++ b/src/components/script/dom/htmltableheadercellelement.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLTableHeaderCellElementBinding; use dom::document::AbstractDocument; use dom::element::HTMLTableHeaderCellElementTypeId; use dom::htmltablecellelement::HTMLTableCellElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLTableHeaderCellElement { htmltablecellelement: HTMLTableCellElement, @@ -19,7 +19,7 @@ impl HTMLTableHeaderCellElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLTableHeaderCellElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLTableHeaderCellElementBinding::Wrap) } diff --git a/src/components/script/dom/htmltablerowelement.rs b/src/components/script/dom/htmltablerowelement.rs index e8966bdc298..67ecfe7fd5c 100644 --- a/src/components/script/dom/htmltablerowelement.rs +++ b/src/components/script/dom/htmltablerowelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLTableRowElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLTableRowElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLTableRowElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLTableRowElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLTableRowElementBinding::Wrap) } diff --git a/src/components/script/dom/htmltablesectionelement.rs b/src/components/script/dom/htmltablesectionelement.rs index a1282bd70cc..4d22c72a2e1 100644 --- a/src/components/script/dom/htmltablesectionelement.rs +++ b/src/components/script/dom/htmltablesectionelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLTableSectionElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLTableSectionElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLTableSectionElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLTableSectionElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLTableSectionElementBinding::Wrap) } diff --git a/src/components/script/dom/htmltemplateelement.rs b/src/components/script/dom/htmltemplateelement.rs index b42e8f5df06..389e1313631 100644 --- a/src/components/script/dom/htmltemplateelement.rs +++ b/src/components/script/dom/htmltemplateelement.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLTemplateElementBinding; use dom::document::AbstractDocument; use dom::element::HTMLTemplateElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLTemplateElement { htmlelement: HTMLElement, @@ -19,7 +19,7 @@ impl HTMLTemplateElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLTemplateElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLTemplateElementBinding::Wrap) } diff --git a/src/components/script/dom/htmltextareaelement.rs b/src/components/script/dom/htmltextareaelement.rs index c4553ec5c32..3fb59cce249 100644 --- a/src/components/script/dom/htmltextareaelement.rs +++ b/src/components/script/dom/htmltextareaelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult, Fallible}; use dom::document::AbstractDocument; use dom::element::HTMLTextAreaElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLTextAreaElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLTextAreaElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLTextAreaElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLTextAreaElementBinding::Wrap) } diff --git a/src/components/script/dom/htmltimeelement.rs b/src/components/script/dom/htmltimeelement.rs index f619e6562ba..0aff5d026e4 100644 --- a/src/components/script/dom/htmltimeelement.rs +++ b/src/components/script/dom/htmltimeelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLTimeElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLTimeElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLTimeElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLTimeElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLTimeElementBinding::Wrap) } diff --git a/src/components/script/dom/htmltitleelement.rs b/src/components/script/dom/htmltitleelement.rs index da30b76728a..aa654e6086d 100644 --- a/src/components/script/dom/htmltitleelement.rs +++ b/src/components/script/dom/htmltitleelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLTitleElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLTitleElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLTitleElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLTitleElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLTitleElementBinding::Wrap) } diff --git a/src/components/script/dom/htmltrackelement.rs b/src/components/script/dom/htmltrackelement.rs index 3ca6b5ff803..db42315564e 100644 --- a/src/components/script/dom/htmltrackelement.rs +++ b/src/components/script/dom/htmltrackelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLTrackElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLTrackElement { htmlelement: HTMLElement, @@ -20,7 +20,7 @@ impl HTMLTrackElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLTrackElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLTrackElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlulistelement.rs b/src/components/script/dom/htmlulistelement.rs index eeee90fe46a..16c4a44b6e2 100644 --- a/src/components/script/dom/htmlulistelement.rs +++ b/src/components/script/dom/htmlulistelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLUListElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLUListElement { htmlelement: HTMLElement @@ -20,7 +20,7 @@ impl HTMLUListElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLUListElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLUListElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlunknownelement.rs b/src/components/script/dom/htmlunknownelement.rs index 4ff25898e13..1ff729cc39f 100644 --- a/src/components/script/dom/htmlunknownelement.rs +++ b/src/components/script/dom/htmlunknownelement.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::HTMLUnknownElementBinding; use dom::document::AbstractDocument; use dom::element::HTMLUnknownElementTypeId; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLUnknownElement { htmlelement: HTMLElement @@ -19,7 +19,7 @@ impl HTMLUnknownElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLUnknownElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLUnknownElementBinding::Wrap) } diff --git a/src/components/script/dom/htmlvideoelement.rs b/src/components/script/dom/htmlvideoelement.rs index 3ab2c780a66..38bb636d9d4 100644 --- a/src/components/script/dom/htmlvideoelement.rs +++ b/src/components/script/dom/htmlvideoelement.rs @@ -7,7 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLVideoElementTypeId; use dom::htmlmediaelement::HTMLMediaElement; -use dom::node::{AbstractNode, Node, ScriptView}; +use dom::node::{AbstractNode, Node}; pub struct HTMLVideoElement { htmlmediaelement: HTMLMediaElement @@ -20,7 +20,7 @@ impl HTMLVideoElement { } } - pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLVideoElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLVideoElementBinding::Wrap) } diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs index 1e71b5c2fea..35c1f01569a 100644 --- a/src/components/script/dom/node.rs +++ b/src/components/script/dom/node.rs @@ -31,36 +31,160 @@ use style::TNode; // 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 wrapper so that layout can access only the properties that it should have access to. Layout +/// should only ever see this. +#[deriving(Clone, Eq)] +pub struct LayoutNode { + priv node: AbstractNode, +} -/// 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; +impl LayoutNode { + // NB: Do not make this public. + // + // FIXME(pcwalton): Probably this should be marked `unsafe`. + fn new(node: AbstractNode) -> LayoutNode { + LayoutNode { + node: node, + } + } -// We shouldn't need Eq for ScriptView and LayoutView; see Rust #7671. + /// FIXME(pcwalton): This isn't safe, as it exposes guts, and should be deprecated. + pub fn get<'a>(&'a self) -> &'a Node { + unsafe { + cast::transmute(self.node.node()) + } + } + + /// Returns the first child of this node. + pub fn first_child(&self) -> Option { + self.node.first_child().map(|node| LayoutNode::new(node)) + } + + /// Returns the first child of this node. + pub fn last_child(&self) -> Option { + self.node.last_child().map(|node| LayoutNode::new(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 { + 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 { + 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() + } + + /// Downcasts this node to an image element and calls the given closure. + /// + /// FIXME(pcwalton): RAII. + /// FIXME(pcwalton): This isn't safe, as it allows layout to access `AbstractNode`s, and should + /// be deprecated. + pub fn with_image_element(self, f: &fn(&HTMLImageElement) -> R) -> R { + if !self.node.is_image_element() { + fail!(~"node is not an image element"); + } + self.node.transmute(f) + } + + /// Downcasts this node to an iframe element and calls the given closure. + /// + /// FIXME(pcwalton): RAII. + /// FIXME(pcwalton): This isn't safe, as it allows layout to access `AbstractNode`s, and should + /// be deprecated. + pub fn with_iframe_element(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() + } + + /// Downcasts this node to a text node and calls the given closure. + /// + /// FIXME(pcwalton): RAII. + /// FIXME(pcwalton): This isn't safe, as it allows layout to access `AbstractNode`s, and should + /// be deprecated. + pub fn with_text(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() + } +} + +impl TNode for LayoutNode { + fn parent_node(&self) -> Option { + self.node.node().parent_node.map(|node| LayoutNode::new(node)) + } + + fn prev_sibling(&self) -> Option { + self.node.node().prev_sibling.map(|node| LayoutNode::new(node)) + } + + fn next_sibling(&self) -> Option { + self.node.node().next_sibling.map(|node| LayoutNode::new(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 + } + } + + #[inline] + fn with_element(&self, f: &fn(&Element) -> R) -> R { + self.node.with_imm_element(f) + } +} /// This is what a Node looks like if you do not know what kind of node it is. To unpack it, use /// downcast(). /// /// FIXME: This should be replaced with a trait once they can inherit from structs. #[deriving(Eq)] -pub struct AbstractNode { - priv obj: *mut Box>, +pub struct AbstractNode { + priv obj: *mut Box>, } -pub struct AbstractNodeChildrenIterator { - priv current_node: Option>, -} +/// The script task's mutable view of a node. +pub struct ScriptView; + +/// The layout task's mutable view of a node. +pub struct LayoutView; /// An HTML 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 { /// The JavaScript reflector for this node. eventtarget: EventTarget, @@ -68,22 +192,22 @@ pub struct Node { /// The type of node that this is. type_id: NodeTypeId, - abstract: Option>, + abstract: Option, /// The parent of this node. - parent_node: Option>, + parent_node: Option, /// The first child of this node. - first_child: Option>, + first_child: Option, /// The last child of this node. - last_child: Option>, + last_child: Option, /// The next sibling of this node. - next_sibling: Option>, + next_sibling: Option, /// The previous sibling of this node. - prev_sibling: Option>, + prev_sibling: Option, /// The document that this node belongs to. priv owner_doc: Option, @@ -204,68 +328,53 @@ pub enum NodeTypeId { TextNodeTypeId, } -impl Clone for AbstractNode { - fn clone(&self) -> AbstractNode { +impl Clone for AbstractNode { + fn clone(&self) -> AbstractNode { *self } } -impl TNode for AbstractNode { - fn parent_node(&self) -> Option> { +impl AbstractNode { + 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 { self.node().parent_node } - fn prev_sibling(&self) -> Option> { - self.node().prev_sibling - } - - fn next_sibling(&self) -> Option> { - self.node().next_sibling + pub fn first_child(&self) -> Option { + self.node().first_child } - fn is_element(&self) -> bool { + pub fn last_child(&self) -> Option { + self.node().last_child + } + + pub fn is_element(&self) -> bool { match self.type_id() { ElementNodeTypeId(*) => true, _ => false } } - fn is_document(&self) -> bool { + pub fn is_document(&self) -> bool { match self.type_id() { DocumentNodeTypeId(*) => true, _ => false } } - - #[inline] - fn with_element(&self, f: &fn(&Element) -> R) -> R { - self.with_imm_element(f) - } } -impl AbstractNode { - 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 first_child(&self) -> Option> { - self.node().first_child - } - - pub fn last_child(&self) -> Option> { - self.node().last_child - } -} - -impl<'self, View> AbstractNode { +impl<'self> AbstractNode { // Unsafe accessors pub unsafe fn as_cacheable_wrapper(&self) -> @mut Reflectable { @@ -283,20 +392,22 @@ impl<'self, View> AbstractNode { /// 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 /// chain for nodes. - pub fn from_box(ptr: *mut Box) -> AbstractNode { + /// + /// FIXME(pcwalton): Mark unsafe? + pub fn from_box(ptr: *mut Box) -> AbstractNode { AbstractNode { - obj: ptr as *mut Box> + obj: ptr as *mut Box> } } /// Allow consumers to upcast from derived classes. - pub fn from_document(doc: AbstractDocument) -> AbstractNode { + pub fn from_document(doc: AbstractDocument) -> AbstractNode { unsafe { cast::transmute(doc) } } - pub fn from_eventtarget(target: AbstractEventTarget) -> AbstractNode { + pub fn from_eventtarget(target: AbstractEventTarget) -> AbstractNode { assert!(target.is_node()); unsafe { cast::transmute(target) @@ -311,12 +422,12 @@ impl<'self, View> AbstractNode { } /// Returns the previous sibling of this node. Fails if this node is borrowed mutably. - pub fn prev_sibling(self) -> Option> { + pub fn prev_sibling(self) -> Option { self.node().prev_sibling } /// Returns the next sibling of this node. Fails if this node is borrowed mutably. - pub fn next_sibling(self) -> Option> { + pub fn next_sibling(self) -> Option { self.node().next_sibling } @@ -326,7 +437,7 @@ impl<'self, View> AbstractNode { pub fn transmute(self, f: &fn(&T) -> R) -> R { unsafe { - let node_box: *mut Box> = transmute(self.obj); + let node_box: *mut Box> = transmute(self.obj); let node = &mut (*node_box).data; let old = node.abstract; node.abstract = Some(self); @@ -339,7 +450,7 @@ impl<'self, View> AbstractNode { pub fn transmute_mut(self, f: &fn(&mut T) -> R) -> R { unsafe { - let node_box: *mut Box> = transmute(self.obj); + let node_box: *mut Box> = transmute(self.obj); let node = &mut (*node_box).data; let old = node.abstract; node.abstract = Some(self); @@ -446,13 +557,6 @@ impl<'self, View> AbstractNode { } } - pub fn with_imm_image_element(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(self, f: &fn(&mut HTMLImageElement) -> R) -> R { if !self.is_image_element() { fail!(~"node is not an image element"); @@ -464,13 +568,6 @@ impl<'self, View> AbstractNode { self.type_id() == ElementNodeTypeId(HTMLIframeElementTypeId) } - pub fn with_imm_iframe_element(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(self, f: &fn(&mut HTMLIFrameElement) -> R) -> R { if !self.is_iframe_element() { fail!(~"node is not an iframe element"); @@ -486,11 +583,11 @@ impl<'self, View> AbstractNode { self.type_id() == ElementNodeTypeId(HTMLAnchorElementTypeId) } - pub unsafe fn raw_object(self) -> *mut Box> { + pub unsafe fn raw_object(self) -> *mut Box> { self.obj } - pub fn from_raw(raw: *mut Box>) -> AbstractNode { + pub fn from_raw(raw: *mut Box>) -> AbstractNode { AbstractNode { obj: raw } @@ -530,7 +627,7 @@ impl<'self, View> AbstractNode { self.first_child().is_none() } - pub fn children(&self) -> AbstractNodeChildrenIterator { + pub fn children(&self) -> AbstractNodeChildrenIterator { self.node().children() } @@ -539,12 +636,12 @@ impl<'self, View> AbstractNode { } } -impl AbstractNode { - pub fn AppendChild(self, node: AbstractNode) -> Fallible> { +impl AbstractNode { + pub fn AppendChild(self, node: AbstractNode) -> Fallible { self.node().AppendChild(self, node) } - pub fn RemoveChild(self, node: AbstractNode) -> Fallible> { + pub fn RemoveChild(self, node: AbstractNode) -> Fallible { self.node().RemoveChild(self, node) } @@ -577,9 +674,7 @@ impl AbstractNode { /// Adds a new child to the end of this node's list of children. /// /// Fails unless `new_child` is disconnected from the tree. - fn add_child(&self, - new_child: AbstractNode, - before: Option>) { + fn add_child(&self, new_child: AbstractNode, before: Option) { let this_node = self.mut_node(); let new_child_node = new_child.mut_node(); assert!(new_child_node.parent_node.is_none()); @@ -626,7 +721,7 @@ impl AbstractNode { /// 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.) - fn remove_child(&self, child: AbstractNode) { + fn remove_child(&self, child: AbstractNode) { let this_node = self.mut_node(); let child_node = child.mut_node(); assert!(child_node.parent_node.is_some()); @@ -656,27 +751,27 @@ impl AbstractNode { // Low-level pointer stitching wrappers // - fn set_parent_node(&self, new_parent_node: Option>) { + fn set_parent_node(&self, new_parent_node: Option) { let node = self.mut_node(); node.set_parent_node(new_parent_node) } - fn set_first_child(&self, new_first_child: Option>) { + fn set_first_child(&self, new_first_child: Option) { let node = self.mut_node(); node.set_first_child(new_first_child) } - fn set_last_child(&self, new_last_child: Option>) { + fn set_last_child(&self, new_last_child: Option) { let node = self.mut_node(); node.set_last_child(new_last_child) } - fn set_prev_sibling(&self, new_prev_sibling: Option>) { + fn set_prev_sibling(&self, new_prev_sibling: Option) { let node = self.mut_node(); node.set_prev_sibling(new_prev_sibling) } - fn set_next_sibling(&self, new_next_sibling: Option>) { + fn set_next_sibling(&self, new_next_sibling: Option) { let node = self.mut_node(); node.set_next_sibling(new_next_sibling) } @@ -686,8 +781,12 @@ impl AbstractNode { // Iteration and traversal // -impl Iterator> for AbstractNodeChildrenIterator { - fn next(&mut self) -> Option> { +pub struct AbstractNodeChildrenIterator { + priv current_node: Option, +} + +impl Iterator for AbstractNodeChildrenIterator { + fn next(&mut self) -> Option { let node = self.current_node; self.current_node = do self.current_node.and_then |node| { node.next_sibling() @@ -696,12 +795,26 @@ impl Iterator> for AbstractNodeChildrenIterator { } } -pub struct AncestorIterator { - priv current: Option>, +pub struct LayoutNodeChildrenIterator { + priv current_node: Option, } -impl Iterator> for AncestorIterator { - fn next(&mut self) -> Option> { +impl Iterator for LayoutNodeChildrenIterator { + fn next(&mut self) -> Option { + let node = self.current_node; + self.current_node = do self.current_node.and_then |node| { + node.next_sibling() + }; + node + } +} + +pub struct AncestorIterator { + priv current: Option, +} + +impl Iterator for AncestorIterator { + fn next(&mut self) -> Option { if self.current.is_none() { return None; } @@ -715,13 +828,13 @@ impl Iterator> for AncestorIterator { // FIXME: Do this without precomputing a vector of refs. // Easy for preorder; harder for postorder. -pub struct TreeIterator { - priv nodes: ~[AbstractNode], +pub struct TreeIterator { + priv nodes: ~[AbstractNode], priv index: uint, } -impl TreeIterator { - fn new(nodes: ~[AbstractNode]) -> TreeIterator { +impl TreeIterator { + fn new(nodes: ~[AbstractNode]) -> TreeIterator { TreeIterator { nodes: nodes, index: 0, @@ -729,8 +842,8 @@ impl TreeIterator { } } -impl Iterator> for TreeIterator { - fn next(&mut self) -> Option> { +impl Iterator for TreeIterator { + fn next(&mut self) -> Option { if self.index >= self.nodes.len() { None } else { @@ -741,37 +854,80 @@ impl Iterator> for TreeIterator { } } -fn gather(cur: &AbstractNode, refs: &mut ~[AbstractNode], postorder: bool) { +fn gather_abstract_nodes(cur: &AbstractNode, refs: &mut ~[AbstractNode], postorder: bool) { if !postorder { refs.push(cur.clone()); } for kid in cur.children() { - gather(&kid, refs, postorder) + gather_abstract_nodes(&kid, refs, postorder) } if postorder { refs.push(cur.clone()); } } -impl AbstractNode { +// 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 { + priv nodes: ~[LayoutNode], + priv index: uint, +} + +impl LayoutTreeIterator { + fn new(nodes: ~[LayoutNode]) -> LayoutTreeIterator { + LayoutTreeIterator { + nodes: nodes, + index: 0, + } + } +} + +impl Iterator for LayoutTreeIterator { + fn next(&mut self) -> Option { + 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(cur: &LayoutNode, refs: &mut ~[LayoutNode], 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()); + } +} + +impl AbstractNode { /// Iterates over all ancestors of this node. - pub fn ancestors(&self) -> AncestorIterator { + pub fn ancestors(&self) -> AncestorIterator { AncestorIterator { current: self.parent_node(), } } /// Iterates over this node and all its descendants, in preorder. - pub fn traverse_preorder(&self) -> TreeIterator { + pub fn traverse_preorder(&self) -> TreeIterator { let mut nodes = ~[]; - gather(self, &mut nodes, false); + gather_abstract_nodes(self, &mut nodes, false); TreeIterator::new(nodes) } /// Iterates over this node and all its descendants, in postorder. - pub fn sequential_traverse_postorder(&self) -> TreeIterator { + pub fn sequential_traverse_postorder(&self) -> TreeIterator { let mut nodes = ~[]; - gather(self, &mut nodes, true); + gather_abstract_nodes(self, &mut nodes, true); TreeIterator::new(nodes) } } @@ -780,24 +936,24 @@ impl Node { pub fn owner_doc(&self) -> AbstractDocument { self.owner_doc.unwrap() } +} +impl Node { pub fn set_owner_doc(&mut self, document: AbstractDocument) { self.owner_doc = Some(document); } - pub fn children(&self) -> AbstractNodeChildrenIterator { + pub fn children(&self) -> AbstractNodeChildrenIterator { AbstractNodeChildrenIterator { current_node: self.first_child, } } -} -impl Node { pub fn reflect_node (node: @mut N, document: AbstractDocument, wrap_fn: extern "Rust" fn(*JSContext, *JSObject, @mut N) -> *JSObject) - -> AbstractNode { + -> AbstractNode { assert!(node.reflector().get_jsobject().is_null()); let node = reflect_dom_object(node, document.document().window, wrap_fn); assert!(node.reflector().get_jsobject().is_not_null()); @@ -860,7 +1016,7 @@ impl Node { } } - pub fn NodeName(&self, abstract_self: AbstractNode) -> DOMString { + pub fn NodeName(&self, abstract_self: AbstractNode) -> DOMString { match self.type_id { ElementNodeTypeId(*) => { do abstract_self.with_imm_element |element| { @@ -894,11 +1050,11 @@ impl Node { } } - pub fn GetParentNode(&self) -> Option> { + pub fn GetParentNode(&self) -> Option { self.parent_node } - pub fn GetParentElement(&self) -> Option> { + pub fn GetParentElement(&self) -> Option { self.parent_node.filtered(|parent| parent.is_element()) } @@ -906,23 +1062,23 @@ impl Node { self.first_child.is_some() } - pub fn GetFirstChild(&self) -> Option> { + pub fn GetFirstChild(&self) -> Option { self.first_child } - pub fn GetLastChild(&self) -> Option> { + pub fn GetLastChild(&self) -> Option { self.last_child } - pub fn GetPreviousSibling(&self) -> Option> { + pub fn GetPreviousSibling(&self) -> Option { self.prev_sibling } - pub fn GetNextSibling(&self) -> Option> { + pub fn GetNextSibling(&self) -> Option { self.next_sibling } - pub fn GetNodeValue(&self, abstract_self: AbstractNode) -> Option { + pub fn GetNodeValue(&self, abstract_self: AbstractNode) -> Option { match self.type_id { // ProcessingInstruction CommentNodeTypeId | TextNodeTypeId => { @@ -936,11 +1092,12 @@ impl Node { } } - pub fn SetNodeValue(&mut self, _abstract_self: AbstractNode, _val: Option) -> ErrorResult { + pub fn SetNodeValue(&mut self, _abstract_self: AbstractNode, _val: Option) + -> ErrorResult { Ok(()) } - pub fn GetTextContent(&self, abstract_self: AbstractNode) -> Option { + pub fn GetTextContent(&self, abstract_self: AbstractNode) -> Option { match self.type_id { DocumentFragmentNodeTypeId | ElementNodeTypeId(*) => { let mut content = ~""; @@ -964,7 +1121,7 @@ impl Node { } } - pub fn ChildNodes(&mut self, abstract_self: AbstractNode) -> @mut NodeList { + pub fn ChildNodes(&mut self, abstract_self: AbstractNode) -> @mut NodeList { match self.child_list { None => { let window = self.owner_doc().document().window; @@ -977,7 +1134,7 @@ impl Node { } // http://dom.spec.whatwg.org/#concept-node-adopt - fn adopt(node: AbstractNode, document: AbstractDocument) { + fn adopt(node: AbstractNode, document: AbstractDocument) { // Step 1. match node.parent_node() { Some(parent) => Node::remove(node, parent, false), @@ -996,11 +1153,9 @@ impl Node { } // http://dom.spec.whatwg.org/#concept-node-pre-insert - fn pre_insert(node: AbstractNode, - parent: AbstractNode, - child: Option>) -> Fallible> { - fn is_inclusive_ancestor_of(node: AbstractNode, - parent: AbstractNode) -> bool { + fn pre_insert(node: AbstractNode, parent: AbstractNode, child: Option) + -> Fallible { + fn is_inclusive_ancestor_of(node: AbstractNode, parent: AbstractNode) -> bool { node == parent || parent.ancestors().any(|ancestor| ancestor == node) } @@ -1060,7 +1215,7 @@ impl Node { // Step 6. match parent.type_id() { DocumentNodeTypeId(_) => { - fn inclusively_followed_by_doctype(child: Option>) -> bool{ + fn inclusively_followed_by_doctype(child: Option) -> bool{ match child { Some(child) if child.is_doctype() => true, Some(child) => { @@ -1159,9 +1314,9 @@ impl Node { } // http://dom.spec.whatwg.org/#concept-node-insert - fn insert(node: AbstractNode, - parent: AbstractNode, - child: Option>, + fn insert(node: AbstractNode, + parent: AbstractNode, + child: Option, suppress_observers: bool) { // XXX assert owner_doc // Step 1-3: ranges. @@ -1198,8 +1353,7 @@ impl Node { } // http://dom.spec.whatwg.org/#concept-node-replace-all - pub fn replace_all(node: Option>, - parent: AbstractNode) { + pub fn replace_all(node: Option, parent: AbstractNode) { // Step 1. match node { Some(node) => Node::adopt(node, parent.node().owner_doc()), @@ -1207,7 +1361,7 @@ impl Node { } // Step 2. - let removedNodes: ~[AbstractNode] = parent.children().collect(); + let removedNodes: ~[AbstractNode] = parent.children().collect(); // Step 3. let addedNodes = match node { @@ -1241,8 +1395,7 @@ impl Node { } // http://dom.spec.whatwg.org/#concept-node-pre-remove - fn pre_remove(child: AbstractNode, - parent: AbstractNode) -> Fallible> { + fn pre_remove(child: AbstractNode, parent: AbstractNode) -> Fallible { // Step 1. if child.parent_node() != Some(parent) { return Err(NotFound); @@ -1256,9 +1409,7 @@ impl Node { } // http://dom.spec.whatwg.org/#concept-node-remove - fn remove(node: AbstractNode, - parent: AbstractNode, - suppress_observers: bool) { + fn remove(node: AbstractNode, parent: AbstractNode, suppress_observers: bool) { assert!(node.parent_node() == Some(parent)); // Step 1-5: ranges. @@ -1273,9 +1424,8 @@ impl Node { } } - pub fn SetTextContent(&mut self, - abstract_self: AbstractNode, - value: Option) -> ErrorResult { + pub fn SetTextContent(&mut self, abstract_self: AbstractNode, value: Option) + -> ErrorResult { let value = null_str_as_empty(&value); match self.type_id { DocumentFragmentNodeTypeId | ElementNodeTypeId(*) => { @@ -1305,9 +1455,8 @@ impl Node { Ok(()) } - pub fn InsertBefore(&self, - node: AbstractNode, - child: Option>) -> Fallible> { + pub fn InsertBefore(&self, node: AbstractNode, child: Option) + -> Fallible { Node::pre_insert(node, node, child) } @@ -1316,38 +1465,37 @@ impl Node { document.document().wait_until_safe_to_modify_dom(); } - pub fn AppendChild(&self, - abstract_self: AbstractNode, - node: AbstractNode) -> Fallible> { + pub fn AppendChild(&self, abstract_self: AbstractNode, node: AbstractNode) + -> Fallible { Node::pre_insert(node, abstract_self, None) } - pub fn ReplaceChild(&mut self, _node: AbstractNode, _child: AbstractNode) -> Fallible> { + pub fn ReplaceChild(&mut self, _node: AbstractNode, _child: AbstractNode) + -> Fallible { fail!("stub") } - pub fn RemoveChild(&self, - abstract_self: AbstractNode, - node: AbstractNode) -> Fallible> { + pub fn RemoveChild(&self, abstract_self: AbstractNode, node: AbstractNode) + -> Fallible { Node::pre_remove(node, abstract_self) } pub fn Normalize(&mut self) { } - pub fn CloneNode(&self, _deep: bool) -> Fallible> { + pub fn CloneNode(&self, _deep: bool) -> Fallible { fail!("stub") } - pub fn IsEqualNode(&self, _node: Option>) -> bool { + pub fn IsEqualNode(&self, _node: Option) -> bool { false } - pub fn CompareDocumentPosition(&self, _other: AbstractNode) -> u16 { + pub fn CompareDocumentPosition(&self, _other: AbstractNode) -> u16 { 0 } - pub fn Contains(&self, _other: Option>) -> bool { + pub fn Contains(&self, _other: Option) -> bool { false } @@ -1384,31 +1532,31 @@ impl Node { // Low-level pointer stitching // - pub fn set_parent_node(&mut self, new_parent_node: Option>) { + pub fn set_parent_node(&mut self, new_parent_node: Option) { let doc = self.owner_doc(); doc.document().wait_until_safe_to_modify_dom(); self.parent_node = new_parent_node } - pub fn set_first_child(&mut self, new_first_child: Option>) { + pub fn set_first_child(&mut self, new_first_child: Option) { let doc = self.owner_doc(); doc.document().wait_until_safe_to_modify_dom(); self.first_child = new_first_child } - pub fn set_last_child(&mut self, new_last_child: Option>) { + pub fn set_last_child(&mut self, new_last_child: Option) { let doc = self.owner_doc(); doc.document().wait_until_safe_to_modify_dom(); self.last_child = new_last_child } - pub fn set_prev_sibling(&mut self, new_prev_sibling: Option>) { + pub fn set_prev_sibling(&mut self, new_prev_sibling: Option) { let doc = self.owner_doc(); doc.document().wait_until_safe_to_modify_dom(); self.prev_sibling = new_prev_sibling } - pub fn set_next_sibling(&mut self, new_next_sibling: Option>) { + pub fn set_next_sibling(&mut self, new_next_sibling: Option) { let doc = self.owner_doc(); doc.document().wait_until_safe_to_modify_dom(); self.next_sibling = new_next_sibling @@ -1428,12 +1576,12 @@ impl Reflectable for Node { /// 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) -> bool; + fn process(&self, node: LayoutNode) -> 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) -> bool { + fn should_prune(&self, _node: LayoutNode) -> bool { false } } @@ -1441,18 +1589,17 @@ pub trait PostorderNodeTraversal { /// 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) -> bool; + fn process(&mut self, node: LayoutNode) -> 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) -> bool { + fn should_prune(&self, _node: LayoutNode) -> bool { false } } - -impl AbstractNode { +impl LayoutNode { /// Traverses the tree in postorder. /// /// TODO(pcwalton): Offer a parallel version with a compatible API. diff --git a/src/components/script/dom/nodelist.rs b/src/components/script/dom/nodelist.rs index ce44222a604..6857add6600 100644 --- a/src/components/script/dom/nodelist.rs +++ b/src/components/script/dom/nodelist.rs @@ -4,12 +4,12 @@ use dom::bindings::codegen::NodeListBinding; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; -use dom::node::{AbstractNode, ScriptView}; +use dom::node::AbstractNode; use dom::window::Window; enum NodeListType { - Simple(~[AbstractNode]), - Children(AbstractNode) + Simple(~[AbstractNode]), + Children(AbstractNode) } pub struct NodeList { @@ -34,11 +34,11 @@ impl NodeList { window, NodeListBinding::Wrap) } - pub fn new_simple_list(window: @mut Window, elements: ~[AbstractNode]) -> @mut NodeList { + pub fn new_simple_list(window: @mut Window, elements: ~[AbstractNode]) -> @mut NodeList { NodeList::new(window, Simple(elements)) } - pub fn new_child_list(window: @mut Window, node: AbstractNode) -> @mut NodeList { + pub fn new_child_list(window: @mut Window, node: AbstractNode) -> @mut NodeList { NodeList::new(window, Children(node)) } @@ -49,7 +49,7 @@ impl NodeList { } } - pub fn Item(&self, index: u32) -> Option> { + pub fn Item(&self, index: u32) -> Option { match self.list_type { _ if index >= self.Length() => None, Simple(ref elems) => Some(elems[index]), @@ -57,7 +57,7 @@ impl NodeList { } } - pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { + pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option { let item = self.Item(index); *found = item.is_some(); item diff --git a/src/components/script/dom/text.rs b/src/components/script/dom/text.rs index 34f981f3a53..2875d115245 100644 --- a/src/components/script/dom/text.rs +++ b/src/components/script/dom/text.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::TextBinding; use dom::bindings::utils::{DOMString, Fallible}; use dom::characterdata::CharacterData; use dom::document::AbstractDocument; -use dom::node::{AbstractNode, ScriptView, Node, TextNodeTypeId}; +use dom::node::{AbstractNode, Node, TextNodeTypeId}; use dom::window::Window; /// An HTML text node. @@ -21,16 +21,16 @@ impl Text { } } - pub fn new(text: ~str, document: AbstractDocument) -> AbstractNode { + pub fn new(text: ~str, document: AbstractDocument) -> AbstractNode { let node = Text::new_inherited(text, document); Node::reflect_node(@mut node, document, TextBinding::Wrap) } - pub fn Constructor(owner: @mut Window, text: DOMString) -> Fallible> { + pub fn Constructor(owner: @mut Window, text: DOMString) -> Fallible { Ok(Text::new(text.clone(), owner.Document())) } - pub fn SplitText(&self, _offset: u32) -> Fallible> { + pub fn SplitText(&self, _offset: u32) -> Fallible { fail!("unimplemented") } diff --git a/src/components/script/dom/uievent.rs b/src/components/script/dom/uievent.rs index db087a0e6e4..83503c7ee56 100644 --- a/src/components/script/dom/uievent.rs +++ b/src/components/script/dom/uievent.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::UIEventBinding; use dom::bindings::utils::{DOMString, Fallible}; 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::window::Window; use dom::windowproxy::WindowProxy; @@ -85,7 +85,7 @@ impl UIEvent { 0 } - pub fn GetRangeParent(&self) -> Option> { + pub fn GetRangeParent(&self) -> Option { //TODO None } diff --git a/src/components/script/dom/window.rs b/src/components/script/dom/window.rs index 9f55e3cf3c5..54660c4286a 100644 --- a/src/components/script/dom/window.rs +++ b/src/components/script/dom/window.rs @@ -8,7 +8,7 @@ use dom::bindings::utils::{trace_option, trace_reflector}; use dom::bindings::utils::DOMString; use dom::document::AbstractDocument; use dom::eventtarget::{EventTarget, WindowTypeId}; -use dom::node::{AbstractNode, ScriptView}; +use dom::node::AbstractNode; use dom::location::Location; use dom::navigator::Navigator; @@ -114,7 +114,7 @@ impl Window { pub fn Blur(&self) { } - pub fn GetFrameElement(&self) -> Option> { + pub fn GetFrameElement(&self) -> Option { None } diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index f854a546371..da9adf01680 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -9,7 +9,7 @@ use dom::htmlheadingelement::{Heading1, Heading2, Heading3, Heading4, Heading5, use dom::htmliframeelement::IFrameSize; use dom::htmlformelement::HTMLFormElement; use dom::namespace; -use dom::node::{AbstractNode, ElementNodeTypeId, ScriptView}; +use dom::node::{AbstractNode, ElementNodeTypeId}; use dom::types::*; use html::cssparse::{InlineProvenance, StylesheetProvenance, UrlProvenance, spawn_css_parser}; use script_task::page_from_context; @@ -77,11 +77,11 @@ trait NodeWrapping { unsafe fn from_hubbub_node(n: hubbub::NodeDataPtr) -> Self; } -impl NodeWrapping for AbstractNode { +impl NodeWrapping for AbstractNode { unsafe fn to_hubbub_node(self) -> hubbub::NodeDataPtr { cast::transmute(self) } - unsafe fn from_hubbub_node(n: hubbub::NodeDataPtr) -> AbstractNode { + unsafe fn from_hubbub_node(n: hubbub::NodeDataPtr) -> AbstractNode { cast::transmute(n) } } @@ -159,7 +159,7 @@ fn js_script_listener(to_parent: SharedChan, // Silly macros to handle constructing DOM nodes. This produces bad code and should be optimized // via atomization (issue #85). -pub fn build_element_from_tag(tag: ~str, document: AbstractDocument) -> AbstractNode { +pub fn build_element_from_tag(tag: ~str, document: AbstractDocument) -> AbstractNode { // TODO (Issue #85): use atoms handle_element!(document, tag, "a", HTMLAnchorElement); handle_element!(document, tag, "applet", HTMLAppletElement); @@ -299,7 +299,7 @@ pub fn parse_html(cx: *JSContext, let mut parser = hubbub::Parser("UTF-8", false); debug!("created parser"); - let document_node = AbstractNode::::from_document(document); + let document_node = AbstractNode::from_document(document); parser.set_document_node(unsafe { document_node.to_hubbub_node() }); parser.enable_scripting(true); parser.enable_styling(true); @@ -415,8 +415,8 @@ pub fn parse_html(cx: *JSContext, append_child: |parent: hubbub::NodeDataPtr, child: hubbub::NodeDataPtr| { unsafe { debug!("append child {:x} {:x}", parent, child); - let parent: AbstractNode = NodeWrapping::from_hubbub_node(parent); - let child: AbstractNode = NodeWrapping::from_hubbub_node(child); + let parent: AbstractNode = NodeWrapping::from_hubbub_node(parent); + let child: AbstractNode = NodeWrapping::from_hubbub_node(child); parent.AppendChild(child); } child @@ -460,7 +460,7 @@ pub fn parse_html(cx: *JSContext, }, complete_script: |script| { unsafe { - let scriptnode: AbstractNode = NodeWrapping::from_hubbub_node(script); + let scriptnode: AbstractNode = NodeWrapping::from_hubbub_node(script); do scriptnode.with_imm_element |script| { match script.get_attr(None, "src") { Some(src) => { @@ -489,7 +489,7 @@ pub fn parse_html(cx: *JSContext, complete_style: |style| { // We've reached the end of a