servo: Update for impl language changes

Source-Repo: https://github.com/servo/servo
Source-Revision: 95c9188f581e04a4a0ad587d7de804c2df1627e5
This commit is contained in:
Patrick Walton 2012-08-09 12:12:23 -07:00
Родитель 9ff002d06f
Коммит 36e7ddccf8
31 изменённых файлов: 120 добавлений и 151 удалений

Просмотреть файл

@ -17,7 +17,6 @@ import result::{ok, err};
import dom::base::{Node, NodeScope, define_bindings};
import dom::event::{Event, ResizeEvent};
import dom::rcu::WriterMethods;
import dom::style;
import dom::style::Stylesheet;
import gfx::renderer::Sink;
@ -31,7 +30,6 @@ import js::rust::methods;
import js::global::{global_class, debug_fns};
import either::{either, left, right};
import result::extensions;
import dom::bindings::utils::rust_box;
import js::rust::compartment;

Просмотреть файл

@ -1,6 +1,5 @@
#[doc="The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements."]
import dom::rcu::WriterMethods;
import gfx::geometry::au;
import geom::size::Size2D;
import layout::base::LayoutData;
@ -10,12 +9,11 @@ import js::jsapi::{JSClass, JSObject, JSPropertySpec, JSContext, jsid, jsval, JS
import js::{JSPROP_ENUMERATE, JSPROP_SHARED};
import js::crust::*;
import js::glue::bindgen::RUST_OBJECT_TO_JSVAL;
import dvec::dvec;
import ptr::null;
import content::Document;
import bindings;
import dvec::{dvec, extensions};
enum NodeData = {
tree: tree::Tree<Node>,
kind: ~NodeKind,
@ -86,19 +84,19 @@ fn NodeScope() -> NodeScope {
rcu::Scope()
}
trait node_scope {
trait NodeScopeExtensions {
fn new_node(-k: NodeKind) -> Node;
}
#[allow(non_implicitly_copyable_typarams)]
impl NodeScope of node_scope for NodeScope {
impl NodeScope : NodeScopeExtensions {
fn new_node(-k: NodeKind) -> Node {
self.handle(NodeData({tree: tree::empty(), kind: ~k}))
}
}
#[allow(non_implicitly_copyable_typarams)]
impl TreeReadMethods of tree::ReadMethods<Node> for NodeScope {
impl NodeScope : tree::ReadMethods<Node> {
fn each_child(node: Node, f: fn(Node) -> bool) {
tree::each_child(self, node, f)
}
@ -113,7 +111,7 @@ impl TreeReadMethods of tree::ReadMethods<Node> for NodeScope {
}
#[allow(non_implicitly_copyable_typarams)]
impl TreeWriteMethods of tree::WriteMethods<Node> for NodeScope {
impl NodeScope : tree::WriteMethods<Node> {
fn add_child(node: Node, child: Node) {
tree::add_child(self, node, child)
}

Просмотреть файл

@ -13,7 +13,6 @@ import dom::base::{Node, Element};
import utils::{rust_box, squirrel_away_unique, get_compartment, domstring_to_jsval, str};
import libc::c_uint;
import ptr::null;
import rcu::ReaderMethods;
extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) {
#debug("node finalize!");

Просмотреть файл

@ -49,8 +49,8 @@ of the RCU nodes themselves.
")];
import ptr::extensions;
import core::libc::types::os::arch::c95::size_t;
import ptr::ptr;
import vec::push;
export Handle;
@ -84,7 +84,8 @@ enum Handle<T:send,A> {
_Handle(*HandleData<T,A>)
}
impl HandlePrivate<T:send,A> for Handle<T,A> {
// Private methods
impl<T:send,A> Handle<T,A> {
fn read_ptr() -> *T unsafe { (**self).read_ptr }
fn write_ptr() -> *mut T unsafe { (**self).write_ptr }
fn read_aux() -> *A unsafe { (**self).read_aux }
@ -99,7 +100,7 @@ impl HandlePrivate<T:send,A> for Handle<T,A> {
fn is_not_null() -> bool { (*self).is_not_null() }
}
impl ReaderMethods<T:send,A> for Handle<T,A> {
impl<T:send,A> Handle<T,A> {
#[doc(str = "Access the reader's view of the handle's data.")]
fn read<U>(f: fn(T) -> U) -> U unsafe {
f(*self.read_ptr())
@ -128,7 +129,8 @@ impl ReaderMethods<T:send,A> for Handle<T,A> {
}
}
impl ScopePrivate<T: copy send,A> for Scope<T,A> {
// Private methods
impl<T: copy send,A> Scope<T,A> {
fn clone(v: *T) -> *T unsafe {
let n: *mut T =
unsafe::reinterpret_cast(libc::calloc(sys::size_of::<T>() as size_t, 1u as size_t));
@ -164,7 +166,8 @@ fn Scope<T:send,A>() -> Scope<T,A> {
mut first_dirty: null_handle()})
}
impl WriterMethods<T:copy send,A> for Scope<T,A> {
// Writer methods
impl<T:copy send,A> Scope<T,A> {
fn is_reader_forked() -> bool {
self.d.layout_active
}
@ -228,7 +231,6 @@ impl WriterMethods<T:copy send,A> for Scope<T,A> {
#[cfg(test)]
#[allow(non_implicitly_copyable_typarams)]
mod test {
type animal = {name: ~str, species: species};
enum species {
chicken(~chicken),
@ -307,5 +309,4 @@ mod test {
assert henrietta.read(read_characteristic) == iter1 * iter2;
assert ferdinand.read(read_characteristic) == iter1 * iter2;
}
}

Просмотреть файл

@ -5,7 +5,7 @@ import num::num;
enum au = int;
impl au of num for au {
impl au : num {
pure fn add(&&other: au) -> au { au(*self + *other) }
pure fn sub(&&other: au) -> au { au(*self - *other) }
pure fn mul(&&other: au) -> au { au(*self * *other) }

Просмотреть файл

@ -35,7 +35,7 @@ enum Msg {
Exit
}
impl PngSink of Sink for chan<Msg> {
impl chan<Msg> : Sink {
fn begin_drawing(+next_dt: pipes::chan<AzDrawTargetRef>) {
self.send(BeginDrawing(next_dt))
}

Просмотреть файл

@ -77,7 +77,7 @@ trait to_float {
fn to_float() -> float;
}
impl to_float of to_float for u8 {
impl u8 : to_float {
fn to_float() -> float {
(self as float) / 255f
}

Просмотреть файл

@ -1,5 +1,4 @@
import geom::size::Size2D;
import int::num;
enum format {
fo_rgba_8888
@ -12,7 +11,7 @@ type image_surface = {
buffer: ~[u8]
};
impl format for format {
impl format {
fn bpp() -> uint {
match self {
fo_rgba_8888 => 32u

Просмотреть файл

@ -3,7 +3,6 @@
import dom::base::{Element, ElementKind, HTMLDivElement, HTMLImageElement, Node, NodeData};
import dom::base::{NodeKind};
import dom::rcu;
import dom::rcu::ReaderMethods;
import dom::style::Unit;
import gfx::geometry;
import gfx::geometry::{au, zero_size_au};
@ -11,13 +10,10 @@ import geom::point::Point2D;
import geom::rect::Rect;
import geom::size::Size2D;
import image::base::{image, load};
import layout::block::block_layout_methods;
import layout::inline::inline_layout_methods;
import util::tree;
import util::color::{Color, css_colors};
import text::text_box;
import style::style::{SpecifiedStyle, default_style_methods};
import text::text_layout_methods;
import style::style::SpecifiedStyle;
import text::TextBox;
import vec::{push, push_all};
import arc::{arc, clone};
@ -26,7 +22,7 @@ enum BoxKind {
BlockBox,
InlineBox,
IntrinsicBox(@Size2D<au>),
TextBox(@text_box)
TextBoxKind(@TextBox)
}
class Appearance {
@ -127,7 +123,7 @@ enum LayoutData = {
// FIXME: This is way too complex! Why do these have to have dummy receivers? --pcw
enum NTree { NTree }
impl NodeTreeReadMethods of tree::ReadMethods<Node> for NTree {
impl NTree : tree::ReadMethods<Node> {
fn each_child(node: Node, f: fn(Node) -> bool) {
tree::each_child(self, node, f)
}
@ -139,7 +135,7 @@ impl NodeTreeReadMethods of tree::ReadMethods<Node> for NTree {
enum BTree { BTree }
impl BoxTreeReadMethods of tree::ReadMethods<@Box> for BTree {
impl BTree : tree::ReadMethods<@Box> {
fn each_child(node: @Box, f: fn(&&@Box) -> bool) {
tree::each_child(self, node, f)
}
@ -149,7 +145,7 @@ impl BoxTreeReadMethods of tree::ReadMethods<@Box> for BTree {
}
}
impl BoxTreeWriteMethods of tree::WriteMethods<@Box> for BTree {
impl BTree : tree::WriteMethods<@Box> {
fn add_child(node: @Box, child: @Box) {
tree::add_child(self, node, child)
}
@ -159,7 +155,8 @@ impl BoxTreeWriteMethods of tree::WriteMethods<@Box> for BTree {
}
}
impl layout_methods_priv for @Box {
// Private methods
impl @Box {
#[doc="Dumps the box tree, for debugging, with indentation."]
fn dump_indent(indent: uint) {
let mut s = ~"";
@ -176,14 +173,15 @@ impl layout_methods_priv for @Box {
}
}
impl layout_methods for @Box {
// Public methods
impl @Box {
#[doc="The main reflow routine."]
fn reflow(available_width: au) {
match self.kind {
BlockBox => self.reflow_block(available_width),
InlineBox => self.reflow_inline(available_width),
IntrinsicBox(size) => self.reflow_intrinsic(*size),
TextBox(subbox) => self.reflow_text(available_width, subbox)
TextBoxKind(subbox) => self.reflow_text(available_width, subbox)
}
}
@ -202,11 +200,11 @@ impl layout_methods for @Box {
// Debugging
trait PrivateNodeMethods{
trait PrivateNodeMethods {
fn dump_indent(ident: uint);
}
impl PrivateNodeMethods of PrivateNodeMethods for Node {
impl Node : PrivateNodeMethods {
#[doc="Dumps the node tree, for debugging, with indentation."]
fn dump_indent(indent: uint) {
let mut s = ~"";
@ -227,7 +225,7 @@ trait NodeMethods {
fn dump();
}
impl NodeMethods of NodeMethods for Node {
impl Node : NodeMethods {
#[doc="Dumps the subtree rooted at this node, for debugging."]
fn dump() {
self.dump_indent(0u);
@ -237,9 +235,8 @@ impl NodeMethods of NodeMethods for Node {
#[cfg(test)]
mod test {
import dom::base::{Element, ElementData, HTMLDivElement, HTMLImageElement, Node, NodeKind};
import dom::base::{NodeScope, TreeWriteMethods};
import dom::base::{NodeScope};
import dom::rcu::Scope;
import box_builder::{box_builder_methods};
/*
use sdl;

Просмотреть файл

@ -4,14 +4,14 @@ import geom::point::Point2D;
import geom::size::Size2D;
import gfx::geometry::au;
import util::tree;
import base::{Box, BlockBox, BTree, layout_methods, BoxTreeReadMethods};
import base::{Box, BlockBox, BTree};
trait block_layout_methods {
trait BlockLayoutMethods {
fn reflow_block(available_widh: au);
}
#[doc="The public block layout methods."]
impl block_layout_methods of block_layout_methods for @Box {
impl @Box : BlockLayoutMethods {
#[doc="The main reflow routine for block layout."]
fn reflow_block(available_width: au) {
assert self.kind == BlockBox;

Просмотреть файл

@ -2,13 +2,10 @@
import dom::base::{ElementData, HTMLDivElement, HTMLImageElement, Element, Text, Node};
import dom::style::{DisplayType, DisBlock, DisInline, DisNone};
import dom::rcu::ReaderMethods;
import gfx::geometry;
import layout::base::{BlockBox, Box, BoxKind, BoxTreeReadMethods, BoxTreeWriteMethods, InlineBox};
import layout::base::{IntrinsicBox, NodeMethods, NodeTreeReadMethods, TextBox};
import layout::base::{Appearance, BTree, NTree};
import layout::style::style::{style_methods};
import layout::text::text_box;
import layout::base::{Appearance, BTree, BlockBox, Box, BoxKind, InlineBox, IntrinsicBox, NTree};
import layout::base::{TextBoxKind};
import layout::text::TextBox;
import util::tree;
import option::is_none;
@ -37,7 +34,7 @@ fn create_context(parent_node: Node, parent_box: @Box) -> ctxt {
});
}
impl methods for ctxt {
impl ctxt {
#[doc="
Constructs boxes for the parent's children, when the parent's 'display' attribute is 'block'.
"]
@ -149,18 +146,18 @@ impl methods for ctxt {
}
}
trait box_builder_priv {
trait PrivBoxBuilder {
fn determine_box_kind() -> BoxKind;
}
impl box_builder_priv of box_builder_priv for Node {
impl Node : PrivBoxBuilder {
#[doc="
Determines the kind of box that this node needs. Also, for images, computes the intrinsic
size.
"]
fn determine_box_kind() -> BoxKind {
match self.read(|n| copy n.kind) {
~Text(string) => TextBox(@text_box(copy string)),
~Text(string) => TextBoxKind(@TextBox(copy string)),
~Element(element) => {
match *element.kind {
HTMLDivElement => BlockBox,
@ -172,11 +169,11 @@ impl box_builder_priv of box_builder_priv for Node {
}
}
trait box_builder_methods {
trait BoxBuilder {
fn construct_boxes() -> @Box;
}
impl box_builder_methods of box_builder_methods for Node {
impl Node : BoxBuilder {
#[doc="Creates boxes for this node. This is the entry point."]
fn construct_boxes() -> @Box {
let box_kind = self.determine_box_kind();

Просмотреть файл

@ -1,7 +1,6 @@
export build_display_list;
import base::{Box, TextBox, BTree, BoxTreeReadMethods, ImageHolder};
import box_builder::box_builder_methods;
import base::{Box, BTree, ImageHolder, TextBoxKind};
import dl = display_list;
import dom::base::{Text, NodeScope};
import dom::rcu::Scope;
@ -12,11 +11,9 @@ import geom::size::Size2D;
import gfx::geometry::{au, au_to_px, box, px_to_au};
import gfx::renderer;
import image::base::load;
import text::text_layout_methods;
import util::color::methods;
import util::tree;
import dvec::{dvec, extensions};
import dvec::dvec;
import vec::push;
#[doc = "
@ -73,7 +70,7 @@ fn box_to_display_items(list: dl::display_list, box: @Box, origin: Point2D<au>)
let col = box.appearance.background_color;
match box.kind {
TextBox(subbox) => {
TextBoxKind(subbox) => {
let run = copy subbox.run;
assert run.is_some();
list.push(dl::display_item({
@ -119,7 +116,7 @@ fn should_convert_text_boxes_to_solid_color_background_items() {
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
let subbox = match check b.kind { TextBox(subbox) => subbox };
let subbox = match check b.kind { TextBoxKind(subbox) => subbox };
b.reflow_text(px_to_au(800), subbox);
let list = dvec();
@ -140,7 +137,7 @@ fn should_convert_text_boxes_to_text_items() {
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
let subbox = match check b.kind { TextBox(subbox) => { subbox } };
let subbox = match check b.kind { TextBoxKind(subbox) => { subbox } };
b.reflow_text(px_to_au(800), subbox);
let list = dvec();
@ -160,7 +157,7 @@ fn should_calculate_the_bounds_of_the_text_box_background_color() {
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
let subbox = match check b.kind { TextBox(subbox) => { subbox } };
let subbox = match check b.kind { TextBoxKind(subbox) => { subbox } };
b.reflow_text(px_to_au(800), subbox);
let list = dvec();
@ -182,7 +179,7 @@ fn should_calculate_the_bounds_of_the_text_items() {
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
let subbox = match check b.kind { TextBox(subbox) => { subbox } };
let subbox = match check b.kind { TextBoxKind(subbox) => { subbox } };
b.reflow_text(px_to_au(800), subbox);
let list = dvec();

Просмотреть файл

@ -1,19 +1,18 @@
#[doc="Inline layout."]
import dom::rcu;
import dom::rcu::ReaderMethods;
import geom::point::Point2D;
import geom::size::Size2D;
import gfx::geometry::au;
import util::tree;
import base::{Box, InlineBox, BTree, layout_methods, BoxTreeReadMethods};
import base::{Box, InlineBox, BTree};
trait inline_layout_methods {
trait InlineLayout {
fn reflow_inline(available_width: au);
}
#[doc="The main reflow routine for inline layout."]
impl inline_layout_methods of inline_layout_methods for @Box {
impl @Box : InlineLayout {
fn reflow_inline(available_width: au) {
assert self.kind == InlineBox;

Просмотреть файл

@ -4,16 +4,11 @@
"];
import arc::arc;
import display_list_builder::build_display_list;
import dom::base::{Node};
import dom::base::Node;
import dom::style::Stylesheet;
import gfx::geometry::px_to_au;
import gfx::renderer::Renderer;
import base::{NodeMethods, layout_methods};
import layout::style::style::style_methods;
import box_builder::box_builder_methods;
import layout::style::apply::ApplyStyleBoxMethods;
import task::*;
import comm::*;

Просмотреть файл

@ -1,11 +1,9 @@
#[doc="Applies the appropriate CSS style to boxes."]
import dom::base::{Element, HTMLImageElement, Node};
import dom::rcu::ReaderMethods;
import either::right;
import image::base::load;
import base::{Box, BTree, NTree, LayoutData, BoxTreeReadMethods, SpecifiedStyle, ImageHolder};
import style::{default_style_methods, style_methods};
import base::{Box, BTree, ImageHolder, LayoutData, NTree, SpecifiedStyle};
import traverse::top_down_traversal;
trait ApplyStyleBoxMethods {
@ -18,7 +16,7 @@ fn apply_style_wrapper(box : @Box) {
box.apply_style();
}
impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box {
impl @Box : ApplyStyleBoxMethods {
fn apply_css_style() {
top_down_traversal(self, apply_style_wrapper);
}

Просмотреть файл

@ -6,11 +6,8 @@ import base::{ElementData, Node, Text};
import dom::style::{Selector, StyleDeclaration, FontSize, Display, TextColor, BackgroundColor,
Stylesheet, Element, Child, Descendant, Sibling, Attr, Exact, Exists, Includes,
StartsWith, Width, Height};
import dom::rcu::ReaderMethods;
import style::{SpecifiedStyle};
export matching_methods;
#[doc="Check if a CSS attribute matches the attribute of an HTML element."]
fn attrs_match(attr: Attr, elmt: ElementData) -> bool {
match attr {
@ -55,12 +52,12 @@ fn attrs_match(attr: Attr, elmt: ElementData) -> bool {
}
}
trait priv_matching_methods {
trait PrivMatchingMethods {
fn matches_element(sel: ~Selector) -> bool;
fn matches_selector(sel : ~Selector) -> bool;
}
impl priv_matching_methods of priv_matching_methods for Node {
impl Node : PrivMatchingMethods {
#[doc="
Checks if the given CSS selector, which must describe a single element with no relational
information, describes the given HTML element.
@ -162,11 +159,11 @@ impl priv_matching_methods of priv_matching_methods for Node {
}
}
trait priv_style_methods {
trait PrivStyleMethods {
fn update_style(decl : StyleDeclaration);
}
impl priv_style_methods of priv_style_methods for Node {
impl Node : PrivStyleMethods {
#[doc="Update the computed style of an HTML element with a style specified by CSS."]
fn update_style(decl : StyleDeclaration) {
self.aux(|layout| {
@ -182,11 +179,11 @@ impl priv_style_methods of priv_style_methods for Node {
}
}
trait matching_methods {
trait MatchingMethods {
fn match_css_style(styles : Stylesheet);
}
impl matching_methods of matching_methods for Node {
impl Node : MatchingMethods {
#[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) {
@ -213,8 +210,8 @@ impl matching_methods of matching_methods for Node {
#[cfg(test)]
mod test {
import dom::base::{Attr, HTMLDivElement, HTMLHeadElement, HTMLImageElement};
import dom::base::{NodeScope, TreeReadMethods, TreeWriteMethods, UnknownElement};
import dvec::{dvec, extensions};
import dom::base::{NodeScope, UnknownElement};
import dvec::dvec;
import io::println;
#[allow(non_implicitly_copyable_typarams)]

Просмотреть файл

@ -5,11 +5,9 @@ import arc::{arc, get, clone};
import dom::style::{DisplayType, DisBlock, DisInline, DisNone, Stylesheet, Unit, Auto};
import dom::base::{Element, HTMLDivElement, HTMLHeadElement, HTMLImageElement, Node, NodeKind};
import dom::base::{Text};
import dom::rcu::ReaderMethods;
import matching::matching_methods;
import util::color::{Color, rgb};
import util::color::css_colors::{white, black};
import base::{LayoutData, NTree, NodeTreeReadMethods};
import base::{LayoutData, NTree};
type SpecifiedStyle = {mut background_color : option<Color>,
mut display_type : option<DisplayType>,
@ -19,15 +17,15 @@ type SpecifiedStyle = {mut background_color : option<Color>,
mut width : option<Unit>
};
trait default_style_methods {
trait DefaultStyleMethods {
fn default_color() -> Color;
fn default_display_type() -> DisplayType;
fn default_width() -> Unit;
fn default_height() -> Unit;
}
#[doc="Default stylesfor various attributes in case they don't get initialized from css selectors"]
impl default_style_methods of default_style_methods for NodeKind {
/// Default styles for various attributes in case they don't get initialized from CSS selectors.
impl NodeKind : DefaultStyleMethods {
fn default_color() -> Color {
match self {
Text(*) => { white() }
@ -61,14 +59,13 @@ impl default_style_methods of default_style_methods for NodeKind {
}
}
#[doc="Create a specified style that can be used to initialize a node before selector matching.
Everything is initialized to none except the display style. The
default value of thee display style is computed so that it can be
used to short-circuit selector matching to avoid computing style
for children of display:none objects.
"]
/**
* Create a specified style that can be used to initialize a node before selector matching.
*
* Everything is initialized to none except the display style. The default value of the display
* style is computed so that it can be used to short-circuit selector matching to avoid computing
* style for children of display:none objects.
*/
fn empty_style_for_node_kind(kind: NodeKind) -> SpecifiedStyle {
let display_type = kind.default_display_type();
@ -80,12 +77,13 @@ fn empty_style_for_node_kind(kind: NodeKind) -> SpecifiedStyle {
mut width : none}
}
trait style_priv {
trait StylePriv {
fn initialize_style();
}
impl style_priv of style_priv for Node {
#[doc="Set a default auxilliary data so that other threads can modify it.
impl Node : StylePriv {
#[doc="
Set a default auxiliary data so that other threads can modify it.
This is, importantly, the function that creates the layout
data for the node (the reader-auxiliary box in the RCU model)
@ -105,13 +103,13 @@ impl style_priv of style_priv for Node {
}
}
trait style_methods {
trait StyleMethods {
fn initialize_style_for_subtree();
fn get_specified_style() -> SpecifiedStyle;
fn recompute_style_for_subtree(styles : arc<Stylesheet>);
}
impl style_methods of style_methods for Node {
impl Node : StyleMethods {
#[doc="Sequentially initialize the nodes' auxilliary data so they can be updated in parallel."]
fn initialize_style_for_subtree() {
self.initialize_style();

Просмотреть файл

@ -4,11 +4,11 @@ import geom::size::Size2D;
import gfx::geometry::au;
import servo_text::text_run::TextRun;
import servo_text::font_library::FontLibrary;
import base::{Box, TextBox};
import base::{Box, TextBoxKind};
class text_box {
let text: ~str;
let mut run: option<TextRun>;
struct TextBox {
text: ~str;
mut run: option<TextRun>;
new(-text: ~str) {
self.text = text;
@ -16,15 +16,15 @@ class text_box {
}
}
trait text_layout_methods {
fn reflow_text(_available_width: au, subbox: @text_box);
trait TextLayout {
fn reflow_text(_available_width: au, subbox: @TextBox);
}
#[doc="The main reflow routine for text layout."]
impl text_layout_methods of text_layout_methods for @Box {
fn reflow_text(_available_width: au, subbox: @text_box) {
impl @Box : TextLayout {
fn reflow_text(_available_width: au, subbox: @TextBox) {
match self.kind {
TextBox(*) => { /* ok */ }
TextBoxKind(*) => { /* ok */ }
_ => { fail ~"expected text box in reflow_text!" }
};
@ -43,7 +43,6 @@ fn should_calculate_the_size_of_the_text_box() {
import dom::rcu::{Scope};
import dom::base::{Text, NodeScope};
import box_builder::box_builder_methods;
import util::tree;
import gfx::geometry::px_to_au;
@ -51,7 +50,7 @@ fn should_calculate_the_size_of_the_text_box() {
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
let subbox = match check b.kind { TextBox(subbox) => { subbox } };
let subbox = match check b.kind { TextBoxKind(subbox) => { subbox } };
b.reflow_text(px_to_au(800), subbox);
let expected = Size2D(px_to_au(84), px_to_au(20));
assert b.bounds.size == expected;

Просмотреть файл

@ -19,12 +19,12 @@ import vec::push;
type TokenReader = {stream : pipes::port<Token>, mut lookahead : option<Token>};
trait util_methods {
trait TokenReaderMethods {
fn get() -> Token;
fn unget(-tok : Token);
}
impl util_methods of util_methods for TokenReader {
impl TokenReader : TokenReaderMethods {
fn get() -> Token {
match copy self.lookahead {
some(tok) => { self.lookahead = none; copy tok }
@ -38,14 +38,14 @@ impl util_methods of util_methods for TokenReader {
}
}
trait parser_methods {
trait ParserMethods {
fn parse_element() -> option<~style::Selector>;
fn parse_selector() -> option<~[~Selector]>;
fn parse_description() -> option<~[StyleDeclaration]>;
fn parse_rule() -> option<~style::Rule>;
}
impl parser_methods of parser_methods for TokenReader {
impl TokenReader : ParserMethods {
fn parse_element() -> option<~style::Selector> {
// Get the current element type
let elmt_name = match self.get() {

Просмотреть файл

@ -38,7 +38,7 @@ enum Token {
Eof
}
trait css_methods {
trait CssLexerMethods {
fn parse_css() -> Token;
fn parse_css_relation(c : u8) -> Token;
fn parse_css_element(c : u8) -> Token;
@ -46,7 +46,7 @@ trait css_methods {
fn parse_css_description(c: u8) -> Token;
}
impl css_methods of css_methods for CssLexer {
impl CssLexer : CssLexerMethods {
fn parse_css() -> Token {
let mut ch: u8;
match self.input_state.get() {

Просмотреть файл

@ -2,9 +2,7 @@
import dom::base::{Attr, Element, ElementData, ElementKind, HTMLDivElement, HTMLHeadElement,
HTMLScriptElement};
import dom::base::{HTMLImageElement, Node, NodeScope, Text, TreeReadMethods, TreeWriteMethods};
import dom::base::{UnknownElement};
import dom::rcu::WriterMethods;
import dom::base::{HTMLImageElement, Node, NodeScope, Text, UnknownElement};
import geom::size::Size2D;
import gfx::geometry;
import gfx::geometry::au;
@ -14,7 +12,6 @@ import dom::style::Stylesheet;
import vec::{push, push_all_move, flat_map};
import std::net::url::url;
import resource::resource_task::{ResourceTask, Load, Payload, Done};
import dvec::extensions;
import result::{ok, err};
import to_str::to_str;

Просмотреть файл

@ -29,13 +29,13 @@ type HtmlLexer = {
mut parser_state: ParseState
};
trait html_methods {
trait HtmlLexerMethods {
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 {
impl HtmlLexer : HtmlLexerMethods {
fn parse_html() -> Token {
let mut ch: u8;
match self.input_state.get() {

Просмотреть файл

@ -3,7 +3,7 @@
import option::is_none;
import str::from_bytes;
import vec::push;
import comm::{port, methods};
import comm::port;
import resource::resource_task::{ProgressMsg, Payload, Done};
enum CharOrEof {
@ -18,12 +18,12 @@ type InputState = {
mut eof: bool
};
trait u8_methods {
trait U8Methods {
fn is_whitespace() -> bool;
fn is_alpha() -> bool;
}
impl u8_methods of u8_methods for u8 {
impl u8 : U8Methods {
fn is_whitespace() -> bool {
return self == ' ' as u8 || self == '\n' as u8 || self == '\t' as u8;
}
@ -34,7 +34,7 @@ impl u8_methods of u8_methods for u8 {
}
}
trait util_methods {
trait InputStateUtil {
fn get() -> CharOrEof;
fn unget(ch: u8);
fn parse_err(err: ~str) -> !;
@ -44,7 +44,7 @@ trait util_methods {
fn eat_whitespace();
}
impl util_methods of util_methods for InputState {
impl InputState : InputStateUtil {
fn get() -> CharOrEof {
match copy self.lookahead {
some(coe) => {

Просмотреть файл

@ -6,9 +6,9 @@ import azure::bindgen::*;
import azure::cairo;
import azure::cairo::bindgen::*;
import comm::*;
import dvec::{dvec, extensions};
import dvec::dvec;
import azure::cairo::cairo_surface_t;
import gfx::renderer::{Sink};
import gfx::renderer::Sink;
import dom::event::{Event, ResizeEvent};
import layers::ImageLayer;
import geom::size::Size2D;
@ -131,7 +131,7 @@ fn mainloop(po: port<Msg>) {
Implementation to allow the osmain channel to be used as a graphics
sink for the renderer
"]
impl OSMain of Sink for OSMain {
impl OSMain : Sink {
fn begin_drawing(+next_dt: pipes::chan<AzDrawTargetRef>) {
self.send(BeginDrawing(next_dt))
}

Просмотреть файл

@ -1,6 +1,6 @@
export factory;
import comm::{chan, methods};
import comm::chan;
import task::spawn;
import resource_task::{ProgressMsg, Payload, Done};
import std::net::url::url;

Просмотреть файл

@ -1,6 +1,6 @@
export factory;
import comm::{chan, methods};
import comm::chan;
import task::spawn;
import resource_task::{ProgressMsg, Payload, Done};
import std::net::url::url;

Просмотреть файл

@ -8,7 +8,7 @@ export ControlMsg, Load, Exit;
export ProgressMsg, Payload, Done;
export ResourceTask, ResourceManager, LoaderTaskFactory;
import comm::{chan, port, methods};
import comm::{chan, port};
import task::{spawn, spawn_listener};
import std::net::url;
import std::net::url::url;

Просмотреть файл

@ -182,12 +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;
trait methods {
trait FTErrorMethods {
fn for_sure();
fn failed() -> bool;
}
impl methods of methods for FT_Error {
impl FT_Error : FTErrorMethods {
fn for_sure() { assert !self.failed() }
fn failed() -> bool { self != 0 as FT_Error }
}

Просмотреть файл

@ -81,11 +81,11 @@ fn create(lib: FT_Library, buf: &~[u8]) -> result<FreeTypeNativeFont, ()> {
})
}
trait methods {
trait FTErrorMethods {
fn succeeded() -> bool;
}
impl methods of methods for FT_Error {
impl FT_Error : FTErrorMethods {
fn succeeded() -> bool { self == 0 as FT_Error }
}

Просмотреть файл

@ -11,7 +11,7 @@ import cmp::eq;
enum Color = {red : u8, green : u8, blue : u8, alpha : float};
impl Color of eq for Color {
impl Color : eq {
pure fn eq(&&other: Color) -> bool {
return self.red == other.red && self.green == other.green && self.blue == other.blue &&
self.alpha == other.alpha;
@ -56,7 +56,7 @@ fn hsl(h : float, s : float, l : float) -> Color {
return hsla(h, s, l, 1.0);
}
impl methods for Color {
impl Color {
fn print() -> ~str {
#fmt["rgba(%u,%u,%u,%f)", self.red as uint, self.green as uint,
self.blue as uint, self.alpha]

Просмотреть файл

@ -83,13 +83,13 @@ mod test {
enum dtree { dtree }
impl of ReadMethods<dummy> for dtree {
impl dtree : ReadMethods<dummy> {
fn with_tree_fields<R>(d: dummy, f: fn(Tree<dummy>) -> R) -> R {
f(d.fields)
}
}
impl of WriteMethods<dummy> for dtree {
impl dtree : WriteMethods<dummy> {
fn with_tree_fields<R>(d: dummy, f: fn(Tree<dummy>) -> R) -> R {
f(d.fields)
}