mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
s/import/use/g; fix class method syntax
This commit is contained in:
parent
1292fa2965
commit
0fa87ebfbf
44 changed files with 365 additions and 355 deletions
|
@ -76,9 +76,9 @@ fn parse_display_type(str : ~str) -> ParseResult<CSSDisplay> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
import css::lexer::spawn_css_lexer_from_string;
|
use css::lexer::spawn_css_lexer_from_string;
|
||||||
import css::parser::build_stylesheet;
|
use css::parser::build_stylesheet;
|
||||||
import css::values::{Stylesheet, Element, FontSize, Width, Height};
|
use css::values::{Stylesheet, Element, FontSize, Width, Height};
|
||||||
|
|
||||||
// TODO: use helper methods to create test values
|
// TODO: use helper methods to create test values
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#[doc="Applies the appropriate CSS style to boxes."]
|
#[doc="Applies the appropriate CSS style to boxes."]
|
||||||
|
|
||||||
import gfx::geometry::au_to_px;
|
use gfx::geometry::au_to_px;
|
||||||
import layout::base::{Box, BTree, NTree, LayoutData, SpecifiedStyle, ImageHolder,
|
use layout::base::{Box, BTree, NTree, LayoutData, SpecifiedStyle, ImageHolder,
|
||||||
BlockBox, InlineBox, IntrinsicBox, TextBox};
|
BlockBox, InlineBox, IntrinsicBox, TextBox};
|
||||||
import layout::traverse::{top_down_traversal};
|
use layout::traverse::{top_down_traversal};
|
||||||
import std::net::url::Url;
|
use std::net::url::Url;
|
||||||
import resource::image_cache_task::ImageCacheTask;
|
use resource::image_cache_task::ImageCacheTask;
|
||||||
|
|
||||||
import css::values::*;
|
use css::values::*;
|
||||||
|
|
||||||
trait ResolveMethods<T> {
|
trait ResolveMethods<T> {
|
||||||
pure fn initial() -> T;
|
pure fn initial() -> T;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#[doc="Performs CSS selector matching."]
|
#[doc="Performs CSS selector matching."]
|
||||||
|
|
||||||
import dom::base::{LayoutData};
|
use dom::base::{LayoutData};
|
||||||
import dom::base;
|
use dom::base;
|
||||||
import base::{ElementData, Node, Text};
|
use base::{ElementData, Node, Text};
|
||||||
|
|
||||||
import values::*;
|
use values::*;
|
||||||
import styles::{SpecifiedStyle};
|
use styles::{SpecifiedStyle};
|
||||||
|
|
||||||
#[doc="Check if a CSS attribute matches the attribute of an HTML element."]
|
#[doc="Check if a CSS attribute matches the attribute of an HTML element."]
|
||||||
fn attrs_match(attr: Attr, elmt: ElementData) -> bool {
|
fn attrs_match(attr: Attr, elmt: ElementData) -> bool {
|
||||||
|
@ -208,9 +208,9 @@ impl Node : MatchingMethods {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
import dom::base::{Attr, HTMLDivElement, HTMLHeadElement, HTMLImageElement};
|
use dom::base::{Attr, HTMLDivElement, HTMLHeadElement, HTMLImageElement};
|
||||||
import dom::base::{NodeScope, UnknownElement};
|
use dom::base::{NodeScope, UnknownElement};
|
||||||
import dvec::DVec;
|
use dvec::DVec;
|
||||||
|
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
fn new_node_from_attr(scope: NodeScope, -name: ~str, -val: ~str) -> Node {
|
fn new_node_from_attr(scope: NodeScope, -name: ~str, -val: ~str) -> Node {
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#[doc="High-level interface to CSS selector matching."]
|
#[doc="High-level interface to CSS selector matching."]
|
||||||
|
|
||||||
import std::arc::{ARC, get, clone};
|
use std::arc::{ARC, get, clone};
|
||||||
|
|
||||||
import css::values::*;
|
use css::values::*;
|
||||||
import css::values::Stylesheet;
|
use css::values::Stylesheet;
|
||||||
import dom::base::{HTMLDivElement, HTMLHeadElement, HTMLImageElement, UnknownElement, HTMLScriptElement};
|
use dom::base::{HTMLDivElement, HTMLHeadElement, HTMLImageElement, UnknownElement, HTMLScriptElement};
|
||||||
import dom::base::{Comment, Doctype, Element, Node, NodeKind, Text};
|
use dom::base::{Comment, Doctype, Element, Node, NodeKind, Text};
|
||||||
import util::color::{Color, rgb};
|
use util::color::{Color, rgb};
|
||||||
import util::color::css_colors::{white, black};
|
use util::color::css_colors::{white, black};
|
||||||
import layout::base::{LayoutData, NTree};
|
use layout::base::{LayoutData, NTree};
|
||||||
|
|
||||||
type SpecifiedStyle = {mut background_color : CSSValue<CSSBackgroundColor>,
|
type SpecifiedStyle = {mut background_color : CSSValue<CSSBackgroundColor>,
|
||||||
mut display_type : CSSValue<CSSDisplay>,
|
mut display_type : CSSValue<CSSDisplay>,
|
||||||
|
|
|
@ -94,7 +94,9 @@ struct ElementData {
|
||||||
tag_name: ~str,
|
tag_name: ~str,
|
||||||
kind: ~ElementKind,
|
kind: ~ElementKind,
|
||||||
attrs: DVec<~Attr>,
|
attrs: DVec<~Attr>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ElementData {
|
||||||
fn get_attr(attr_name: ~str) -> Option<~str> {
|
fn get_attr(attr_name: ~str) -> Option<~str> {
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
while i < self.attrs.len() {
|
while i < self.attrs.len() {
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import js::rust::{compartment, bare_compartment, methods, jsobj};
|
use js::rust::{compartment, bare_compartment, methods, jsobj};
|
||||||
import js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED,
|
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED,
|
||||||
JSVAL_NULL, JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
|
JSVAL_NULL, JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
|
||||||
import js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
|
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
|
||||||
import js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
|
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
|
||||||
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
|
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
|
||||||
JS_DefineFunctions, JS_DefineProperty, JS_DefineProperties};
|
JS_DefineFunctions, JS_DefineProperty, JS_DefineProperties};
|
||||||
import js::glue::bindgen::*;
|
use js::glue::bindgen::*;
|
||||||
import js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB};
|
use js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB};
|
||||||
import js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub, JS_ResolveStub};
|
use js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub, JS_ResolveStub};
|
||||||
import ptr::null;
|
use ptr::null;
|
||||||
import libc::c_uint;
|
use libc::c_uint;
|
||||||
import utils::{DOMString, domstring_to_jsval, rust_box, squirrel_away, str};
|
use utils::{DOMString, domstring_to_jsval, rust_box, squirrel_away, str};
|
||||||
import bindings::node::create;
|
use bindings::node::create;
|
||||||
import base::Document;
|
use base::Document;
|
||||||
|
|
||||||
enum DOMException {
|
enum DOMException {
|
||||||
INVALID_CHARACTER_ERR
|
INVALID_CHARACTER_ERR
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
import js::rust::{bare_compartment, methods, jsobj};
|
use js::rust::{bare_compartment, methods, jsobj};
|
||||||
import js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
|
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
|
||||||
JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
|
JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
|
||||||
import js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec};
|
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec};
|
||||||
import js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
|
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
|
||||||
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
|
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
|
||||||
JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate};
|
JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate};
|
||||||
import js::jsapi::bindgen::*;
|
use js::jsapi::bindgen::*;
|
||||||
import js::glue::bindgen::*;
|
use js::glue::bindgen::*;
|
||||||
import js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub};
|
use js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub};
|
||||||
|
|
||||||
import dom::base::{Node, NodeScope, Element};
|
use dom::base::{Node, NodeScope, Element};
|
||||||
import node::NodeBundle;
|
use node::NodeBundle;
|
||||||
import utils::{rust_box, squirrel_away_unique, get_compartment, domstring_to_jsval, str};
|
use utils::{rust_box, squirrel_away_unique, get_compartment, domstring_to_jsval, str};
|
||||||
import libc::c_uint;
|
use libc::c_uint;
|
||||||
import ptr::null;
|
use ptr::null;
|
||||||
import node::unwrap;
|
use node::unwrap;
|
||||||
import dom::base::{HTMLImageElement, HTMLScriptElement, HTMLHeadElement, HTMLDivElement,
|
use dom::base::{HTMLImageElement, HTMLScriptElement, HTMLHeadElement, HTMLDivElement,
|
||||||
UnknownElement};
|
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) {
|
extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) {
|
||||||
#debug("element finalize!");
|
#debug("element finalize!");
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import js::rust::{bare_compartment, methods, jsobj};
|
use js::rust::{bare_compartment, methods, jsobj};
|
||||||
import js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
|
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
|
||||||
JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
|
JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
|
||||||
import js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec};
|
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec};
|
||||||
import js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
|
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
|
||||||
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
|
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
|
||||||
JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate};
|
JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate};
|
||||||
import js::jsapi::bindgen::*;
|
use js::jsapi::bindgen::*;
|
||||||
import js::glue::bindgen::*;
|
use js::glue::bindgen::*;
|
||||||
import js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub};
|
use js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub};
|
||||||
|
|
||||||
import dom::base::{Node, NodeScope, Element, Text, Doctype, Comment};
|
use dom::base::{Node, NodeScope, Element, Text, Doctype, Comment};
|
||||||
import utils::{rust_box, squirrel_away_unique, get_compartment, domstring_to_jsval, str};
|
use utils::{rust_box, squirrel_away_unique, get_compartment, domstring_to_jsval, str};
|
||||||
import libc::c_uint;
|
use libc::c_uint;
|
||||||
import ptr::null;
|
use ptr::null;
|
||||||
|
|
||||||
fn init(compartment: bare_compartment) {
|
fn init(compartment: bare_compartment) {
|
||||||
let obj = utils::define_empty_prototype(~"Node", None, compartment);
|
let obj = utils::define_empty_prototype(~"Node", None, compartment);
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import js::rust::{compartment, bare_compartment, methods};
|
use js::rust::{compartment, bare_compartment, methods};
|
||||||
import js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
|
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
|
||||||
JS_THIS_OBJECT, JS_SET_RVAL};
|
JS_THIS_OBJECT, JS_SET_RVAL};
|
||||||
import js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
|
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
|
||||||
import js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
|
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
|
||||||
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
|
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
|
||||||
JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate,
|
JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate,
|
||||||
JS_GetClass, JS_GetPrototype};
|
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};
|
RESOLVE_STUB};
|
||||||
import js::glue::bindgen::*;
|
use js::glue::bindgen::*;
|
||||||
import ptr::null;
|
use ptr::null;
|
||||||
|
|
||||||
enum DOMString {
|
enum DOMString {
|
||||||
str(~str),
|
str(~str),
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import js::rust::{bare_compartment, methods};
|
use js::rust::{bare_compartment, methods};
|
||||||
import js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
|
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
|
||||||
JS_THIS_OBJECT, JS_SET_RVAL};
|
JS_THIS_OBJECT, JS_SET_RVAL};
|
||||||
import js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
|
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
|
||||||
import js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
|
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
|
||||||
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
|
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
|
||||||
JS_DefineFunctions, JS_DefineProperty, JS_DefineProperties, JS_EncodeString, JS_free};
|
JS_DefineFunctions, JS_DefineProperty, JS_DefineProperties, JS_EncodeString, JS_free};
|
||||||
import js::glue::bindgen::*;
|
use js::glue::bindgen::*;
|
||||||
import js::global::jsval_to_rust_str;
|
use js::global::jsval_to_rust_str;
|
||||||
import js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub, JS_ResolveStub};
|
use js::crust::{JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ConvertStub, JS_ResolveStub};
|
||||||
import js::glue::bindgen::RUST_JSVAL_TO_INT;
|
use js::glue::bindgen::RUST_JSVAL_TO_INT;
|
||||||
import ptr::null;
|
use ptr::null;
|
||||||
import libc::c_uint;
|
use libc::c_uint;
|
||||||
import utils::{rust_box, squirrel_away, jsval_to_str};
|
use utils::{rust_box, squirrel_away, jsval_to_str};
|
||||||
import bindings::node::create;
|
use bindings::node::create;
|
||||||
import dom::base::{Node, Window};
|
use dom::base::{Node, Window};
|
||||||
import dvec::DVec;
|
use dvec::DVec;
|
||||||
|
|
||||||
extern fn alert(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool {
|
extern fn alert(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
export EngineTask, EngineTask_, EngineProto;
|
export EngineTask, EngineTask_, EngineProto;
|
||||||
|
|
||||||
import gfx::compositor::Compositor;
|
use gfx::compositor::Compositor;
|
||||||
import gfx::render_task;
|
use gfx::render_task;
|
||||||
import render_task::RenderTask;
|
use render_task::RenderTask;
|
||||||
import pipes::{spawn_service, select};
|
use pipes::{spawn_service, select};
|
||||||
import layout::layout_task;
|
use layout::layout_task;
|
||||||
import layout_task::LayoutTask;
|
use layout_task::LayoutTask;
|
||||||
import content::content_task;
|
use content::content_task;
|
||||||
import content_task::{ContentTask};
|
use content_task::{ContentTask};
|
||||||
import resource::resource_task;
|
use resource::resource_task;
|
||||||
import resource::resource_task::{ResourceTask};
|
use resource::resource_task::{ResourceTask};
|
||||||
import std::net::url::Url;
|
use std::net::url::Url;
|
||||||
import resource::image_cache_task;
|
use resource::image_cache_task;
|
||||||
import image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
|
use image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
|
||||||
|
|
||||||
import pipes::{Port, Chan};
|
use pipes::{Port, Chan};
|
||||||
|
|
||||||
fn macros() {
|
fn macros() {
|
||||||
include!("macros.rs");
|
include!("macros.rs");
|
||||||
|
@ -62,7 +62,7 @@ struct Engine<C:Compositor> {
|
||||||
|
|
||||||
impl<C: Compositor> Engine<C> {
|
impl<C: Compositor> Engine<C> {
|
||||||
fn run(+request: EngineProto::server::Running) {
|
fn run(+request: EngineProto::server::Running) {
|
||||||
import EngineProto::*;
|
use EngineProto::*;
|
||||||
let mut request = request;
|
let mut request = request;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import dom::event::Event;
|
use dom::event::Event;
|
||||||
import azure::azure_hl::DrawTarget;
|
use azure::azure_hl::DrawTarget;
|
||||||
|
|
||||||
#[doc = "
|
#[doc = "
|
||||||
The interface used to by the renderer to aquire draw targets for
|
The interface used to by the renderer to aquire draw targets for
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
import geom::rect::Rect;
|
use geom::rect::Rect;
|
||||||
import geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
import num::{Num, from_int};
|
use num::{Num, from_int};
|
||||||
|
|
||||||
enum au = i32;
|
enum au = i32;
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
import platform::osmain;
|
use platform::osmain;
|
||||||
import geometry::*;
|
use geometry::*;
|
||||||
import comm::*;
|
use comm::*;
|
||||||
import image::base::Image;
|
use image::base::Image;
|
||||||
import dl = layout::display_list;
|
use dl = layout::display_list;
|
||||||
import azure::*;
|
use azure::*;
|
||||||
import azure::bindgen::*;
|
use azure::bindgen::*;
|
||||||
import libc::size_t;
|
use libc::size_t;
|
||||||
import text::font::Font;
|
use text::font::Font;
|
||||||
import text::text_run::TextRun;
|
use text::text_run::TextRun;
|
||||||
import geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
import geom::rect::Rect;
|
use geom::rect::Rect;
|
||||||
import geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
import azure_hl::{AsAzureRect, B8G8R8A8, Color, ColorPattern, DrawOptions, DrawSurfaceOptions};
|
use azure_hl::{AsAzureRect, B8G8R8A8, Color, ColorPattern, DrawOptions, DrawSurfaceOptions};
|
||||||
import azure_hl::{DrawTarget, Linear};
|
use azure_hl::{DrawTarget, Linear};
|
||||||
import ptr::addr_of;
|
use ptr::addr_of;
|
||||||
import std::arc::ARC;
|
use std::arc::ARC;
|
||||||
import azure::cairo::{cairo_font_face_t, cairo_scaled_font_t};
|
use azure::cairo::{cairo_font_face_t, cairo_scaled_font_t};
|
||||||
import std::cell::Cell;
|
use std::cell::Cell;
|
||||||
import compositor::Compositor;
|
use compositor::Compositor;
|
||||||
|
|
||||||
import pipes::{Port, Chan};
|
use pipes::{Port, Chan};
|
||||||
|
|
||||||
type Renderer = comm::Chan<Msg>;
|
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) {
|
fn draw_text(draw_target: &DrawTarget, item: dl::DisplayItem, text_run: TextRun) {
|
||||||
import ptr::{addr_of, null};
|
use ptr::{addr_of, null};
|
||||||
import vec::unsafe::to_ptr;
|
use vec::unsafe::to_ptr;
|
||||||
import libc::types::common::c99::{uint16_t, uint32_t};
|
use libc::types::common::c99::{uint16_t, uint32_t};
|
||||||
import geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
import text::font_library::FontLibrary;
|
use text::font_library::FontLibrary;
|
||||||
import text::font::Font;
|
use text::font::Font;
|
||||||
import azure::{AzNativeFont, AzFloat, AZ_NATIVE_FONT_CAIRO_FONT_FACE};
|
use azure::{AzNativeFont, AzFloat, AZ_NATIVE_FONT_CAIRO_FONT_FACE};
|
||||||
import azure::bindgen::{AzCreateScaledFontWithCairo,
|
use azure::bindgen::{AzCreateScaledFontWithCairo,
|
||||||
AzReleaseScaledFont,
|
AzReleaseScaledFont,
|
||||||
AzCreateColorPattern,
|
AzCreateColorPattern,
|
||||||
AzReleaseColorPattern};
|
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;
|
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")]
|
#[cfg(target_os = "linux")]
|
||||||
fn get_cairo_face(font: &Font) -> *cairo_font_face_t {
|
fn get_cairo_face(font: &Font) -> *cairo_font_face_t {
|
||||||
|
|
||||||
import libc::c_int;
|
use libc::c_int;
|
||||||
import azure::cairo_ft::bindgen::{cairo_ft_font_face_create_for_ft_face};
|
use azure::cairo_ft::bindgen::{cairo_ft_font_face_create_for_ft_face};
|
||||||
|
|
||||||
let ftface = font.native_font.face;
|
let ftface = font.native_font.face;
|
||||||
let cface = cairo_ft_font_face_create_for_ft_face(ftface, 0 as c_int);
|
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")]
|
#[cfg(target_os = "macos")]
|
||||||
fn get_cairo_face(font: &Font) -> *cairo_font_face_t {
|
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 cgfont = font.native_font.cgfont;
|
||||||
let face = cairo_quartz_font_face_create_for_cgfont(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 {
|
fn get_cairo_font(font: &Font) -> *cairo_scaled_font_t {
|
||||||
|
|
||||||
import libc::c_double;
|
use libc::c_double;
|
||||||
import azure::cairo;
|
use azure::cairo;
|
||||||
import cairo::cairo_matrix_t;
|
use cairo::cairo_matrix_t;
|
||||||
import cairo::bindgen::{cairo_matrix_init_identity,
|
use cairo::bindgen::{cairo_matrix_init_identity,
|
||||||
cairo_matrix_scale,
|
cairo_matrix_scale,
|
||||||
cairo_font_options_create,
|
cairo_font_options_create,
|
||||||
cairo_scaled_font_create,
|
cairo_scaled_font_create,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
|
|
||||||
enum format {
|
enum format {
|
||||||
fo_rgba_8888
|
fo_rgba_8888
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import comm::{Port, Chan};
|
use comm::{Port, Chan};
|
||||||
import option::is_none;
|
use option::is_none;
|
||||||
import str::from_bytes;
|
use str::from_bytes;
|
||||||
import vec::push;
|
use vec::push;
|
||||||
import lexer_util::*;
|
use lexer_util::*;
|
||||||
import resource::resource_task;
|
use resource::resource_task;
|
||||||
import resource_task::{ResourceTask, ProgressMsg, Load};
|
use resource_task::{ResourceTask, ProgressMsg, Load};
|
||||||
import std::net::url::Url;
|
use std::net::url::Url;
|
||||||
|
|
||||||
enum Token {
|
enum Token {
|
||||||
StartOpeningTag(~str),
|
StartOpeningTag(~str),
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#[doc = "A collection of functions that are useful for both css and html parsing."]
|
#[doc = "A collection of functions that are useful for both css and html parsing."]
|
||||||
|
|
||||||
import option::is_none;
|
use option::is_none;
|
||||||
import str::from_bytes;
|
use str::from_bytes;
|
||||||
import vec::push;
|
use vec::push;
|
||||||
import comm::Port;
|
use comm::Port;
|
||||||
import resource::resource_task::{ProgressMsg, Payload, Done};
|
use resource::resource_task::{ProgressMsg, Payload, Done};
|
||||||
|
|
||||||
enum CharOrEof {
|
enum CharOrEof {
|
||||||
CoeChar(u8),
|
CoeChar(u8),
|
||||||
|
|
|
@ -4,7 +4,7 @@ export load;
|
||||||
export load_from_memory;
|
export load_from_memory;
|
||||||
export test_image_bin;
|
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
|
// FIXME: Images must not be copied every frame. Instead we should atomically
|
||||||
// reference count them.
|
// reference count them.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import gfx::surface;
|
use gfx::surface;
|
||||||
import io::WriterUtil;
|
use io::WriterUtil;
|
||||||
|
|
||||||
fn encode(writer: io::Writer, surface: surface::image_surface) {
|
fn encode(writer: io::Writer, surface: surface::image_surface) {
|
||||||
assert surface.format == gfx::surface::fo_rgba_8888;
|
assert surface.format == gfx::surface::fo_rgba_8888;
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
#[doc="Fundamental layout structures and algorithms."]
|
#[doc="Fundamental layout structures and algorithms."]
|
||||||
|
|
||||||
import css::styles::SpecifiedStyle;
|
use css::styles::SpecifiedStyle;
|
||||||
import css::values::{BoxSizing, Length, Px};
|
use css::values::{BoxSizing, Length, Px};
|
||||||
import dom::base::{Element, ElementKind, HTMLDivElement, HTMLImageElement, Node, NodeData};
|
use dom::base::{Element, ElementKind, HTMLDivElement, HTMLImageElement, Node, NodeData};
|
||||||
import dom::base::{NodeKind};
|
use dom::base::{NodeKind};
|
||||||
import dom::rcu;
|
use dom::rcu;
|
||||||
import gfx::geometry;
|
use gfx::geometry;
|
||||||
import gfx::geometry::{au, zero_size_au};
|
use gfx::geometry::{au, zero_size_au};
|
||||||
import geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
import geom::rect::Rect;
|
use geom::rect::Rect;
|
||||||
import geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
import image::base::Image;
|
use image::base::Image;
|
||||||
import util::tree;
|
use util::tree;
|
||||||
import util::color::Color;
|
use util::color::Color;
|
||||||
import text::TextBox;
|
use text::TextBox;
|
||||||
import traverse::extended_full_traversal;
|
use traverse::extended_full_traversal;
|
||||||
import vec::{push, push_all};
|
use vec::{push, push_all};
|
||||||
import std::net::url::Url;
|
use std::net::url::Url;
|
||||||
import resource::image_cache_task;
|
use resource::image_cache_task;
|
||||||
import image_cache_task::ImageCacheTask;
|
use image_cache_task::ImageCacheTask;
|
||||||
import core::to_str::ToStr;
|
use core::to_str::ToStr;
|
||||||
import std::arc::{ARC, clone};
|
use std::arc::{ARC, clone};
|
||||||
import task::spawn;
|
use task::spawn;
|
||||||
|
|
||||||
enum BoxKind {
|
enum BoxKind {
|
||||||
BlockBox,
|
BlockBox,
|
||||||
|
@ -50,7 +50,9 @@ struct Appearance {
|
||||||
mut width: BoxSizing,
|
mut width: BoxSizing,
|
||||||
mut height: BoxSizing,
|
mut height: BoxSizing,
|
||||||
mut font_size: Length,
|
mut font_size: Length,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Appearance {
|
||||||
// This will be very unhappy if it is getting run in parallel with
|
// This will be very unhappy if it is getting run in parallel with
|
||||||
// anything trying to read the background image
|
// anything trying to read the background image
|
||||||
fn get_image() -> Option<ARC<~Image>> {
|
fn get_image() -> Option<ARC<~Image>> {
|
||||||
|
@ -336,13 +338,13 @@ impl Node : NodeMethods {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
import dom::base::{Element, ElementData, HTMLDivElement, HTMLImageElement, Node, NodeKind};
|
use dom::base::{Element, ElementData, HTMLDivElement, HTMLImageElement, Node, NodeKind};
|
||||||
import dom::base::{NodeScope};
|
use dom::base::{NodeScope};
|
||||||
import dom::rcu::Scope;
|
use dom::rcu::Scope;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
use sdl;
|
use sdl;
|
||||||
import sdl::video;
|
use sdl::video;
|
||||||
|
|
||||||
fn with_screen(f: fn(*sdl::surface)) {
|
fn with_screen(f: fn(*sdl::surface)) {
|
||||||
let screen = video::set_video_mode(
|
let screen = video::set_video_mode(
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#[doc="Block layout."]
|
#[doc="Block layout."]
|
||||||
|
|
||||||
import css::values::*;
|
use css::values::*;
|
||||||
import geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
import geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
import gfx::geometry::{px_to_au, au};
|
use gfx::geometry::{px_to_au, au};
|
||||||
import util::tree;
|
use util::tree;
|
||||||
import base::{Box, BlockBox, BTree};
|
use base::{Box, BlockBox, BTree};
|
||||||
|
|
||||||
trait BlockLayoutMethods {
|
trait BlockLayoutMethods {
|
||||||
fn reflow_block();
|
fn reflow_block();
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import gfx::geometry::*;
|
use gfx::geometry::*;
|
||||||
import geom::rect::Rect;
|
use geom::rect::Rect;
|
||||||
import image::base::Image;
|
use image::base::Image;
|
||||||
import servo_text::text_run::TextRun;
|
use servo_text::text_run::TextRun;
|
||||||
|
|
||||||
import std::arc::ARC;
|
use std::arc::ARC;
|
||||||
import dvec::DVec;
|
use dvec::DVec;
|
||||||
|
|
||||||
// TODO: convert to DisplayItem trait with methods like bounds(), paint(), etc.
|
// TODO: convert to DisplayItem trait with methods like bounds(), paint(), etc.
|
||||||
enum ItemKind {
|
enum ItemKind {
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
export build_display_list;
|
export build_display_list;
|
||||||
|
|
||||||
import css::values::{BgColor, BgTransparent, Specified};
|
use css::values::{BgColor, BgTransparent, Specified};
|
||||||
import base::{Box, BTree, ImageHolder, TextBoxKind};
|
use base::{Box, BTree, ImageHolder, TextBoxKind};
|
||||||
import dl = layout::display_list;
|
use dl = layout::display_list;
|
||||||
import dom::base::{Text, NodeScope};
|
use dom::base::{Text, NodeScope};
|
||||||
import dom::rcu::Scope;
|
use dom::rcu::Scope;
|
||||||
import either::{Left, Right};
|
use either::{Left, Right};
|
||||||
import geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
import geom::rect::Rect;
|
use geom::rect::Rect;
|
||||||
import geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
import gfx::geometry::{au, au_to_px, box, px_to_au};
|
use gfx::geometry::{au, au_to_px, box, px_to_au};
|
||||||
import util::tree;
|
use util::tree;
|
||||||
|
|
||||||
import dvec::DVec;
|
use dvec::DVec;
|
||||||
import vec::push;
|
use vec::push;
|
||||||
|
|
||||||
#[doc = "
|
#[doc = "
|
||||||
|
|
||||||
|
|
|
@ -3,22 +3,22 @@
|
||||||
rendered.
|
rendered.
|
||||||
"];
|
"];
|
||||||
|
|
||||||
import std::arc::ARC;
|
use std::arc::ARC;
|
||||||
import display_list_builder::build_display_list;
|
use display_list_builder::build_display_list;
|
||||||
import dom::base::Node;
|
use dom::base::Node;
|
||||||
import css::values::Stylesheet;
|
use css::values::Stylesheet;
|
||||||
import gfx::geometry::px_to_au;
|
use gfx::geometry::px_to_au;
|
||||||
import gfx::render_task;
|
use gfx::render_task;
|
||||||
import render_task::RenderTask;
|
use render_task::RenderTask;
|
||||||
import layout::base::Box;
|
use layout::base::Box;
|
||||||
import resource::image_cache_task::ImageCacheTask;
|
use resource::image_cache_task::ImageCacheTask;
|
||||||
import std::net::url::Url;
|
use std::net::url::Url;
|
||||||
import css::resolve::apply::apply_style;
|
use css::resolve::apply::apply_style;
|
||||||
import dom::event::{Event, ReflowEvent};
|
use dom::event::{Event, ReflowEvent};
|
||||||
import content::content_task;
|
use content::content_task;
|
||||||
|
|
||||||
import task::*;
|
use task::*;
|
||||||
import comm::*;
|
use comm::*;
|
||||||
|
|
||||||
type LayoutTask = Chan<Msg>;
|
type LayoutTask = Chan<Msg>;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#[doc = "Interface for running tree-based traversals over layout boxes"]
|
#[doc = "Interface for running tree-based traversals over layout boxes"]
|
||||||
|
|
||||||
import base::{Box, BTree, NodeMethods};
|
use base::{Box, BTree, NodeMethods};
|
||||||
import intrinsic::TyDesc;
|
use intrinsic::TyDesc;
|
||||||
|
|
||||||
export full_traversal;
|
export full_traversal;
|
||||||
export top_down_traversal;
|
export top_down_traversal;
|
||||||
|
|
|
@ -17,7 +17,7 @@ enum RenderMode {
|
||||||
|
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
fn from_cmdline_args(args: ~[~str]) -> Opts {
|
fn from_cmdline_args(args: ~[~str]) -> Opts {
|
||||||
import std::getopts;
|
use std::getopts;
|
||||||
|
|
||||||
let args = args.tail();
|
let args = args.tail();
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
export OSMain;
|
export OSMain;
|
||||||
export Msg, BeginDrawing, Draw, AddKeyHandler, Exit;
|
export Msg, BeginDrawing, Draw, AddKeyHandler, Exit;
|
||||||
|
|
||||||
import azure::*;
|
use azure::*;
|
||||||
import azure::azure_hl::DrawTarget;
|
use azure::azure_hl::DrawTarget;
|
||||||
import azure::bindgen::*;
|
use azure::bindgen::*;
|
||||||
import azure::cairo;
|
use azure::cairo;
|
||||||
import azure::cairo::bindgen::*;
|
use azure::cairo::bindgen::*;
|
||||||
import azure::cairo_hl::ImageSurface;
|
use azure::cairo_hl::ImageSurface;
|
||||||
import comm::*;
|
use comm::*;
|
||||||
import dvec::DVec;
|
use dvec::DVec;
|
||||||
import azure::cairo::cairo_surface_t;
|
use azure::cairo::cairo_surface_t;
|
||||||
import gfx::compositor::Compositor;
|
use gfx::compositor::Compositor;
|
||||||
import dom::event::{Event, ResizeEvent};
|
use dom::event::{Event, ResizeEvent};
|
||||||
import layers::ImageLayer;
|
use layers::ImageLayer;
|
||||||
import geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
import std::cmp::FuzzyEq;
|
use std::cmp::FuzzyEq;
|
||||||
import task::TaskBuilder;
|
use task::TaskBuilder;
|
||||||
import vec::push;
|
use vec::push;
|
||||||
|
|
||||||
import pipes::chan;
|
use pipes::chan;
|
||||||
|
|
||||||
type OSMain = comm::Chan<Msg>;
|
type OSMain = comm::Chan<Msg>;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
export factory;
|
export factory;
|
||||||
|
|
||||||
import comm::Chan;
|
use comm::Chan;
|
||||||
import task::spawn;
|
use task::spawn;
|
||||||
import resource_task::{ProgressMsg, Payload, Done};
|
use resource_task::{ProgressMsg, Payload, Done};
|
||||||
import std::net::url::Url;
|
use std::net::url::Url;
|
||||||
import io::{file_reader, ReaderUtil};
|
use io::{file_reader, ReaderUtil};
|
||||||
|
|
||||||
const READ_SIZE: uint = 1024;
|
const READ_SIZE: uint = 1024;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
export factory;
|
export factory;
|
||||||
|
|
||||||
import comm::Chan;
|
use comm::Chan;
|
||||||
import task::spawn;
|
use task::spawn;
|
||||||
import resource_task::{ProgressMsg, Payload, Done};
|
use resource_task::{ProgressMsg, Payload, Done};
|
||||||
import std::net::url::Url;
|
use std::net::url::Url;
|
||||||
import http_client::{uv_http_request};
|
use http_client::{uv_http_request};
|
||||||
|
|
||||||
fn factory(+url: Url, progress_chan: Chan<ProgressMsg>) {
|
fn factory(+url: Url, progress_chan: Chan<ProgressMsg>) {
|
||||||
assert url.scheme == ~"http";
|
assert url.scheme == ~"http";
|
||||||
|
|
|
@ -4,17 +4,17 @@ export ImageCacheTask;
|
||||||
export ImageCacheTaskClient;
|
export ImageCacheTaskClient;
|
||||||
export SyncImageCacheTask;
|
export SyncImageCacheTask;
|
||||||
|
|
||||||
import image::base::{Image, load_from_memory, test_image_bin};
|
use image::base::{Image, load_from_memory, test_image_bin};
|
||||||
import std::net::url::Url;
|
use std::net::url::Url;
|
||||||
import util::url::{make_url, UrlMap, url_map};
|
use util::url::{make_url, UrlMap, url_map};
|
||||||
import comm::{Chan, Port};
|
use comm::{Chan, Port};
|
||||||
import task::{spawn, spawn_listener};
|
use task::{spawn, spawn_listener};
|
||||||
import resource::resource_task;
|
use resource::resource_task;
|
||||||
import resource_task::ResourceTask;
|
use resource_task::ResourceTask;
|
||||||
import std::arc::ARC;
|
use std::arc::ARC;
|
||||||
import clone_arc = std::arc::clone;
|
use clone_arc = std::arc::clone;
|
||||||
import std::cell::Cell;
|
use std::cell::Cell;
|
||||||
import to_str::ToStr;
|
use to_str::ToStr;
|
||||||
|
|
||||||
enum Msg {
|
enum Msg {
|
||||||
/// Tell the cache that we may need a particular image soon. Must be posted
|
/// Tell the cache that we may need a particular image soon. Must be posted
|
||||||
|
|
|
@ -8,10 +8,10 @@ export ControlMsg, Load, Exit;
|
||||||
export ProgressMsg, Payload, Done;
|
export ProgressMsg, Payload, Done;
|
||||||
export ResourceTask, ResourceManager, LoaderTaskFactory;
|
export ResourceTask, ResourceManager, LoaderTaskFactory;
|
||||||
|
|
||||||
import comm::{Chan, Port};
|
use comm::{Chan, Port};
|
||||||
import task::{spawn, spawn_listener};
|
use task::{spawn, spawn_listener};
|
||||||
import std::net::url;
|
use std::net::url;
|
||||||
import std::net::url::{Url, to_str};
|
use std::net::url::{Url, to_str};
|
||||||
|
|
||||||
enum ControlMsg {
|
enum ControlMsg {
|
||||||
/// Request the data associated with a particular URL
|
/// Request the data associated with a particular URL
|
||||||
|
|
|
@ -127,4 +127,4 @@ mod util {
|
||||||
|
|
||||||
mod opts;
|
mod opts;
|
||||||
|
|
||||||
import servo_text = text;
|
use servo_text = text;
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import comm::*;
|
use comm::*;
|
||||||
import option::swap_unwrap;
|
use option::swap_unwrap;
|
||||||
import platform::osmain;
|
use platform::osmain;
|
||||||
import osmain::{OSMain, AddKeyHandler};
|
use osmain::{OSMain, AddKeyHandler};
|
||||||
import opts::{Opts, Screen, Png};
|
use opts::{Opts, Screen, Png};
|
||||||
import engine::{EngineTask, EngineProto};
|
use engine::{EngineTask, EngineProto};
|
||||||
|
|
||||||
import url_to_str = std::net::url::to_str;
|
use url_to_str = std::net::url::to_str;
|
||||||
import util::url::make_url;
|
use util::url::make_url;
|
||||||
|
|
||||||
import pipes::{Port, Chan};
|
use pipes::{Port, Chan};
|
||||||
|
|
||||||
fn main(args: ~[~str]) {
|
fn main(args: ~[~str]) {
|
||||||
run(opts::from_cmdline_args(args))
|
run(opts::from_cmdline_args(args))
|
||||||
|
@ -65,12 +65,12 @@ fn run_pipeline_screen(urls: ~[~str]) {
|
||||||
fn run_pipeline_png(-url: ~str, outfile: ~str) {
|
fn run_pipeline_png(-url: ~str, outfile: ~str) {
|
||||||
|
|
||||||
// Use a PNG encoder as the graphics compositor
|
// Use a PNG encoder as the graphics compositor
|
||||||
import gfx::png_compositor;
|
use gfx::png_compositor;
|
||||||
import png_compositor::PngCompositor;
|
use png_compositor::PngCompositor;
|
||||||
import io::{Writer, buffered_file_writer};
|
use io::{Writer, buffered_file_writer};
|
||||||
import resource::resource_task::ResourceTask;
|
use resource::resource_task::ResourceTask;
|
||||||
import resource::image_cache_task::SyncImageCacheTask;
|
use resource::image_cache_task::SyncImageCacheTask;
|
||||||
import engine::EngineTask_;
|
use engine::EngineTask_;
|
||||||
|
|
||||||
listen(|pngdata_from_compositor| {
|
listen(|pngdata_from_compositor| {
|
||||||
let compositor = PngCompositor(pngdata_from_compositor);
|
let compositor = PngCompositor(pngdata_from_compositor);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
export Font, test_font_bin, create_test_font;
|
export Font, test_font_bin, create_test_font;
|
||||||
|
|
||||||
import glyph::GlyphIndex;
|
use glyph::GlyphIndex;
|
||||||
import vec_to_ptr = vec::unsafe::to_ptr;
|
use vec_to_ptr = vec::unsafe::to_ptr;
|
||||||
import libc::{ c_int, c_double, c_ulong };
|
use libc::{ c_int, c_double, c_ulong };
|
||||||
import ptr::{ null, addr_of };
|
use ptr::{ null, addr_of };
|
||||||
import native_font::NativeFont;
|
use native_font::NativeFont;
|
||||||
import font_library::FontLibrary;
|
use font_library::FontLibrary;
|
||||||
|
|
||||||
#[doc = "
|
#[doc = "
|
||||||
A font handle. Layout can use this to calculate glyph metrics
|
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 {
|
struct Font {
|
||||||
fontbuf: @~[u8],
|
fontbuf: @~[u8],
|
||||||
native_font: NativeFont,
|
native_font: NativeFont,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Font {
|
||||||
fn buf() -> @~[u8] {
|
fn buf() -> @~[u8] {
|
||||||
self.fontbuf
|
self.fontbuf
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export FontLibrary, native;
|
export FontLibrary, native;
|
||||||
|
|
||||||
import font::{Font, test_font_bin};
|
use font::{Font, test_font_bin};
|
||||||
|
|
||||||
struct FontLibrary {
|
struct FontLibrary {
|
||||||
native_lib: native::NativeFontLibrary,
|
native_lib: native::NativeFontLibrary,
|
||||||
|
@ -8,7 +8,9 @@ struct FontLibrary {
|
||||||
drop {
|
drop {
|
||||||
native::destroy_native_lib(&self.native_lib);
|
native::destroy_native_lib(&self.native_lib);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FontLibrary {
|
||||||
fn get_font() -> @Font {
|
fn get_font() -> @Font {
|
||||||
match create_font(&self.native_lib) {
|
match create_font(&self.native_lib) {
|
||||||
Ok(font) => font,
|
Ok(font) => font,
|
||||||
|
@ -40,10 +42,10 @@ fn create_font(native_lib: &native::NativeFontLibrary) -> Result<@Font, ()> {
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
mod native {
|
mod native {
|
||||||
import ptr::{null, addr_of};
|
use ptr::{null, addr_of};
|
||||||
import azure::freetype;
|
use azure::freetype;
|
||||||
import freetype::{FT_Library, FT_Error};
|
use freetype::{FT_Library, FT_Error};
|
||||||
import freetype::bindgen::{FT_Init_FreeType, FT_Done_FreeType};
|
use freetype::bindgen::{FT_Init_FreeType, FT_Done_FreeType};
|
||||||
|
|
||||||
type NativeFontLibrary = FT_Library;
|
type NativeFontLibrary = FT_Library;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export GlyphIndex, GlyphPos, Glyph;
|
export GlyphIndex, GlyphPos, Glyph;
|
||||||
|
|
||||||
import gfx::geometry::au;
|
use gfx::geometry::au;
|
||||||
import geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
|
|
||||||
#[doc = "The index of a particular glyph within a font"]
|
#[doc = "The index of a particular glyph within a font"]
|
||||||
type GlyphIndex = uint;
|
type GlyphIndex = uint;
|
||||||
|
|
|
@ -9,7 +9,7 @@ font resources needed by the graphics layer to draw glyphs.
|
||||||
|
|
||||||
export NativeFont, create;
|
export NativeFont, create;
|
||||||
|
|
||||||
import font_library::native::NativeFontLibrary;
|
use font_library::native::NativeFontLibrary;
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
type NativeFont/& = quartz_native_font::QuartzNativeFont;
|
type NativeFont/& = quartz_native_font::QuartzNativeFont;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
export FreeTypeNativeFont, with_test_native_font, create;
|
export FreeTypeNativeFont, with_test_native_font, create;
|
||||||
|
|
||||||
import vec_as_buf = vec::as_buf;
|
use vec_as_buf = vec::as_buf;
|
||||||
import ptr::{addr_of, null};
|
use ptr::{addr_of, null};
|
||||||
import unsafe::reinterpret_cast;
|
use unsafe::reinterpret_cast;
|
||||||
import glyph::GlyphIndex;
|
use glyph::GlyphIndex;
|
||||||
import azure::freetype;
|
use azure::freetype;
|
||||||
import freetype::{ FT_Error, FT_Library, FT_Face, FT_Long, FT_ULong, FT_UInt, FT_GlyphSlot };
|
use freetype::{ FT_Error, FT_Library, FT_Face, FT_Long, FT_ULong, FT_UInt, FT_GlyphSlot };
|
||||||
import freetype::bindgen::{
|
use freetype::bindgen::{
|
||||||
FT_Init_FreeType,
|
FT_Init_FreeType,
|
||||||
FT_Done_FreeType,
|
FT_Done_FreeType,
|
||||||
FT_New_Memory_Face,
|
FT_New_Memory_Face,
|
||||||
|
@ -92,8 +92,8 @@ impl FT_Error : FTErrorMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_test_native_font(f: fn@(nf: &NativeFont)) {
|
fn with_test_native_font(f: fn@(nf: &NativeFont)) {
|
||||||
import font::test_font_bin;
|
use font::test_font_bin;
|
||||||
import unwrap_result = result::unwrap;
|
use unwrap_result = result::unwrap;
|
||||||
|
|
||||||
with_lib(|lib| {
|
with_lib(|lib| {
|
||||||
let buf = test_font_bin();
|
let buf = test_font_bin();
|
||||||
|
|
|
@ -2,14 +2,14 @@ use cocoa;
|
||||||
|
|
||||||
export QuartzNativeFont, with_test_native_font, create;
|
export QuartzNativeFont, with_test_native_font, create;
|
||||||
|
|
||||||
import libc::size_t;
|
use libc::size_t;
|
||||||
import ptr::null;
|
use ptr::null;
|
||||||
import glyph::GlyphIndex;
|
use glyph::GlyphIndex;
|
||||||
import cocoa::cg::{
|
use cocoa::cg::{
|
||||||
CGDataProviderRef,
|
CGDataProviderRef,
|
||||||
CGFontRef
|
CGFontRef
|
||||||
};
|
};
|
||||||
import cocoa::cg::cg::{
|
use cocoa::cg::cg::{
|
||||||
CGDataProviderCreateWithData,
|
CGDataProviderCreateWithData,
|
||||||
CGDataProviderRelease,
|
CGDataProviderRelease,
|
||||||
CGFontCreateWithDataProvider,
|
CGFontCreateWithDataProvider,
|
||||||
|
@ -75,8 +75,8 @@ fn QuartzNativeFont(fontprov: CGDataProviderRef, cgfont: CGFontRef) -> QuartzNat
|
||||||
impl QuartzNativeFont {
|
impl QuartzNativeFont {
|
||||||
fn glyph_index(codepoint: char) -> Option<GlyphIndex> {
|
fn glyph_index(codepoint: char) -> Option<GlyphIndex> {
|
||||||
|
|
||||||
import coretext::{UniChar, CGGlyph, CFIndex};
|
use coretext::{UniChar, CGGlyph, CFIndex};
|
||||||
import coretext::coretext::{CFRelease, CTFontGetGlyphsForCharacters};
|
use coretext::coretext::{CFRelease, CTFontGetGlyphsForCharacters};
|
||||||
|
|
||||||
let ctfont = ctfont_from_cgfont(self.cgfont);
|
let ctfont = ctfont_from_cgfont(self.cgfont);
|
||||||
assert ctfont.is_not_null();
|
assert ctfont.is_not_null();
|
||||||
|
@ -103,8 +103,8 @@ impl QuartzNativeFont {
|
||||||
|
|
||||||
// FIXME: What unit is this returning? Let's have a custom type
|
// FIXME: What unit is this returning? Let's have a custom type
|
||||||
fn glyph_h_advance(glyph: GlyphIndex) -> Option<int> {
|
fn glyph_h_advance(glyph: GlyphIndex) -> Option<int> {
|
||||||
import coretext::{CGGlyph, kCTFontDefaultOrientation};
|
use coretext::{CGGlyph, kCTFontDefaultOrientation};
|
||||||
import coretext::coretext::{CFRelease, CTFontGetAdvancesForGlyphs};
|
use coretext::coretext::{CFRelease, CTFontGetAdvancesForGlyphs};
|
||||||
|
|
||||||
let ctfont = ctfont_from_cgfont(self.cgfont);
|
let ctfont = ctfont_from_cgfont(self.cgfont);
|
||||||
assert ctfont.is_not_null();
|
assert ctfont.is_not_null();
|
||||||
|
@ -120,8 +120,8 @@ impl QuartzNativeFont {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ctfont_from_cgfont(cgfont: CGFontRef) -> coretext::CTFontRef {
|
fn ctfont_from_cgfont(cgfont: CGFontRef) -> coretext::CTFontRef {
|
||||||
import coretext::CGFloat;
|
use coretext::CGFloat;
|
||||||
import coretext::coretext::CTFontCreateWithGraphicsFont;
|
use coretext::coretext::CTFontCreateWithGraphicsFont;
|
||||||
|
|
||||||
assert cgfont.is_not_null();
|
assert cgfont.is_not_null();
|
||||||
CTFontCreateWithGraphicsFont(cgfont, 21f as CGFloat, null(), 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)) {
|
fn with_test_native_font(f: fn@(nf: &NativeFont)) {
|
||||||
import font::test_font_bin;
|
use font::test_font_bin;
|
||||||
import unwrap_result = result::unwrap;
|
use unwrap_result = result::unwrap;
|
||||||
|
|
||||||
let buf = test_font_bin();
|
let buf = test_font_bin();
|
||||||
let res = create(&buf);
|
let res = create(&buf);
|
||||||
|
|
|
@ -2,22 +2,22 @@ use harfbuzz;
|
||||||
|
|
||||||
export shape_text;
|
export shape_text;
|
||||||
|
|
||||||
import libc::types::common::c99::int32_t;
|
use libc::types::common::c99::int32_t;
|
||||||
import libc::{c_uint, c_int, c_void};
|
use libc::{c_uint, c_int, c_void};
|
||||||
import font::Font;
|
use font::Font;
|
||||||
import glyph::{Glyph, GlyphPos};
|
use glyph::{Glyph, GlyphPos};
|
||||||
import ptr::{null, addr_of, offset};
|
use ptr::{null, addr_of, offset};
|
||||||
import gfx::geometry::{au, px_to_au};
|
use gfx::geometry::{au, px_to_au};
|
||||||
import geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
import font_library::FontLibrary;
|
use font_library::FontLibrary;
|
||||||
|
|
||||||
import unsafe::reinterpret_cast;
|
use unsafe::reinterpret_cast;
|
||||||
import harfbuzz::{HB_MEMORY_MODE_READONLY,
|
use harfbuzz::{HB_MEMORY_MODE_READONLY,
|
||||||
HB_DIRECTION_LTR};
|
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_codepoint_t, hb_bool_t, hb_glyph_position_t,
|
||||||
hb_var_int_t, hb_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_face_create, hb_face_destroy,
|
||||||
hb_font_create, hb_font_destroy,
|
hb_font_create, hb_font_destroy,
|
||||||
hb_buffer_create, hb_buffer_destroy,
|
hb_buffer_create, hb_buffer_destroy,
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
import geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
import geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
import gfx::geometry::{au, px_to_au};
|
use gfx::geometry::{au, px_to_au};
|
||||||
import libc::{c_void};
|
use libc::{c_void};
|
||||||
import font_library::FontLibrary;
|
use font_library::FontLibrary;
|
||||||
import font::Font;
|
use font::Font;
|
||||||
import glyph::Glyph;
|
use glyph::Glyph;
|
||||||
import shaper::shape_text;
|
use shaper::shape_text;
|
||||||
|
|
||||||
#[doc="A single, unbroken line of text."]
|
#[doc="A single, unbroken line of text."]
|
||||||
struct TextRun {
|
struct TextRun {
|
||||||
glyphs: ~[Glyph],
|
glyphs: ~[Glyph],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TextRun {
|
||||||
fn size() -> Size2D<au> {
|
fn size() -> Size2D<au> {
|
||||||
let height = px_to_au(20);
|
let height = px_to_au(20);
|
||||||
let pen_start_x = px_to_au(0);
|
let pen_start_x = px_to_au(0);
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
// sanitize input / crop it to correct ranges, predefine other 130
|
// sanitize input / crop it to correct ranges, predefine other 130
|
||||||
// css-defined colors
|
// css-defined colors
|
||||||
|
|
||||||
import float::round;
|
use float::round;
|
||||||
import libc::types::os::arch::c95::c_double;
|
use libc::types::os::arch::c95::c_double;
|
||||||
import css_colors::*;
|
use css_colors::*;
|
||||||
import cmp::Eq;
|
use cmp::Eq;
|
||||||
|
|
||||||
enum Color = {red : u8, green : u8, blue : u8, alpha : float};
|
enum Color = {red : u8, green : u8, blue : u8, alpha : float};
|
||||||
|
|
||||||
|
@ -179,9 +179,9 @@ mod parsing {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
import css_colors::*;
|
use css_colors::*;
|
||||||
import option::unwrap;
|
use option::unwrap;
|
||||||
import parsing::parse_color;
|
use parsing::parse_color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_by_name() {
|
fn test_parse_by_name() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Timing functions.
|
// Timing functions.
|
||||||
import std::time::precise_time_ns;
|
use std::time::precise_time_ns;
|
||||||
|
|
||||||
fn time(msg: ~str, callback: fn()) {
|
fn time(msg: ~str, callback: fn()) {
|
||||||
let start_time = precise_time_ns();
|
let start_time = precise_time_ns();
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
export make_url, UrlMap, url_map;
|
export make_url, UrlMap, url_map;
|
||||||
|
|
||||||
import std::net::url;
|
use std::net::url;
|
||||||
import std::net::url::Url;
|
use std::net::url::Url;
|
||||||
import std::map::hashmap;
|
use std::map::hashmap;
|
||||||
import path::Path;
|
use path::Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a URL object from a string. Does various helpful browsery things like
|
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>;
|
type UrlMap<T: Copy> = hashmap<Url, T>;
|
||||||
|
|
||||||
fn url_map<T: Copy>() -> UrlMap<T> {
|
fn url_map<T: Copy>() -> UrlMap<T> {
|
||||||
import core::to_str::ToStr;
|
use core::to_str::ToStr;
|
||||||
|
|
||||||
hashmap::<Url, T>()
|
hashmap::<Url, T>()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue