aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Moffitt <jack@metajack.im>2013-10-14 23:11:35 -0600
committerJack Moffitt <jack@metajack.im>2013-10-21 17:38:34 -0600
commit94202661c03500fffcc7ec3e566e2a2a168c7dfc (patch)
tree111764fc98e2cfe3995e2c9d20332c29b989f761 /src
parent8b47221ff8c77281eb55c5c671f23ae455cfe6bd (diff)
downloadservo-94202661c03500fffcc7ec3e566e2a2a168c7dfc.tar.gz
servo-94202661c03500fffcc7ec3e566e2a2a168c7dfc.zip
Update to latest Rust.
Diffstat (limited to 'src')
m---------src/compiler/rust0
-rw-r--r--src/compiler/rust-auto-clean-trigger2
-rw-r--r--src/components/gfx/color.rs2
-rw-r--r--src/components/gfx/font.rs10
-rw-r--r--src/components/gfx/font_context.rs14
-rw-r--r--src/components/gfx/font_list.rs2
-rw-r--r--src/components/gfx/gfx.rc2
-rw-r--r--src/components/gfx/opts.rs24
-rw-r--r--src/components/gfx/platform/linux/font.rs34
-rw-r--r--src/components/gfx/platform/linux/font_context.rs6
-rw-r--r--src/components/gfx/platform/linux/font_list.rs2
-rw-r--r--src/components/gfx/platform/macos/font.rs26
-rw-r--r--src/components/gfx/platform/macos/font_context.rs2
-rw-r--r--src/components/gfx/render_context.rs8
-rw-r--r--src/components/gfx/render_task.rs2
-rw-r--r--src/components/gfx/text/glyph.rs10
-rw-r--r--src/components/gfx/text/shaping/harfbuzz.rs8
-rw-r--r--src/components/gfx/text/text_run.rs6
-rw-r--r--src/components/gfx/text/util.rs6
-rw-r--r--src/components/main/compositing/mod.rs10
-rw-r--r--src/components/main/compositing/quadtree.rs4
-rw-r--r--src/components/main/constellation.rs10
-rw-r--r--src/components/main/css/node_util.rs4
-rw-r--r--src/components/main/css/select.rs22
-rw-r--r--src/components/main/css/select_handler.rs2
-rw-r--r--src/components/main/layout/block.rs21
-rw-r--r--src/components/main/layout/box.rs14
-rw-r--r--src/components/main/layout/box_builder.rs2
-rw-r--r--src/components/main/layout/display_list_builder.rs2
-rw-r--r--src/components/main/layout/float.rs18
-rw-r--r--src/components/main/layout/float_context.rs4
-rw-r--r--src/components/main/layout/flow.rs4
-rw-r--r--src/components/main/layout/incremental.rs11
-rw-r--r--src/components/main/layout/inline.rs34
-rw-r--r--src/components/main/layout/layout_task.rs14
-rw-r--r--src/components/main/layout/model.rs12
-rw-r--r--src/components/main/layout/text.rs2
-rw-r--r--src/components/main/layout/util.rs2
-rw-r--r--src/components/main/pipeline.rs2
-rw-r--r--src/components/main/platform/common/glfw_windowing.rs55
-rw-r--r--src/components/main/platform/common/glut_windowing.rs2
-rwxr-xr-xsrc/components/main/servo.rc7
-rw-r--r--src/components/msg/constellation_msg.rs2
-rw-r--r--src/components/net/file_loader.rs2
-rw-r--r--src/components/net/local_image_cache.rs6
-rw-r--r--src/components/net/net.rc2
-rw-r--r--src/components/script/dom/bindings/proxyhandler.rs2
-rw-r--r--src/components/script/dom/bindings/utils.rs8
-rw-r--r--src/components/script/dom/document.rs13
-rw-r--r--src/components/script/dom/element.rs18
-rw-r--r--src/components/script/dom/formdata.rs2
-rw-r--r--src/components/script/dom/htmliframeelement.rs2
-rw-r--r--src/components/script/dom/htmlimageelement.rs2
-rw-r--r--src/components/script/dom/node.rs4
-rw-r--r--src/components/script/dom/window.rs3
-rw-r--r--src/components/script/html/cssparse.rs48
-rw-r--r--src/components/script/html/hubbub_html_parser.rs4
-rw-r--r--src/components/script/script.rc2
-rw-r--r--src/components/script/script_task.rs12
-rw-r--r--src/components/style/common_types.rs4
-rw-r--r--src/components/style/media_queries.rs8
-rw-r--r--src/components/style/properties.rs.mako48
-rw-r--r--src/components/style/selectors.rs6
-rw-r--r--src/components/style/style.rc1
-rw-r--r--src/components/style/stylesheets.rs2
-rw-r--r--src/components/util/debug.rs2
-rw-r--r--src/components/util/geometry.rs62
-rw-r--r--src/components/util/range.rs4
-rw-r--r--src/components/util/time.rs18
-rw-r--r--src/components/util/url.rs16
-rw-r--r--src/components/util/util.rc2
-rw-r--r--src/components/util/vec.rs2
m---------src/platform/linux/rust-fontconfig0
m---------src/platform/linux/rust-freetype0
m---------src/platform/linux/rust-xlib0
m---------src/platform/macos/rust-cocoa0
m---------src/platform/macos/rust-core-foundation0
m---------src/platform/macos/rust-core-graphics0
m---------src/platform/macos/rust-core-text0
m---------src/platform/macos/rust-io-surface0
m---------src/support/alert/rust-alert0
m---------src/support/azure/rust-azure0
m---------src/support/css/rust-css0
m---------src/support/css/rust-cssparser0
m---------src/support/geom/rust-geom0
m---------src/support/glfw/glfw0
m---------src/support/glfw/glfw-rs0
m---------src/support/harfbuzz/rust-harfbuzz0
m---------src/support/http/rust-http0
m---------src/support/hubbub/rust-hubbub0
m---------src/support/layers/rust-layers0
m---------src/support/netsurfcss/rust-netsurfcss0
m---------src/support/opengles/rust-opengles0
m---------src/support/png/rust-png0
m---------src/support/sharegl/sharegl0
m---------src/support/spidermonkey/rust-mozjs0
m---------src/support/stb-image/rust-stb-image0
m---------src/support/wapcaplet/rust-wapcaplet0
-rw-r--r--src/test/harness/contenttest/contenttest.rs17
-rw-r--r--src/test/harness/reftest/reftest.rs16
100 files changed, 412 insertions, 352 deletions
diff --git a/src/compiler/rust b/src/compiler/rust
-Subproject d39cec65b025ad4c6de50e778ffd1177279b5b3
+Subproject 3f240fedecf84f9bb614c52f5cc133505700874
diff --git a/src/compiler/rust-auto-clean-trigger b/src/compiler/rust-auto-clean-trigger
index cd080b46feb..1a4b4b90bd6 100644
--- a/src/compiler/rust-auto-clean-trigger
+++ b/src/compiler/rust-auto-clean-trigger
@@ -1,4 +1,4 @@
# If this file is modified, then rust will be forcibly cleaned and then rebuilt.
# The actual contents of this file do not matter, but to trigger a change on the
# build bots then the contents should be changed so git updates the mtime.
-2013-10-14
+2013-10-18
diff --git a/src/components/gfx/color.rs b/src/components/gfx/color.rs
index 274b30a3212..ef0f7871f7e 100644
--- a/src/components/gfx/color.rs
+++ b/src/components/gfx/color.rs
@@ -11,7 +11,7 @@ pub fn rgb(r: u8, g: u8, b: u8) -> AzColor {
rgba(r, g, b, 1.0)
}
-pub fn rgba(r: u8, g: u8, b: u8, a: float) -> AzColor {
+pub fn rgba(r: u8, g: u8, b: u8, a: f64) -> AzColor {
AzColor {
r: (r as AzFloat) / (255.0 as AzFloat),
g: (g as AzFloat) / (255.0 as AzFloat),
diff --git a/src/components/gfx/font.rs b/src/components/gfx/font.rs
index a8ce3985aab..f5d71a843e8 100644
--- a/src/components/gfx/font.rs
+++ b/src/components/gfx/font.rs
@@ -55,7 +55,7 @@ pub trait FontHandleMethods {
}
// Used to abstract over the shaper's choice of fixed int representation.
-pub type FractionalPixel = float;
+pub type FractionalPixel = f64;
pub type FontTableTag = u32;
@@ -123,7 +123,7 @@ impl CSSFontWeight {
// For now, the cases are differentiated with a typedef
#[deriving(Clone, Eq)]
pub struct FontStyle {
- pt_size: float,
+ pt_size: f64,
weight: CSSFontWeight,
italic: bool,
oblique: bool,
@@ -391,7 +391,7 @@ impl Font {
assert!(azure_pattern.is_not_null());
let options = struct__AzDrawOptions {
- mAlpha: 1f as AzFloat,
+ mAlpha: 1f64 as AzFloat,
fields: 0x0200 as uint16_t
};
@@ -402,7 +402,7 @@ impl Font {
for (glyphs, _offset, slice_range) in run.iter_slices_for_range(range) {
for (_i, glyph) in glyphs.iter_glyphs_for_char_range(&slice_range) {
let glyph_advance = glyph.advance();
- let glyph_offset = glyph.offset().unwrap_or_default(Au::zero_point());
+ let glyph_offset = glyph.offset().unwrap_or(Au::zero_point());
let azglyph = struct__AzGlyph {
mIndex: glyph.index() as uint32_t,
@@ -481,7 +481,7 @@ impl Font {
do self.glyph_advance_cache.find_or_create(&glyph) |glyph| {
match self.handle.glyph_h_advance(*glyph) {
Some(adv) => adv,
- None => /* FIXME: Need fallback strategy */ 10f as FractionalPixel
+ None => /* FIXME: Need fallback strategy */ 10f64 as FractionalPixel
}
}
}
diff --git a/src/components/gfx/font_context.rs b/src/components/gfx/font_context.rs
index a9d71cf1aa7..c0f5f85970a 100644
--- a/src/components/gfx/font_context.rs
+++ b/src/components/gfx/font_context.rs
@@ -20,7 +20,7 @@ use std::hashmap::HashMap;
pub fn dummy_style() -> FontStyle {
use font::FontWeight300;
return FontStyle {
- pt_size: 20f,
+ pt_size: 20f64,
weight: FontWeight300,
italic: false,
oblique: false,
@@ -131,8 +131,9 @@ impl<'self> FontContext {
let transformed_family_name = self.transform_family(family_name);
debug!("(create font group) transformed family is `%s`", transformed_family_name);
- let result = do self.font_list.chain_ref |fl| {
- fl.find_font_in_family(transformed_family_name, style)
+ let result = match self.font_list {
+ Some(ref fl) => fl.find_font_in_family(transformed_family_name, style),
+ None => None,
};
let mut found = false;
@@ -156,8 +157,9 @@ impl<'self> FontContext {
let last_resort = FontList::get_last_resort_font_families();
for family in last_resort.iter() {
- let result = do self.font_list.chain_ref |fl| {
- fl.find_font_in_family(*family, style)
+ let result = match self.font_list {
+ Some(ref fl) => fl.find_font_in_family(*family, style),
+ None => None,
};
for font_entry in result.iter() {
@@ -188,7 +190,7 @@ impl<'self> FontContext {
&SelectorPlatformIdentifier(ref identifier) => {
let result_handle = self.handle.create_font_from_identifier((*identifier).clone(),
desc.style.clone());
- do result_handle.chain |handle| {
+ do result_handle.and_then |handle| {
Ok(Font::new_from_adopted_handle(self,
handle,
&desc.style,
diff --git a/src/components/gfx/font_list.rs b/src/components/gfx/font_list.rs
index f3d46bb7cce..ac3e23a6ae8 100644
--- a/src/components/gfx/font_list.rs
+++ b/src/components/gfx/font_list.rs
@@ -84,7 +84,7 @@ impl FontList {
debug!("FontList: %s font family with name=%s", decision, family_name);
// TODO(Issue #188): look up localized font family names if canonical name not found
- family.map(|f| **f)
+ family.map(|f| *f)
}
pub fn get_last_resort_font_families() -> ~[~str] {
diff --git a/src/components/gfx/gfx.rc b/src/components/gfx/gfx.rc
index a9664d5c2e0..3a35c44b34d 100644
--- a/src/components/gfx/gfx.rc
+++ b/src/components/gfx/gfx.rc
@@ -8,6 +8,8 @@
url = "http://servo.org/")];
#[crate_type = "lib"];
+#[feature(globs)];
+
extern mod azure;
extern mod geom;
extern mod newcss (name = "css");
diff --git a/src/components/gfx/opts.rs b/src/components/gfx/opts.rs
index 8e201c7a2a7..c2accbf0054 100644
--- a/src/components/gfx/opts.rs
+++ b/src/components/gfx/opts.rs
@@ -8,9 +8,7 @@
use azure::azure_hl::{BackendType, CairoBackend, CoreGraphicsBackend};
use azure::azure_hl::{CoreGraphicsAcceleratedBackend, Direct2DBackend, SkiaBackend};
-use std::float;
use std::result;
-use std::uint;
#[deriving(Clone)]
pub struct Opts {
@@ -18,7 +16,7 @@ pub struct Opts {
render_backend: BackendType,
n_render_threads: uint,
tile_size: uint,
- profiler_period: Option<float>,
+ profiler_period: Option<f64>,
exit_after_load: bool,
output_file: Option<~str>,
}
@@ -39,7 +37,7 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts {
let opt_match = match getopts::getopts(args, opts) {
result::Ok(m) => m,
- result::Err(f) => fail!(getopts::fail_str(f.clone())),
+ result::Err(f) => fail!(f.to_err_msg()),
};
let urls = if opt_match.free.is_empty() {
@@ -48,7 +46,7 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts {
opt_match.free.clone()
};
- let render_backend = match getopts::opt_maybe_str(&opt_match, "r") {
+ let render_backend = match opt_match.opt_str("r") {
Some(backend_str) => {
if backend_str == ~"direct2d" {
Direct2DBackend
@@ -67,24 +65,24 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts {
None => SkiaBackend
};
- let tile_size: uint = match getopts::opt_maybe_str(&opt_match, "s") {
- Some(tile_size_str) => uint::from_str(tile_size_str).unwrap(),
+ let tile_size: uint = match opt_match.opt_str("s") {
+ Some(tile_size_str) => from_str(tile_size_str).unwrap(),
None => 512,
};
- let n_render_threads: uint = match getopts::opt_maybe_str(&opt_match, "t") {
- Some(n_render_threads_str) => uint::from_str(n_render_threads_str).unwrap(),
+ let n_render_threads: uint = match opt_match.opt_str("t") {
+ Some(n_render_threads_str) => from_str(n_render_threads_str).unwrap(),
None => 1, // FIXME: Number of cores.
};
// if only flag is present, default to 5 second period
- let profiler_period = do getopts::opt_default(&opt_match, "p", "5").map |period| {
- float::from_str(*period).unwrap()
+ let profiler_period = do opt_match.opt_default("p", "5").map |period| {
+ from_str(period).unwrap()
};
- let exit_after_load = getopts::opt_present(&opt_match, "x");
+ let exit_after_load = opt_match.opt_present("x");
- let output_file = getopts::opt_maybe_str(&opt_match, "o");
+ let output_file = opt_match.opt_str("o");
Opts {
urls: urls,
diff --git a/src/components/gfx/platform/linux/font.rs b/src/components/gfx/platform/linux/font.rs
index 7da80b3d9cf..27634bc9541 100644
--- a/src/components/gfx/platform/linux/font.rs
+++ b/src/components/gfx/platform/linux/font.rs
@@ -29,11 +29,11 @@ use std::cast;
use std::ptr;
use std::str;
-fn float_to_fixed_ft(f: float) -> i32 {
+fn float_to_fixed_ft(f: f64) -> i32 {
float_to_fixed(6, f)
}
-fn fixed_to_float_ft(f: i32) -> float {
+fn fixed_to_float_ft(f: i32) -> f64 {
fixed_to_float(6, f)
}
@@ -63,7 +63,7 @@ pub struct FontHandle {
#[unsafe_destructor]
impl Drop for FontHandle {
#[fixed_stack_segment]
- fn drop(&self) {
+ fn drop(&mut self) {
assert!(self.face.is_not_null());
unsafe {
if !FT_Done_Face(self.face).succeeded() {
@@ -102,7 +102,7 @@ impl FontHandleMethods for FontHandle {
#[fixed_stack_segment]
fn create_face_from_buffer(lib: FT_Library,
- cbuf: *u8, cbuflen: uint, pt_size: float)
+ cbuf: *u8, cbuflen: uint, pt_size: f64)
-> Result<FT_Face, ()> {
unsafe {
@@ -224,12 +224,12 @@ impl FontHandleMethods for FontHandle {
/* TODO(Issue #76): complete me */
let face = self.get_face_rec();
- let underline_size = self.font_units_to_au(face.underline_thickness as float);
- let underline_offset = self.font_units_to_au(face.underline_position as float);
- let em_size = self.font_units_to_au(face.units_per_EM as float);
- let ascent = self.font_units_to_au(face.ascender as float);
- let descent = self.font_units_to_au(face.descender as float);
- let max_advance = self.font_units_to_au(face.max_advance_width as float);
+ let underline_size = self.font_units_to_au(face.underline_thickness as f64);
+ let underline_offset = self.font_units_to_au(face.underline_position as f64);
+ let em_size = self.font_units_to_au(face.units_per_EM as f64);
+ let ascent = self.font_units_to_au(face.ascender as f64);
+ let descent = self.font_units_to_au(face.descender as f64);
+ let max_advance = self.font_units_to_au(face.max_advance_width as f64);
let mut strikeout_size = geometry::from_pt(0.0);
let mut strikeout_offset = geometry::from_pt(0.0);
@@ -238,9 +238,9 @@ impl FontHandleMethods for FontHandle {
let os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2) as *TT_OS2;
let valid = os2.is_not_null() && (*os2).version != 0xffff;
if valid {
- strikeout_size = self.font_units_to_au((*os2).yStrikeoutSize as float);
- strikeout_offset = self.font_units_to_au((*os2).yStrikeoutPosition as float);
- x_height = self.font_units_to_au((*os2).sxHeight as float);
+ strikeout_size = self.font_units_to_au((*os2).yStrikeoutSize as f64);
+ strikeout_offset = self.font_units_to_au((*os2).yStrikeoutPosition as f64);
+ x_height = self.font_units_to_au((*os2).sxHeight as f64);
}
}
@@ -265,7 +265,7 @@ impl FontHandleMethods for FontHandle {
impl<'self> FontHandle {
#[fixed_stack_segment]
- fn set_char_size(face: FT_Face, pt_size: float) -> Result<(), ()>{
+ fn set_char_size(face: FT_Face, pt_size: f64) -> Result<(), ()>{
let char_width = float_to_fixed_ft(pt_size) as FT_F26Dot6;
let char_height = float_to_fixed_ft(pt_size) as FT_F26Dot6;
let h_dpi = 72;
@@ -336,7 +336,7 @@ impl<'self> FontHandle {
}
}
- fn font_units_to_au(&self, value: float) -> Au {
+ fn font_units_to_au(&self, value: f64) -> Au {
let face = self.get_face_rec();
// face.size is a *c_void in the bindings, presumably to avoid
@@ -344,8 +344,8 @@ impl<'self> FontHandle {
let size: &FT_SizeRec = unsafe { cast::transmute(&(*face.size)) };
let metrics: &FT_Size_Metrics = &(*size).metrics;
- let em_size = face.units_per_EM as float;
- let x_scale = (metrics.x_ppem as float) / em_size as float;
+ let em_size = face.units_per_EM as f64;
+ let x_scale = (metrics.x_ppem as f64) / em_size as f64;
// If this isn't true then we're scaling one of the axes wrong
assert!(metrics.x_ppem == metrics.y_ppem);
diff --git a/src/components/gfx/platform/linux/font_context.rs b/src/components/gfx/platform/linux/font_context.rs
index e2a97f55db6..4cca6822737 100644
--- a/src/components/gfx/platform/linux/font_context.rs
+++ b/src/components/gfx/platform/linux/font_context.rs
@@ -18,7 +18,7 @@ struct FreeTypeLibraryHandle {
impl Drop for FreeTypeLibraryHandle {
#[fixed_stack_segment]
- fn drop(&self) {
+ fn drop(&mut self) {
assert!(self.ctx.is_not_null());
unsafe {
FT_Done_FreeType(self.ctx);
@@ -53,9 +53,9 @@ impl FontContextHandleMethods for FontContextHandle {
fn create_font_from_identifier(&self, name: ~str, style: UsedFontStyle)
-> Result<FontHandle, ()> {
debug!("Creating font handle for %s", name);
- do path_from_identifier(name, &style).chain |file_name| {
+ do path_from_identifier(name, &style).and_then |file_name| {
debug!("Opening font face %s", file_name);
- FontHandle::new_from_file(self, file_name, &style)
+ FontHandle::new_from_file(self, file_name.to_owned(), &style)
}
}
}
diff --git a/src/components/gfx/platform/linux/font_list.rs b/src/components/gfx/platform/linux/font_list.rs
index e5c637d7e53..2f9cd629886 100644
--- a/src/components/gfx/platform/linux/font_list.rs
+++ b/src/components/gfx/platform/linux/font_list.rs
@@ -141,7 +141,7 @@ struct AutoPattern {
impl Drop for AutoPattern {
#[fixed_stack_segment]
- fn drop(&self) {
+ fn drop(&mut self) {
unsafe {
FcPatternDestroy(self.pattern);
}
diff --git a/src/components/gfx/platform/macos/font.rs b/src/components/gfx/platform/macos/font.rs
index 6568593e4c1..47b2fca99a3 100644
--- a/src/components/gfx/platform/macos/font.rs
+++ b/src/components/gfx/platform/macos/font.rs
@@ -37,7 +37,7 @@ pub struct FontTable {
// Noncopyable.
impl Drop for FontTable {
- fn drop(&self) {}
+ fn drop(&mut self) {}
}
impl FontTable {
@@ -158,39 +158,39 @@ impl FontHandleMethods for FontHandle {
fn get_metrics(&self) -> FontMetrics {
let bounding_rect: CGRect = self.ctfont.bounding_box();
- let ascent = Au::from_pt(self.ctfont.ascent() as float);
- let descent = Au::from_pt(self.ctfont.descent() as float);
- let em_size = Au::from_frac_px(self.ctfont.pt_size() as float);
+ let ascent = Au::from_pt(self.ctfont.ascent() as f64);
+ let descent = Au::from_pt(self.ctfont.descent() as f64);
+ let em_size = Au::from_frac_px(self.ctfont.pt_size() as f64);
- let scale = px_to_pt(self.ctfont.pt_size() as float) / (self.ctfont.ascent() as float + self.ctfont.descent() as float);
+ let scale = px_to_pt(self.ctfont.pt_size() as f64) / (self.ctfont.ascent() as f64 + self.ctfont.descent() as f64);
let metrics = FontMetrics {
- underline_size: Au::from_pt(self.ctfont.underline_thickness() as float),
+ underline_size: Au::from_pt(self.ctfont.underline_thickness() as f64),
// TODO(Issue #201): underline metrics are not reliable. Have to pull out of font table
// directly.
//
// see also: https://bugs.webkit.org/show_bug.cgi?id=16768
// see also: https://bugreports.qt-project.org/browse/QTBUG-13364
- underline_offset: Au::from_pt(self.ctfont.underline_position() as float),
+ underline_offset: Au::from_pt(self.ctfont.underline_position() as f64),
strikeout_size: geometry::from_pt(0.0), // FIXME(Issue #942)
strikeout_offset: geometry::from_pt(0.0), // FIXME(Issue #942)
- leading: Au::from_pt(self.ctfont.leading() as float),
- x_height: Au::from_pt(self.ctfont.x_height() as float),
+ leading: Au::from_pt(self.ctfont.leading() as f64),
+ x_height: Au::from_pt(self.ctfont.x_height() as f64),
em_size: em_size,
ascent: ascent.scale_by(scale),
descent: descent.scale_by(scale),
- max_advance: Au::from_pt(bounding_rect.size.width as float)
+ max_advance: Au::from_pt(bounding_rect.size.width as f64)
};
- debug!("Font metrics (@%f pt): %?", self.ctfont.pt_size() as float, metrics);
+ debug!("Font metrics (@%f pt): %?", self.ctfont.pt_size() as f64, metrics);
return metrics;
}
fn get_table_for_tag(&self, tag: FontTableTag) -> Option<FontTable> {
let result: Option<CFData> = self.ctfont.get_font_table(tag);
- result.chain(|data| {
+ do result.and_then |data| {
Some(FontTable::wrap(data))
- })
+ }
}
fn face_identifier(&self) -> ~str {
diff --git a/src/components/gfx/platform/macos/font_context.rs b/src/components/gfx/platform/macos/font_context.rs
index 79ebf1548c3..0c824073573 100644
--- a/src/components/gfx/platform/macos/font_context.rs
+++ b/src/components/gfx/platform/macos/font_context.rs
@@ -31,7 +31,7 @@ impl FontContextHandleMethods for FontContextHandle {
style: UsedFontStyle)
-> Result<FontHandle, ()> {
let ctfont_result = core_text::font::new_from_name(name, style.pt_size);
- do ctfont_result.chain |ctfont| {
+ do ctfont_result.and_then |ctfont| {
FontHandle::new_from_CTFont(self, ctfont)
}
}
diff --git a/src/components/gfx/render_context.rs b/src/components/gfx/render_context.rs
index 25031f6b695..d1f3f6fbd02 100644
--- a/src/components/gfx/render_context.rs
+++ b/src/components/gfx/render_context.rs
@@ -95,7 +95,7 @@ impl<'self> RenderContext<'self> {
Size2D(image.width as AzFloat, image.height as AzFloat));
let dest_rect = bounds.to_azure_rect();
let draw_surface_options = DrawSurfaceOptions(Linear, true);
- let draw_options = DrawOptions(1.0f as AzFloat, 0);
+ let draw_options = DrawOptions(1.0f64 as AzFloat, 0);
draw_target_ref.draw_surface(azure_surface,
dest_rect,
source_rect,
@@ -171,12 +171,12 @@ impl<'self> RenderContext<'self> {
}
trait to_float {
- fn to_float(&self) -> float;
+ fn to_float(&self) -> f64;
}
impl to_float for u8 {
- fn to_float(&self) -> float {
- (*self as float) / 255f
+ fn to_float(&self) -> f64 {
+ (*self as f64) / 255f64
}
}
diff --git a/src/components/gfx/render_task.rs b/src/components/gfx/render_task.rs
index 63374dd71d6..26ac7186fda 100644
--- a/src/components/gfx/render_task.rs
+++ b/src/components/gfx/render_task.rs
@@ -82,7 +82,7 @@ impl<T: Send> GenericSmartChan<Msg<T>> for RenderChan<T> {
}
}
-struct RenderTask<C,T> {
+pub struct RenderTask<C,T> {
id: PipelineId,
port: Port<Msg<T>>,
compositor: C,
diff --git a/src/components/gfx/text/glyph.rs b/src/components/gfx/text/glyph.rs
index 8e2e0bf8015..0baa11dff51 100644
--- a/src/components/gfx/text/glyph.rs
+++ b/src/components/gfx/text/glyph.rs
@@ -12,7 +12,7 @@ use std::num::NumCast;
use std::u16;
use std::vec;
use std::util;
-use std::iterator;
+use std::iter;
use geom::point::Point2D;
use extra::sort;
@@ -157,7 +157,7 @@ fn is_simple_glyph_id(glyphId: GlyphIndex) -> bool {
}
fn is_simple_advance(advance: Au) -> bool {
- let unsignedAu = advance.to_int() as u32;
+ let unsignedAu = advance.to_u32().unwrap();
(unsignedAu & (GLYPH_ADVANCE_MASK >> GLYPH_ADVANCE_SHIFT)) == unsignedAu
}
@@ -169,7 +169,7 @@ impl GlyphEntry {
// getter methods
#[inline(always)]
fn advance(&self) -> Au {
- NumCast::from((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT)
+ NumCast::from((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT).unwrap()
}
fn index(&self) -> GlyphIndex {
@@ -678,8 +678,8 @@ impl<'self> GlyphStore {
pub struct GlyphIterator<'self> {
priv store: &'self GlyphStore,
priv char_index: uint,
- priv char_range: iterator::Range<uint>,
- priv glyph_range: Option<iterator::Range<uint>>,
+ priv char_range: iter::Range<uint>,
+ priv glyph_range: Option<iter::Range<uint>>,
}
impl<'self> Iterator<(uint, GlyphInfo<'self>)> for GlyphIterator<'self> {
diff --git a/src/components/gfx/text/shaping/harfbuzz.rs b/src/components/gfx/text/shaping/harfbuzz.rs
index cebc7360d9e..314fc975de9 100644
--- a/src/components/gfx/text/shaping/harfbuzz.rs
+++ b/src/components/gfx/text/shaping/harfbuzz.rs
@@ -145,7 +145,7 @@ pub struct Shaper {
#[unsafe_destructor]
impl Drop for Shaper {
#[fixed_stack_segment]
- fn drop(&self) {
+ fn drop(&mut self) {
unsafe {
assert!(self.hb_face.is_not_null());
hb_face_destroy(self.hb_face);
@@ -198,11 +198,11 @@ impl Shaper {
}
}
- fn float_to_fixed(f: float) -> i32 {
+ fn float_to_fixed(f: f64) -> i32 {
float_to_fixed(16, f)
}
- fn fixed_to_float(i: hb_position_t) -> float {
+ fn fixed_to_float(i: hb_position_t) -> f64 {
fixed_to_float(16, i)
}
@@ -350,7 +350,7 @@ impl Shaper {
if glyph_span.length() == 1 { break; }
// if no glyphs were found yet, extend the char byte range more.
- if glyph_span.length() == 0 { loop; }
+ if glyph_span.length() == 0 { continue; }
debug!("Complex (multi-glyph to multi-char) association found. This case \
probably doesn't work.");
diff --git a/src/components/gfx/text/text_run.rs b/src/components/gfx/text/text_run.rs
index 3ca1960921f..bc195005bf2 100644
--- a/src/components/gfx/text/text_run.rs
+++ b/src/components/gfx/text/text_run.rs
@@ -61,7 +61,7 @@ impl<'self> Iterator<(&'self GlyphStore, uint, Range)> for SliceIterator<'self>
let slice_range = Range::new(self.offset, slice_glyphs.char_len());
let mut char_range = self.range.intersect(&slice_range);
- char_range.shift_by(-(self.offset.to_int()));
+ char_range.shift_by(-(self.offset.to_int().unwrap()));
let old_offset = self.offset;
self.offset += slice_glyphs.char_len();
@@ -86,11 +86,11 @@ impl<'self> Iterator<Range> for LineIterator<'self> {
Some((glyphs, offset, slice_range)) => {
match (glyphs.is_whitespace(), self.clump) {
(false, Some(ref mut c)) => {
- c.extend_by(slice_range.length().to_int());
+ c.extend_by(slice_range.length().to_int().unwrap());
}
(false, None) => {
let mut c = slice_range;
- c.shift_by(offset.to_int());
+ c.shift_by(offset.to_int().unwrap());
self.clump = Some(c);
}
(true, None) => { /* chomp whitespace */ }
diff --git a/src/components/gfx/text/util.rs b/src/components/gfx/text/util.rs
index cca38493729..7b741e11a6f 100644
--- a/src/components/gfx/text/util.rs
+++ b/src/components/gfx/text/util.rs
@@ -95,12 +95,12 @@ pub fn transform_text(text: &str, mode: CompressionMode, incoming_whitespace: bo
}
}
-pub fn float_to_fixed(before: int, f: float) -> i32 {
+pub fn float_to_fixed(before: int, f: f64) -> i32 {
(1i32 << before) * (f as i32)
}
-pub fn fixed_to_float(before: int, f: i32) -> float {
- f as float * 1.0f / ((1i32 << before) as float)
+pub fn fixed_to_float(before: int, f: i32) -> f64 {
+ f as f64 * 1.0f64 / ((1i32 << before) as f64)
}
pub fn fixed_to_rounded_int(before: int, f: i32) -> int {
diff --git a/src/components/main/compositing/mod.rs b/src/components/main/compositing/mod.rs
index eab36c2997c..7e236dddc70 100644
--- a/src/components/main/compositing/mod.rs
+++ b/src/components/main/compositing/mod.rs
@@ -22,7 +22,7 @@ use std::comm;
use std::comm::{Chan, SharedChan, Port};
use std::num::Orderable;
use std::vec;
-use std::rt::rtio::RtioTimer;
+use std::path::Path;
use std::rt::io::timer::Timer;
use geom::matrix::identity;
use geom::point::Point2D;
@@ -38,7 +38,7 @@ use servo_util::{time, url};
use servo_util::time::profile;
use servo_util::time::ProfilerChan;
-use extra::future::from_value;
+use extra::future::Future;
use extra::time::precise_time_s;
use constellation::SendableFrameTree;
@@ -226,7 +226,7 @@ impl CompositorTask {
// Keeps track of the current zoom factor
let mut world_zoom = 1f32;
let mut zoom_action = false;
- let mut zoom_time = 0f;
+ let mut zoom_time = 0f64;
// The root CompositorLayer
let mut compositor_layer: Option<CompositorLayer> = None;
@@ -395,7 +395,7 @@ impl CompositorTask {
match constellation_chan {
Some(ref chan) => chan.send(LoadUrlMsg(root_pipeline_id,
url::make_url(url_string.to_str(), None),
- from_value(window_size))),
+ Future::from_value(window_size))),
None => error!("Compositor: Recieved loadurl event without initialized layout chan"),
}
}
@@ -488,7 +488,7 @@ impl CompositorTask {
// window.present()) as OpenGL ES 2 does not have glReadBuffer().
if write_png {
let (width, height) = (window_size.width as uint, window_size.height as uint);
- let path = Path(*self.opts.output_file.get_ref());
+ let path = from_str::<Path>(*self.opts.output_file.get_ref()).unwrap();
let mut pixels = gl2::read_pixels(0, 0,
width as gl2::GLsizei,
height as gl2::GLsizei,
diff --git a/src/components/main/compositing/quadtree.rs b/src/components/main/compositing/quadtree.rs
index 7756e740c01..6ca058cc883 100644
--- a/src/components/main/compositing/quadtree.rs
+++ b/src/components/main/compositing/quadtree.rs
@@ -9,7 +9,7 @@ use geom::point::Point2D;
use geom::size::Size2D;
use geom::rect::Rect;
use std::uint::{div_ceil, next_power_of_two};
-use std::vec::build_sized;
+use std::vec;
use std::util::replace;
use gfx::render_task::BufferRequest;
use servo_msg::compositor_msg::Tile;
@@ -622,7 +622,7 @@ impl<T: Tile> QuadtreeNode<T> {
}
};
- let quads_to_check = build_sized(4, builder);
+ let quads_to_check = vec::build(Some(4), builder);
let mut request = ~[];
let mut unused = ~[];
diff --git a/src/components/main/constellation.rs b/src/components/main/constellation.rs
index 3e3b2e969ab..e242c74ba48 100644
--- a/src/components/main/constellation.rs
+++ b/src/components/main/constellation.rs
@@ -25,7 +25,7 @@ use servo_util::url::make_url;
use std::hashmap::{HashMap, HashSet};
use std::util::replace;
use extra::url::Url;
-use extra::future::{Future, from_value};
+use extra::future::Future;
/// Maintains the pipelines and navigation context and grants permission to composite
pub struct Constellation {
@@ -377,7 +377,7 @@ impl Constellation {
self.opts.clone(),
{
let size = self.compositor_chan.get_size();
- from_value(Size2D(size.width as uint, size.height as uint))
+ Future::from_value(Size2D(size.width as uint, size.height as uint))
});
let failure = ~"about:failure";
let url = make_url(failure, None);
@@ -402,7 +402,7 @@ impl Constellation {
self.opts.clone(),
{
let size = self.compositor_chan.get_size();
- from_value(Size2D(size.width as uint, size.height as uint))
+ Future::from_value(Size2D(size.width as uint, size.height as uint))
});
pipeline.load(url);
@@ -458,7 +458,7 @@ impl Constellation {
for source_frame in source_frame.iter() {
let found_child = source_frame.children.mut_iter()
.find(|child| subpage_eq(child));
- found_child.map_move(|child| update_child_rect(child, true));
+ found_child.map(|child| update_child_rect(child, true));
}
}
@@ -467,7 +467,7 @@ impl Constellation {
for frame_tree in frames.iter() {
let found_child = frame_tree.children.mut_iter()
.find(|child| subpage_eq(child));
- found_child.map_move(|child| update_child_rect(child, false));
+ found_child.map(|child| update_child_rect(child, false));
}
// At this point, if no pipelines were sent a resize msg, then this subpage id
diff --git a/src/components/main/css/node_util.rs b/src/components/main/css/node_util.rs
index f76a079464c..f6b36a66f16 100644
--- a/src/components/main/css/node_util.rs
+++ b/src/components/main/css/node_util.rs
@@ -61,8 +61,8 @@ impl<'self> NodeUtil<'self> for AbstractNode<LayoutView> {
do self.read_layout_data |layout_data| {
layout_data.restyle_damage
- .map(|&x| RestyleDamage::from_int(x))
- .unwrap_or_default(default)
+ .map(|x| RestyleDamage::from_int(x))
+ .unwrap_or(default)
}
}
diff --git a/src/components/main/css/select.rs b/src/components/main/css/select.rs
index af183503e67..eadfee5688c 100644
--- a/src/components/main/css/select.rs
+++ b/src/components/main/css/select.rs
@@ -30,14 +30,24 @@ fn default_url(name: &str) -> Url {
FromStr::from_str(fmt!("http://%s", name)).unwrap()
}
-fn style_stream(style: &str) -> DataStream {
+fn style_stream(style: &str) -> @mut DataStream {
let style = Cell::new(style.as_bytes().to_owned());
- let d: DataStream = || if !style.is_empty() {
- Some(style.take())
- } else {
- None
+ struct StyleDataStream {
+ style: Cell<~[u8]>,
+ }
+ impl DataStream for StyleDataStream {
+ fn read(&mut self) -> Option<~[u8]> {
+ if !self.style.is_empty() {
+ Some(self.style.take())
+ } else {
+ None
+ }
+ }
+ }
+ let stream = @mut StyleDataStream {
+ style: style,
};
- return d;
+ stream as @mut DataStream
}
fn html4_default_style_str() -> &'static str {
diff --git a/src/components/main/css/select_handler.rs b/src/components/main/css/select_handler.rs
index 75cce0e0d0c..aea2925b3d3 100644
--- a/src/components/main/css/select_handler.rs
+++ b/src/components/main/css/select_handler.rs
@@ -31,7 +31,7 @@ impl SelectHandler<AbstractNode<LayoutView>> for NodeSelectHandler {
fn named_parent_node(&self, node: &AbstractNode<LayoutView>, name: &str)
-> Option<AbstractNode<LayoutView>> {
- do node.parent_node().chain |parent| {
+ do node.parent_node().and_then |parent| {
do with_node_name(parent) |node_name| {
if eq_slice(name, node_name) {
Some(parent)
diff --git a/src/components/main/layout/block.rs b/src/components/main/layout/block.rs
index f81fa2e45c9..88bb1e9369e 100644
--- a/src/components/main/layout/block.rs
+++ b/src/components/main/layout/block.rs
@@ -106,10 +106,10 @@ impl BlockFlowData {
/* if not an anonymous block context, add in block box's widths.
these widths will not include child elements, just padding etc. */
- self.box.map(|&box| {
+ for box in self.box.iter() {
min_width = min_width.add(&box.get_min_width(ctx));
pref_width = pref_width.add(&box.get_pref_width(ctx));
- });
+ }
self.common.min_width = min_width;
self.common.pref_width = pref_width;
@@ -409,7 +409,7 @@ impl BlockFlowData {
}
let mut noncontent_height = Au(0);
- self.box.map(|&box| {
+ for box in self.box.mut_iter() {
do box.with_mut_base |base| {
//The associated box is the border box of this flow
base.model.margin.top = margin_top;
@@ -424,7 +424,7 @@ impl BlockFlowData {
noncontent_height = noncontent_height + clearance +
base.model.margin.top + base.model.margin.bottom;
}
- });
+ }
//TODO(eatkinson): compute heights using the 'height' property.
self.common.position.size.height = height + noncontent_height;
@@ -444,16 +444,16 @@ impl BlockFlowData {
-> bool {
if self.common.node.is_iframe_element() {
- let x = self.common.abs_position.x + do self.box.map_default(Au(0)) |box| {
+ let x = self.common.abs_position.x + do self.box.as_ref().map_default(Au(0)) |box| {
box.with_model(|model| model.margin.left + model.border.left + model.padding.left)
};
- let y = self.common.abs_position.y + do self.box.map_default(Au(0)) |box| {
+ let y = self.common.abs_position.y + do self.box.as_ref().map_default(Au(0)) |box| {
box.with_model(|model| model.margin.top + model.border.top + model.padding.top)
};
- let w = self.common.position.size.width - do self.box.map_default(Au(0)) |box| {
+ let w = self.common.position.size.width - do self.box.as_ref().map_default(Au(0)) |box| {
box.with_model(|model| model.noncontent_width())
};
- let h = self.common.position.size.height - do self.box.map_default(Au(0)) |box| {
+ let h = self.common.position.size.height - do self.box.as_ref().map_default(Au(0)) |box| {
box.with_model(|model| model.noncontent_height())
};
do self.common.node.with_mut_iframe_element |iframe_element| {
@@ -472,10 +472,9 @@ impl BlockFlowData {
debug!("build_display_list_block: adding display element");
// add box that starts block context
- self.box.map(|&box| {
+ for box in self.box.iter() {
box.build_display_list(builder, dirty, &self.common.abs_position, list)
- });
-
+ }
// TODO: handle any out-of-flow elements
let this_position = self.common.abs_position;
diff --git a/src/components/main/layout/box.rs b/src/components/main/layout/box.rs
index 9d1491c11fe..3ee83d4407c 100644
--- a/src/components/main/layout/box.rs
+++ b/src/components/main/layout/box.rs
@@ -362,10 +362,10 @@ impl RenderBox {
None
};
- let right_box = do right_range.map_default(None) |range: &Range| {
+ let right_box = do right_range.map_default(None) |range: Range| {
let new_text_box = @mut text::adapt_textbox_with_range(text_box.base,
text_box.run,
- *range);
+ range);
Some(TextRenderBoxClass(new_text_box))
};
@@ -498,7 +498,7 @@ impl RenderBox {
let px_width = if attr_width.is_some() {
attr_width.unwrap()
} else {
- image_box.image.get_size().unwrap_or_default(Size2D(0, 0)).width
+ image_box.image.get_size().unwrap_or(Size2D(0, 0)).width
};
Au::from_px(px_width)
@@ -524,7 +524,7 @@ impl RenderBox {
let px_height = if attr_height.is_some() {
attr_height.unwrap()
} else {
- image_box.image.get_size().unwrap_or_default(Size2D(0, 0)).height
+ image_box.image.get_size().unwrap_or(Size2D(0, 0)).height
};
Au::from_px(px_height)
@@ -852,10 +852,10 @@ impl RenderBox {
debug!("(font style) font families: `%s`", font_families);
let font_size = match my_style.font_size() {
- CSSFontSizeLength(Px(length)) => length,
+ CSSFontSizeLength(Px(length)) => length as f64,
// todo: this is based on a hard coded font size, should be the parent element's font size
- CSSFontSizeLength(Em(length)) => length * 16f,
- _ => 16f // px units
+ CSSFontSizeLength(Em(length)) => (length as f64) * 16f64,
+ _ => 16f64 // px units
};
debug!("(font style) font size: `%fpx`", font_size);
diff --git a/src/components/main/layout/box_builder.rs b/src/components/main/layout/box_builder.rs
index 950370f06cb..e0c821fc945 100644
--- a/src/components/main/layout/box_builder.rs
+++ b/src/components/main/layout/box_builder.rs
@@ -405,7 +405,7 @@ impl LayoutTreeBuilder {
}
};
- let sibling_flow: Option<&mut FlowContext> = sibling_generator.map_mut(|gen| &mut *gen.flow);
+ let sibling_flow: Option<&mut FlowContext> = sibling_generator.as_mut().map(|gen| &mut *gen.flow);
// TODO(eatkinson): use the value of the float property to
// determine whether to float left or right.
diff --git a/src/components/main/layout/display_list_builder.rs b/src/components/main/layout/display_list_builder.rs
index cc89f7cb61b..6d175cf6a9a 100644
--- a/src/components/main/layout/display_list_builder.rs
+++ b/src/components/main/layout/display_list_builder.rs
@@ -63,7 +63,7 @@ pub trait ToGfxColor {
impl ToGfxColor for newcss::color::Color {
fn to_gfx_color(&self) -> gfx::color::Color {
- gfx::color::rgba(self.red, self.green, self.blue, self.alpha)
+ gfx::color::rgba(self.red, self.green, self.blue, self.alpha as f64)
}
}
diff --git a/src/components/main/layout/float.rs b/src/components/main/layout/float.rs
index c63d8e8f8a6..588a0dabff9 100644
--- a/src/components/main/layout/float.rs
+++ b/src/components/main/layout/float.rs
@@ -81,7 +81,7 @@ impl FloatFlowData {
self.floated_children = num_floats;
- self.box.map(|&box| {
+ for box in self.box.iter() {
let style = box.style();
do box.with_model |model| {
model.compute_borders(style)
@@ -89,7 +89,7 @@ impl FloatFlowData {
min_width = min_width.add(&box.get_min_width(ctx));
pref_width = pref_width.add(&box.get_pref_width(ctx));
- });
+ }
self.common.min_width = min_width;
self.common.pref_width = pref_width;
@@ -185,7 +185,7 @@ impl FloatFlowData {
let mut full_noncontent_width = Au(0);
let mut margin_height = Au(0);
- self.box.map(|&box| {
+ for box in self.box.iter() {
height = do box.with_base |base| {
base.position.size.height
};
@@ -204,7 +204,7 @@ impl FloatFlowData {
margin_height = base.model.margin.top + base.model.margin.bottom;
}
- });
+ }
let info = PlacementInfo {
width: self.common.position.size.width + full_noncontent_width,
@@ -257,7 +257,7 @@ impl FloatFlowData {
let mut noncontent_width = Au(0);
let mut noncontent_height = Au(0);
- self.box.map(|&box| {
+ for box in self.box.mut_iter() {
do box.with_mut_base |base| {
//The associated box is the border box of this flow
base.position.origin.y = base.model.margin.top;
@@ -269,8 +269,7 @@ impl FloatFlowData {
base.position.size.height = height + noncontent_height;
}
- });
-
+ }
//TODO(eatkinson): compute heights properly using the 'height' property.
for &box in self.box.iter() {
@@ -305,10 +304,9 @@ impl FloatFlowData {
let offset = self.common.abs_position + self.rel_pos;
// add box that starts block context
- self.box.map(|&box| {
+ for box in self.box.iter() {
box.build_display_list(builder, dirty, &offset, list)
- });
-
+ }
// TODO: handle any out-of-flow elements
diff --git a/src/components/main/layout/float_context.rs b/src/components/main/layout/float_context.rs
index adc083105fe..e9f39586081 100644
--- a/src/components/main/layout/float_context.rs
+++ b/src/components/main/layout/float_context.rs
@@ -300,7 +300,7 @@ impl FloatContextBase{
f_data.bounds.origin.x + f_data.bounds.size.width > left &&
f_data.bounds.origin.x < left + width {
let new_y = f_data.bounds.origin.y;
- max_height = Some(min(max_height.unwrap_or_default(new_y), new_y));
+ max_height = Some(min(max_height.unwrap_or(new_y), new_y));
}
}
}
@@ -340,7 +340,7 @@ impl FloatContextBase{
let height = self.max_height_for_bounds(rect.origin.x,
rect.origin.y,
rect.size.width);
- let height = height.unwrap_or_default(Au(max_value));
+ let height = height.unwrap_or(Au(max_value));
return match info.f_type {
FloatLeft => Rect(Point2D(rect.origin.x, float_y),
Size2D(rect.size.width, height)),
diff --git a/src/components/main/layout/flow.rs b/src/components/main/layout/flow.rs
index a1675c46204..273272fbe04 100644
--- a/src/components/main/layout/flow.rs
+++ b/src/components/main/layout/flow.rs
@@ -425,7 +425,7 @@ impl<'self> FlowContext {
pub fn foldl_all_boxes<B:Clone>(&mut self, seed: B, cb: &fn(a: B, b: RenderBox) -> B) -> B {
match *self {
BlockFlow(ref mut block) => {
- do block.box.map_default(seed.clone()) |box| {
+ do block.box.as_ref().map_default(seed.clone()) |box| {
cb(seed.clone(), *box)
}
}
@@ -455,7 +455,7 @@ impl<'self> FlowContext {
pub fn iter_all_boxes(&mut self) -> BoxIterator {
BoxIterator {
boxes: match *self {
- BlockFlow (ref mut block) => block.box.map_default(~[], |&x| ~[x]),
+ BlockFlow(ref mut block) => block.box.as_ref().map_default(~[], |&x| ~[x]),
InlineFlow(ref mut inline) => inline.boxes.clone(),
_ => fail!(fmt!("Don't know how to iterate node's RenderBoxes for %?", self))
},
diff --git a/src/components/main/layout/incremental.rs b/src/components/main/layout/incremental.rs
index 6beea28cf0c..85f565c04bc 100644
--- a/src/components/main/layout/incremental.rs
+++ b/src/components/main/layout/incremental.rs
@@ -112,9 +112,10 @@ impl RestyleDamage {
// version of this macro might be safe anyway, but we want to avoid silent
// breakage on modifications.
macro_rules! add_if_not_equal(
- ([ $($effect:ident),* ], [ $($getter:ident),* ]) => ({
- if $( (old.$getter() != new.$getter()) )||* {
- damage.union_in_place( restyle_damage!( $($effect),* ) );
+ ($old:ident, $new:ident, $damage:ident,
+ [ $($effect:ident),* ], [ $($getter:ident),* ]) => ({
+ if $( ($old.$getter() != $new.$getter()) )||* {
+ $damage.union_in_place( restyle_damage!( $($effect),* ) );
}
})
)
@@ -132,11 +133,11 @@ pub fn compute_damage(node: &AbstractNode<LayoutView>,
// FIXME: We can short-circuit more of this.
- add_if_not_equal!([ Repaint ],
+ add_if_not_equal!(old, new, damage, [ Repaint ],
[ color, background_color, border_top_color, border_right_color,
border_bottom_color, border_left_color ]);
- add_if_not_equal!([ Repaint, BubbleWidths, Reflow ],
+ add_if_not_equal!(old, new, damage, [ Repaint, BubbleWidths, Reflow ],
[ border_top_width, border_right_width, border_bottom_width,
border_left_width, margin_top, margin_right, margin_bottom, margin_left,
padding_top, padding_right, padding_bottom, padding_left, position,
diff --git a/src/components/main/layout/inline.rs b/src/components/main/layout/inline.rs
index c623077f519..b19bc15a11f 100644
--- a/src/components/main/layout/inline.rs
+++ b/src/components/main/layout/inline.rs
@@ -171,11 +171,11 @@ impl LineboxScanner {
fn calculate_line_height(&self, box: RenderBox, font_size: Au) -> Au {
match box.line_height() {
- CSSLineHeightNormal => font_size.scale_by(1.14f),
- CSSLineHeightNumber(l) => font_size.scale_by(l),
- CSSLineHeightLength(Em(l)) => font_size.scale_by(l),
- CSSLineHeightLength(Px(l)) => Au::from_frac_px(l),
- CSSLineHeightPercentage(p) => font_size.scale_by(p / 100.0f)
+ CSSLineHeightNormal => font_size.scale_by(1.14f64),
+ CSSLineHeightNumber(l) => font_size.scale_by(l as f64),
+ CSSLineHeightLength(Em(l)) => font_size.scale_by(l as f64),
+ CSSLineHeightLength(Px(l)) => Au::from_frac_px(l as f64),
+ CSSLineHeightPercentage(p) => font_size.scale_by(p as f64 / 100.0f64)
}
}
@@ -183,7 +183,7 @@ impl LineboxScanner {
match box {
ImageRenderBoxClass(image_box) => {
let size = image_box.image.get_size();
- let height = Au::from_px(size.unwrap_or_default(Size2D(0, 0)).height);
+ let height = Au::from_px(size.unwrap_or(Size2D(0, 0)).height);
image_box.base.position.size.height = height;
debug!("box_height: found image height: %?", height);
height
@@ -645,7 +645,7 @@ impl InlineFlowData {
}
}
CSSTextAlignCenter => {
- offset_x = offset_x + slack_width.scale_by(0.5f);
+ offset_x = offset_x + slack_width.scale_by(0.5f64);
for i in line.range.eachi() {
do self.boxes[i].with_mut_base |base| {
base.position.origin.x = offset_x;
@@ -715,7 +715,7 @@ impl InlineFlowData {
let text_ascent = text_box.run.font.metrics.ascent;
// Offset from the top of the box is 1/2 of the leading + ascent
- let text_offset = text_ascent + (line_height - em_size).scale_by(0.5f);
+ let text_offset = text_ascent + (line_height - em_size).scale_by(0.5f64);
text_bounds.translate(&Point2D(text_box.base.position.origin.x, Au(0)));
(text_offset, line_height - text_offset, text_ascent)
@@ -746,13 +746,17 @@ impl InlineFlowData {
let parent_text_bottom = Au(0);
do cur_box.with_mut_base |base| {
// Get parent node
- let parent = base.node.parent_node().map_default(base.node, |parent| *parent);
+ let parent = match base.node.parent_node() {
+ None => base.node,
+ Some(parent) => parent,
+ };
+
// TODO: When the calculation of font-size style is supported, it should be updated.
let font_size = match parent.style().font_size() {
- CSSFontSizeLength(Px(length)) => length,
+ CSSFontSizeLength(Px(length)) => length as f64,
// todo: this is based on a hard coded font size, should be the parent element's font size
- CSSFontSizeLength(Em(length)) => length * 16f,
- _ => 16f // px units
+ CSSFontSizeLength(Em(length)) => length as f64 * 16f64,
+ _ => 16f64 // px units
};
parent_text_top = Au::from_frac_px(font_size);
}
@@ -814,15 +818,15 @@ impl InlineFlowData {
},
CSSVerticalAlignLength(length) => {
let length_offset = match length {
- Em(l) => Au::from_frac_px(cur_box.font_style().pt_size * l),
- Px(l) => Au::from_frac_px(l),
+ Em(l) => Au::from_frac_px(cur_box.font_style().pt_size * l as f64),
+ Px(l) => Au::from_frac_px(l as f64),
};
-(length_offset + ascent)
},
CSSVerticalAlignPercentage(p) => {
let pt_size = cur_box.font_style().pt_size;
let line_height = scanner.calculate_line_height(cur_box, Au::from_pt(pt_size));
- let percent_offset = line_height.scale_by(p / 100.0f);
+ let percent_offset = line_height.scale_by(p as f64 / 100.0f64);
-(percent_offset + ascent)
}
};
diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs
index 1feb7338c62..056b9477b19 100644
--- a/src/components/main/layout/layout_task.rs
+++ b/src/components/main/layout/layout_task.rs
@@ -391,7 +391,7 @@ impl LayoutTask {
for child in node.children() {
let rect = box_for_node(child);
match rect {
- None => loop,
+ None => continue,
Some(rect) => acc = match acc {
Some(acc) => Some(acc.union(&rect)),
None => Some(rect)
@@ -404,8 +404,8 @@ impl LayoutTask {
}
}
- let rect = box_for_node(node).unwrap_or_default(Rect(Point2D(Au(0), Au(0)),
- Size2D(Au(0), Au(0))));
+ let rect = box_for_node(node).unwrap_or(Rect(Point2D(Au(0), Au(0)),
+ Size2D(Au(0), Au(0))));
reply_chan.send(ContentBoxResponse(rect))
}
ContentBoxesQuery(node, reply_chan) => {
@@ -444,8 +444,8 @@ impl LayoutTask {
match self.display_list {
Some(ref list) => {
let display_list = list.get();
- let (x, y) = (Au::from_frac_px(point.x as float),
- Au::from_frac_px(point.y as float));
+ let (x, y) = (Au::from_frac_px(point.x as f64),
+ Au::from_frac_px(point.y as f64));
let mut resp = Err(());
// iterate in reverse to ensure we have the most recently painted render box
for display_item in display_list.list.rev_iter() {
@@ -482,13 +482,13 @@ impl LayoutTask {
// re-requested. We probably don't need to go all the way back to
// the script task for this.
fn make_on_image_available_cb(&self, script_chan: ScriptChan)
- -> @fn() -> ~fn(ImageResponseMsg) {
+ -> ~fn() -> ~fn(ImageResponseMsg) {
// This has a crazy signature because the image cache needs to
// make multiple copies of the callback, and the dom event
// channel is not a copyable type, so this is actually a
// little factory to produce callbacks
let id = self.id.clone();
- let f: @fn() -> ~fn(ImageResponseMsg) = || {
+ let f: ~fn() -> ~fn(ImageResponseMsg) = || {
let script_chan = script_chan.clone();
let f: ~fn(ImageResponseMsg) = |_| {
script_chan.send(SendEventMsg(id.clone(), ReflowEvent))
diff --git a/src/components/main/layout/model.rs b/src/components/main/layout/model.rs
index e51095ae086..c4d6e453ec5 100644
--- a/src/components/main/layout/model.rs
+++ b/src/components/main/layout/model.rs
@@ -26,10 +26,10 @@ pub struct BoxModel {
fn from_length(length: Length, font_size: CSSFontSize) -> Au {
match length {
- Px(v) => Au::from_frac_px(v),
+ Px(v) => Au::from_frac_px(v as f64),
Em(em) => {
match font_size {
- CSSFontSizeLength(Px(v)) => Au::from_frac_px(em * v),
+ CSSFontSizeLength(Px(v)) => Au::from_frac_px((em * v) as f64),
_ => fail!("expected non-relative font size")
}
}
@@ -46,7 +46,7 @@ impl MaybeAuto {
pub fn from_margin(margin: CSSMargin, containing_width: Au, font_size: CSSFontSize) -> MaybeAuto {
match margin {
CSSMarginAuto => Auto,
- CSSMarginPercentage(percent) => Specified(containing_width.scale_by(percent/100.0)),
+ CSSMarginPercentage(percent) => Specified(containing_width.scale_by(percent as f64 / 100.0f64)),
CSSMarginLength(length) => Specified(from_length(length, font_size))
}
}
@@ -54,7 +54,7 @@ impl MaybeAuto {
pub fn from_width(width: CSSWidth, containing_width: Au, font_size: CSSFontSize) -> MaybeAuto {
match width {
CSSWidthAuto => Auto,
- CSSWidthPercentage(percent) => Specified(containing_width.scale_by(percent/100.0)),
+ CSSWidthPercentage(percent) => Specified(containing_width.scale_by(percent as f64 / 100.0f64)),
CSSWidthLength(length) => Specified(from_length(length, font_size))
}
}
@@ -62,7 +62,7 @@ impl MaybeAuto {
pub fn from_height(height: CSSHeight, cb_height: Au, font_size: CSSFontSize) -> MaybeAuto {
match height {
CSSHeightAuto => Auto,
- CSSHeightPercentage(percent) => Specified(cb_height.scale_by(percent/100.0)),
+ CSSHeightPercentage(percent) => Specified(cb_height.scale_by(percent as f64 / 100.0f64)),
CSSHeightLength(length) => Specified(from_length(length, font_size))
}
}
@@ -140,7 +140,7 @@ impl BoxModel {
pub fn compute_padding_length(&self, padding: CSSPadding, content_box_width: Au, font_size: CSSFontSize) -> Au {
match padding {
CSSPaddingLength(length) => from_length(length, font_size),
- CSSPaddingPercentage(p) => content_box_width.scale_by(p/100.0)
+ CSSPaddingPercentage(p) => content_box_width.scale_by(p as f64 / 100.0f64)
}
}
}
diff --git a/src/components/main/layout/text.rs b/src/components/main/layout/text.rs
index 5dd9306c26d..a14dd2bf74a 100644
--- a/src/components/main/layout/text.rs
+++ b/src/components/main/layout/text.rs
@@ -231,7 +231,7 @@ impl TextRunScanner {
debug!("Elided an `UnscannedTextbox` because it was zero-length after \
compression; %s",
in_boxes[i].debug_str());
- loop
+ continue
}
do in_boxes[i].with_base |base| {
diff --git a/src/components/main/layout/util.rs b/src/components/main/layout/util.rs
index e976e50c635..c45ca1f3631 100644
--- a/src/components/main/layout/util.rs
+++ b/src/components/main/layout/util.rs
@@ -6,7 +6,7 @@ use layout::box::{RenderBox};
use script::dom::node::{AbstractNode, LayoutView};
use servo_util::range::Range;
-use std::iterator::Enumerate;
+use std::iter::Enumerate;
use std::vec::VecIterator;
pub struct NodeRange {
diff --git a/src/components/main/pipeline.rs b/src/components/main/pipeline.rs
index da9848c0181..fc34ecd9f29 100644
--- a/src/components/main/pipeline.rs
+++ b/src/components/main/pipeline.rs
@@ -180,7 +180,7 @@ impl Pipeline {
}
pub fn reload(&mut self) {
- do self.url.clone().map_move() |url| {
+ do self.url.clone().map() |url| {
self.load(url);
};
}
diff --git a/src/components/main/platform/common/glfw_windowing.rs b/src/components/main/platform/common/glfw_windowing.rs
index d257439b85f..6dee5c7f97b 100644
--- a/src/components/main/platform/common/glfw_windowing.rs
+++ b/src/components/main/platform/common/glfw_windowing.rs
@@ -38,7 +38,7 @@ impl ApplicationMethods for Application {
}
impl Drop for Application {
- fn drop(&self) {
+ fn drop(&mut self) {
drop_local_window();
glfw::terminate();
}
@@ -52,7 +52,7 @@ pub struct Window {
drag_origin: Point2D<c_int>,
- mouse_down_button: @mut c_int,
+ mouse_down_button: @mut Option<glfw::MouseButton>,
mouse_down_point: @mut Point2D<c_int>,
ready_state: ReadyState,
@@ -76,7 +76,7 @@ impl WindowMethods<Application> for Window {
drag_origin: Point2D(0 as c_int, 0),
- mouse_down_button: @mut 0,
+ mouse_down_button: @mut None,
mouse_down_point: @mut Point2D(0 as c_int, 0),
ready_state: Blank,
@@ -91,7 +91,7 @@ impl WindowMethods<Application> for Window {
local_window().event_queue.push(ResizeWindowEvent(width as uint, height as uint))
}
do window.glfw_window.set_key_callback |_win, key, _scancode, action, mods| {
- if action == glfw::PRESS {
+ if action == glfw::Press {
local_window().handle_key(key, mods)
}
}
@@ -103,7 +103,7 @@ impl WindowMethods<Application> for Window {
let hidpi = (backing_size as f32) / (window_size as f32);
let x = x as f32 * hidpi;
let y = y as f32 * hidpi;
- if button < 3 {
+ if button == glfw::MouseButtonLeft || button == glfw::MouseButtonRight {
local_window().handle_mouse(button, action, x as i32, y as i32);
}
}
@@ -206,21 +206,20 @@ impl Window {
}
/// Helper function to handle keyboard events.
- fn handle_key(&self, key: c_int, mods: glfw::KeyMods) {
- let mods = *mods;
+ fn handle_key(&self, key: glfw::Key, mods: glfw::Modifiers) {
match key {
- glfw::KEY_ESCAPE => self.glfw_window.set_should_close(true),
- glfw::KEY_L if mods & glfw::MOD_CONTROL != 0 => self.load_url(), // Ctrl+L
- glfw::KEY_EQUAL if mods & glfw::MOD_CONTROL != 0 => { // Ctrl-+
+ glfw::KeyEscape => self.glfw_window.set_should_close(true),
+ glfw::KeyL if mods.contains(glfw::Control) => self.load_url(), // Ctrl+L
+ glfw::KeyEqual if mods.contains(glfw::Control) => { // Ctrl-+
self.event_queue.push(ZoomWindowEvent(1.1));
}
- glfw::KEY_MINUS if mods & glfw::MOD_CONTROL != 0 => { // Ctrl--
+ glfw::KeyMinus if mods.contains(glfw::Control) => { // Ctrl--
self.event_queue.push(ZoomWindowEvent(0.90909090909));
}
- glfw::KEY_BACKSPACE if mods & glfw::MOD_SHIFT != 0 => { // Shift-Backspace
+ glfw::KeyBackspace if mods.contains(glfw::Shift) => { // Shift-Backspace
self.event_queue.push(NavigationWindowEvent(Forward));
}
- glfw::KEY_BACKSPACE => { // Backspace
+ glfw::KeyBackspace => { // Backspace
self.event_queue.push(NavigationWindowEvent(Back));
}
_ => {}
@@ -228,25 +227,29 @@ impl Window {
}
/// Helper function to handle a click
- fn handle_mouse(&self, button: c_int, action: c_int, x: c_int, y: c_int) {
+ fn handle_mouse(&self, button: glfw::MouseButton, action: glfw::Action, x: c_int, y: c_int) {
// FIXME(tkuehn): max pixel dist should be based on pixel density
- let max_pixel_dist = 10f;
+ let max_pixel_dist = 10f64;
let event = match action {
- glfw::PRESS => {
+ glfw::Press => {
*self.mouse_down_point = Point2D(x, y);
- *self.mouse_down_button = button;
+ *self.mouse_down_button = Some(button);
MouseWindowMouseDownEvent(button as uint, Point2D(x as f32, y as f32))
}
- glfw::RELEASE => {
- if *self.mouse_down_button == button {
- let pixel_dist = *self.mouse_down_point - Point2D(x, y);
- let pixel_dist = ((pixel_dist.x * pixel_dist.x +
- pixel_dist.y * pixel_dist.y) as float).sqrt();
- if pixel_dist < max_pixel_dist {
- let click_event = MouseWindowClickEvent(button as uint,
- Point2D(x as f32, y as f32));
- self.event_queue.push(MouseWindowEventClass(click_event));
+ glfw::Release => {
+ match *self.mouse_down_button {
+ None => (),
+ Some(but) if button == but => {
+ let pixel_dist = *self.mouse_down_point - Point2D(x, y);
+ let pixel_dist = ((pixel_dist.x * pixel_dist.x +
+ pixel_dist.y * pixel_dist.y) as f64).sqrt();
+ if pixel_dist < max_pixel_dist {
+ let click_event = MouseWindowClickEvent(button as uint,
+ Point2D(x as f32, y as f32));
+ self.event_queue.push(MouseWindowEventClass(click_event));
+ }
}
+ Some(_) => (),
}
MouseWindowMouseUpEvent(button as uint, Point2D(x as f32, y as f32))
}
diff --git a/src/components/main/platform/common/glut_windowing.rs b/src/components/main/platform/common/glut_windowing.rs
index 373975a2ca1..5f9c4785353 100644
--- a/src/components/main/platform/common/glut_windowing.rs
+++ b/src/components/main/platform/common/glut_windowing.rs
@@ -206,7 +206,7 @@ impl Window {
/// Helper function to handle a click
fn handle_mouse(&self, button: c_int, state: c_int, x: c_int, y: c_int) {
// FIXME(tkuehn): max pixel dist should be based on pixel density
- let max_pixel_dist = 10f;
+ let max_pixel_dist = 10f64;
let event = match state {
glut::MOUSE_DOWN => {
*self.mouse_down_point = Point2D(x, y);
diff --git a/src/components/main/servo.rc b/src/components/main/servo.rc
index a06330973b2..3eb4119c8c8 100755
--- a/src/components/main/servo.rc
+++ b/src/components/main/servo.rc
@@ -11,6 +11,8 @@
#[license = "MPL"];
#[crate_type = "lib"];
+#[feature(globs, macro_rules)];
+
extern mod alert;
extern mod azure;
extern mod geom;
@@ -55,7 +57,6 @@ pub use servo_util::url::make_url;
use std::comm;
#[cfg(not(test))]
use std::os;
-use std::rt::rtio::RtioTimer;
use std::task::spawn_with;
#[path="compositing/mod.rs"]
@@ -103,7 +104,7 @@ pub mod util;
#[cfg(not(test))]
#[start]
-fn start(argc: int, argv: **u8, crate_map: *u8) -> int {
+fn start(argc: int, argv: **u8) -> int {
#[cfg(target_os="linux")]
#[cfg(target_os="macos")]
fn getopts() -> Opts {
@@ -120,7 +121,7 @@ fn start(argc: int, argv: **u8, crate_map: *u8) -> int {
}
opts::from_cmdline_args(args)
}
- do std::rt::start_on_main_thread(argc, argv, crate_map) {
+ do std::rt::start_on_main_thread(argc, argv) {
run(getopts())
}
}
diff --git a/src/components/msg/constellation_msg.rs b/src/components/msg/constellation_msg.rs
index 1e61114e3b1..f0b4084049f 100644
--- a/src/components/msg/constellation_msg.rs
+++ b/src/components/msg/constellation_msg.rs
@@ -39,7 +39,7 @@ pub enum Msg {
/// Represents the two different ways to which a page can be navigated
#[deriving(Clone, Eq, IterBytes)]
-enum NavigationType {
+pub enum NavigationType {
Load, // entered or clicked on a url
Navigate, // browser forward/back buttons
}
diff --git a/src/components/net/file_loader.rs b/src/components/net/file_loader.rs
index 85ce0f03502..40588cad275 100644
--- a/src/components/net/file_loader.rs
+++ b/src/components/net/file_loader.rs
@@ -14,7 +14,7 @@ pub fn factory() -> LoaderTask {
assert!("file" == url.scheme);
let progress_chan = start_sending(start_chan, Metadata::default(url.clone()));
do task::spawn {
- match file_reader(&Path(url.path)) {
+ match file_reader(&from_str(url.path).unwrap()) {
Ok(reader) => {
while !reader.eof() {
let data = reader.read_bytes(READ_SIZE);
diff --git a/src/components/net/local_image_cache.rs b/src/components/net/local_image_cache.rs
index 9c6bf12191c..c7c922e6910 100644
--- a/src/components/net/local_image_cache.rs
+++ b/src/components/net/local_image_cache.rs
@@ -29,7 +29,7 @@ pub fn LocalImageCache(image_cache_task: ImageCacheTask) -> LocalImageCache {
pub struct LocalImageCache {
priv image_cache_task: ImageCacheTask,
priv round_number: uint,
- priv on_image_available: Option<@fn() -> ~fn(ImageResponseMsg)>,
+ priv on_image_available: Option<~fn() -> ~fn(ImageResponseMsg)>,
priv state_map: UrlMap<@mut ImageState>
}
@@ -43,7 +43,7 @@ struct ImageState {
impl LocalImageCache {
/// The local cache will only do a single remote request for a given
/// URL in each 'round'. Layout should call this each time it begins
- pub fn next_round(&mut self, on_image_available: @fn() -> ~fn(ImageResponseMsg)) {
+ pub fn next_round(&mut self, on_image_available: ~fn() -> ~fn(ImageResponseMsg)) {
self.round_number += 1;
self.on_image_available = Some(on_image_available);
}
@@ -109,7 +109,7 @@ impl LocalImageCache {
// on the image to load and triggering layout
let image_cache_task = self.image_cache_task.clone();
assert!(self.on_image_available.is_some());
- let on_image_available = self.on_image_available.unwrap()();
+ let on_image_available = (*self.on_image_available.get_ref())();
let url = (*url).clone();
do task::spawn {
let (response_port, response_chan) = comm::stream();
diff --git a/src/components/net/net.rc b/src/components/net/net.rc
index fee23e16fa4..623a530cecb 100644
--- a/src/components/net/net.rc
+++ b/src/components/net/net.rc
@@ -8,6 +8,8 @@
url = "http://servo.org/")];
#[crate_type = "lib"];
+#[feature(globs)];
+
extern mod geom;
extern mod http;
extern mod servo_util (name = "util");
diff --git a/src/components/script/dom/bindings/proxyhandler.rs b/src/components/script/dom/bindings/proxyhandler.rs
index a96ba1b08e4..5201b724070 100644
--- a/src/components/script/dom/bindings/proxyhandler.rs
+++ b/src/components/script/dom/bindings/proxyhandler.rs
@@ -16,7 +16,7 @@ use std::cast;
use std::libc;
use std::ptr;
use std::str;
-use std::sys::size_of;
+use std::mem::size_of;
type c_bool = libc::c_int;
diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs
index 87fa9477e52..6cb7cacea92 100644
--- a/src/components/script/dom/bindings/utils.rs
+++ b/src/components/script/dom/bindings/utils.rs
@@ -39,7 +39,7 @@ use js;
static TOSTRING_CLASS_RESERVED_SLOT: libc::size_t = 0;
static TOSTRING_NAME_RESERVED_SLOT: libc::size_t = 1;
-struct GlobalStaticData {
+pub struct GlobalStaticData {
proxy_handlers: HashMap<uint, *libc::c_void>,
attribute_ids: HashMap<uint, ~[jsid]>,
method_ids: HashMap<uint, ~[jsid]>,
@@ -165,7 +165,7 @@ pub unsafe fn get_dom_class(obj: *JSObject) -> Result<DOMClass, ()> {
pub fn unwrap_object<T>(obj: *JSObject, proto_id: PrototypeList::id::ID, proto_depth: uint) -> Result<T, ()> {
unsafe {
- do get_dom_class(obj).chain |dom_class| {
+ do get_dom_class(obj).and_then |dom_class| {
if dom_class.interface_chain[proto_depth] == proto_id {
debug!("good prototype");
Ok(unwrap(obj))
@@ -671,7 +671,7 @@ pub fn XrayResolveProperty(cx: *JSContext,
for &elem in attrs.iter() {
let (attr, attr_id) = elem;
if attr_id == JSID_VOID || attr_id != id {
- loop;
+ continue;
}
(*desc).attrs = (attr.flags & !(JSPROP_NATIVE_ACCESSORS as u8)) as u32;
@@ -783,7 +783,7 @@ pub fn FindEnumStringIndex(cx: *JSContext,
}
for (i, value) in values.iter().enumerate() {
if value.length != length as uint {
- loop;
+ continue;
}
let mut equal = true;
for j in range(0, length as int) {
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs
index bd323e15f85..510fdcb1235 100644
--- a/src/components/script/dom/document.rs
+++ b/src/components/script/dom/document.rs
@@ -254,7 +254,10 @@ impl Document {
let key: &~str = &null_str_as_empty(id);
// TODO: "in tree order, within the context object's tree"
// http://dom.spec.whatwg.org/#dom-document-getelementbyid.
- self.idmap.find_equiv(key).map(|node| **node)
+ match self.idmap.find_equiv(key) {
+ None => None,
+ Some(node) => Some(*node),
+ }
}
pub fn CreateElement(&self, abstract_self: AbstractDocument, local_name: &DOMString) -> Fallible<AbstractNode<ScriptView>> {
@@ -321,7 +324,7 @@ impl Document {
Some(root) => {
for node in root.traverse_preorder() {
if node.type_id() != ElementNodeTypeId(HTMLTitleElementTypeId) {
- loop;
+ continue;
}
for child in node.children() {
if child.is_text() {
@@ -355,12 +358,12 @@ impl Document {
Some(root) => {
for node in root.traverse_preorder() {
if node.type_id() != ElementNodeTypeId(HTMLHeadElementTypeId) {
- loop;
+ continue;
}
let mut has_title = false;
for child in node.children() {
if child.type_id() != ElementNodeTypeId(HTMLTitleElementTypeId) {
- loop;
+ continue;
}
has_title = true;
for title_child in child.children() {
@@ -526,7 +529,7 @@ fn foreach_ided_elements(root: &AbstractNode<ScriptView>,
callback: &fn(&~str, &AbstractNode<ScriptView>)) {
for node in root.traverse_preorder() {
if !node.is_element() {
- loop;
+ continue;
}
do node.with_imm_element |element| {
diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs
index 2ee2e8ade5a..2babf101e6b 100644
--- a/src/components/script/dom/element.rs
+++ b/src/components/script/dom/element.rs
@@ -133,7 +133,7 @@ impl ElementLike for Element {
fn get_attr<'a>(&'a self, name: &str) -> Option<&'a str> {
// FIXME: only case-insensitive in the HTML namespace (as opposed to SVG, etc.)
let name = name.to_ascii_lower();
- let value: Option<&str> = self.attrs.find_equiv(&name).map(|&value| {
+ let value: Option<&str> = self.attrs.find_equiv(&name).map(|value| {
let value: &str = *value;
value
});
@@ -296,10 +296,10 @@ impl Element {
let scope = win.reflector().get_jsobject();
let rects = do rects.map |r| {
ClientRect::new(
- r.origin.y.to_f32(),
- (r.origin.y + r.size.height).to_f32(),
- r.origin.x.to_f32(),
- (r.origin.x + r.size.width).to_f32(),
+ r.origin.y.to_f32().unwrap(),
+ (r.origin.y + r.size.height).to_f32().unwrap(),
+ r.origin.x.to_f32().unwrap(),
+ (r.origin.x + r.size.width).to_f32().unwrap(),
cx,
scope)
};
@@ -320,10 +320,10 @@ impl Element {
let cx = win.get_cx();
let scope = win.reflector().get_jsobject();
ClientRect::new(
- rect.origin.y.to_f32(),
- (rect.origin.y + rect.size.height).to_f32(),
- rect.origin.x.to_f32(),
- (rect.origin.x + rect.size.width).to_f32(),
+ rect.origin.y.to_f32().unwrap(),
+ (rect.origin.y + rect.size.height).to_f32().unwrap(),
+ rect.origin.x.to_f32().unwrap(),
+ (rect.origin.x + rect.size.width).to_f32().unwrap(),
cx,
scope)
}
diff --git a/src/components/script/dom/formdata.rs b/src/components/script/dom/formdata.rs
index b6879f9b81d..cc3f1d6b6ab 100644
--- a/src/components/script/dom/formdata.rs
+++ b/src/components/script/dom/formdata.rs
@@ -46,7 +46,7 @@ impl FormData {
pub fn Append(&mut self, name: &DOMString, value: @mut Blob, filename: Option<DOMString>) {
let blob = BlobData {
blob: value,
- name: filename.unwrap_or_default(Some(~"default"))
+ name: filename.unwrap_or(Some(~"default"))
};
self.data.insert(null_str_as_empty(name), blob);
}
diff --git a/src/components/script/dom/htmliframeelement.rs b/src/components/script/dom/htmliframeelement.rs
index 61b6f7a27f6..bbe98d4565e 100644
--- a/src/components/script/dom/htmliframeelement.rs
+++ b/src/components/script/dom/htmliframeelement.rs
@@ -44,7 +44,7 @@ struct IFrameSize {
impl IFrameSize {
pub fn set_rect(&mut self, rect: Rect<f32>) {
let future_chan = replace(&mut self.future_chan, None);
- do future_chan.map_move |future_chan| {
+ do future_chan.map |future_chan| {
let Size2D { width, height } = rect.size;
future_chan.send(Size2D(width as uint, height as uint));
};
diff --git a/src/components/script/dom/htmlimageelement.rs b/src/components/script/dom/htmlimageelement.rs
index dc60d560743..49010ee0f62 100644
--- a/src/components/script/dom/htmlimageelement.rs
+++ b/src/components/script/dom/htmlimageelement.rs
@@ -45,7 +45,7 @@ impl HTMLImageElement {
if "src" == name {
let document = self.htmlelement.element.node.owner_doc();
let window = document.document().window;
- let url = window.page.url.map(|&(ref url, _)| url.clone());
+ let url = window.page.url.as_ref().map(|&(ref url, _)| url.clone());
self.update_image(window.image_cache_task.clone(), url);
}
}
diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs
index 6169864edac..913812fa594 100644
--- a/src/components/script/dom/node.rs
+++ b/src/components/script/dom/node.rs
@@ -455,7 +455,9 @@ impl<'self, View> AbstractNode<View> {
impl<View> Iterator<AbstractNode<View>> for AbstractNodeChildrenIterator<View> {
fn next(&mut self) -> Option<AbstractNode<View>> {
let node = self.current_node;
- self.current_node = self.current_node.chain(|node| node.next_sibling());
+ self.current_node = do self.current_node.and_then |node| {
+ node.next_sibling()
+ };
node
}
}
diff --git a/src/components/script/dom/window.rs b/src/components/script/dom/window.rs
index 6f1e931586e..8f9994458fb 100644
--- a/src/components/script/dom/window.rs
+++ b/src/components/script/dom/window.rs
@@ -27,7 +27,6 @@ use std::io;
use std::ptr;
use std::int;
use std::libc;
-use std::rt::rtio::RtioTimer;
use std::rt::io::timer::Timer;
use std::task::spawn_with;
use js::jsapi::JSVal;
@@ -58,7 +57,7 @@ impl Window {
#[unsafe_destructor]
impl Drop for Window {
- fn drop(&self) {
+ fn drop(&mut self) {
self.timer_chan.send(TimerMessage_Close);
}
}
diff --git a/src/components/script/html/cssparse.rs b/src/components/script/html/cssparse.rs
index 3123a2d24e8..e6383599d39 100644
--- a/src/components/script/html/cssparse.rs
+++ b/src/components/script/html/cssparse.rs
@@ -10,7 +10,7 @@ use std::comm::Port;
use std::task;
use newcss::stylesheet::Stylesheet;
use newcss::util::DataStream;
-use servo_net::resource_task::{Load, LoadResponse, Payload, Done, ResourceTask};
+use servo_net::resource_task::{Load, LoadResponse, Payload, Done, ResourceTask, ProgressMsg};
use extra::url::Url;
/// Where a style sheet comes from.
@@ -41,7 +41,7 @@ pub fn spawn_css_parser(provenance: StylesheetProvenance,
return result_port;
}
-fn data_stream(provenance: StylesheetProvenance, resource_task: ResourceTask) -> DataStream {
+fn data_stream(provenance: StylesheetProvenance, resource_task: ResourceTask) -> @mut DataStream {
match provenance {
UrlProvenance(url) => {
debug!("cssparse: loading style sheet at %s", url.to_str());
@@ -55,26 +55,44 @@ fn data_stream(provenance: StylesheetProvenance, resource_task: ResourceTask) ->
}
}
-fn resource_port_to_data_stream(input_port: Port<LoadResponse>) -> DataStream {
+fn resource_port_to_data_stream(input_port: Port<LoadResponse>) -> @mut DataStream {
let progress_port = input_port.recv().progress_port;
- return || {
- match progress_port.recv() {
- Payload(data) => Some(data),
- Done(*) => None
+ struct ResourcePortDataStream {
+ progress_port: Port<ProgressMsg>,
+ };
+ impl DataStream for ResourcePortDataStream {
+ fn read(&mut self) -> Option<~[u8]> {
+ match self.progress_port.recv() {
+ Payload(data) => Some(data),
+ Done(*) => None
+ }
}
}
+ let stream = @mut ResourcePortDataStream {
+ progress_port: progress_port,
+ };
+ stream as @mut DataStream
}
-fn data_to_data_stream(data: ~str) -> DataStream {
+fn data_to_data_stream(data: ~str) -> @mut DataStream {
let data_cell = Cell::new(data);
- return || {
- if data_cell.is_empty() {
- None
- } else {
- // FIXME: Blech, a copy.
- let data = data_cell.take();
- Some(data.as_bytes().to_owned())
+ struct DataDataStream {
+ data_cell: Cell<~str>,
+ };
+ impl DataStream for DataDataStream {
+ fn read(&mut self) -> Option<~[u8]> {
+ if self.data_cell.is_empty() {
+ None
+ } else {
+ // FIXME: Blech, a copy.
+ let data = self.data_cell.take();
+ Some(data.as_bytes().to_owned())
+ }
}
}
+ let stream = @mut DataDataStream {
+ data_cell: data_cell,
+ };
+ stream as @mut DataStream
}
diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs
index 7aba3987f53..66d85e0dfac 100644
--- a/src/components/script/html/hubbub_html_parser.rs
+++ b/src/components/script/html/hubbub_html_parser.rs
@@ -29,7 +29,7 @@ use servo_net::resource_task::{Load, Payload, Done, ResourceTask, load_whole_res
use servo_util::tree::{TreeNodeRef, ElementLike};
use servo_util::url::make_url;
use extra::url::Url;
-use extra::future::{Future, from_port};
+use extra::future::Future;
use geom::size::Size2D;
macro_rules! handle_element(
@@ -431,7 +431,7 @@ pub fn parse_html(cx: *JSContext,
// Size future
let (port, chan) = comm::oneshot();
- let size_future = from_port(port);
+ let size_future = Future::from_port(port);
// Subpage Id
let subpage_id = next_subpage_id.take();
diff --git a/src/components/script/script.rc b/src/components/script/script.rc
index 3fd36ee3724..9aa5f2f3a76 100644
--- a/src/components/script/script.rc
+++ b/src/components/script/script.rc
@@ -11,6 +11,8 @@
#[license = "MPL"];
#[crate_type = "lib"];
+#[feature(globs, macro_rules, struct_variant)];
+
extern mod geom;
extern mod gfx (name = "gfx");
extern mod hubbub;
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs
index 43a87eca228..e710dfb6d95 100644
--- a/src/components/script/script_task.rs
+++ b/src/components/script/script_task.rs
@@ -48,7 +48,7 @@ use servo_net::resource_task::ResourceTask;
use servo_util::tree::{TreeNodeRef, ElementLike};
use servo_util::url::make_url;
use extra::url::Url;
-use extra::future::{from_value, Future};
+use extra::future::Future;
/// Messages used to control the script task.
pub enum ScriptMsg {
@@ -178,7 +178,7 @@ impl PageTree {
self.inner.mut_iter()
.enumerate()
.find(|&(_idx, ref page_tree)| page_tree.page.id == id)
- .map(|&(idx, _)| idx)
+ .map(|(idx, _)| idx)
};
match remove_idx {
Some(idx) => return Some(self.inner.remove(idx)),
@@ -608,7 +608,7 @@ impl ScriptTask {
fn handle_resize_inactive_msg(&mut self, id: PipelineId, new_size: Size2D<uint>) {
let page = self.page_tree.find(id).expect("Received resize message for PipelineId not associated
with a page in the page tree. This is a bug.").page;
- page.window_size = from_value(new_size);
+ page.window_size = Future::from_value(new_size);
let last_loaded_url = replace(&mut page.url, None);
for url in last_loaded_url.iter() {
page.url = Some((url.first(), true));
@@ -780,7 +780,7 @@ impl ScriptTask {
ResizeEvent(new_width, new_height) => {
debug!("script got resize event: %u, %u", new_width, new_height);
- page.window_size = from_value(Size2D(new_width, new_height));
+ page.window_size = Future::from_value(Size2D(new_width, new_height));
if page.frame.is_some() {
page.damage(ReflowDocumentDamage);
@@ -845,12 +845,12 @@ impl ScriptTask {
let attr = element.get_attr("href");
for href in attr.iter() {
debug!("ScriptTask: clicked on link to %s", *href);
- let current_url = do page.url.map |&(ref url, _)| {
+ let current_url = do page.url.as_ref().map |&(ref url, _)| {
url.clone()
};
debug!("ScriptTask: current url is %?", current_url);
let url = make_url(href.to_owned(), current_url);
- self.constellation_chan.send(LoadUrlMsg(page.id, url, from_value(page.window_size.get())));
+ self.constellation_chan.send(LoadUrlMsg(page.id, url, Future::from_value(page.window_size.get())));
}
}
}
diff --git a/src/components/style/common_types.rs b/src/components/style/common_types.rs
index 96341e5d286..be3e87bb072 100644
--- a/src/components/style/common_types.rs
+++ b/src/components/style/common_types.rs
@@ -77,7 +77,7 @@ pub mod specified {
-> Option<LengthOrPercentage> {
match input {
&Dimension(ref value, ref unit) if negative_ok || value.value >= 0.
- => Length::parse_dimension(value.value, unit.as_slice()).map_move(LP_Length),
+ => Length::parse_dimension(value.value, unit.as_slice()).map(LP_Length),
&ast::Percentage(ref value) if negative_ok || value.value >= 0.
=> Some(LP_Percentage(value.value / 100.)),
&Number(ref value) if value.value == 0. => Some(LP_Length(Au_(Au(0)))),
@@ -105,7 +105,7 @@ pub mod specified {
-> Option<LengthOrPercentageOrAuto> {
match input {
&Dimension(ref value, ref unit) if negative_ok || value.value >= 0.
- => Length::parse_dimension(value.value, unit.as_slice()).map_move(LPA_Length),
+ => Length::parse_dimension(value.value, unit.as_slice()).map(LPA_Length),
&ast::Percentage(ref value) if negative_ok || value.value >= 0.
=> Some(LPA_Percentage(value.value / 100.)),
&Number(ref value) if value.value == 0. => Some(LPA_Length(Au_(Au(0)))),
diff --git a/src/components/style/media_queries.rs b/src/components/style/media_queries.rs
index 3266130fcf1..0c6e39e16a9 100644
--- a/src/components/style/media_queries.rs
+++ b/src/components/style/media_queries.rs
@@ -91,11 +91,15 @@ pub fn parse_media_query_list(input: &[ComponentValue]) -> MediaQueryList {
};
match iter.next() {
None => {
- mq.map_move(|mq| queries.push(mq));
+ for mq in mq.move_iter() {
+ queries.push(mq);
+ }
return MediaQueryList{ media_queries: queries }
},
Some(&Comma) => {
- mq.map_move(|mq| queries.push(mq));
+ for mq in mq.move_iter() {
+ queries.push(mq);
+ }
},
// Ingnore this comma-separated part
_ => loop {
diff --git a/src/components/style/properties.rs.mako b/src/components/style/properties.rs.mako
index 7e5425f78ed..e507ee132a7 100644
--- a/src/components/style/properties.rs.mako
+++ b/src/components/style/properties.rs.mako
@@ -5,7 +5,7 @@
// This file is a Mako template: http://www.makotemplates.org/
use std::ascii::StrAsciiExt;
-pub use std::iterator;
+pub use std::iter;
pub use cssparser::*;
pub use errors::{ErrorLoggerIterator, log_css_error};
pub use parsing_utils::*;
@@ -86,7 +86,7 @@ pub mod longhands {
${caller.body()}
pub fn parse_specified(input: &[ComponentValue])
-> Option<DeclaredValue<SpecifiedValue>> {
- parse(input).map_move(super::SpecifiedValue)
+ parse(input).map(super::SpecifiedValue)
}
</%self:raw_longhand>
</%def>
@@ -95,7 +95,7 @@ pub mod longhands {
<%self:longhand name="${name}" inherited="${inherited}">
${caller.body()}
pub fn parse(input: &[ComponentValue]) -> Option<SpecifiedValue> {
- one_component_value(input).chain(from_component_value)
+ one_component_value(input).and_then(from_component_value)
}
</%self:longhand>
</%def>
@@ -117,7 +117,7 @@ pub mod longhands {
${to_rust_ident(values.split()[0])}
}
pub fn from_component_value(v: &ComponentValue) -> Option<SpecifiedValue> {
- do get_ident_lower(v).chain |keyword| {
+ do get_ident_lower(v).and_then |keyword| {
match keyword.as_slice() {
% for value in values.split():
"${value}" => Some(${to_rust_ident(value)}),
@@ -201,7 +201,7 @@ pub mod longhands {
Au::from_px(3) // medium
}
pub fn parse(input: &[ComponentValue]) -> Option<SpecifiedValue> {
- one_component_value(input).chain(parse_border_width)
+ one_component_value(input).and_then(parse_border_width)
}
pub fn to_computed_value(value: SpecifiedValue, context: &computed::Context)
-> computed_value::T {
@@ -252,7 +252,7 @@ pub mod longhands {
=> Some(SpecifiedLength(specified::Em(value.value / 100.))),
&Dimension(ref value, ref unit) if value.value >= 0.
=> specified::Length::parse_dimension(value.value, unit.as_slice())
- .map_move(SpecifiedLength),
+ .map(SpecifiedLength),
&Ident(ref value) if value.eq_ignore_ascii_case("normal")
=> Some(SpecifiedNormal),
_ => None,
@@ -299,7 +299,7 @@ pub mod longhands {
_ => None,
},
_ => specified::LengthOrPercentage::parse_non_negative(input)
- .map_move(SpecifiedLengthOrPercentage)
+ .map(SpecifiedLengthOrPercentage)
}
}
pub mod computed_value {
@@ -356,7 +356,7 @@ pub mod longhands {
RGBA { red: 0., green: 0., blue: 0., alpha: 1. } /* black */
}
pub fn parse_specified(input: &[ComponentValue]) -> Option<DeclaredValue<SpecifiedValue>> {
- match one_component_value(input).chain(Color::parse) {
+ match one_component_value(input).and_then(Color::parse) {
Some(RGBA(rgba)) => Some(SpecifiedValue(rgba)),
Some(CurrentColor) => Some(CSSWideKeyword(Inherit)),
None => None,
@@ -535,7 +535,7 @@ pub mod longhands {
/// <length> | <percentage>
/// TODO: support <absolute-size> and <relative-size>
pub fn from_component_value(input: &ComponentValue) -> Option<SpecifiedValue> {
- do specified::LengthOrPercentage::parse_non_negative(input).map_move |value| {
+ do specified::LengthOrPercentage::parse_non_negative(input).map |value| {
match value {
specified::LP_Length(value) => value,
specified::LP_Percentage(value) => specified::Em(value),
@@ -633,10 +633,10 @@ pub mod shorthands {
// two values set (top, bottom) and (left, right)
// three values set top, (left, right) and bottom
// four values set them in order
- let top = iter.next().unwrap_or_default(None);
- let right = iter.next().unwrap_or_default(top);
- let bottom = iter.next().unwrap_or_default(top);
- let left = iter.next().unwrap_or_default(right);
+ let top = iter.next().unwrap_or(None);
+ let right = iter.next().unwrap_or(top);
+ let bottom = iter.next().unwrap_or(top);
+ let left = iter.next().unwrap_or(right);
if top.is_some() && right.is_some() && bottom.is_some() && left.is_some()
&& iter.next().is_none() {
Some(Longhands {
@@ -653,7 +653,7 @@ pub mod shorthands {
// TODO: other background-* properties
<%self:shorthand name="background" sub_properties="background-color">
- do one_component_value(input).chain(specified::CSSColor::parse).map_move |color| {
+ do one_component_value(input).and_then(specified::CSSColor::parse).map |color| {
Longhands { background_color: Some(color) }
}
</%self:shorthand>
@@ -677,19 +677,19 @@ pub mod shorthands {
for component_value in input.skip_whitespace() {
if color.is_none() {
match specified::CSSColor::parse(component_value) {
- Some(c) => { color = Some(c); any = true; loop },
+ Some(c) => { color = Some(c); any = true; continue },
None => ()
}
}
if style.is_none() {
match border_top_style::from_component_value(component_value) {
- Some(s) => { style = Some(s); any = true; loop },
+ Some(s) => { style = Some(s); any = true; continue },
None => ()
}
}
if width.is_none() {
match parse_border_width(component_value) {
- Some(w) => { width = Some(w); any = true; loop },
+ Some(w) => { width = Some(w); any = true; continue },
None => ()
}
}
@@ -704,7 +704,7 @@ pub mod shorthands {
'border-%s-%s' % (side, prop)
for prop in ['color', 'style', 'width']
)}">
- do parse_border(input).map_move |(color, style, width)| {
+ do parse_border(input).map |(color, style, width)| {
Longhands {
% for prop in ["color", "style", "width"]:
${"border_%s_%s: %s," % (side, prop, prop)}
@@ -719,7 +719,7 @@ pub mod shorthands {
for side in ['top', 'right', 'bottom', 'left']
for prop in ['color', 'style', 'width']
)}">
- do parse_border(input).map_move |(color, style, width)| {
+ do parse_border(input).map |(color, style, width)| {
Longhands {
% for side in ["top", "right", "bottom", "left"]:
% for prop in ["color", "style", "width"]:
@@ -746,23 +746,23 @@ pub mod shorthands {
if get_ident_lower(component_value).filtered(
|v| v.eq_ignore_ascii_case("normal")).is_some() {
nb_normals += 1;
- loop;
+ continue;
}
if style.is_none() {
match font_style::from_component_value(component_value) {
- Some(s) => { style = Some(s); loop },
+ Some(s) => { style = Some(s); continue },
None => ()
}
}
if weight.is_none() {
match font_weight::from_component_value(component_value) {
- Some(w) => { weight = Some(w); loop },
+ Some(w) => { weight = Some(w); continue },
None => ()
}
}
if variant.is_none() {
match font_variant::from_component_value(component_value) {
- Some(v) => { variant = Some(v); loop },
+ Some(v) => { variant = Some(v); continue },
None => ()
}
}
@@ -852,7 +852,7 @@ struct Unset;
impl CSSWideKeyword {
pub fn parse(input: &[ComponentValue]) -> Option<Either<CSSWideKeyword, Unset>> {
- do one_component_value(input).chain(get_ident_lower).chain |keyword| {
+ do one_component_value(input).and_then(get_ident_lower).and_then |keyword| {
match keyword.as_slice() {
"initial" => Some(Left(Initial)),
"inherit" => Some(Left(Inherit)),
diff --git a/src/components/style/selectors.rs b/src/components/style/selectors.rs
index 4a2ed8caed3..11077d8d029 100644
--- a/src/components/style/selectors.rs
+++ b/src/components/style/selectors.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use std::{vec, iterator};
+use std::{vec, iter};
use std::ascii::StrAsciiExt;
use cssparser::*;
use namespaces::NamespaceMap;
@@ -73,7 +73,7 @@ pub struct AttrSelector {
}
-type Iter = iterator::Peekable<ComponentValue, vec::MoveIterator<ComponentValue>>;
+type Iter = iter::Peekable<ComponentValue, vec::MoveIterator<ComponentValue>>;
// None means invalid selector
@@ -310,7 +310,7 @@ fn parse_qualified_name(iter: &mut Iter, allow_universal: bool, namespaces: &Nam
#[inline]
fn default_namespace(namespaces: &NamespaceMap, local_name: Option<~str>)
-> Option<Option<(Option<~str>, Option<~str>)>> {
- Some(Some((namespaces.default.map(|url| url.to_owned()), local_name)))
+ Some(Some((namespaces.default.as_ref().map(|url| url.to_owned()), local_name)))
}
#[inline]
diff --git a/src/components/style/style.rc b/src/components/style/style.rc
index c926e41649d..d005e81bd70 100644
--- a/src/components/style/style.rc
+++ b/src/components/style/style.rc
@@ -11,6 +11,7 @@
#[license = "MPL"];
#[crate_type = "lib"];
+#[feature(globs, macro_rules)];
extern mod extra;
extern mod cssparser;
diff --git a/src/components/style/stylesheets.rs b/src/components/style/stylesheets.rs
index e3c8d5a6ad8..b54ad06e5ca 100644
--- a/src/components/style/stylesheets.rs
+++ b/src/components/style/stylesheets.rs
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::str;
-use std::iterator::Iterator;
+use std::iter::Iterator;
use std::ascii::StrAsciiExt;
use cssparser::*;
use selectors;
diff --git a/src/components/util/debug.rs b/src/components/util/debug.rs
index 1c4549fc27a..67a1d7d5f21 100644
--- a/src/components/util/debug.rs
+++ b/src/components/util/debug.rs
@@ -5,7 +5,7 @@
use std::io;
use std::vec::raw::buf_as_slice;
use std::cast::transmute;
-use std::sys::size_of;
+use std::mem::size_of;
fn hexdump_slice(buf: &[u8]) {
let stderr = io::stderr();
diff --git a/src/components/util/geometry.rs b/src/components/util/geometry.rs
index b89d0f29343..4acc8d8dd72 100644
--- a/src/components/util/geometry.rs
+++ b/src/components/util/geometry.rs
@@ -57,23 +57,19 @@ pub fn min(x: Au, y: Au) -> Au { if x < y { x } else { y } }
pub fn max(x: Au, y: Au) -> Au { if x > y { x } else { y } }
impl NumCast for Au {
- fn from<T:NumCast>(n: T) -> Au { Au(n.to_i32()) }
-
- fn to_u8(&self) -> u8 { (**self).to_u8() }
- fn to_u16(&self) -> u16 { (**self).to_u16() }
- fn to_u32(&self) -> u32 { (**self).to_u32() }
- fn to_u64(&self) -> u64 { (**self).to_u64() }
- fn to_uint(&self) -> uint { (**self).to_uint() }
+ fn from<T:ToPrimitive>(n: T) -> Option<Au> {
+ Some(Au(n.to_i32().unwrap()))
+ }
+}
- fn to_i8(&self) -> i8 { (**self).to_i8() }
- fn to_i16(&self) -> i16 { (**self).to_i16() }
- fn to_i32(&self) -> i32 { (**self).to_i32() }
- fn to_i64(&self) -> i64 { (**self).to_i64() }
- fn to_int(&self) -> int { (**self).to_int() }
+impl ToPrimitive for Au {
+ fn to_i64(&self) -> Option<i64> {
+ Some(**self as i64)
+ }
- fn to_f32(&self) -> f32 { (**self).to_f32() }
- fn to_f64(&self) -> f64 { (**self).to_f64() }
- fn to_float(&self) -> float { (**self).to_float() }
+ fn to_u64(&self) -> Option<u64> {
+ Some(**self as u64)
+ }
}
pub fn box<T:Clone + Ord + Add<T,T> + Sub<T,T>>(x: T, y: T, w: T, h: T) -> Rect<T> {
@@ -81,16 +77,16 @@ pub fn box<T:Clone + Ord + Add<T,T> + Sub<T,T>>(x: T, y: T, w: T, h: T) -> Rect<
}
impl Au {
- pub fn scale_by(self, factor: float) -> Au {
- Au(((*self as float) * factor).round() as i32)
+ pub fn scale_by(self, factor: f64) -> Au {
+ Au(((*self as f64) * factor).round() as i32)
}
pub fn from_px(px: int) -> Au {
- NumCast::from(px * 60)
+ NumCast::from(px * 60).unwrap()
}
pub fn to_nearest_px(&self) -> int {
- ((**self as float) / 60f).round() as int
+ ((**self as f64) / 60f64).round() as int
}
pub fn to_snapped(&self) -> Au {
@@ -108,12 +104,12 @@ impl Au {
Rect(Point2D(z, z), Size2D(z, z))
}
- pub fn from_pt(pt: float) -> Au {
+ pub fn from_pt(pt: f64) -> Au {
from_px(pt_to_px(pt) as int)
}
- pub fn from_frac_px(px: float) -> Au {
- Au((px * 60f) as i32)
+ pub fn from_frac_px(px: f64) -> Au {
+ Au((px * 60f64) as i32)
}
pub fn min(x: Au, y: Au) -> Au { if *x < *y { x } else { y } }
@@ -121,13 +117,13 @@ impl Au {
}
// assumes 72 points per inch, and 96 px per inch
-pub fn pt_to_px(pt: float) -> float {
- pt / 72f * 96f
+pub fn pt_to_px(pt: f64) -> f64 {
+ pt / 72f64 * 96f64
}
// assumes 72 points per inch, and 96 px per inch
-pub fn px_to_pt(px: float) -> float {
- px / 96f * 72f
+pub fn px_to_pt(px: f64) -> f64 {
+ px / 96f64 * 72f64
}
pub fn zero_rect() -> Rect<Au> {
@@ -143,23 +139,23 @@ pub fn zero_size() -> Size2D<Au> {
Size2D(Au(0), Au(0))
}
-pub fn from_frac_px(px: float) -> Au {
- Au((px * 60f) as i32)
+pub fn from_frac_px(px: f64) -> Au {
+ Au((px * 60f64) as i32)
}
pub fn from_px(px: int) -> Au {
- NumCast::from(px * 60)
+ NumCast::from(px * 60).unwrap()
}
pub fn to_px(au: Au) -> int {
(*au / 60) as int
}
-pub fn to_frac_px(au: Au) -> float {
- (*au as float) / 60f
+pub fn to_frac_px(au: Au) -> f64 {
+ (*au as f64) / 60f64
}
// assumes 72 points per inch, and 96 px per inch
-pub fn from_pt(pt: float) -> Au {
- from_px((pt / 72f * 96f) as int)
+pub fn from_pt(pt: f64) -> Au {
+ from_px((pt / 72f64 * 96f64) as int)
}
diff --git a/src/components/util/range.rs b/src/components/util/range.rs
index 6f3ce3e9e86..a0943728a77 100644
--- a/src/components/util/range.rs
+++ b/src/components/util/range.rs
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::cmp::{max, min};
-use std::iterator;
+use std::iter;
enum RangeRelation {
OverlapsBegin(/* overlap */ uint),
@@ -36,7 +36,7 @@ impl Range {
pub fn length(&self) -> uint { self.len }
pub fn end(&self) -> uint { self.off + self.len }
- pub fn eachi(&self) -> iterator::Range<uint> {
+ pub fn eachi(&self) -> iter::Range<uint> {
range(self.off, self.off + self.len)
}
diff --git a/src/components/util/time.rs b/src/components/util/time.rs
index 58985410c54..35186ef3fa5 100644
--- a/src/components/util/time.rs
+++ b/src/components/util/time.rs
@@ -4,7 +4,7 @@
// Timing functions.
use std::comm::{Port, SharedChan};
-use std::iterator::AdditiveIterator;
+use std::iter::AdditiveIterator;
use std::rt::io::timer::Timer;
use std::task::spawn_with;
@@ -23,7 +23,7 @@ impl ProfilerChan {
pub enum ProfilerMsg {
// Normal message used for reporting time
- TimeMsg(ProfilerCategory, float),
+ TimeMsg(ProfilerCategory, f64),
// Message used to force print the profiling metrics
PrintMsg,
}
@@ -85,7 +85,7 @@ impl ProfilerCategory {
}
}
-type ProfilerBuckets = TreeMap<ProfilerCategory, ~[float]>;
+type ProfilerBuckets = TreeMap<ProfilerCategory, ~[f64]>;
// back end of the profiler that handles data aggregation and performance metrics
pub struct Profiler {
@@ -95,10 +95,10 @@ pub struct Profiler {
}
impl Profiler {
- pub fn create(port: Port<ProfilerMsg>, chan: ProfilerChan, period: Option<float>) {
+ pub fn create(port: Port<ProfilerMsg>, chan: ProfilerChan, period: Option<f64>) {
match period {
Some(period) => {
- let period = (period * 1000f) as u64;
+ let period = (period * 1000f64) as u64;
do spawn {
let mut timer = Timer::new().unwrap();
loop {
@@ -164,7 +164,7 @@ impl Profiler {
let data_len = data.len();
if data_len > 0 {
let (mean, median, &min, &max) =
- (data.iter().map(|&x|x).sum() / (data_len as float),
+ (data.iter().map(|&x|x).sum() / (data_len as f64),
data[data_len / 2],
data.iter().min().unwrap(),
data.iter().max().unwrap());
@@ -184,7 +184,7 @@ pub fn profile<T>(category: ProfilerCategory,
let start_time = precise_time_ns();
let val = callback();
let end_time = precise_time_ns();
- let ms = ((end_time - start_time) as float / 1000000f);
+ let ms = ((end_time - start_time) as f64 / 1000000f64);
profiler_chan.send(TimeMsg(category, ms));
return val;
}
@@ -193,8 +193,8 @@ pub fn time<T>(msg: &str, callback: &fn() -> T) -> T{
let start_time = precise_time_ns();
let val = callback();
let end_time = precise_time_ns();
- let ms = ((end_time - start_time) as float / 1000000f);
- if ms >= 5f {
+ let ms = ((end_time - start_time) as f64 / 1000000f64);
+ if ms >= 5f64 {
debug!("%s took %? ms", msg, ms);
}
return val;
diff --git a/src/components/util/url.rs b/src/components/util/url.rs
index a2a3b07d537..309117081ec 100644
--- a/src/components/util/url.rs
+++ b/src/components/util/url.rs
@@ -27,7 +27,10 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
if str_url.starts_with("/") {
~"file://" + str_url
} else {
- ~"file://" + os::getcwd().push(str_url).to_str()
+ let mut path = os::getcwd();
+ path.push(str_url);
+ // FIXME (#1094): not the right way to transform a path
+ ~"file://" + path.display().to_str()
}
} else {
let current_url = current_url.unwrap();
@@ -57,7 +60,12 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
match scheme {
~"about" => {
match page {
- ~"failure" => ~"file://" + os::getcwd().push("../src/test/html/failure.html").to_str(),
+ ~"failure" => {
+ let mut path = os::getcwd();
+ path.push("../src/test/html/failure.html");
+ // FIXME (#1094): not the right way to transform a path
+ ~"file://" + path.display().to_str()
+ }
// TODO: handle the rest of the about: pages
_ => str_url
}
@@ -88,7 +96,9 @@ mod make_url_tests {
let url = make_url(file, None);
debug!("url: %?", url);
assert!(url.scheme == ~"file");
- assert!(url.path.contains(os::getcwd().to_str()));
+ let path = os::getcwd();
+ // FIXME (#1094): not the right way to transform a path
+ assert!(url.path.contains(path.display().to_str()));
}
#[test]
diff --git a/src/components/util/util.rc b/src/components/util/util.rc
index 946ffb21f4a..bbcf7203740 100644
--- a/src/components/util/util.rc
+++ b/src/components/util/util.rc
@@ -8,6 +8,8 @@
url = "http://servo.org/")];
#[crate_type = "lib"];
+#[feature(macro_rules)];
+
extern mod extra;
extern mod geom;
diff --git a/src/components/util/vec.rs b/src/components/util/vec.rs
index 93c900192de..76ddb5cd978 100644
--- a/src/components/util/vec.rs
+++ b/src/components/util/vec.rs
@@ -11,7 +11,7 @@ pub trait BinarySearchMethods<'self, T: Ord + Eq> {
impl<'self, T: Ord + Eq> BinarySearchMethods<'self, T> for &'self [T] {
fn binary_search(&self, key: &T) -> Option<&'self T> {
- self.binary_search_index(key).map(|i| &self[*i])
+ self.binary_search_index(key).map(|i| &self[i])
}
fn binary_search_index(&self, key: &T) -> Option<uint> {
diff --git a/src/platform/linux/rust-fontconfig b/src/platform/linux/rust-fontconfig
-Subproject af20d6eea6eb4efe31f7f883e8d7073b2bd692a
+Subproject a1e265ebb541c0402d5ce7a1e7dfdeaeac340fe
diff --git a/src/platform/linux/rust-freetype b/src/platform/linux/rust-freetype
-Subproject 9621863ca3147412e78782122873d316b8a0f73
+Subproject 710a4f1ac7bb5d6732b712574a7cfa098f804d0
diff --git a/src/platform/linux/rust-xlib b/src/platform/linux/rust-xlib
-Subproject 4e8043abbf103805fd6bb3708e111a4220d4280
+Subproject deefb42dd238f54f95bf09f47d19e1c2acfd1c7
diff --git a/src/platform/macos/rust-cocoa b/src/platform/macos/rust-cocoa
-Subproject fcc8d5865e0002d8d75f1098e956c120d8131c8
+Subproject ff58b354ffa18f0ea8c9acfe05eb6589b2e3156
diff --git a/src/platform/macos/rust-core-foundation b/src/platform/macos/rust-core-foundation
-Subproject 7d71796ef24101422e17a4704b4a8389dd718ea
+Subproject b0565c60dc4327a534e6bbe24aac12f0939543a
diff --git a/src/platform/macos/rust-core-graphics b/src/platform/macos/rust-core-graphics
-Subproject adb526a6ca8deee37152ef3ba1197894286e220
+Subproject 747fb760771f07038267ae842a6fa1cb3558642
diff --git a/src/platform/macos/rust-core-text b/src/platform/macos/rust-core-text
-Subproject 129e99ff088fad6ea8f3187680c15a0a3e2cc40
+Subproject 95afade467fe16720bf812c0aa7cacdad1c745f
diff --git a/src/platform/macos/rust-io-surface b/src/platform/macos/rust-io-surface
-Subproject d685aad6f6ab3559c8de5ca76520b8f1e0e21b6
+Subproject 45e3f33cf6a3109b4dbb7bf9e0cb814d6e1e4b5
diff --git a/src/support/alert/rust-alert b/src/support/alert/rust-alert
-Subproject 6fbd1581ae7baede892c543c05f3509ded1ce8e
+Subproject b8215b6e727947648e58ed799f9616e683d9772
diff --git a/src/support/azure/rust-azure b/src/support/azure/rust-azure
-Subproject 71e4819490fa05b7841aab1722335da02473838
+Subproject 4690e855ac79f9a3a0bd8603eace36e4fd82cff
diff --git a/src/support/css/rust-css b/src/support/css/rust-css
-Subproject 6d44ce5cc97ccb3bfa9c06833b852921025d9b1
+Subproject f385f19b847a394abffb76875d84f960496f01d
diff --git a/src/support/css/rust-cssparser b/src/support/css/rust-cssparser
-Subproject a41aec5f184a9e587ad675d34b5da518d58c083
+Subproject db686662725cb0fe3b41877599564343f8fc186
diff --git a/src/support/geom/rust-geom b/src/support/geom/rust-geom
-Subproject 43a9dbb81bbd4fb3eb130484f87848a701ecf79
+Subproject b5212699f9ad364898b685f5f945b821ee52877
diff --git a/src/support/glfw/glfw b/src/support/glfw/glfw
-Subproject 738b78899bb271258f55ae842e180de2c5ec87d
+Subproject 63c7c8f877536869c3b71567943579b135835ad
diff --git a/src/support/glfw/glfw-rs b/src/support/glfw/glfw-rs
-Subproject a459a4491340f33bec7b09e33750106bfab864c
+Subproject 126ad38a33bf16e977cbb5d05c0c410a1c37345
diff --git a/src/support/harfbuzz/rust-harfbuzz b/src/support/harfbuzz/rust-harfbuzz
-Subproject 1ed1ed819a90fc6c559282d3a5c02fc8cf3fba0
+Subproject e29c85ecc7b0d61dcc669ce578c7957e88b617e
diff --git a/src/support/http/rust-http b/src/support/http/rust-http
-Subproject 852c2c439b2198989181d52e39e0e8cb28d6417
+Subproject c450d468c29f1105c47b408f744bd9660d9adc4
diff --git a/src/support/hubbub/rust-hubbub b/src/support/hubbub/rust-hubbub
-Subproject df7d4e1467a2341a4b4186d848df1d1d0adf9b7
+Subproject 38e8aa7422dc86d78fdb5d4571e24372d6db232
diff --git a/src/support/layers/rust-layers b/src/support/layers/rust-layers
-Subproject 8e469443a9fec36de8eec09036f8051723ee59b
+Subproject 716c3326d3d6073c48ecfb301c2ab6e7eeeccfc
diff --git a/src/support/netsurfcss/rust-netsurfcss b/src/support/netsurfcss/rust-netsurfcss
-Subproject f69e26f4d97316063b6c20f0c71d7568d8d42a7
+Subproject d94c0ab178fa06e7f270ea8c3a1d1202f4e23e1
diff --git a/src/support/opengles/rust-opengles b/src/support/opengles/rust-opengles
-Subproject 2079b5f8da888eca65ef0e61d0a9438c794f2d9
+Subproject 71dcba600f546d6c4daec56659e02c8db9fdf00
diff --git a/src/support/png/rust-png b/src/support/png/rust-png
-Subproject 698124d5994d99183cbc51d07d15d1c16b0f75a
+Subproject a06ce5aadebbc5fe3feea49583b741e1b96a0bf
diff --git a/src/support/sharegl/sharegl b/src/support/sharegl/sharegl
-Subproject 8dc1939cdf37dda742d4910e3265cf03c0fc960
+Subproject 96665d2033e5cda1ae419ce70a4071b61bc58b0
diff --git a/src/support/spidermonkey/rust-mozjs b/src/support/spidermonkey/rust-mozjs
-Subproject dc50fb7958312e8ee5b4a03db516bcafd6df3d5
+Subproject 4218161656d60a148332b589f1605641d99c589
diff --git a/src/support/stb-image/rust-stb-image b/src/support/stb-image/rust-stb-image
-Subproject fed8ed305e4bf0e3ff283da1a45768e5d2e19ed
+Subproject 0f55db952f5e5cd36f0f661e322e6c902ae172b
diff --git a/src/support/wapcaplet/rust-wapcaplet b/src/support/wapcaplet/rust-wapcaplet
-Subproject 881bdb753b3a51023d54b653cd88b7e26678847
+Subproject fa32f481eade263241c54bd3212f50466c802ea
diff --git a/src/test/harness/contenttest/contenttest.rs b/src/test/harness/contenttest/contenttest.rs
index 80714d5ad4f..861c758d62b 100644
--- a/src/test/harness/contenttest/contenttest.rs
+++ b/src/test/harness/contenttest/contenttest.rs
@@ -11,7 +11,7 @@ extern mod std;
extern mod extra;
use extra::test::{TestOpts, run_tests_console, TestDesc, TestDescAndFn, DynTestFn, DynTestName};
-use extra::getopts::{getopts, reqopt, opt_str, fail_str};
+use extra::getopts::{getopts, reqopt};
use std::{os, run, io, str};
use std::cell::Cell;
use std::os::list_dir_path;
@@ -35,11 +35,11 @@ fn parse_config(args: ~[~str]) -> Config {
let opts = ~[reqopt("source-dir")];
let matches = match getopts(args, opts) {
Ok(m) => m,
- Err(f) => fail!(fail_str(f))
+ Err(f) => fail!(f.to_err_msg())
};
Config {
- source_dir: opt_str(&matches, "source-dir"),
+ source_dir: matches.opt_str("source-dir").unwrap(),
filter: if matches.free.is_empty() {
None
} else {
@@ -63,9 +63,10 @@ fn test_options(config: Config) -> TestOpts {
}
fn find_tests(config: Config) -> ~[TestDescAndFn] {
- let mut files = list_dir_path(&Path(config.source_dir));
- files.retain( |file| file.to_str().ends_with(".html") );
- return files.map(|file| make_test((*file).to_str()) );
+ let mut files = list_dir_path(&Path::new(config.source_dir));
+ // FIXME (#1094): not the right way to transform a path
+ files.retain( |file| file.display().to_str().ends_with(".html") );
+ return files.map(|file| make_test(file.display().to_str()) );
}
fn make_test(file: ~str) -> TestDescAndFn {
@@ -81,7 +82,9 @@ fn make_test(file: ~str) -> TestDescAndFn {
}
fn run_test(file: ~str) {
- let infile = ~"file://" + os::make_absolute(&Path(file)).to_str();
+ let path = os::make_absolute(&Path::new(file));
+ // FIXME (#1094): not the right way to transform a path
+ let infile = ~"file://" + path.display().to_str();
let res = run::process_output("./servo", [infile]);
let out = str::from_utf8(res.output);
io::print(out);
diff --git a/src/test/harness/reftest/reftest.rs b/src/test/harness/reftest/reftest.rs
index 416ec680141..6f7c13a42ba 100644
--- a/src/test/harness/reftest/reftest.rs
+++ b/src/test/harness/reftest/reftest.rs
@@ -37,6 +37,7 @@ fn main() {
ratchet_noise_percent: None,
ratchet_metrics: None,
save_metrics: None,
+ test_shard: None,
};
if !run_tests_console(&test_opts, tests) {
@@ -59,7 +60,7 @@ struct Reftest {
fn parse_lists(filenames: &[~str]) -> ~[TestDescAndFn] {
let mut tests: ~[TestDescAndFn] = ~[];
for file in filenames.iter() {
- let file_path = Path(*file);
+ let file_path = Path::new(file.clone());
let contents = match io::read_whole_file_str(&file_path) {
Ok(x) => x,
Err(s) => fail!(s)
@@ -78,8 +79,8 @@ fn parse_lists(filenames: &[~str]) -> ~[TestDescAndFn] {
_ => fail!(fmt!("reftest line: '%s' has invalid kind '%s'",
line, parts[0]))
};
- let src_dir = file_path.dirname();
- let file_left = src_dir + "/" + parts[1];
+ let src_dir = file_path.dirname().to_str();
+ let file_left = src_dir + "/" + parts[1];
let file_right = src_dir + "/" + parts[2];
let reftest = Reftest {
@@ -114,17 +115,16 @@ fn check_reftest(reftest: Reftest) {
let id = gen_id(&reftest);
let left_filename = fmt!("/tmp/%s-left.png", id);
let right_filename = fmt!("/tmp/%s-right.png", id);
- let left_path = Path(left_filename);
- let right_path = Path(right_filename);
+ let left_path = Path::new(left_filename.clone());
+ let right_path = Path::new(right_filename.clone());
- let options = run::ProcessOptions::new();
let args = ~[~"-o", left_filename.clone(), reftest.left.clone()];
- let mut process = run::Process::new("./servo", args, options);
+ let mut process = run::Process::new("./servo", args, run::ProcessOptions::new());
let _retval = process.finish();
// assert!(retval == 0);
let args = ~[~"-o", right_filename.clone(), reftest.right.clone()];
- let mut process = run::Process::new("./servo", args, options);
+ let mut process = run::Process::new("./servo", args, run::ProcessOptions::new());
let _retval = process.finish();
// assert!(retval == 0);