diff --git a/src/rust-azure b/src/rust-azure index 065a91cf885..c787b5eb2b3 160000 --- a/src/rust-azure +++ b/src/rust-azure @@ -1 +1 @@ -Subproject commit 065a91cf8855489a71b06157d19c1e61888af5b7 +Subproject commit c787b5eb2b3cc9ec5be5024098bdc1a368791fb7 diff --git a/src/rust-mozjs b/src/rust-mozjs index 678688c3b62..8e60882ebf2 160000 --- a/src/rust-mozjs +++ b/src/rust-mozjs @@ -1 +1 @@ -Subproject commit 678688c3b624761ece89afe45e650158f7ecbc8d +Subproject commit 8e60882ebf2c68766747b1d673a94c77b75f2b78 diff --git a/src/servo/dom/base.rs b/src/servo/dom/base.rs index c76c674f899..b5955e87672 100644 --- a/src/servo/dom/base.rs +++ b/src/servo/dom/base.rs @@ -72,8 +72,12 @@ fn NodeScope() -> NodeScope { rcu::Scope() } +trait node_scope { + fn new_node(-k: NodeKind) -> Node; +} + #[warn(no_non_implicitly_copyable_typarams)] -impl NodeScope for NodeScope { +impl NodeScope of node_scope for NodeScope { fn new_node(-k: NodeKind) -> Node { self.handle(NodeData({tree: tree::empty(), kind: ~k})) } diff --git a/src/servo/gfx/renderer.rs b/src/servo/gfx/renderer.rs index 87215863de2..690f5bafeb0 100644 --- a/src/servo/gfx/renderer.rs +++ b/src/servo/gfx/renderer.rs @@ -58,7 +58,11 @@ fn Renderer(sink: S) -> chan { }) } -impl to_float for u8 { +trait to_float { + fn to_float() -> float; +} + +impl to_float of to_float for u8 { fn to_float() -> float { (self as float) / 255f } diff --git a/src/servo/layout/base.rs b/src/servo/layout/base.rs index d9e7ba1d28c..32b1d0515c5 100644 --- a/src/servo/layout/base.rs +++ b/src/servo/layout/base.rs @@ -134,7 +134,11 @@ impl layout_methods for @Box { // Debugging -impl PrivateNodeMethods for Node { +trait PrivateNodeMethods{ + fn dump_indent(ident: uint); +} + +impl PrivateNodeMethods of PrivateNodeMethods for Node { #[doc="Dumps the node tree, for debugging, with indentation."] fn dump_indent(indent: uint) { let mut s = ~""; @@ -151,7 +155,11 @@ impl PrivateNodeMethods for Node { } } -impl NodeMethods for Node { +trait NodeMethods { + fn dump(); +} + +impl NodeMethods of NodeMethods for Node { #[doc="Dumps the subtree rooted at this node, for debugging."] fn dump() { self.dump_indent(0u); diff --git a/src/servo/layout/block.rs b/src/servo/layout/block.rs index ded4fd70ec8..3bcc1fd9e3b 100644 --- a/src/servo/layout/block.rs +++ b/src/servo/layout/block.rs @@ -6,8 +6,12 @@ import gfx::geometry::au; import util::tree; import base::{Box, BlockBox, BTree, layout_methods, BoxTreeReadMethods}; +trait block_layout_methods { + fn reflow_block(available_widh: au); +} + #[doc="The public block layout methods."] -impl block_layout_methods for @Box { +impl block_layout_methods of block_layout_methods for @Box { #[doc="The main reflow routine for block layout."] fn reflow_block(available_width: au) { assert self.kind == BlockBox; diff --git a/src/servo/layout/box_builder.rs b/src/servo/layout/box_builder.rs index 620ce76d4a6..fb89d127be3 100644 --- a/src/servo/layout/box_builder.rs +++ b/src/servo/layout/box_builder.rs @@ -146,7 +146,11 @@ impl methods for ctxt { } } -impl box_builder_priv for Node { +trait box_builder_priv { + fn determine_box_kind() -> BoxKind; +} + +impl box_builder_priv of box_builder_priv for Node { #[doc=" Determines the kind of box that this node needs. Also, for images, computes the intrinsic size. @@ -167,7 +171,11 @@ impl box_builder_priv for Node { } } -impl box_builder_methods for Node { +trait box_builder_methods { + fn construct_boxes() -> @Box; +} + +impl box_builder_methods of box_builder_methods for Node { #[doc="Creates boxes for this node. This is the entry point."] fn construct_boxes() -> @Box { let box_kind = self.determine_box_kind(); diff --git a/src/servo/layout/inline.rs b/src/servo/layout/inline.rs index b7f75e1265f..9d5333096c1 100644 --- a/src/servo/layout/inline.rs +++ b/src/servo/layout/inline.rs @@ -8,8 +8,12 @@ import gfx::geometry::au; import util::tree; import base::{Box, InlineBox, BTree, layout_methods, BoxTreeReadMethods}; +trait inline_layout_methods { + fn reflow_inline(available_width: au); +} + #[doc="The main reflow routine for inline layout."] -impl inline_layout_methods for @Box { +impl inline_layout_methods of inline_layout_methods for @Box { fn reflow_inline(available_width: au) { assert self.kind == InlineBox; diff --git a/src/servo/layout/style/apply.rs b/src/servo/layout/style/apply.rs index f92d680782b..83e744d59ed 100644 --- a/src/servo/layout/style/apply.rs +++ b/src/servo/layout/style/apply.rs @@ -6,7 +6,12 @@ import image::base::load; import base::{Box, BTree, NTree, LayoutData, BoxTreeReadMethods}; import style::style_methods; -impl ApplyStyleBoxMethods for @Box { +trait ApplyStyleBoxMethods { + fn apply_style_for_subtree(); + fn apply_style(); +} + +impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box { fn apply_style_for_subtree() { self.apply_style(); for BTree.each_child(self) |child| { diff --git a/src/servo/layout/style/matching.rs b/src/servo/layout/style/matching.rs index 766b9c040ff..836b95fc9a9 100644 --- a/src/servo/layout/style/matching.rs +++ b/src/servo/layout/style/matching.rs @@ -55,7 +55,12 @@ fn attrs_match(attr: Attr, elmt: ElementData) -> bool { } } -impl priv_matching_methods for Node { +trait priv_matching_methods { + fn matches_element(sel: ~Selector) -> bool; + fn matches_selector(sel : ~Selector) -> bool; +} + +impl priv_matching_methods of priv_matching_methods for Node { #[doc=" Checks if the given CSS selector, which must describe a single element with no relational information, describes the given HTML element. @@ -162,7 +167,11 @@ impl priv_matching_methods for Node { } } -impl priv_style_methods for Node { +trait priv_style_methods { + fn update_style(decl : StyleDeclaration); +} + +impl priv_style_methods of priv_style_methods for Node { #[doc="Update the computed style of an HTML element with a style specified by CSS."] fn update_style(decl : StyleDeclaration) { self.aux(|layout| { @@ -175,7 +184,11 @@ impl priv_style_methods for Node { } } -impl matching_methods for Node { +trait matching_methods { + fn match_css_style(styles : Stylesheet); +} + +impl matching_methods of matching_methods for Node { #[doc="Compare an html element to a list of css rules and update its style according to the rules matching it."] fn match_css_style(styles : Stylesheet) { diff --git a/src/servo/layout/style/style.rs b/src/servo/layout/style/style.rs index a9d7f2b1eee..e94992d776a 100644 --- a/src/servo/layout/style/style.rs +++ b/src/servo/layout/style/style.rs @@ -33,7 +33,11 @@ fn default_style_for_node_kind(kind: NodeKind) -> computed_style { } } -impl style_priv for Node { +trait style_priv { + fn initialize_style(); +} + +impl style_priv of style_priv for Node { #[doc="Set a default auxilliary data so that other threads can modify it. This is, importantly, the function that creates the layout data for the node (the reader- @@ -50,7 +54,13 @@ impl style_priv for Node { } } -impl style_methods for Node { +trait style_methods { + fn initialize_style_for_subtree(); + fn get_computed_style() -> computed_style; + fn recompute_style_for_subtree(styles : arc); +} + +impl style_methods of style_methods for Node { #[doc="Sequentially initialize the nodes' auxilliary data so they can be updated in parallel."] fn initialize_style_for_subtree() { self.initialize_style(); diff --git a/src/servo/layout/text.rs b/src/servo/layout/text.rs index ea3f90b4b00..5095ecfddb2 100644 --- a/src/servo/layout/text.rs +++ b/src/servo/layout/text.rs @@ -16,8 +16,12 @@ class text_box { } } +trait text_layout_methods { + fn reflow_text(_available_width: au, subbox: @text_box); +} + #[doc="The main reflow routine for text layout."] -impl text_layout_methods for @Box { +impl text_layout_methods of text_layout_methods for @Box { fn reflow_text(_available_width: au, subbox: @text_box) { alt self.kind { TextBox(*) { /* ok */ } diff --git a/src/servo/parser/css_builder.rs b/src/servo/parser/css_builder.rs index 0c794ac1cd9..370380c3c8c 100644 --- a/src/servo/parser/css_builder.rs +++ b/src/servo/parser/css_builder.rs @@ -16,7 +16,12 @@ import vec::push; type TokenReader = {stream : port, mut lookahead : option}; -impl methods for TokenReader { +trait methods { + fn get() -> Token; + fn unget(-tok : Token); +} + +impl methods of methods for TokenReader { fn get() -> Token { alt copy self.lookahead { some(tok) { self.lookahead = none; copy tok } diff --git a/src/servo/parser/css_lexer.rs b/src/servo/parser/css_lexer.rs index 9c09850ea9f..3354a3f4ad6 100644 --- a/src/servo/parser/css_lexer.rs +++ b/src/servo/parser/css_lexer.rs @@ -31,7 +31,15 @@ enum Token { Eof } -impl css_methods for CssLexer { +trait css_methods { + fn parse_css() -> Token; + fn parse_css_relation(c : u8) -> Token; + fn parse_css_element(c : u8) -> Token; + fn parse_css_attribute(c : u8) -> Token; + fn parse_css_description(c: u8) -> Token; +} + +impl css_methods of css_methods for CssLexer { fn parse_css() -> Token { let mut ch: u8; alt self.input_state.get() { diff --git a/src/servo/parser/html_lexer.rs b/src/servo/parser/html_lexer.rs index 3c4fced71c4..895b23c0766 100644 --- a/src/servo/parser/html_lexer.rs +++ b/src/servo/parser/html_lexer.rs @@ -26,7 +26,13 @@ type HtmlLexer = { mut parser_state: ParseState }; -impl html_methods for HtmlLexer { +trait html_methods { + fn parse_html() -> Token; + fn parse_in_normal_state(c: u8) -> Token; + fn parse_in_tag_state(c: u8) -> Token; +} + +impl html_methods of html_methods for HtmlLexer { fn parse_html() -> Token { let mut ch: u8; alt self.input_state.get() { diff --git a/src/servo/parser/lexer_util.rs b/src/servo/parser/lexer_util.rs index a2ee3c767b6..31efb947e82 100644 --- a/src/servo/parser/lexer_util.rs +++ b/src/servo/parser/lexer_util.rs @@ -12,7 +12,13 @@ type InputState = { reader: io::reader }; -impl u8_methods for u8 { +trait u8_methods { + fn is_whitespace() -> bool; + fn is_alpha() -> bool; +} + + +impl u8_methods of u8_methods for u8 { fn is_whitespace() -> bool { ret self == ' ' as u8 || self == '\n' as u8 || self == '\t' as u8; } @@ -23,7 +29,17 @@ impl u8_methods for u8 { } } -impl util_methods for InputState { +trait util_methods { + fn get() -> CharOrEof; + fn unget(ch: u8); + fn parse_err(err: ~str) -> !; + fn expect(ch: u8); + fn parse_ident() -> ~str; + fn expect_ident(expected: ~str); + fn eat_whitespace(); +} + +impl util_methods of util_methods for InputState { fn get() -> CharOrEof { alt copy self.lookahead { some(coe) { diff --git a/src/servo/text/font.rs b/src/servo/text/font.rs index 1217b7542dc..53dd1879fd1 100644 --- a/src/servo/text/font.rs +++ b/src/servo/text/font.rs @@ -182,7 +182,12 @@ fn get_cairo_face(buf: &~[u8]) -> (*cairo_font_face_t, fn@()) { import azure::cairo_ft; import cairo_ft::bindgen::cairo_ft_font_face_create_for_ft_face; - impl methods for FT_Error { + trait methods { + fn for_sure(); + fn failed() -> bool; + } + + impl methods of methods for FT_Error { fn for_sure() { assert !self.failed() } fn failed() -> bool { self != 0 as FT_Error } } diff --git a/src/servo/text/native_font/ft_native_font.rs b/src/servo/text/native_font/ft_native_font.rs index fa66638f0eb..259b5c992ac 100644 --- a/src/servo/text/native_font/ft_native_font.rs +++ b/src/servo/text/native_font/ft_native_font.rs @@ -81,7 +81,11 @@ fn create(lib: FT_Library, buf: &~[u8]) -> result { }) } -impl methods for FT_Error { +trait methods { + fn succeeded() -> bool; +} + +impl methods of methods for FT_Error { fn succeeded() -> bool { self == 0 as FT_Error } } diff --git a/src/servo/util/unsafe.rs b/src/servo/util/unsafe.rs index c2c2e3ea966..1e89cd55f58 100644 --- a/src/servo/util/unsafe.rs +++ b/src/servo/util/unsafe.rs @@ -1,4 +1,9 @@ -impl methods for *T { +trait methods { + unsafe fn +(idx: uint) -> *T; + unsafe fn [](idx: uint) -> T; +} + +impl methods of methods for *T { unsafe fn +(idx: uint) -> *T { ptr::offset(self, idx) }