s/import/use/g; fix class method syntax

This commit is contained in:
Brian J. Burg 2012-09-11 14:52:22 -07:00
parent 1292fa2965
commit 0fa87ebfbf
44 changed files with 365 additions and 355 deletions

View file

@ -76,9 +76,9 @@ fn parse_display_type(str : ~str) -> ParseResult<CSSDisplay> {
#[cfg(test)]
mod test {
import css::lexer::spawn_css_lexer_from_string;
import css::parser::build_stylesheet;
import css::values::{Stylesheet, Element, FontSize, Width, Height};
use css::lexer::spawn_css_lexer_from_string;
use css::parser::build_stylesheet;
use css::values::{Stylesheet, Element, FontSize, Width, Height};
// TODO: use helper methods to create test values

View file

@ -1,13 +1,13 @@
#[doc="Applies the appropriate CSS style to boxes."]
import gfx::geometry::au_to_px;
import layout::base::{Box, BTree, NTree, LayoutData, SpecifiedStyle, ImageHolder,
use gfx::geometry::au_to_px;
use layout::base::{Box, BTree, NTree, LayoutData, SpecifiedStyle, ImageHolder,
BlockBox, InlineBox, IntrinsicBox, TextBox};
import layout::traverse::{top_down_traversal};
import std::net::url::Url;
import resource::image_cache_task::ImageCacheTask;
use layout::traverse::{top_down_traversal};
use std::net::url::Url;
use resource::image_cache_task::ImageCacheTask;
import css::values::*;
use css::values::*;
trait ResolveMethods<T> {
pure fn initial() -> T;

View file

@ -1,11 +1,11 @@
#[doc="Performs CSS selector matching."]
import dom::base::{LayoutData};
import dom::base;
import base::{ElementData, Node, Text};
use dom::base::{LayoutData};
use dom::base;
use base::{ElementData, Node, Text};
import values::*;
import styles::{SpecifiedStyle};
use values::*;
use styles::{SpecifiedStyle};
#[doc="Check if a CSS attribute matches the attribute of an HTML element."]
fn attrs_match(attr: Attr, elmt: ElementData) -> bool {
@ -208,9 +208,9 @@ impl Node : MatchingMethods {
#[cfg(test)]
mod test {
import dom::base::{Attr, HTMLDivElement, HTMLHeadElement, HTMLImageElement};
import dom::base::{NodeScope, UnknownElement};
import dvec::DVec;
use dom::base::{Attr, HTMLDivElement, HTMLHeadElement, HTMLImageElement};
use dom::base::{NodeScope, UnknownElement};
use dvec::DVec;
#[allow(non_implicitly_copyable_typarams)]
fn new_node_from_attr(scope: NodeScope, -name: ~str, -val: ~str) -> Node {

View file

@ -1,14 +1,14 @@
#[doc="High-level interface to CSS selector matching."]
import std::arc::{ARC, get, clone};
use std::arc::{ARC, get, clone};
import css::values::*;
import css::values::Stylesheet;
import dom::base::{HTMLDivElement, HTMLHeadElement, HTMLImageElement, UnknownElement, HTMLScriptElement};
import dom::base::{Comment, Doctype, Element, Node, NodeKind, Text};
import util::color::{Color, rgb};
import util::color::css_colors::{white, black};
import layout::base::{LayoutData, NTree};
use css::values::*;
use css::values::Stylesheet;
use dom::base::{HTMLDivElement, HTMLHeadElement, HTMLImageElement, UnknownElement, HTMLScriptElement};
use dom::base::{Comment, Doctype, Element, Node, NodeKind, Text};
use util::color::{Color, rgb};
use util::color::css_colors::{white, black};
use layout::base::{LayoutData, NTree};
type SpecifiedStyle = {mut background_color : CSSValue<CSSBackgroundColor>,
mut display_type : CSSValue<CSSDisplay>,

View file

@ -94,7 +94,9 @@ struct ElementData {
tag_name: ~str,
kind: ~ElementKind,
attrs: DVec<~Attr>,
}
impl ElementData {
fn get_attr(attr_name: ~str) -> Option<~str> {
let mut i = 0u;
while i < self.attrs.len() {

View file

@ -1,18 +1,18 @@
import js::rust::{compartment, bare_compartment, methods, jsobj};
import js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED,
use js::rust::{compartment, bare_compartment, methods, jsobj};
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED,
JSVAL_NULL, JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
import js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
import js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty, JS_DefineProperties};
import js::glue::bindgen::*;
import js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB};
import js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub, JS_ResolveStub};
import ptr::null;
import libc::c_uint;
import utils::{DOMString, domstring_to_jsval, rust_box, squirrel_away, str};
import bindings::node::create;
import base::Document;
use js::glue::bindgen::*;
use js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB};
use js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub, JS_ResolveStub};
use ptr::null;
use libc::c_uint;
use utils::{DOMString, domstring_to_jsval, rust_box, squirrel_away, str};
use bindings::node::create;
use base::Document;
enum DOMException {
INVALID_CHARACTER_ERR

View file

@ -1,23 +1,23 @@
import js::rust::{bare_compartment, methods, jsobj};
import js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
use js::rust::{bare_compartment, methods, jsobj};
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
import js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec};
import js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate};
import js::jsapi::bindgen::*;
import js::glue::bindgen::*;
import js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub};
use js::jsapi::bindgen::*;
use js::glue::bindgen::*;
use js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub};
import dom::base::{Node, NodeScope, Element};
import node::NodeBundle;
import utils::{rust_box, squirrel_away_unique, get_compartment, domstring_to_jsval, str};
import libc::c_uint;
import ptr::null;
import node::unwrap;
import dom::base::{HTMLImageElement, HTMLScriptElement, HTMLHeadElement, HTMLDivElement,
use dom::base::{Node, NodeScope, Element};
use node::NodeBundle;
use utils::{rust_box, squirrel_away_unique, get_compartment, domstring_to_jsval, str};
use libc::c_uint;
use ptr::null;
use node::unwrap;
use dom::base::{HTMLImageElement, HTMLScriptElement, HTMLHeadElement, HTMLDivElement,
UnknownElement};
import gfx::geometry::{au_to_px, px_to_au};
use gfx::geometry::{au_to_px, px_to_au};
extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) {
#debug("element finalize!");

View file

@ -1,18 +1,18 @@
import js::rust::{bare_compartment, methods, jsobj};
import js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
use js::rust::{bare_compartment, methods, jsobj};
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
import js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec};
import js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate};
import js::jsapi::bindgen::*;
import js::glue::bindgen::*;
import js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub};
use js::jsapi::bindgen::*;
use js::glue::bindgen::*;
use js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub};
import dom::base::{Node, NodeScope, Element, Text, Doctype, Comment};
import utils::{rust_box, squirrel_away_unique, get_compartment, domstring_to_jsval, str};
import libc::c_uint;
import ptr::null;
use dom::base::{Node, NodeScope, Element, Text, Doctype, Comment};
use utils::{rust_box, squirrel_away_unique, get_compartment, domstring_to_jsval, str};
use libc::c_uint;
use ptr::null;
fn init(compartment: bare_compartment) {
let obj = utils::define_empty_prototype(~"Node", None, compartment);

View file

@ -1,15 +1,15 @@
import js::rust::{compartment, bare_compartment, methods};
import js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
use js::rust::{compartment, bare_compartment, methods};
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
JS_THIS_OBJECT, JS_SET_RVAL};
import js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
import js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate,
JS_GetClass, JS_GetPrototype};
import js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB, ENUMERATE_STUB, CONVERT_STUB,
use js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB, ENUMERATE_STUB, CONVERT_STUB,
RESOLVE_STUB};
import js::glue::bindgen::*;
import ptr::null;
use js::glue::bindgen::*;
use ptr::null;
enum DOMString {
str(~str),

View file

@ -1,20 +1,20 @@
import js::rust::{bare_compartment, methods};
import js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
use js::rust::{bare_compartment, methods};
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
JS_THIS_OBJECT, JS_SET_RVAL};
import js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
import js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty, JS_DefineProperties, JS_EncodeString, JS_free};
import js::glue::bindgen::*;
import js::global::jsval_to_rust_str;
import js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub, JS_ResolveStub};
import js::glue::bindgen::RUST_JSVAL_TO_INT;
import ptr::null;
import libc::c_uint;
import utils::{rust_box, squirrel_away, jsval_to_str};
import bindings::node::create;
import dom::base::{Node, Window};
import dvec::DVec;
use js::glue::bindgen::*;
use js::global::jsval_to_rust_str;
use js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub, JS_ResolveStub};
use js::glue::bindgen::RUST_JSVAL_TO_INT;
use ptr::null;
use libc::c_uint;
use utils::{rust_box, squirrel_away, jsval_to_str};
use bindings::node::create;
use dom::base::{Node, Window};
use dvec::DVec;
extern fn alert(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool {
unsafe {

View file

@ -1,20 +1,20 @@
export EngineTask, EngineTask_, EngineProto;
import gfx::compositor::Compositor;
import gfx::render_task;
import render_task::RenderTask;
import pipes::{spawn_service, select};
import layout::layout_task;
import layout_task::LayoutTask;
import content::content_task;
import content_task::{ContentTask};
import resource::resource_task;
import resource::resource_task::{ResourceTask};
import std::net::url::Url;
import resource::image_cache_task;
import image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
use gfx::compositor::Compositor;
use gfx::render_task;
use render_task::RenderTask;
use pipes::{spawn_service, select};
use layout::layout_task;
use layout_task::LayoutTask;
use content::content_task;
use content_task::{ContentTask};
use resource::resource_task;
use resource::resource_task::{ResourceTask};
use std::net::url::Url;
use resource::image_cache_task;
use image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
import pipes::{Port, Chan};
use pipes::{Port, Chan};
fn macros() {
include!("macros.rs");
@ -62,7 +62,7 @@ struct Engine<C:Compositor> {
impl<C: Compositor> Engine<C> {
fn run(+request: EngineProto::server::Running) {
import EngineProto::*;
use EngineProto::*;
let mut request = request;
loop {

View file

@ -1,5 +1,5 @@
import dom::event::Event;
import azure::azure_hl::DrawTarget;
use dom::event::Event;
use azure::azure_hl::DrawTarget;
#[doc = "
The interface used to by the renderer to aquire draw targets for

View file

@ -1,7 +1,7 @@
import geom::point::Point2D;
import geom::rect::Rect;
import geom::size::Size2D;
import num::{Num, from_int};
use geom::point::Point2D;
use geom::rect::Rect;
use geom::size::Size2D;
use num::{Num, from_int};
enum au = i32;

View file

@ -1,25 +1,25 @@
import platform::osmain;
import geometry::*;
import comm::*;
import image::base::Image;
import dl = layout::display_list;
import azure::*;
import azure::bindgen::*;
import libc::size_t;
import text::font::Font;
import text::text_run::TextRun;
import geom::size::Size2D;
import geom::rect::Rect;
import geom::point::Point2D;
import azure_hl::{AsAzureRect, B8G8R8A8, Color, ColorPattern, DrawOptions, DrawSurfaceOptions};
import azure_hl::{DrawTarget, Linear};
import ptr::addr_of;
import std::arc::ARC;
import azure::cairo::{cairo_font_face_t, cairo_scaled_font_t};
import std::cell::Cell;
import compositor::Compositor;
use platform::osmain;
use geometry::*;
use comm::*;
use image::base::Image;
use dl = layout::display_list;
use azure::*;
use azure::bindgen::*;
use libc::size_t;
use text::font::Font;
use text::text_run::TextRun;
use geom::size::Size2D;
use geom::rect::Rect;
use geom::point::Point2D;
use azure_hl::{AsAzureRect, B8G8R8A8, Color, ColorPattern, DrawOptions, DrawSurfaceOptions};
use azure_hl::{DrawTarget, Linear};
use ptr::addr_of;
use std::arc::ARC;
use azure::cairo::{cairo_font_face_t, cairo_scaled_font_t};
use std::cell::Cell;
use compositor::Compositor;
import pipes::{Port, Chan};
use pipes::{Port, Chan};
type Renderer = comm::Chan<Msg>;
@ -132,18 +132,18 @@ fn draw_image(draw_target: &DrawTarget, item: dl::DisplayItem, image: ARC<~Image
}
fn draw_text(draw_target: &DrawTarget, item: dl::DisplayItem, text_run: TextRun) {
import ptr::{addr_of, null};
import vec::unsafe::to_ptr;
import libc::types::common::c99::{uint16_t, uint32_t};
import geom::point::Point2D;
import text::font_library::FontLibrary;
import text::font::Font;
import azure::{AzNativeFont, AzFloat, AZ_NATIVE_FONT_CAIRO_FONT_FACE};
import azure::bindgen::{AzCreateScaledFontWithCairo,
use ptr::{addr_of, null};
use vec::unsafe::to_ptr;
use libc::types::common::c99::{uint16_t, uint32_t};
use geom::point::Point2D;
use text::font_library::FontLibrary;
use text::font::Font;
use azure::{AzNativeFont, AzFloat, AZ_NATIVE_FONT_CAIRO_FONT_FACE};
use azure::bindgen::{AzCreateScaledFontWithCairo,
AzReleaseScaledFont,
AzCreateColorPattern,
AzReleaseColorPattern};
import azure::cairo::bindgen::cairo_scaled_font_destroy;
use azure::cairo::bindgen::cairo_scaled_font_destroy;
let draw_target = draw_target.azure_draw_target;
@ -205,8 +205,8 @@ fn draw_text(draw_target: &DrawTarget, item: dl::DisplayItem, text_run: TextRun)
#[cfg(target_os = "linux")]
fn get_cairo_face(font: &Font) -> *cairo_font_face_t {
import libc::c_int;
import azure::cairo_ft::bindgen::{cairo_ft_font_face_create_for_ft_face};
use libc::c_int;
use azure::cairo_ft::bindgen::{cairo_ft_font_face_create_for_ft_face};
let ftface = font.native_font.face;
let cface = cairo_ft_font_face_create_for_ft_face(ftface, 0 as c_int);
@ -216,7 +216,7 @@ fn get_cairo_face(font: &Font) -> *cairo_font_face_t {
#[cfg(target_os = "macos")]
fn get_cairo_face(font: &Font) -> *cairo_font_face_t {
import azure::cairo_quartz::bindgen::cairo_quartz_font_face_create_for_cgfont;
use azure::cairo_quartz::bindgen::cairo_quartz_font_face_create_for_cgfont;
let cgfont = font.native_font.cgfont;
let face = cairo_quartz_font_face_create_for_cgfont(cgfont);
@ -226,10 +226,10 @@ fn get_cairo_face(font: &Font) -> *cairo_font_face_t {
fn get_cairo_font(font: &Font) -> *cairo_scaled_font_t {
import libc::c_double;
import azure::cairo;
import cairo::cairo_matrix_t;
import cairo::bindgen::{cairo_matrix_init_identity,
use libc::c_double;
use azure::cairo;
use cairo::cairo_matrix_t;
use cairo::bindgen::{cairo_matrix_init_identity,
cairo_matrix_scale,
cairo_font_options_create,
cairo_scaled_font_create,

View file

@ -1,4 +1,4 @@
import geom::size::Size2D;
use geom::size::Size2D;
enum format {
fo_rgba_8888

View file

@ -1,11 +1,11 @@
import comm::{Port, Chan};
import option::is_none;
import str::from_bytes;
import vec::push;
import lexer_util::*;
import resource::resource_task;
import resource_task::{ResourceTask, ProgressMsg, Load};
import std::net::url::Url;
use comm::{Port, Chan};
use option::is_none;
use str::from_bytes;
use vec::push;
use lexer_util::*;
use resource::resource_task;
use resource_task::{ResourceTask, ProgressMsg, Load};
use std::net::url::Url;
enum Token {
StartOpeningTag(~str),

View file

@ -1,10 +1,10 @@
#[doc = "A collection of functions that are useful for both css and html parsing."]
import option::is_none;
import str::from_bytes;
import vec::push;
import comm::Port;
import resource::resource_task::{ProgressMsg, Payload, Done};
use option::is_none;
use str::from_bytes;
use vec::push;
use comm::Port;
use resource::resource_task::{ProgressMsg, Payload, Done};
enum CharOrEof {
CoeChar(u8),

View file

@ -4,7 +4,7 @@ export load;
export load_from_memory;
export test_image_bin;
import stb_image = stb_image::Image;
use stb_image = stb_image::Image;
// FIXME: Images must not be copied every frame. Instead we should atomically
// reference count them.

View file

@ -1,5 +1,5 @@
import gfx::surface;
import io::WriterUtil;
use gfx::surface;
use io::WriterUtil;
fn encode(writer: io::Writer, surface: surface::image_surface) {
assert surface.format == gfx::surface::fo_rgba_8888;

View file

@ -1,27 +1,27 @@
#[doc="Fundamental layout structures and algorithms."]
import css::styles::SpecifiedStyle;
import css::values::{BoxSizing, Length, Px};
import dom::base::{Element, ElementKind, HTMLDivElement, HTMLImageElement, Node, NodeData};
import dom::base::{NodeKind};
import dom::rcu;
import gfx::geometry;
import gfx::geometry::{au, zero_size_au};
import geom::point::Point2D;
import geom::rect::Rect;
import geom::size::Size2D;
import image::base::Image;
import util::tree;
import util::color::Color;
import text::TextBox;
import traverse::extended_full_traversal;
import vec::{push, push_all};
import std::net::url::Url;
import resource::image_cache_task;
import image_cache_task::ImageCacheTask;
import core::to_str::ToStr;
import std::arc::{ARC, clone};
import task::spawn;
use css::styles::SpecifiedStyle;
use css::values::{BoxSizing, Length, Px};
use dom::base::{Element, ElementKind, HTMLDivElement, HTMLImageElement, Node, NodeData};
use dom::base::{NodeKind};
use dom::rcu;
use gfx::geometry;
use gfx::geometry::{au, zero_size_au};
use geom::point::Point2D;
use geom::rect::Rect;
use geom::size::Size2D;
use image::base::Image;
use util::tree;
use util::color::Color;
use text::TextBox;
use traverse::extended_full_traversal;
use vec::{push, push_all};
use std::net::url::Url;
use resource::image_cache_task;
use image_cache_task::ImageCacheTask;
use core::to_str::ToStr;
use std::arc::{ARC, clone};
use task::spawn;
enum BoxKind {
BlockBox,
@ -50,7 +50,9 @@ struct Appearance {
mut width: BoxSizing,
mut height: BoxSizing,
mut font_size: Length,
}
impl Appearance {
// This will be very unhappy if it is getting run in parallel with
// anything trying to read the background image
fn get_image() -> Option<ARC<~Image>> {
@ -336,13 +338,13 @@ impl Node : NodeMethods {
#[cfg(test)]
mod test {
import dom::base::{Element, ElementData, HTMLDivElement, HTMLImageElement, Node, NodeKind};
import dom::base::{NodeScope};
import dom::rcu::Scope;
use dom::base::{Element, ElementData, HTMLDivElement, HTMLImageElement, Node, NodeKind};
use dom::base::{NodeScope};
use dom::rcu::Scope;
/*
use sdl;
import sdl::video;
use sdl::video;
fn with_screen(f: fn(*sdl::surface)) {
let screen = video::set_video_mode(

View file

@ -1,11 +1,11 @@
#[doc="Block layout."]
import css::values::*;
import geom::point::Point2D;
import geom::size::Size2D;
import gfx::geometry::{px_to_au, au};
import util::tree;
import base::{Box, BlockBox, BTree};
use css::values::*;
use geom::point::Point2D;
use geom::size::Size2D;
use gfx::geometry::{px_to_au, au};
use util::tree;
use base::{Box, BlockBox, BTree};
trait BlockLayoutMethods {
fn reflow_block();

View file

@ -1,10 +1,10 @@
import gfx::geometry::*;
import geom::rect::Rect;
import image::base::Image;
import servo_text::text_run::TextRun;
use gfx::geometry::*;
use geom::rect::Rect;
use image::base::Image;
use servo_text::text_run::TextRun;
import std::arc::ARC;
import dvec::DVec;
use std::arc::ARC;
use dvec::DVec;
// TODO: convert to DisplayItem trait with methods like bounds(), paint(), etc.
enum ItemKind {

View file

@ -1,19 +1,19 @@
export build_display_list;
import css::values::{BgColor, BgTransparent, Specified};
import base::{Box, BTree, ImageHolder, TextBoxKind};
import dl = layout::display_list;
import dom::base::{Text, NodeScope};
import dom::rcu::Scope;
import either::{Left, Right};
import geom::point::Point2D;
import geom::rect::Rect;
import geom::size::Size2D;
import gfx::geometry::{au, au_to_px, box, px_to_au};
import util::tree;
use css::values::{BgColor, BgTransparent, Specified};
use base::{Box, BTree, ImageHolder, TextBoxKind};
use dl = layout::display_list;
use dom::base::{Text, NodeScope};
use dom::rcu::Scope;
use either::{Left, Right};
use geom::point::Point2D;
use geom::rect::Rect;
use geom::size::Size2D;
use gfx::geometry::{au, au_to_px, box, px_to_au};
use util::tree;
import dvec::DVec;
import vec::push;
use dvec::DVec;
use vec::push;
#[doc = "

View file

@ -3,22 +3,22 @@
rendered.
"];
import std::arc::ARC;
import display_list_builder::build_display_list;
import dom::base::Node;
import css::values::Stylesheet;
import gfx::geometry::px_to_au;
import gfx::render_task;
import render_task::RenderTask;
import layout::base::Box;
import resource::image_cache_task::ImageCacheTask;
import std::net::url::Url;
import css::resolve::apply::apply_style;
import dom::event::{Event, ReflowEvent};
import content::content_task;
use std::arc::ARC;
use display_list_builder::build_display_list;
use dom::base::Node;
use css::values::Stylesheet;
use gfx::geometry::px_to_au;
use gfx::render_task;
use render_task::RenderTask;
use layout::base::Box;
use resource::image_cache_task::ImageCacheTask;
use std::net::url::Url;
use css::resolve::apply::apply_style;
use dom::event::{Event, ReflowEvent};
use content::content_task;
import task::*;
import comm::*;
use task::*;
use comm::*;
type LayoutTask = Chan<Msg>;

View file

@ -1,7 +1,7 @@
#[doc = "Interface for running tree-based traversals over layout boxes"]
import base::{Box, BTree, NodeMethods};
import intrinsic::TyDesc;
use base::{Box, BTree, NodeMethods};
use intrinsic::TyDesc;
export full_traversal;
export top_down_traversal;

View file

@ -17,7 +17,7 @@ enum RenderMode {
#[allow(non_implicitly_copyable_typarams)]
fn from_cmdline_args(args: ~[~str]) -> Opts {
import std::getopts;
use std::getopts;
let args = args.tail();

View file

@ -1,24 +1,24 @@
export OSMain;
export Msg, BeginDrawing, Draw, AddKeyHandler, Exit;
import azure::*;
import azure::azure_hl::DrawTarget;
import azure::bindgen::*;
import azure::cairo;
import azure::cairo::bindgen::*;
import azure::cairo_hl::ImageSurface;
import comm::*;
import dvec::DVec;
import azure::cairo::cairo_surface_t;
import gfx::compositor::Compositor;
import dom::event::{Event, ResizeEvent};
import layers::ImageLayer;
import geom::size::Size2D;
import std::cmp::FuzzyEq;
import task::TaskBuilder;
import vec::push;
use azure::*;
use azure::azure_hl::DrawTarget;
use azure::bindgen::*;
use azure::cairo;
use azure::cairo::bindgen::*;
use azure::cairo_hl::ImageSurface;
use comm::*;
use dvec::DVec;
use azure::cairo::cairo_surface_t;
use gfx::compositor::Compositor;
use dom::event::{Event, ResizeEvent};
use layers::ImageLayer;
use geom::size::Size2D;
use std::cmp::FuzzyEq;
use task::TaskBuilder;
use vec::push;
import pipes::chan;
use pipes::chan;
type OSMain = comm::Chan<Msg>;

View file

@ -1,10 +1,10 @@
export factory;
import comm::Chan;
import task::spawn;
import resource_task::{ProgressMsg, Payload, Done};
import std::net::url::Url;
import io::{file_reader, ReaderUtil};
use comm::Chan;
use task::spawn;
use resource_task::{ProgressMsg, Payload, Done};
use std::net::url::Url;
use io::{file_reader, ReaderUtil};
const READ_SIZE: uint = 1024;

View file

@ -1,10 +1,10 @@
export factory;
import comm::Chan;
import task::spawn;
import resource_task::{ProgressMsg, Payload, Done};
import std::net::url::Url;
import http_client::{uv_http_request};
use comm::Chan;
use task::spawn;
use resource_task::{ProgressMsg, Payload, Done};
use std::net::url::Url;
use http_client::{uv_http_request};
fn factory(+url: Url, progress_chan: Chan<ProgressMsg>) {
assert url.scheme == ~"http";

View file

@ -4,17 +4,17 @@ export ImageCacheTask;
export ImageCacheTaskClient;
export SyncImageCacheTask;
import image::base::{Image, load_from_memory, test_image_bin};
import std::net::url::Url;
import util::url::{make_url, UrlMap, url_map};
import comm::{Chan, Port};
import task::{spawn, spawn_listener};
import resource::resource_task;
import resource_task::ResourceTask;
import std::arc::ARC;
import clone_arc = std::arc::clone;
import std::cell::Cell;
import to_str::ToStr;
use image::base::{Image, load_from_memory, test_image_bin};
use std::net::url::Url;
use util::url::{make_url, UrlMap, url_map};
use comm::{Chan, Port};
use task::{spawn, spawn_listener};
use resource::resource_task;
use resource_task::ResourceTask;
use std::arc::ARC;
use clone_arc = std::arc::clone;
use std::cell::Cell;
use to_str::ToStr;
enum Msg {
/// Tell the cache that we may need a particular image soon. Must be posted

View file

@ -8,10 +8,10 @@ export ControlMsg, Load, Exit;
export ProgressMsg, Payload, Done;
export ResourceTask, ResourceManager, LoaderTaskFactory;
import comm::{Chan, Port};
import task::{spawn, spawn_listener};
import std::net::url;
import std::net::url::{Url, to_str};
use comm::{Chan, Port};
use task::{spawn, spawn_listener};
use std::net::url;
use std::net::url::{Url, to_str};
enum ControlMsg {
/// Request the data associated with a particular URL

View file

@ -127,4 +127,4 @@ mod util {
mod opts;
import servo_text = text;
use servo_text = text;

View file

@ -1,14 +1,14 @@
import comm::*;
import option::swap_unwrap;
import platform::osmain;
import osmain::{OSMain, AddKeyHandler};
import opts::{Opts, Screen, Png};
import engine::{EngineTask, EngineProto};
use comm::*;
use option::swap_unwrap;
use platform::osmain;
use osmain::{OSMain, AddKeyHandler};
use opts::{Opts, Screen, Png};
use engine::{EngineTask, EngineProto};
import url_to_str = std::net::url::to_str;
import util::url::make_url;
use url_to_str = std::net::url::to_str;
use util::url::make_url;
import pipes::{Port, Chan};
use pipes::{Port, Chan};
fn main(args: ~[~str]) {
run(opts::from_cmdline_args(args))
@ -65,12 +65,12 @@ fn run_pipeline_screen(urls: ~[~str]) {
fn run_pipeline_png(-url: ~str, outfile: ~str) {
// Use a PNG encoder as the graphics compositor
import gfx::png_compositor;
import png_compositor::PngCompositor;
import io::{Writer, buffered_file_writer};
import resource::resource_task::ResourceTask;
import resource::image_cache_task::SyncImageCacheTask;
import engine::EngineTask_;
use gfx::png_compositor;
use png_compositor::PngCompositor;
use io::{Writer, buffered_file_writer};
use resource::resource_task::ResourceTask;
use resource::image_cache_task::SyncImageCacheTask;
use engine::EngineTask_;
listen(|pngdata_from_compositor| {
let compositor = PngCompositor(pngdata_from_compositor);

View file

@ -1,11 +1,11 @@
export Font, test_font_bin, create_test_font;
import glyph::GlyphIndex;
import vec_to_ptr = vec::unsafe::to_ptr;
import libc::{ c_int, c_double, c_ulong };
import ptr::{ null, addr_of };
import native_font::NativeFont;
import font_library::FontLibrary;
use glyph::GlyphIndex;
use vec_to_ptr = vec::unsafe::to_ptr;
use libc::{ c_int, c_double, c_ulong };
use ptr::{ null, addr_of };
use native_font::NativeFont;
use font_library::FontLibrary;
#[doc = "
A font handle. Layout can use this to calculate glyph metrics
@ -14,7 +14,9 @@ and the renderer can use it to render text.
struct Font {
fontbuf: @~[u8],
native_font: NativeFont,
}
impl Font {
fn buf() -> @~[u8] {
self.fontbuf
}

View file

@ -1,6 +1,6 @@
export FontLibrary, native;
import font::{Font, test_font_bin};
use font::{Font, test_font_bin};
struct FontLibrary {
native_lib: native::NativeFontLibrary,
@ -8,7 +8,9 @@ struct FontLibrary {
drop {
native::destroy_native_lib(&self.native_lib);
}
}
impl FontLibrary {
fn get_font() -> @Font {
match create_font(&self.native_lib) {
Ok(font) => font,
@ -40,10 +42,10 @@ fn create_font(native_lib: &native::NativeFontLibrary) -> Result<@Font, ()> {
#[cfg(target_os = "linux")]
mod native {
import ptr::{null, addr_of};
import azure::freetype;
import freetype::{FT_Library, FT_Error};
import freetype::bindgen::{FT_Init_FreeType, FT_Done_FreeType};
use ptr::{null, addr_of};
use azure::freetype;
use freetype::{FT_Library, FT_Error};
use freetype::bindgen::{FT_Init_FreeType, FT_Done_FreeType};
type NativeFontLibrary = FT_Library;

View file

@ -1,7 +1,7 @@
export GlyphIndex, GlyphPos, Glyph;
import gfx::geometry::au;
import geom::point::Point2D;
use gfx::geometry::au;
use geom::point::Point2D;
#[doc = "The index of a particular glyph within a font"]
type GlyphIndex = uint;

View file

@ -9,7 +9,7 @@ font resources needed by the graphics layer to draw glyphs.
export NativeFont, create;
import font_library::native::NativeFontLibrary;
use font_library::native::NativeFontLibrary;
#[cfg(target_os = "macos")]
type NativeFont/& = quartz_native_font::QuartzNativeFont;

View file

@ -1,12 +1,12 @@
export FreeTypeNativeFont, with_test_native_font, create;
import vec_as_buf = vec::as_buf;
import ptr::{addr_of, null};
import unsafe::reinterpret_cast;
import glyph::GlyphIndex;
import azure::freetype;
import freetype::{ FT_Error, FT_Library, FT_Face, FT_Long, FT_ULong, FT_UInt, FT_GlyphSlot };
import freetype::bindgen::{
use vec_as_buf = vec::as_buf;
use ptr::{addr_of, null};
use unsafe::reinterpret_cast;
use glyph::GlyphIndex;
use azure::freetype;
use freetype::{ FT_Error, FT_Library, FT_Face, FT_Long, FT_ULong, FT_UInt, FT_GlyphSlot };
use freetype::bindgen::{
FT_Init_FreeType,
FT_Done_FreeType,
FT_New_Memory_Face,
@ -92,8 +92,8 @@ impl FT_Error : FTErrorMethods {
}
fn with_test_native_font(f: fn@(nf: &NativeFont)) {
import font::test_font_bin;
import unwrap_result = result::unwrap;
use font::test_font_bin;
use unwrap_result = result::unwrap;
with_lib(|lib| {
let buf = test_font_bin();

View file

@ -2,14 +2,14 @@ use cocoa;
export QuartzNativeFont, with_test_native_font, create;
import libc::size_t;
import ptr::null;
import glyph::GlyphIndex;
import cocoa::cg::{
use libc::size_t;
use ptr::null;
use glyph::GlyphIndex;
use cocoa::cg::{
CGDataProviderRef,
CGFontRef
};
import cocoa::cg::cg::{
use cocoa::cg::cg::{
CGDataProviderCreateWithData,
CGDataProviderRelease,
CGFontCreateWithDataProvider,
@ -75,8 +75,8 @@ fn QuartzNativeFont(fontprov: CGDataProviderRef, cgfont: CGFontRef) -> QuartzNat
impl QuartzNativeFont {
fn glyph_index(codepoint: char) -> Option<GlyphIndex> {
import coretext::{UniChar, CGGlyph, CFIndex};
import coretext::coretext::{CFRelease, CTFontGetGlyphsForCharacters};
use coretext::{UniChar, CGGlyph, CFIndex};
use coretext::coretext::{CFRelease, CTFontGetGlyphsForCharacters};
let ctfont = ctfont_from_cgfont(self.cgfont);
assert ctfont.is_not_null();
@ -103,8 +103,8 @@ impl QuartzNativeFont {
// FIXME: What unit is this returning? Let's have a custom type
fn glyph_h_advance(glyph: GlyphIndex) -> Option<int> {
import coretext::{CGGlyph, kCTFontDefaultOrientation};
import coretext::coretext::{CFRelease, CTFontGetAdvancesForGlyphs};
use coretext::{CGGlyph, kCTFontDefaultOrientation};
use coretext::coretext::{CFRelease, CTFontGetAdvancesForGlyphs};
let ctfont = ctfont_from_cgfont(self.cgfont);
assert ctfont.is_not_null();
@ -120,8 +120,8 @@ impl QuartzNativeFont {
}
fn ctfont_from_cgfont(cgfont: CGFontRef) -> coretext::CTFontRef {
import coretext::CGFloat;
import coretext::coretext::CTFontCreateWithGraphicsFont;
use coretext::CGFloat;
use coretext::coretext::CTFontCreateWithGraphicsFont;
assert cgfont.is_not_null();
CTFontCreateWithGraphicsFont(cgfont, 21f as CGFloat, null(), null())
@ -147,8 +147,8 @@ fn create(buf: &~[u8]) -> Result<QuartzNativeFont, ()> {
}
fn with_test_native_font(f: fn@(nf: &NativeFont)) {
import font::test_font_bin;
import unwrap_result = result::unwrap;
use font::test_font_bin;
use unwrap_result = result::unwrap;
let buf = test_font_bin();
let res = create(&buf);

View file

@ -2,22 +2,22 @@ use harfbuzz;
export shape_text;
import libc::types::common::c99::int32_t;
import libc::{c_uint, c_int, c_void};
import font::Font;
import glyph::{Glyph, GlyphPos};
import ptr::{null, addr_of, offset};
import gfx::geometry::{au, px_to_au};
import geom::point::Point2D;
import font_library::FontLibrary;
use libc::types::common::c99::int32_t;
use libc::{c_uint, c_int, c_void};
use font::Font;
use glyph::{Glyph, GlyphPos};
use ptr::{null, addr_of, offset};
use gfx::geometry::{au, px_to_au};
use geom::point::Point2D;
use font_library::FontLibrary;
import unsafe::reinterpret_cast;
import harfbuzz::{HB_MEMORY_MODE_READONLY,
use unsafe::reinterpret_cast;
use harfbuzz::{HB_MEMORY_MODE_READONLY,
HB_DIRECTION_LTR};
import harfbuzz::{hb_blob_t, hb_face_t, hb_font_t, hb_buffer_t,
use harfbuzz::{hb_blob_t, hb_face_t, hb_font_t, hb_buffer_t,
hb_codepoint_t, hb_bool_t, hb_glyph_position_t,
hb_var_int_t, hb_position_t};
import harfbuzz::bindgen::{hb_blob_create, hb_blob_destroy,
use harfbuzz::bindgen::{hb_blob_create, hb_blob_destroy,
hb_face_create, hb_face_destroy,
hb_font_create, hb_font_destroy,
hb_buffer_create, hb_buffer_destroy,

View file

@ -1,16 +1,18 @@
import geom::point::Point2D;
import geom::size::Size2D;
import gfx::geometry::{au, px_to_au};
import libc::{c_void};
import font_library::FontLibrary;
import font::Font;
import glyph::Glyph;
import shaper::shape_text;
use geom::point::Point2D;
use geom::size::Size2D;
use gfx::geometry::{au, px_to_au};
use libc::{c_void};
use font_library::FontLibrary;
use font::Font;
use glyph::Glyph;
use shaper::shape_text;
#[doc="A single, unbroken line of text."]
struct TextRun {
glyphs: ~[Glyph],
}
impl TextRun {
fn size() -> Size2D<au> {
let height = px_to_au(20);
let pen_start_x = px_to_au(0);

View file

@ -4,10 +4,10 @@
// sanitize input / crop it to correct ranges, predefine other 130
// css-defined colors
import float::round;
import libc::types::os::arch::c95::c_double;
import css_colors::*;
import cmp::Eq;
use float::round;
use libc::types::os::arch::c95::c_double;
use css_colors::*;
use cmp::Eq;
enum Color = {red : u8, green : u8, blue : u8, alpha : float};
@ -179,9 +179,9 @@ mod parsing {
#[cfg(test)]
mod test {
import css_colors::*;
import option::unwrap;
import parsing::parse_color;
use css_colors::*;
use option::unwrap;
use parsing::parse_color;
#[test]
fn test_parse_by_name() {

View file

@ -1,5 +1,5 @@
// Timing functions.
import std::time::precise_time_ns;
use std::time::precise_time_ns;
fn time(msg: ~str, callback: fn()) {
let start_time = precise_time_ns();

View file

@ -1,9 +1,9 @@
export make_url, UrlMap, url_map;
import std::net::url;
import std::net::url::Url;
import std::map::hashmap;
import path::Path;
use std::net::url;
use std::net::url::Url;
use std::map::hashmap;
use path::Path;
/**
Create a URL object from a string. Does various helpful browsery things like
@ -103,7 +103,7 @@ mod make_url_tests {
type UrlMap<T: Copy> = hashmap<Url, T>;
fn url_map<T: Copy>() -> UrlMap<T> {
import core::to_str::ToStr;
use core::to_str::ToStr;
hashmap::<Url, T>()
}