aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
m---------src/compiler/rust0
-rw-r--r--src/components/gfx/display_list.rs2
-rw-r--r--src/components/gfx/font.rs6
-rw-r--r--src/components/gfx/font_list.rs2
-rw-r--r--src/components/gfx/platform/linux/font.rs5
-rw-r--r--src/components/gfx/platform/linux/font_context.rs2
-rw-r--r--src/components/gfx/platform/linux/font_list.rs2
-rw-r--r--src/components/gfx/platform/macos/font.rs7
-rw-r--r--src/components/gfx/render_task.rs2
-rw-r--r--src/components/gfx/text/glyph.rs12
-rw-r--r--src/components/gfx/text/shaping/harfbuzz.rs4
-rw-r--r--src/components/gfx/text/text_run.rs4
-rw-r--r--src/components/main/constellation.rs4
-rw-r--r--src/components/main/layout/block.rs10
-rw-r--r--src/components/main/layout/box.rs64
-rw-r--r--src/components/main/layout/float.rs8
-rw-r--r--src/components/main/layout/float_context.rs12
-rw-r--r--src/components/main/layout/flow.rs22
-rw-r--r--src/components/main/layout/inline.rs26
-rw-r--r--src/components/main/layout/model.rs67
-rw-r--r--src/components/main/layout/text.rs4
-rw-r--r--src/components/main/layout/util.rs14
-rw-r--r--src/components/main/pipeline.rs4
-rw-r--r--src/components/main/platform/common/glfw_windowing.rs24
-rw-r--r--src/components/main/platform/common/shared_gl_windowing.rs3
-rwxr-xr-xsrc/components/main/servo.rc2
-rw-r--r--src/components/main/util/task.rs4
-rw-r--r--src/components/main/windowing.rs5
-rw-r--r--src/components/net/image_cache_task.rs6
-rw-r--r--src/components/net/resource_task.rs2
-rw-r--r--src/components/net/util.rs2
-rw-r--r--src/components/script/dom/bindings/clientrect.rs62
-rw-r--r--src/components/script/dom/bindings/clientrectlist.rs45
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py2
-rw-r--r--src/components/script/dom/bindings/document.rs9
-rw-r--r--src/components/script/dom/bindings/element.rs17
-rw-r--r--src/components/script/dom/bindings/event.rs59
-rw-r--r--src/components/script/dom/bindings/eventtarget.rs61
-rw-r--r--src/components/script/dom/bindings/formdata.rs62
-rw-r--r--src/components/script/dom/bindings/htmlcollection.rs45
-rw-r--r--src/components/script/dom/bindings/node.rs36
-rw-r--r--src/components/script/dom/bindings/utils.rs18
-rw-r--r--src/components/script/dom/clientrect.rs54
-rw-r--r--src/components/script/dom/clientrectlist.rs39
-rw-r--r--src/components/script/dom/event.rs52
-rw-r--r--src/components/script/dom/eventtarget.rs58
-rw-r--r--src/components/script/dom/formdata.rs57
-rw-r--r--src/components/script/dom/htmlcollection.rs36
-rw-r--r--src/components/script/dom/node.rs34
-rw-r--r--src/components/script/dom/window.rs2
-rw-r--r--src/components/script/html/hubbub_html_parser.rs9
-rw-r--r--src/components/script/script.rc6
-rw-r--r--src/components/script/script_task.rs14
-rw-r--r--src/components/util/cache.rs4
-rw-r--r--src/components/util/time.rs4
-rw-r--r--src/components/util/tree.rs6
-rw-r--r--src/components/util/url.rs5
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-text0
m---------src/support/azure/rust-azure0
m---------src/support/css/rust-css0
m---------src/support/glfw/glfw-rs0
m---------src/support/glut/rust-glut0
m---------src/support/http-client/rust-http-client0
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/spidermonkey/rust-mozjs0
m---------src/support/stb-image/rust-stb-image0
m---------src/support/wapcaplet/rust-wapcaplet0
75 files changed, 520 insertions, 607 deletions
diff --git a/src/compiler/rust b/src/compiler/rust
-Subproject f348465283d6cd85b69bcdc1711d14985d154c3
+Subproject 5aa0ca9b2eb28166d9ab2e86557a5b1f84230b4
diff --git a/src/components/gfx/display_list.rs b/src/components/gfx/display_list.rs
index b284ebde1de..5d6f5188faa 100644
--- a/src/components/gfx/display_list.rs
+++ b/src/components/gfx/display_list.rs
@@ -48,7 +48,7 @@ impl<E> DisplayList<E> {
/// Draws the display list into the given render context.
pub fn draw_into_context(&self, render_context: &RenderContext) {
debug!("Beginning display list.");
- for self.list.each |item| {
+ for self.list.iter().advance |item| {
// FIXME(Issue #150): crashes
//debug!("drawing %?", *item);
item.draw_into_context(render_context)
diff --git a/src/components/gfx/font.rs b/src/components/gfx/font.rs
index 8e31f138c1e..7f4bddd7805 100644
--- a/src/components/gfx/font.rs
+++ b/src/components/gfx/font.rs
@@ -389,7 +389,7 @@ impl Font {
let mut origin = copy baseline_origin;
let mut azglyphs = ~[];
- vec::reserve(&mut azglyphs, range.length());
+ azglyphs.reserve(range.length());
for run.iter_slices_for_range(range) |glyphs, _offset, slice_range| {
for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| {
@@ -433,7 +433,7 @@ impl Font {
let mut advance = Au(0);
for run.iter_slices_for_range(range) |glyphs, _offset, slice_range| {
for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| {
- advance += glyph.advance_();
+ advance = advance + glyph.advance_();
}
}
RunMetrics::new(advance, self.metrics.ascent, self.metrics.descent)
@@ -445,7 +445,7 @@ impl Font {
-> RunMetrics {
let mut advance = Au(0);
for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| {
- advance += glyph.advance_();
+ advance = advance + glyph.advance_();
}
RunMetrics::new(advance, self.metrics.ascent, self.metrics.descent)
}
diff --git a/src/components/gfx/font_list.rs b/src/components/gfx/font_list.rs
index 77a18a60b5c..835a6916eac 100644
--- a/src/components/gfx/font_list.rs
+++ b/src/components/gfx/font_list.rs
@@ -126,7 +126,7 @@ impl FontFamily {
// TODO(Issue #190): if not in the fast path above, do
// expensive matching of weights, etc.
let this: &mut FontFamily = self; // FIXME: borrow checker workaround
- for this.entries.each |entry| {
+ for this.entries.iter().advance |entry| {
if (style.weight.is_bold() == entry.is_bold()) &&
(style.italic == entry.is_italic()) {
diff --git a/src/components/gfx/platform/linux/font.rs b/src/components/gfx/platform/linux/font.rs
index 95975c8be14..dc2eb8bdd3b 100644
--- a/src/components/gfx/platform/linux/font.rs
+++ b/src/components/gfx/platform/linux/font.rs
@@ -28,7 +28,6 @@ use freetype::tt_os2::TT_OS2;
use std::cast;
use std::ptr;
use std::str;
-use std::vec;
fn float_to_fixed_ft(f: float) -> i32 {
float_to_fixed(6, f)
@@ -63,7 +62,7 @@ pub struct FontHandle {
#[unsafe_destructor]
impl Drop for FontHandle {
- fn finalize(&self) {
+ fn drop(&self) {
assert!(self.face.is_not_null());
unsafe {
if !FT_Done_Face(self.face).succeeded() {
@@ -81,7 +80,7 @@ impl FontHandleMethods for FontHandle {
let ft_ctx: FT_Library = fctx.ctx.ctx;
if ft_ctx.is_null() { return Err(()); }
- let face_result = do vec::as_imm_buf(buf) |bytes: *u8, len: uint| {
+ let face_result = do buf.as_imm_buf |bytes: *u8, len: uint| {
create_face_from_buffer(ft_ctx, bytes, len, style.pt_size)
};
diff --git a/src/components/gfx/platform/linux/font_context.rs b/src/components/gfx/platform/linux/font_context.rs
index 625ea0f490a..5a828ee7438 100644
--- a/src/components/gfx/platform/linux/font_context.rs
+++ b/src/components/gfx/platform/linux/font_context.rs
@@ -17,7 +17,7 @@ struct FreeTypeLibraryHandle {
}
impl Drop for FreeTypeLibraryHandle {
- fn finalize(&self) {
+ fn drop(&self) {
assert!(self.ctx.is_not_null());
unsafe {
FT_Done_FreeType(self.ctx);
diff --git a/src/components/gfx/platform/linux/font_list.rs b/src/components/gfx/platform/linux/font_list.rs
index 919eaa5c907..ae53929855c 100644
--- a/src/components/gfx/platform/linux/font_list.rs
+++ b/src/components/gfx/platform/linux/font_list.rs
@@ -139,7 +139,7 @@ struct AutoPattern {
}
impl Drop for AutoPattern {
- fn finalize(&self) {
+ fn drop(&self) {
unsafe {
FcPatternDestroy(self.pattern);
}
diff --git a/src/components/gfx/platform/macos/font.rs b/src/components/gfx/platform/macos/font.rs
index f4d0beddb31..793fa9a7589 100644
--- a/src/components/gfx/platform/macos/font.rs
+++ b/src/components/gfx/platform/macos/font.rs
@@ -29,7 +29,6 @@ use core_text::font_descriptor::{kCTFontDefaultOrientation};
use core_text;
use std::ptr;
-use std::vec;
pub struct FontTable {
data: CFData,
@@ -37,7 +36,7 @@ pub struct FontTable {
// Noncopyable.
impl Drop for FontTable {
- fn finalize(&self) {}
+ fn drop(&self) {}
}
impl FontTable {
@@ -80,9 +79,9 @@ impl FontHandle {
impl FontHandleMethods for FontHandle {
fn new_from_buffer(_: &FontContextHandle, buf: ~[u8], style: &SpecifiedFontStyle)
-> Result<FontHandle, ()> {
- let fontprov : CGDataProvider = vec::as_imm_buf(buf, |cbuf, len| {
+ let fontprov : CGDataProvider = do buf.as_imm_buf |cbuf, len| {
core_graphics::data_provider::new_from_buffer(cbuf, len)
- });
+ };
let cgfont = core_graphics::font::create_with_data_provider(&fontprov);
let ctfont = core_text::font::new_from_CGFont(&cgfont, style.pt_size);
diff --git a/src/components/gfx/render_task.rs b/src/components/gfx/render_task.rs
index e81337ef0ef..d704c2e8160 100644
--- a/src/components/gfx/render_task.rs
+++ b/src/components/gfx/render_task.rs
@@ -75,7 +75,7 @@ priv struct RenderTask<C> {
last_paint_msg: Option<(arc::ARC<LayerBufferSet>, Size2D<uint>)>,
}
-impl<C: RenderListener + Owned> RenderTask<C> {
+impl<C: RenderListener + Send> RenderTask<C> {
pub fn create(id: uint,
port: Port<Msg>,
compositor: C,
diff --git a/src/components/gfx/text/glyph.rs b/src/components/gfx/text/glyph.rs
index a873b3b841a..f6569cc959b 100644
--- a/src/components/gfx/text/glyph.rs
+++ b/src/components/gfx/text/glyph.rs
@@ -347,7 +347,7 @@ impl<'self> DetailedGlyphStore {
// FIXME: Is this right? --pcwalton
// TODO: should fix this somewhere else
if count == 0 {
- return vec::slice(self.detail_buffer, 0, 0);
+ return self.detail_buffer.slice(0, 0);
}
assert!((count as uint) <= self.detail_buffer.len());
@@ -365,7 +365,7 @@ impl<'self> DetailedGlyphStore {
Some(i) => {
assert!(i + (count as uint) <= self.detail_buffer.len());
// return a slice into the buffer
- vec::slice(self.detail_buffer, i, i + count as uint)
+ self.detail_buffer.slice(i, i + count as uint)
}
}
}
@@ -635,7 +635,8 @@ impl<'self> GlyphStore {
}
for range.eachi |i| {
- if !self.iter_glyphs_for_char_index(i, callback) {
+ // FIXME: Work around rust#2202. We should be able to pass the callback directly.
+ if !self.iter_glyphs_for_char_index(i, |a, b| callback(a, b)) {
break
}
}
@@ -643,9 +644,10 @@ impl<'self> GlyphStore {
true
}
- pub fn iter_all_glyphs(&'self self, cb: &fn(uint, &GlyphInfo<'self>) -> bool) -> bool {
+ pub fn iter_all_glyphs(&'self self, callback: &fn(uint, &GlyphInfo<'self>) -> bool) -> bool {
for uint::range(0, self.entry_buffer.len()) |i| {
- if !self.iter_glyphs_for_char_index(i, cb) {
+ // FIXME: Work around rust#2202. We should be able to pass the callback directly.
+ if !self.iter_glyphs_for_char_index(i, |a, b| callback(a, b)) {
break;
}
}
diff --git a/src/components/gfx/text/shaping/harfbuzz.rs b/src/components/gfx/text/shaping/harfbuzz.rs
index 560f25d72b4..851beb87c8c 100644
--- a/src/components/gfx/text/shaping/harfbuzz.rs
+++ b/src/components/gfx/text/shaping/harfbuzz.rs
@@ -118,7 +118,7 @@ impl ShapedGlyphData {
} else {
// adjust the pen..
if y_advance > Au(0) {
- *y_pos -= y_advance;
+ *y_pos = *y_pos - y_advance;
}
Some(Point2D(x_offset, *y_pos - y_offset))
@@ -143,7 +143,7 @@ pub struct Shaper {
#[unsafe_destructor]
impl Drop for Shaper {
- fn finalize(&self) {
+ fn drop(&self) {
unsafe {
assert!(self.hb_face.is_not_null());
hb_face_destroy(self.hb_face);
diff --git a/src/components/gfx/text/text_run.rs b/src/components/gfx/text/text_run.rs
index cfcbab54680..c436181977c 100644
--- a/src/components/gfx/text/text_run.rs
+++ b/src/components/gfx/text/text_run.rs
@@ -123,7 +123,7 @@ impl<'self> TextRun {
}
pub fn char_len(&self) -> uint {
- do self.glyphs.foldl(0u) |len, slice_glyphs| {
+ do self.glyphs.iter().fold(0u) |len, slice_glyphs| {
len + slice_glyphs.get().char_len()
}
}
@@ -161,7 +161,7 @@ impl<'self> TextRun {
f: &fn(&GlyphStore, uint, &Range) -> bool)
-> bool {
let mut offset = 0;
- for self.glyphs.each |slice_glyphs| {
+ for self.glyphs.iter().advance |slice_glyphs| {
// Determine the range of this slice that we need.
let slice_range = Range::new(offset, slice_glyphs.get().char_len());
let mut char_range = range.intersect(&slice_range);
diff --git a/src/components/main/constellation.rs b/src/components/main/constellation.rs
index 9439c0d7674..b35b24c9403 100644
--- a/src/components/main/constellation.rs
+++ b/src/components/main/constellation.rs
@@ -205,7 +205,7 @@ impl Constellation {
}
ExitMsg(sender) => {
- for self.pipelines.each |_, pipeline| {
+ for self.pipelines.iter().advance |(_, pipeline)| {
pipeline.exit();
}
self.image_cache_task.exit();
@@ -240,7 +240,7 @@ impl Constellation {
// Don't navigate on Navigate type, because that is handled by forward/back
match pipeline.navigation_type.get() {
constellation_msg::Load => {
- let evicted = self.navigation_context.navigate(id);
+ let _evicted = self.navigation_context.navigate(id);
/* FIXME(tkuehn): the following code causes a segfault
for evicted.iter().advance |id| {
self.pipelines.get(id).exit();
diff --git a/src/components/main/layout/block.rs b/src/components/main/layout/block.rs
index 91510190c04..d1827561f5c 100644
--- a/src/components/main/layout/block.rs
+++ b/src/components/main/layout/block.rs
@@ -254,9 +254,9 @@ impl BlockFlowData {
for self.box.iter().advance |&box| {
do box.with_model |model| {
top_offset = model.margin.top + model.border.top + model.padding.top;
- cur_y += top_offset;
+ cur_y = cur_y + top_offset;
left_offset = model.offset();
- }
+ };
}
// TODO(eatkinson): the translation here is probably
@@ -284,8 +284,8 @@ impl BlockFlowData {
for BlockFlow(self).each_child |kid| {
do kid.with_mut_base |child_node| {
child_node.position.origin.y = cur_y;
- cur_y += child_node.position.size.height;
- }
+ cur_y = cur_y + child_node.position.size.height;
+ };
}
let height = if self.is_root {
@@ -304,7 +304,7 @@ impl BlockFlowData {
base.model.border.top + base.model.border.bottom;
base.position.size.height = height + noncontent_height;
- noncontent_height += base.model.margin.top + base.model.margin.bottom;
+ noncontent_height = noncontent_height + base.model.margin.top + base.model.margin.bottom;
}
});
diff --git a/src/components/main/layout/box.rs b/src/components/main/layout/box.rs
index c1008673402..fe4cd77aa89 100644
--- a/src/components/main/layout/box.rs
+++ b/src/components/main/layout/box.rs
@@ -57,6 +57,7 @@ use extra::net::url::Url;
/// A box's type influences how its styles are interpreted during layout. For example, replaced
/// content such as images are resized differently from tables, text, or other content. Different
/// types of boxes may also contain custom data; for example, text boxes contain text.
+#[deriving(Clone)]
pub enum RenderBox {
GenericRenderBoxClass(@mut RenderBoxBase),
ImageRenderBoxClass(@mut ImageRenderBox),
@@ -308,7 +309,7 @@ impl RenderBox {
left_range.shift_by(slice_range.length() as int);
} else {
debug!("split_to_width: case=enlarging span");
- remaining_width -= advance;
+ remaining_width = remaining_width - advance;
left_range.extend_by(slice_range.length() as int);
}
} else { // The advance is more than the remaining width.
@@ -840,10 +841,10 @@ impl RenderBox {
pub fn dump_indent(&self, indent: uint) {
let mut string = ~"";
for uint::range(0u, indent) |_i| {
- string += " ";
+ string.push_str(" ");
}
- string += self.debug_str();
+ string.push_str(self.debug_str());
debug!("%s", string);
}
@@ -863,4 +864,61 @@ impl RenderBox {
fmt!("box b%?: %s", self.id(), representation)
}
+
+ //
+ // Painting
+ //
+
+ /// Adds the display items necessary to paint the borders of this render box to a display list
+ /// if necessary.
+ pub fn paint_borders_if_applicable<E:ExtraDisplayListData>(&self,
+ list: &Cell<DisplayList<E>>,
+ abs_bounds: &Rect<Au>) {
+ // Fast path.
+ let border = do self.with_base |base| {
+ base.model.border
+ };
+ if border.is_zero() {
+ return
+ }
+
+ // Are all the widths equal?
+ //
+ // FIXME(pcwalton): Obviously this is wrong.
+ let borders = [ border.top, border.right, border.bottom ];
+ if borders.iter().all(|a| *a == border.left) {
+ let border_width = border.top;
+ let bounds = Rect {
+ origin: Point2D {
+ x: abs_bounds.origin.x + border_width.scale_by(0.5),
+ y: abs_bounds.origin.y + border_width.scale_by(0.5),
+ },
+ size: Size2D {
+ width: abs_bounds.size.width - border_width,
+ height: abs_bounds.size.height - border_width
+ }
+ };
+
+ let top_color = self.style().border_top_color();
+ let color = top_color.to_gfx_color(); // FIXME
+
+ // Append the border to the display list.
+ do list.with_mut_ref |list| {
+ let border_display_item = ~BorderDisplayItem {
+ base: BaseDisplayItem {
+ bounds: bounds,
+ extra: ExtraDisplayListData::new(*self),
+ },
+ width: border_width,
+ color: color,
+ };
+
+ list.append_item(BorderDisplayItemClass(border_display_item))
+ }
+ } else {
+ warn!("ignoring unimplemented border widths");
+ }
+ }
+
}
+
diff --git a/src/components/main/layout/float.rs b/src/components/main/layout/float.rs
index 50d14307898..426ae8d6281 100644
--- a/src/components/main/layout/float.rs
+++ b/src/components/main/layout/float.rs
@@ -164,15 +164,15 @@ impl FloatFlowData {
for self.box.iter().advance |&box| {
do box.with_model |model| {
top_offset = model.margin.top + model.border.top + model.padding.top;
- cur_y += top_offset;
+ cur_y = cur_y + top_offset;
}
}
for FloatFlow(self).each_child |kid| {
do kid.with_mut_base |child_node| {
child_node.position.origin.y = cur_y;
- cur_y += child_node.position.size.height;
- }
+ cur_y = cur_y + child_node.position.size.height;
+ };
}
let mut height = cur_y - top_offset;
@@ -187,7 +187,7 @@ impl FloatFlowData {
base.model.border.top + base.model.border.bottom;
base.position.size.height = height + noncontent_height;
- noncontent_height += base.model.margin.top + base.model.margin.bottom;
+ noncontent_height = noncontent_height + base.model.margin.top + base.model.margin.bottom;
}
});
diff --git a/src/components/main/layout/float_context.rs b/src/components/main/layout/float_context.rs
index 1b1f192aece..f384c718d60 100644
--- a/src/components/main/layout/float_context.rs
+++ b/src/components/main/layout/float_context.rs
@@ -115,7 +115,7 @@ impl FloatContextBase{
}
fn translate(&mut self, trans: Point2D<Au>) {
- self.offset += trans;
+ self.offset = self.offset + trans;
}
fn last_float_pos(&self) -> Point2D<Au> {
@@ -144,12 +144,16 @@ impl FloatContextBase{
let top = top - self.offset.y;
// Relevant dimensions for the right-most left float
- let mut (max_left, l_top, l_bottom) = (Au(0) - self.offset.x, None, None);
+ let mut max_left = Au(0) - self.offset.x;
+ let mut l_top = None;
+ let mut l_bottom = None;
// Relevant dimensions for the left-most right float
- let mut (min_right, r_top, r_bottom) = (max_x - self.offset.x, None, None);
+ let mut min_right = max_x - self.offset.x;
+ let mut r_top = None;
+ let mut r_bottom = None;
// Find the float collisions for the given vertical range.
- for self.float_data.each |float| {
+ for self.float_data.iter().advance |float| {
match *float{
None => (),
Some(data) => {
diff --git a/src/components/main/layout/flow.rs b/src/components/main/layout/flow.rs
index 9ddd9b0e7e8..ccfe21b9250 100644
--- a/src/components/main/layout/flow.rs
+++ b/src/components/main/layout/flow.rs
@@ -314,25 +314,25 @@ impl<'self> FlowContext {
}
// Actual methods that do not require much flow-specific logic
- pub fn foldl_all_boxes<B:Copy>(&self, seed: B, cb: &fn(a: B, b: RenderBox) -> B) -> B {
+ pub fn foldl_all_boxes<B:Clone>(&self, seed: B, cb: &fn(a: B, b: RenderBox) -> B) -> B {
match *self {
BlockFlow(block) => {
let block = &mut *block;
- do block.box.map_default(copy seed) |box| {
- cb(copy seed, *box)
+ do block.box.map_default(seed.clone()) |box| {
+ cb(seed.clone(), *box)
}
}
InlineFlow(inline) => {
let inline = &mut *inline;
- do inline.boxes.foldl(seed) |acc, box| {
- cb(copy *acc, *box)
+ do inline.boxes.iter().fold(seed) |acc, box| {
+ cb(acc.clone(), *box)
}
}
_ => fail!(fmt!("Don't know how to iterate node's RenderBoxes for %?", self)),
}
}
- pub fn foldl_boxes_for_node<B:Copy>(&self,
+ pub fn foldl_boxes_for_node<B:Clone>(&self,
node: AbstractNode<LayoutView>,
seed: B,
callback: &fn(a: B, RenderBox) -> B)
@@ -394,10 +394,10 @@ impl<'self> FlowContext {
pub fn dump_indent(&self, indent: uint) {
let mut s = ~"|";
for uint::range(0, indent) |_i| {
- s += "---- ";
+ s.push_str("---- ");
}
- s += self.debug_str();
+ s.push_str(self.debug_str());
debug!("%s", s);
// FIXME: this should have a pure/const version?
@@ -409,10 +409,10 @@ impl<'self> FlowContext {
pub fn debug_str(&self) -> ~str {
let repr = match *self {
InlineFlow(inline) => {
- let mut s = inline.boxes.foldl(~"InlineFlow(children=", |s, box| {
- fmt!("%s b%d", *s, box.id())
+ let mut s = inline.boxes.iter().fold(~"InlineFlow(children=", |s, box| {
+ fmt!("%s b%d", s, box.id())
});
- s += ")";
+ s.push_str(")");
s
},
BlockFlow(block) => {
diff --git a/src/components/main/layout/inline.rs b/src/components/main/layout/inline.rs
index cd15e3e8ee5..616f142c76f 100644
--- a/src/components/main/layout/inline.rs
+++ b/src/components/main/layout/inline.rs
@@ -169,8 +169,8 @@ impl LineboxScanner {
for line_range.eachi |i| {
do self.new_boxes[i].with_mut_base |base| {
base.position.origin.x = offset_x;
- offset_x += base.position.size.width;
- }
+ offset_x = offset_x + base.position.size.width;
+ };
}
},
CSSTextAlignCenter => {
@@ -178,8 +178,8 @@ impl LineboxScanner {
for line_range.eachi |i| {
do self.new_boxes[i].with_mut_base |base| {
base.position.origin.x = offset_x;
- offset_x += base.position.size.width;
- }
+ offset_x = offset_x + base.position.size.width;
+ };
}
},
CSSTextAlignRight => {
@@ -187,8 +187,8 @@ impl LineboxScanner {
for line_range.eachi |i| {
do self.new_boxes[i].with_mut_base |base| {
base.position.origin.x = offset_x;
- offset_x += base.position.size.width;
- }
+ offset_x = offset_x + base.position.size.width;
+ };
}
},
}
@@ -292,7 +292,7 @@ impl LineboxScanner {
self.pending_line.range.reset(self.new_boxes.len(), 0);
}
self.pending_line.range.extend_by(1);
- self.pending_line.bounds.size.width += box.position().size.width;
+ self.pending_line.bounds.size.width = self.pending_line.bounds.size.width + box.position().size.width;
self.new_boxes.push(box);
}
}
@@ -325,7 +325,7 @@ impl InlineFlowData {
pub fn teardown(&mut self) {
self.common.teardown();
- for self.boxes.each |box| {
+ for self.boxes.iter().advance |box| {
box.teardown();
}
self.boxes = ~[];
@@ -362,7 +362,7 @@ impl InlineFlowData {
let mut min_width = Au(0);
let mut pref_width = Au(0);
- for this.boxes.each |box| {
+ for this.boxes.iter().advance |box| {
debug!("FlowContext[%d]: measuring %s", self.common.id, box.debug_str());
min_width = Au::max(min_width, box.get_min_width(ctx));
pref_width = Au::max(pref_width, box.get_pref_width(ctx));
@@ -383,7 +383,7 @@ impl InlineFlowData {
// `RenderBox`.
{
let this = &mut *self;
- for this.boxes.each |&box| {
+ for this.boxes.iter().advance |&box| {
match box {
ImageRenderBoxClass(image_box) => {
let size = image_box.image.get_size();
@@ -439,7 +439,7 @@ impl InlineFlowData {
let mut cur_y = Au(0);
- for self.lines.eachi |i, line_span| {
+ for self.lines.iter().enumerate().advance |(i, line_span)| {
debug!("assign_height_inline: processing line %u with box span: %?", i, line_span);
// These coordinates are relative to the left baseline.
@@ -537,7 +537,7 @@ impl InlineFlowData {
}
}
- cur_y += linebox_height;
+ cur_y = cur_y + linebox_height;
} // End of `lines.each` loop.
self.common.position.size.height = cur_y;
@@ -554,7 +554,7 @@ impl InlineFlowData {
self.common.id,
self.boxes.len());
- for self.boxes.each |box| {
+ for self.boxes.iter().advance |box| {
box.build_display_list(builder, dirty, offset, list)
}
diff --git a/src/components/main/layout/model.rs b/src/components/main/layout/model.rs
index 104d4b0037e..4bd45dabe17 100644
--- a/src/components/main/layout/model.rs
+++ b/src/components/main/layout/model.rs
@@ -4,16 +4,8 @@
//! Borders, padding, and margins.
-use layout::display_list_builder::{ExtraDisplayListData, ToGfxColor};
-use layout::box::RenderBox;
-
-use std::cell::Cell;
use std::num::Zero;
-use geom::point::Point2D;
-use geom::rect::Rect;
-use geom::size::Size2D;
use geom::side_offsets::SideOffsets2D;
-use gfx::display_list::{BaseDisplayItem, BorderDisplayItem, BorderDisplayItemClass, DisplayList};
use gfx::geometry::Au;
use newcss::complete::CompleteStyle;
use newcss::units::{Em, Pt, Px};
@@ -150,62 +142,3 @@ impl BoxModel {
}
}
}
-
-//
-// Painting
-//
-
-impl RenderBox {
- /// Adds the display items necessary to paint the borders of this render box to a display list
- /// if necessary.
- pub fn paint_borders_if_applicable<E:ExtraDisplayListData>(&self,
- list: &Cell<DisplayList<E>>,
- abs_bounds: &Rect<Au>) {
- // Fast path.
- let border = do self.with_base |base| {
- base.model.border
- };
- if border.is_zero() {
- return
- }
-
- // Are all the widths equal?
- //
- // FIXME(pcwalton): Obviously this is wrong.
- let borders = [ border.top, border.right, border.bottom ];
- if borders.iter().all(|a| *a == border.left) {
- let border_width = border.top;
- let bounds = Rect {
- origin: Point2D {
- x: abs_bounds.origin.x + border_width.scale_by(0.5),
- y: abs_bounds.origin.y + border_width.scale_by(0.5),
- },
- size: Size2D {
- width: abs_bounds.size.width - border_width,
- height: abs_bounds.size.height - border_width
- }
- };
-
- let top_color = self.style().border_top_color();
- let color = top_color.to_gfx_color(); // FIXME
-
- // Append the border to the display list.
- do list.with_mut_ref |list| {
- let border_display_item = ~BorderDisplayItem {
- base: BaseDisplayItem {
- bounds: bounds,
- extra: ExtraDisplayListData::new(*self),
- },
- width: border_width,
- color: color,
- };
-
- list.append_item(BorderDisplayItemClass(border_display_item))
- }
- } else {
- warn!("ignoring unimplemented border widths");
- }
- }
-
-}
-
diff --git a/src/components/main/layout/text.rs b/src/components/main/layout/text.rs
index 59093ed70ff..cf9d8f49bcc 100644
--- a/src/components/main/layout/text.rs
+++ b/src/components/main/layout/text.rs
@@ -249,13 +249,13 @@ impl TextRunScanner {
} // End of match.
debug!("--- In boxes: ---");
- for in_boxes.eachi |i, box| {
+ for in_boxes.iter().enumerate().advance |(i, box)| {
debug!("%u --> %s", i, box.debug_str());
}
debug!("------------------");
debug!("--- Out boxes: ---");
- for out_boxes.eachi |i, box| {
+ for out_boxes.iter().enumerate().advance |(i, box)| {
debug!("%u --> %s", i, box.debug_str());
}
debug!("------------------");
diff --git a/src/components/main/layout/util.rs b/src/components/main/layout/util.rs
index cc3d0267b7d..00d4dae218c 100644
--- a/src/components/main/layout/util.rs
+++ b/src/components/main/layout/util.rs
@@ -31,7 +31,7 @@ impl ElementMapping {
}
pub fn each(&self, callback: &fn(nr: &NodeRange) -> bool) -> bool {
- for self.entries.each |nr| {
+ for self.entries.iter().advance |nr| {
if !callback(nr) {
break
}
@@ -40,7 +40,7 @@ impl ElementMapping {
}
pub fn eachi(&self, callback: &fn(i: uint, nr: &NodeRange) -> bool) -> bool {
- for self.entries.eachi |i, nr| {
+ for self.entries.iter().enumerate().advance |(i, nr)| {
if !callback(i, nr) {
break
}
@@ -49,7 +49,7 @@ impl ElementMapping {
}
pub fn eachi_mut(&self, callback: &fn(i: uint, nr: &NodeRange) -> bool) -> bool {
- for self.entries.eachi |i, nr| {
+ for self.entries.iter().enumerate().advance |(i, nr)| {
if !callback(i, nr) {
break
}
@@ -61,19 +61,19 @@ impl ElementMapping {
let entries = &mut self.entries;
debug!("--- Old boxes: ---");
- for old_boxes.eachi |i, box| {
+ for old_boxes.iter().enumerate().advance |(i, box)| {
debug!("%u --> %s", i, box.debug_str());
}
debug!("------------------");
debug!("--- New boxes: ---");
- for new_boxes.eachi |i, box| {
+ for new_boxes.iter().enumerate().advance |(i, box)| {
debug!("%u --> %s", i, box.debug_str());
}
debug!("------------------");
debug!("--- Elem ranges before repair: ---");
- for entries.eachi |i: uint, nr: &NodeRange| {
+ for entries.iter().enumerate().advance |(i, nr)| {
debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str());
}
debug!("----------------------------------");
@@ -126,7 +126,7 @@ impl ElementMapping {
}
}
debug!("--- Elem ranges after repair: ---");
- for entries.eachi |i: uint, nr: &NodeRange| {
+ for entries.iter().enumerate().advance |(i, nr)| {
debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str());
}
debug!("----------------------------------");
diff --git a/src/components/main/pipeline.rs b/src/components/main/pipeline.rs
index 42f76d1b537..45852132bbf 100644
--- a/src/components/main/pipeline.rs
+++ b/src/components/main/pipeline.rs
@@ -93,8 +93,8 @@ impl Pipeline {
}
pub fn reload(&self) {
- for self.url.iter().advance |&url| {
- self.script_chan.send(LoadMsg(url));
+ for self.url.iter().advance |url| {
+ self.script_chan.send(LoadMsg(url.clone()));
}
}
diff --git a/src/components/main/platform/common/glfw_windowing.rs b/src/components/main/platform/common/glfw_windowing.rs
index 4aadfea486b..6f9c509f245 100644
--- a/src/components/main/platform/common/glfw_windowing.rs
+++ b/src/components/main/platform/common/glfw_windowing.rs
@@ -4,7 +4,7 @@
//! A windowing implementation using GLFW.
-use windowing::{ApplicationMethods, CompositeCallback, LoadUrlCallback, MouseCallback};
+use windowing::{ApplicationMethods, LoadUrlCallback, MouseCallback};
use windowing::{ResizeCallback, ScrollCallback, WindowMethods, WindowMouseEvent, WindowClickEvent};
use windowing::{WindowMouseDownEvent, WindowMouseUpEvent, ZoomCallback, Forward, Back, NavigationCallback};
@@ -24,15 +24,14 @@ pub struct Application;
impl ApplicationMethods for Application {
pub fn new() -> Application {
- glfw::private::WindowDataMap::init();
- unsafe { glfw::ll::glfwInit(); }
+ glfw::init();
Application
}
}
impl Drop for Application {
- fn finalize(&self) {
- unsafe { glfw::ll::glfwTerminate(); }
+ fn drop(&self) {
+ glfw::terminate();
}
}
@@ -40,7 +39,6 @@ impl Drop for Application {
pub struct Window {
glfw_window: glfw::Window,
- composite_callback: Option<CompositeCallback>,
resize_callback: Option<ResizeCallback>,
load_url_callback: Option<LoadUrlCallback>,
mouse_callback: Option<MouseCallback>,
@@ -69,7 +67,6 @@ impl WindowMethods<Application> for Window {
let window = @mut Window {
glfw_window: glfw_window,
- composite_callback: None,
resize_callback: None,
load_url_callback: None,
mouse_callback: None,
@@ -94,14 +91,6 @@ impl WindowMethods<Application> for Window {
Some(callback) => callback(width as uint, height as uint),
}
}
- do window.glfw_window.set_refresh_callback |_win| {
- // FIXME(pcwalton): This will not work with multiple windows.
- match window.composite_callback {
- None => {}
- Some(callback) => callback(),
- }
- window.present();
- }
do window.glfw_window.set_key_callback |_win, key, _scancode, action, mods| {
if action == glfw::PRESS {
window.handle_key(key, mods)
@@ -134,11 +123,6 @@ impl WindowMethods<Application> for Window {
self.glfw_window.swap_buffers();
}
- /// Registers a callback to run when a composite event occurs.
- pub fn set_composite_callback(&mut self, new_composite_callback: CompositeCallback) {
- self.composite_callback = Some(new_composite_callback)
- }
-
/// Registers a callback to run when a resize event occurs.
pub fn set_resize_callback(&mut self, new_resize_callback: ResizeCallback) {
self.resize_callback = Some(new_resize_callback)
diff --git a/src/components/main/platform/common/shared_gl_windowing.rs b/src/components/main/platform/common/shared_gl_windowing.rs
index aa4a84b12cd..268bb6386d0 100644
--- a/src/components/main/platform/common/shared_gl_windowing.rs
+++ b/src/components/main/platform/common/shared_gl_windowing.rs
@@ -47,9 +47,6 @@ impl WindowingMethods<Application> for Window {
(*self).flush();
}
- /// Registers a callback to run when a composite event occurs.
- pub fn set_composite_callback(&mut self, _: CompositeCallback) {}
-
/// Registers a callback to run when a resize event occurs.
pub fn set_resize_callback(&mut self, _: ResizeCallback) {}
diff --git a/src/components/main/servo.rc b/src/components/main/servo.rc
index 424e90b33f3..10986322516 100755
--- a/src/components/main/servo.rc
+++ b/src/components/main/servo.rc
@@ -131,7 +131,7 @@ fn run(opts: &Opts) {
profiler_chan.clone());
// Send the URL command to the constellation.
- for opts.urls.each |filename| {
+ for opts.urls.iter().advance |filename| {
constellation_chan.send(LoadUrlMsg(make_url(copy *filename, None)))
}
diff --git a/src/components/main/util/task.rs b/src/components/main/util/task.rs
index d45b10c7465..0300fa59200 100644
--- a/src/components/main/util/task.rs
+++ b/src/components/main/util/task.rs
@@ -7,7 +7,7 @@ use std::comm;
use std::comm::{Chan, Port};
use std::task;
-pub fn spawn_listener<A: Owned>(f: ~fn(Port<A>)) -> Chan<A> {
+pub fn spawn_listener<A: Send>(f: ~fn(Port<A>)) -> Chan<A> {
let (setup_po, setup_ch) = comm::stream();
do task::spawn {
let (po, ch) = comm::stream();
@@ -17,7 +17,7 @@ pub fn spawn_listener<A: Owned>(f: ~fn(Port<A>)) -> Chan<A> {
setup_po.recv()
}
-pub fn spawn_conversation<A: Owned, B: Owned>(f: ~fn(Port<A>, Chan<B>)) -> (Port<B>, Chan<A>) {
+pub fn spawn_conversation<A: Send, B: Send>(f: ~fn(Port<A>, Chan<B>)) -> (Port<B>, Chan<A>) {
let (from_child, to_parent) = comm::stream();
let to_parent = Cell::new(to_parent);
let to_child = do spawn_listener |from_parent| {
diff --git a/src/components/main/windowing.rs b/src/components/main/windowing.rs
index edf4bd3800f..1edd0114de1 100644
--- a/src/components/main/windowing.rs
+++ b/src/components/main/windowing.rs
@@ -19,9 +19,6 @@ pub enum WindowNavigateMsg {
Back,
}
-/// Type of the function that is called when the screen is to be redisplayed.
-pub type CompositeCallback = @fn();
-
/// Type of the function that is called when the window is resized.
pub type ResizeCallback = @fn(uint, uint);
@@ -53,8 +50,6 @@ pub trait WindowMethods<A> {
/// Presents the window to the screen (perhaps by page flipping).
pub fn present(&mut self);
- /// Registers a callback to run when a composite event occurs.
- pub fn set_composite_callback(&mut self, new_composite_callback: CompositeCallback);
/// Registers a callback to run when a resize event occurs.
pub fn set_resize_callback(&mut self, new_resize_callback: ResizeCallback);
/// Registers a callback to run when a new URL is to be loaded.
diff --git a/src/components/net/image_cache_task.rs b/src/components/net/image_cache_task.rs
index e4bef56758c..aa0440ff701 100644
--- a/src/components/net/image_cache_task.rs
+++ b/src/components/net/image_cache_task.rs
@@ -179,7 +179,7 @@ impl ImageCache {
loop {
let msg = self.port.recv();
- for msg_handlers.each |handler| {
+ for msg_handlers.iter().advance |handler| {
(*handler)(&msg)
}
@@ -375,7 +375,7 @@ impl ImageCache {
priv fn purge_waiters(&self, url: Url, f: &fn() -> ImageResponseMsg) {
match self.wait_map.pop(&url) {
Some(waiters) => {
- for waiters.each |response| {
+ for waiters.iter().advance |response| {
response.send(f());
}
}
@@ -444,7 +444,7 @@ fn load_image_data(url: Url, resource_task: ResourceTask) -> Result<~[u8], ()> {
loop {
match response_port.recv() {
resource_task::Payload(data) => {
- image_data += data;
+ image_data.push_all(data);
}
resource_task::Done(result::Ok(*)) => {
return Ok(image_data);
diff --git a/src/components/net/resource_task.rs b/src/components/net/resource_task.rs
index 958705c8885..457cd6dfd35 100644
--- a/src/components/net/resource_task.rs
+++ b/src/components/net/resource_task.rs
@@ -105,7 +105,7 @@ impl ResourceManager {
}
fn get_loader_factory(&self, url: &Url) -> Option<LoaderTask> {
- for self.loaders.each |scheme_loader| {
+ for self.loaders.iter().advance |scheme_loader| {
match *scheme_loader {
(ref scheme, ref loader_factory) => {
if (*scheme) == url.scheme {
diff --git a/src/components/net/util.rs b/src/components/net/util.rs
index 92f142f2db7..342f7df5d4e 100644
--- a/src/components/net/util.rs
+++ b/src/components/net/util.rs
@@ -6,7 +6,7 @@ use std::comm;
use std::comm::{Chan, Port};
use std::task;
-pub fn spawn_listener<A: Owned>(f: ~fn(Port<A>)) -> Chan<A> {
+pub fn spawn_listener<A: Send>(f: ~fn(Port<A>)) -> Chan<A> {
let (setup_port, setup_chan) = comm::stream();
do task::spawn {
let (port, chan) = comm::stream();
diff --git a/src/components/script/dom/bindings/clientrect.rs b/src/components/script/dom/bindings/clientrect.rs
deleted file mode 100644
index b910ff1f41c..00000000000
--- a/src/components/script/dom/bindings/clientrect.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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 dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper};
-use dom::bindings::codegen::ClientRectBinding;
-use dom::clientrect::ClientRect;
-use script_task::{task_from_context, global_script_context};
-
-use js::jsapi::{JSObject, JSContext, JSVal};
-use js::glue::RUST_OBJECT_TO_JSVAL;
-
-use std::cast;
-
-impl ClientRect {
- pub fn init_wrapper(@mut self) {
- let script_context = global_script_context();
- let cx = script_context.js_compartment.cx.ptr;
- let owner = script_context.root_frame.get_ref().window;
- let cache = owner.get_wrappercache();
- let scope = cache.get_wrapper();
- self.wrap_object_shared(cx, scope);
- }
-}
-
-impl CacheableWrapper for ClientRect {
- fn get_wrappercache(&mut self) -> &mut WrapperCache {
- unsafe {
- cast::transmute(&self.wrapper)
- }
- }
-
- fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
- let mut unused = false;
- ClientRectBinding::Wrap(cx, scope, self, &mut unused)
- }
-}
-
-impl BindingObject for ClientRect {
- fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
- let script_context = task_from_context(cx);
- unsafe {
- (*script_context).root_frame.get_ref().window as @mut CacheableWrapper
- }
- }
-}
-
-impl DerivedWrapper for ClientRect {
- fn wrap(&mut self, _cx: *JSContext, _scope: *JSObject, _vp: *mut JSVal) -> i32 {
- fail!(~"nyi")
- }
-
- fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
- let obj = self.wrap_object_shared(cx, scope);
- if obj.is_null() {
- return 0;
- } else {
- unsafe { *vp = RUST_OBJECT_TO_JSVAL(obj) };
- return 1;
- }
- }
-}
diff --git a/src/components/script/dom/bindings/clientrectlist.rs b/src/components/script/dom/bindings/clientrectlist.rs
deleted file mode 100644
index a6d19a73a10..00000000000
--- a/src/components/script/dom/bindings/clientrectlist.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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 dom::bindings::codegen::ClientRectListBinding;
-use dom::bindings::utils::{WrapperCache, CacheableWrapper, BindingObject};
-use dom::clientrectlist::ClientRectList;
-use script_task::{task_from_context, global_script_context};
-
-use js::jsapi::{JSObject, JSContext};
-
-use std::cast;
-
-impl ClientRectList {
- pub fn init_wrapper(@mut self) {
- let script_context = global_script_context();
- let cx = script_context.js_compartment.cx.ptr;
- let owner = script_context.root_frame.get_ref().window;
- let cache = owner.get_wrappercache();
- let scope = cache.get_wrapper();
- self.wrap_object_shared(cx, scope);
- }
-}
-
-impl CacheableWrapper for ClientRectList {
- fn get_wrappercache(&mut self) -> &mut WrapperCache {
- unsafe {
- cast::transmute(&self.wrapper)
- }
- }
-
- fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
- let mut unused = false;
- ClientRectListBinding::Wrap(cx, scope, self, &mut unused)
- }
-}
-
-impl BindingObject for ClientRectList {
- fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
- let script_context = task_from_context(cx);
- unsafe {
- (*script_context).root_frame.get_ref().window as @mut CacheableWrapper
- }
- }
-}
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index 66984d6c885..055cb0ce488 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -2153,7 +2153,7 @@ class CGImports(CGWrapper):
# TODO imports to cover descriptors, etc.
def _useString(imports):
- return '#[allow(unused_imports,unused_variable,unused_unsafe,unused_mut)];' + ''.join(['use %s;\n' % i for i in imports]) + '\n'
+ return '#[allow(non_uppercase_statics,unused_imports,unused_variable,unused_unsafe,unused_mut)];' + ''.join(['use %s;\n' % i for i in imports]) + '\n'
CGWrapper.__init__(self, child,
declarePre=_useString(sorted(declareImports)))
diff --git a/src/components/script/dom/bindings/document.rs b/src/components/script/dom/bindings/document.rs
index 731e6619bd9..685b7d2599f 100644
--- a/src/components/script/dom/bindings/document.rs
+++ b/src/components/script/dom/bindings/document.rs
@@ -6,7 +6,6 @@ use std::cast;
use std::libc;
use std::ptr;
use std::result;
-use std::vec;
use dom::bindings::utils::{DOMString, rust_box, squirrel_away, str};
use dom::bindings::utils::{WrapperCache, DerivedWrapper};
use dom::bindings::utils::{jsval_to_str, WrapNewBindingObject, CacheableWrapper};
@@ -102,11 +101,11 @@ pub fn init(compartment: @mut Compartment) {
getter: JSPropertyOpWrapper {op: null(), info: null()},
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
compartment.global_props.push(attrs);
- vec::as_imm_buf(*attrs, |specs, _len| {
+ do attrs.as_imm_buf |specs, _len| {
unsafe {
assert!(JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs) == 1);
}
- });
+ }
let methods = @~[JSFunctionSpec {name: compartment.add_name(~"getElementsByTagName"),
call: JSNativeWrapper {op: getElementsByTagName, info: null()},
@@ -118,11 +117,11 @@ pub fn init(compartment: @mut Compartment) {
nargs: 0,
flags: 0,
selfHostedName: null()}];
- vec::as_imm_buf(*methods, |fns, _len| {
+ do methods.as_imm_buf |fns, _len| {
unsafe {
JS_DefineFunctions(compartment.cx.ptr, obj.ptr, fns);
}
- });
+ }
compartment.register_class(utils::instance_jsclass(~"DocumentInstance",
finalize,
diff --git a/src/components/script/dom/bindings/element.rs b/src/components/script/dom/bindings/element.rs
index b79daf75db7..b37c3f1a43b 100644
--- a/src/components/script/dom/bindings/element.rs
+++ b/src/components/script/dom/bindings/element.rs
@@ -21,7 +21,6 @@ use std::ptr;
use std::ptr::null;
use std::result;
use std::str;
-use std::vec;
use js::glue::*;
use js::jsapi::*;
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, JSFreeOp, JSPropertySpec};
@@ -84,12 +83,12 @@ pub fn init(compartment: @mut Compartment) {
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: JSPropertyOpWrapper {op: null(), info: null()},
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
- vec::push(&mut compartment.global_props, attrs);
- vec::as_imm_buf(*attrs, |specs, _len| {
+ compartment.global_props.push(attrs);
+ do attrs.as_imm_buf |specs, _len| {
unsafe {
JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs);
}
- });
+ }
let methods = @~[JSFunctionSpec {name: compartment.add_name(~"getClientRects"),
call: JSNativeWrapper {op: getClientRects, info: null()},
@@ -111,11 +110,11 @@ pub fn init(compartment: @mut Compartment) {
nargs: 0,
flags: 0,
selfHostedName: null()}];
- vec::as_imm_buf(*methods, |fns, _len| {
+ do methods.as_imm_buf |fns, _len| {
unsafe {
JS_DefineFunctions(compartment.cx.ptr, obj.ptr, fns);
}
- });
+ }
compartment.register_class(utils::instance_jsclass(~"GenericElementInstance",
finalize, trace));
@@ -137,12 +136,12 @@ pub fn init(compartment: @mut Compartment) {
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: JSPropertyOpWrapper {op: null(), info: null()},
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
- vec::push(&mut compartment.global_props, attrs);
- vec::as_imm_buf(*attrs, |specs, _len| {
+ compartment.global_props.push(attrs);
+ do attrs.as_imm_buf |specs, _len| {
unsafe {
JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs);
}
- });
+ }
}
extern fn getClientRects(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool {
diff --git a/src/components/script/dom/bindings/event.rs b/src/components/script/dom/bindings/event.rs
deleted file mode 100644
index 2197646e188..00000000000
--- a/src/components/script/dom/bindings/event.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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::cast;
-use dom::bindings::codegen::EventBinding;
-use dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper};
-use dom::event::Event_;
-use script_task::{task_from_context, global_script_context};
-
-use js::glue::RUST_OBJECT_TO_JSVAL;
-use js::jsapi::{JSObject, JSContext, JSVal};
-
-impl Event_ {
- pub fn init_wrapper(@mut self) {
- let script_context = global_script_context();
- let cx = script_context.js_compartment.cx.ptr;
- let owner = script_context.root_frame.get_ref().window;
- let cache = owner.get_wrappercache();
- let scope = cache.get_wrapper();
- self.wrap_object_shared(cx, scope);
- }
-}
-
-impl CacheableWrapper for Event_ {
- fn get_wrappercache(&mut self) -> &mut WrapperCache {
- unsafe { cast::transmute(&self.wrapper) }
- }
-
- fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
- let mut unused = false;
- EventBinding::Wrap(cx, scope, self, &mut unused)
- }
-}
-
-impl BindingObject for Event_ {
- fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
- let script_context = task_from_context(cx);
- unsafe {
- (*script_context).root_frame.get_ref().window as @mut CacheableWrapper
- }
- }
-}
-
-impl DerivedWrapper for Event_ {
- fn wrap(&mut self, _cx: *JSContext, _scope: *JSObject, _vp: *mut JSVal) -> i32 {
- fail!(~"nyi")
- }
-
- fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
- let obj = self.wrap_object_shared(cx, scope);
- if obj.is_null() {
- return 0;
- } else {
- unsafe { *vp = RUST_OBJECT_TO_JSVAL(obj) };
- return 1;
- }
- }
-}
diff --git a/src/components/script/dom/bindings/eventtarget.rs b/src/components/script/dom/bindings/eventtarget.rs
deleted file mode 100644
index ffb804d905c..00000000000
--- a/src/components/script/dom/bindings/eventtarget.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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::cast;
-use dom::bindings::codegen::EventTargetBinding;
-use dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper};
-use dom::eventtarget::EventTarget;
-use script_task::{task_from_context, global_script_context};
-
-use js::glue::RUST_OBJECT_TO_JSVAL;
-use js::jsapi::{JSObject, JSContext, JSVal};
-
-impl EventTarget {
- pub fn init_wrapper(@mut self) {
- let script_context = global_script_context();
- let cx = script_context.js_compartment.cx.ptr;
- let owner = script_context.root_frame.get_ref().window;
- let cache = owner.get_wrappercache();
- let scope = cache.get_wrapper();
- self.wrap_object_shared(cx, scope);
- }
-}
-
-impl CacheableWrapper for EventTarget {
- fn get_wrappercache(&mut self) -> &mut WrapperCache {
- unsafe { cast::transmute(&self.wrapper) }
- }
-
- fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
- let mut unused = false;
- EventTargetBinding::Wrap(cx, scope, self, &mut unused)
- }
-}
-
-impl BindingObject for EventTarget {
- fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
- let script_context = task_from_context(cx);
- unsafe {
- (*script_context).root_frame.get_ref().window as @mut CacheableWrapper
- }
- }
-}
-
-impl DerivedWrapper for EventTarget {
- fn wrap(&mut self, _cx: *JSContext, _scope: *JSObject, _vp: *mut JSVal) -> i32 {
- fail!(~"nyi")
- }
-
- fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
- let obj = self.wrap_object_shared(cx, scope);
- if obj.is_null() {
- return 0;
- } else {
- unsafe {
- *vp = RUST_OBJECT_TO_JSVAL(obj)
- };
- return 1;
- }
- }
-}
diff --git a/src/components/script/dom/bindings/formdata.rs b/src/components/script/dom/bindings/formdata.rs
deleted file mode 100644
index eaf25a3ebe2..00000000000
--- a/src/components/script/dom/bindings/formdata.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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 dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper};
-use dom::bindings::codegen::FormDataBinding;
-use dom::formdata::FormData;
-use script_task::{task_from_context, global_script_context};
-
-use js::jsapi::{JSObject, JSContext, JSVal};
-use js::glue::RUST_OBJECT_TO_JSVAL;
-
-use std::cast;
-
-impl FormData {
- pub fn init_wrapper(@mut self) {
- let script_context = global_script_context();
- let cx = script_context.js_compartment.cx.ptr;
- let owner = script_context.root_frame.get_ref().window;
- let cache = owner.get_wrappercache();
- let scope = cache.get_wrapper();
- self.wrap_object_shared(cx, scope);
- }
-}
-
-impl CacheableWrapper for FormData {
- fn get_wrappercache(&mut self) -> &mut WrapperCache {
- unsafe {
- cast::transmute(&self.wrapper)
- }
- }
-
- fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
- let mut unused = false;
- FormDataBinding::Wrap(cx, scope, self, &mut unused)
- }
-}
-
-impl BindingObject for FormData {
- fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
- let script_context = task_from_context(cx);
- unsafe {
- (*script_context).root_frame.get_ref().window as @mut CacheableWrapper
- }
- }
-}
-
-impl DerivedWrapper for FormData {
- fn wrap(&mut self, _cx: *JSContext, _scope: *JSObject, _vp: *mut JSVal) -> i32 {
- fail!(~"nyi")
- }
-
- fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
- let obj = self.wrap_object_shared(cx, scope);
- if obj.is_null() {
- return 0;
- } else {
- unsafe { *vp = RUST_OBJECT_TO_JSVAL(obj) };
- return 1;
- }
- }
-}
diff --git a/src/components/script/dom/bindings/htmlcollection.rs b/src/components/script/dom/bindings/htmlcollection.rs
deleted file mode 100644
index fe7ddf3dfe0..00000000000
--- a/src/components/script/dom/bindings/htmlcollection.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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 dom::bindings::codegen::HTMLCollectionBinding;
-use dom::bindings::utils::{CacheableWrapper, BindingObject, WrapperCache};
-use dom::htmlcollection::HTMLCollection;
-use script_task::{task_from_context, global_script_context};
-
-use js::jsapi::{JSObject, JSContext};
-
-use std::cast;
-
-impl HTMLCollection {
- pub fn init_wrapper(@mut self) {
- let script_context = global_script_context();
- let cx = script_context.js_compartment.cx.ptr;
- let owner = script_context.root_frame.get_ref().window;
- let cache = owner.get_wrappercache();
- let scope = cache.get_wrapper();
- self.wrap_object_shared(cx, scope);
- }
-}
-
-impl BindingObject for HTMLCollection {
- fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
- let script_context = task_from_context(cx);
- unsafe {
- (*script_context).root_frame.get_ref().window as @mut CacheableWrapper
- }
- }
-}
-
-impl CacheableWrapper for HTMLCollection {
- fn get_wrappercache(&mut self) -> &mut WrapperCache {
- unsafe {
- cast::transmute(&self.wrapper)
- }
- }
-
- fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
- let mut unused = false;
- HTMLCollectionBinding::Wrap(cx, scope, self, &mut unused)
- }
-}
diff --git a/src/components/script/dom/bindings/node.rs b/src/components/script/dom/bindings/node.rs
index 49a857405a9..b5da86320bb 100644
--- a/src/components/script/dom/bindings/node.rs
+++ b/src/components/script/dom/bindings/node.rs
@@ -13,7 +13,6 @@ use std::cast;
use std::libc::c_uint;
use std::ptr;
use std::ptr::null;
-use std::vec;
use js::jsapi::*;
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, JSPropertySpec};
use js::jsapi::{JSPropertyOpWrapper, JSStrictPropertyOpWrapper};
@@ -54,12 +53,12 @@ pub fn init(compartment: @mut Compartment) {
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: JSPropertyOpWrapper {op: null(), info: null()},
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
- vec::push(&mut compartment.global_props, attrs);
- vec::as_imm_buf(*attrs, |specs, _len| {
+ compartment.global_props.push(attrs);
+ do attrs.as_imm_buf |specs, _len| {
unsafe {
JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs);
}
- });
+ }
}
#[allow(non_implicitly_copyable_typarams)]
@@ -121,35 +120,6 @@ extern fn getNextSibling(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBoo
return 1;
}
-impl Node<ScriptView> {
- fn getNodeType(&self) -> i32 {
- match self.type_id {
- ElementNodeTypeId(_) => 1,
- TextNodeTypeId => 3,
- CommentNodeTypeId => 8,
- DoctypeNodeTypeId => 10
- }
- }
-
- fn getNextSibling(&mut self) -> Option<&mut AbstractNode<ScriptView>> {
- match self.next_sibling {
- // transmute because the compiler can't deduce that the reference
- // is safe outside of with_mut_base blocks.
- Some(ref mut n) => Some(unsafe { cast::transmute(n) }),
- None => None
- }
- }
-
- fn getFirstChild(&mut self) -> Option<&mut AbstractNode<ScriptView>> {
- match self.first_child {
- // transmute because the compiler can't deduce that the reference
- // is safe outside of with_mut_base blocks.
- Some(ref mut n) => Some(unsafe { cast::transmute(n) }),
- None => None
- }
- }
- }
-
extern fn getNodeType(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool {
unsafe {
let obj = JS_THIS_OBJECT(cx, cast::transmute(vp));
diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs
index f72aad15ed9..5fc2fcfc647 100644
--- a/src/components/script/dom/bindings/utils.rs
+++ b/src/components/script/dom/bindings/utils.rs
@@ -13,8 +13,8 @@ use std::ptr;
use std::ptr::{null, to_unsafe_ptr};
use std::result;
use std::str;
-use std::sys;
use std::uint;
+use std::unstable::intrinsics;
use js::glue::*;
use js::glue::{DefineFunctionWithReserved, GetObjectJSClass, RUST_OBJECT_TO_JSVAL};
use js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB, ENUMERATE_STUB, CONVERT_STUB, RESOLVE_STUB};
@@ -105,7 +105,7 @@ impl DOMString {
pub struct rust_box<T> {
rc: uint,
- td: *sys::TypeDesc,
+ td: *intrinsics::TyDesc,
next: *(),
prev: *(),
payload: T
@@ -179,12 +179,12 @@ pub fn get_compartment(cx: *JSContext) -> @mut Compartment {
extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *JSVal, bp: *mut JSBool) -> JSBool {
//XXXjdm this is totally broken for non-object values
unsafe {
- let mut o = RUST_JSVAL_TO_OBJECT(unsafe {*v});
- let obj = unsafe {*obj};
- unsafe { *bp = 0; }
+ let mut o = RUST_JSVAL_TO_OBJECT(*v);
+ let obj = *obj;
+ *bp = 0;
while o.is_not_null() {
if o == obj {
- unsafe { *bp = 1; }
+ *bp = 1;
break;
}
o = JS_GetPrototype(o);
@@ -718,7 +718,7 @@ pub fn XrayResolveProperty(cx: *JSContext,
unsafe {
match attributes {
Some(attrs) => {
- for attrs.each |&elem| {
+ for attrs.iter().advance |&elem| {
let (attr, attr_id) = elem;
if attr_id == JSID_VOID || attr_id != id {
loop;
@@ -769,7 +769,7 @@ fn InternJSString(cx: *JSContext, chars: *libc::c_char) -> Option<jsid> {
pub fn InitIds(cx: *JSContext, specs: &[JSPropertySpec], ids: &mut [jsid]) -> bool {
let mut rval = true;
- for specs.eachi |i, spec| {
+ for specs.iter().enumerate().advance |(i, spec)| {
if spec.name.is_null() == true {
break;
}
@@ -830,7 +830,7 @@ pub fn FindEnumStringIndex(cx: *JSContext,
if chars.is_null() {
return Err(());
}
- for values.eachi |i, value| {
+ for values.iter().enumerate().advance |(i, value)| {
if value.length != length as uint {
loop;
}
diff --git a/src/components/script/dom/clientrect.rs b/src/components/script/dom/clientrect.rs
index ccddcff788f..cd3f9f344e6 100644
--- a/src/components/script/dom/clientrect.rs
+++ b/src/components/script/dom/clientrect.rs
@@ -2,8 +2,14 @@
* 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 dom::bindings::utils::WrapperCache;
+use dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper};
+use dom::bindings::codegen::ClientRectBinding;
+use script_task::{task_from_context, global_script_context};
+use js::jsapi::{JSObject, JSContext, JSVal};
+use js::glue::RUST_OBJECT_TO_JSVAL;
+
+use std::cast;
use std::f32;
pub struct ClientRect {
@@ -27,6 +33,15 @@ impl ClientRect {
rect
}
+ pub fn init_wrapper(@mut self) {
+ let script_context = global_script_context();
+ let cx = script_context.js_compartment.cx.ptr;
+ let owner = script_context.root_frame.get_ref().window;
+ let cache = owner.get_wrappercache();
+ let scope = cache.get_wrapper();
+ self.wrap_object_shared(cx, scope);
+ }
+
pub fn Top(&self) -> f32 {
self.top
}
@@ -52,3 +67,40 @@ impl ClientRect {
}
}
+impl CacheableWrapper for ClientRect {
+ fn get_wrappercache(&mut self) -> &mut WrapperCache {
+ unsafe {
+ cast::transmute(&self.wrapper)
+ }
+ }
+
+ fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
+ let mut unused = false;
+ ClientRectBinding::Wrap(cx, scope, self, &mut unused)
+ }
+}
+
+impl BindingObject for ClientRect {
+ fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
+ let script_context = task_from_context(cx);
+ unsafe {
+ (*script_context).root_frame.get_ref().window as @mut CacheableWrapper
+ }
+ }
+}
+
+impl DerivedWrapper for ClientRect {
+ fn wrap(&mut self, _cx: *JSContext, _scope: *JSObject, _vp: *mut JSVal) -> i32 {
+ fail!(~"nyi")
+ }
+
+ fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
+ let obj = self.wrap_object_shared(cx, scope);
+ if obj.is_null() {
+ return 0;
+ } else {
+ unsafe { *vp = RUST_OBJECT_TO_JSVAL(obj) };
+ return 1;
+ }
+ }
+}
diff --git a/src/components/script/dom/clientrectlist.rs b/src/components/script/dom/clientrectlist.rs
index 6165f13e6e3..2fdbc108f36 100644
--- a/src/components/script/dom/clientrectlist.rs
+++ b/src/components/script/dom/clientrectlist.rs
@@ -2,8 +2,14 @@
* 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 dom::bindings::codegen::ClientRectListBinding;
+use dom::bindings::utils::{WrapperCache, CacheableWrapper, BindingObject};
use dom::clientrect::ClientRect;
-use dom::bindings::utils::WrapperCache;
+use script_task::{task_from_context, global_script_context};
+
+use js::jsapi::{JSObject, JSContext};
+
+use std::cast;
pub struct ClientRectList {
wrapper: WrapperCache,
@@ -20,6 +26,15 @@ impl ClientRectList {
list
}
+ pub fn init_wrapper(@mut self) {
+ let script_context = global_script_context();
+ let cx = script_context.js_compartment.cx.ptr;
+ let owner = script_context.root_frame.get_ref().window;
+ let cache = owner.get_wrappercache();
+ let scope = cache.get_wrapper();
+ self.wrap_object_shared(cx, scope);
+ }
+
pub fn Length(&self) -> u32 {
self.rects.len() as u32
}
@@ -37,3 +52,25 @@ impl ClientRectList {
self.Item(index)
}
}
+
+impl CacheableWrapper for ClientRectList {
+ fn get_wrappercache(&mut self) -> &mut WrapperCache {
+ unsafe {
+ cast::transmute(&self.wrapper)
+ }
+ }
+
+ fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
+ let mut unused = false;
+ ClientRectListBinding::Wrap(cx, scope, self, &mut unused)
+ }
+}
+
+impl BindingObject for ClientRectList {
+ fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
+ let script_context = task_from_context(cx);
+ unsafe {
+ (*script_context).root_frame.get_ref().window as @mut CacheableWrapper
+ }
+ }
+}
diff --git a/src/components/script/dom/event.rs b/src/components/script/dom/event.rs
index 6b4be15b701..952a8a227cd 100644
--- a/src/components/script/dom/event.rs
+++ b/src/components/script/dom/event.rs
@@ -5,9 +5,16 @@
use dom::eventtarget::EventTarget;
use dom::window::Window;
use dom::bindings::codegen::EventBinding;
+use dom::bindings::utils::{CacheableWrapper, BindingObject, DerivedWrapper};
use dom::bindings::utils::{DOMString, ErrorResult, WrapperCache};
+use script_task::{task_from_context, global_script_context};
use geom::point::Point2D;
+use js::glue::RUST_OBJECT_TO_JSVAL;
+use js::jsapi::{JSObject, JSContext, JSVal};
+
+use std::cast;
+
pub enum Event {
ResizeEvent(uint, uint),
@@ -38,6 +45,15 @@ impl Event_ {
}
}
+ pub fn init_wrapper(@mut self) {
+ let script_context = global_script_context();
+ let cx = script_context.js_compartment.cx.ptr;
+ let owner = script_context.root_frame.get_ref().window;
+ let cache = owner.get_wrappercache();
+ let scope = cache.get_wrapper();
+ self.wrap_object_shared(cx, scope);
+ }
+
pub fn EventPhase(&self) -> u16 {
0
}
@@ -101,3 +117,39 @@ impl Event_ {
@mut Event_::new(type_)
}
}
+
+impl CacheableWrapper for Event_ {
+ fn get_wrappercache(&mut self) -> &mut WrapperCache {
+ unsafe { cast::transmute(&self.wrapper) }
+ }
+
+ fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
+ let mut unused = false;
+ EventBinding::Wrap(cx, scope, self, &mut unused)
+ }
+}
+
+impl BindingObject for Event_ {
+ fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
+ let script_context = task_from_context(cx);
+ unsafe {
+ (*script_context).root_frame.get_ref().window as @mut CacheableWrapper
+ }
+ }
+}
+
+impl DerivedWrapper for Event_ {
+ fn wrap(&mut self, _cx: *JSContext, _scope: *JSObject, _vp: *mut JSVal) -> i32 {
+ fail!(~"nyi")
+ }
+
+ fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
+ let obj = self.wrap_object_shared(cx, scope);
+ if obj.is_null() {
+ return 0;
+ } else {
+ unsafe { *vp = RUST_OBJECT_TO_JSVAL(obj) };
+ return 1;
+ }
+ }
+}
diff --git a/src/components/script/dom/eventtarget.rs b/src/components/script/dom/eventtarget.rs
index e4066ccb8d4..d5f3ff309e8 100644
--- a/src/components/script/dom/eventtarget.rs
+++ b/src/components/script/dom/eventtarget.rs
@@ -2,7 +2,14 @@
* 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 dom::bindings::utils::WrapperCache;
+use dom::bindings::codegen::EventTargetBinding;
+use dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper};
+use script_task::{task_from_context, global_script_context};
+
+use js::glue::RUST_OBJECT_TO_JSVAL;
+use js::jsapi::{JSObject, JSContext, JSVal};
+
+use std::cast;
pub struct EventTarget {
wrapper: WrapperCache
@@ -14,4 +21,51 @@ impl EventTarget {
wrapper: WrapperCache::new()
}
}
-} \ No newline at end of file
+
+ pub fn init_wrapper(@mut self) {
+ let script_context = global_script_context();
+ let cx = script_context.js_compartment.cx.ptr;
+ let owner = script_context.root_frame.get_ref().window;
+ let cache = owner.get_wrappercache();
+ let scope = cache.get_wrapper();
+ self.wrap_object_shared(cx, scope);
+ }
+}
+
+impl CacheableWrapper for EventTarget {
+ fn get_wrappercache(&mut self) -> &mut WrapperCache {
+ unsafe { cast::transmute(&self.wrapper) }
+ }
+
+ fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
+ let mut unused = false;
+ EventTargetBinding::Wrap(cx, scope, self, &mut unused)
+ }
+}
+
+impl BindingObject for EventTarget {
+ fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
+ let script_context = task_from_context(cx);
+ unsafe {
+ (*script_context).root_frame.get_ref().window as @mut CacheableWrapper
+ }
+ }
+}
+
+impl DerivedWrapper for EventTarget {
+ fn wrap(&mut self, _cx: *JSContext, _scope: *JSObject, _vp: *mut JSVal) -> i32 {
+ fail!(~"nyi")
+ }
+
+ fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
+ let obj = self.wrap_object_shared(cx, scope);
+ if obj.is_null() {
+ return 0;
+ } else {
+ unsafe {
+ *vp = RUST_OBJECT_TO_JSVAL(obj)
+ };
+ return 1;
+ }
+ }
+}
diff --git a/src/components/script/dom/formdata.rs b/src/components/script/dom/formdata.rs
index cda6b7ae272..5c3d49e1371 100644
--- a/src/components/script/dom/formdata.rs
+++ b/src/components/script/dom/formdata.rs
@@ -2,8 +2,16 @@
* 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 dom::bindings::utils::{CacheableWrapper, BindingObject, DerivedWrapper};
use dom::bindings::utils::{WrapperCache, DOMString, str};
+use dom::bindings::codegen::FormDataBinding;
use dom::blob::Blob;
+use script_task::{task_from_context, global_script_context};
+
+use js::jsapi::{JSObject, JSContext, JSVal};
+use js::glue::RUST_OBJECT_TO_JSVAL;
+
+use std::cast;
use std::hashmap::HashMap;
enum FormDatum {
@@ -24,6 +32,15 @@ impl FormData {
}
}
+ pub fn init_wrapper(@mut self) {
+ let script_context = global_script_context();
+ let cx = script_context.js_compartment.cx.ptr;
+ let owner = script_context.root_frame.get_ref().window;
+ let cache = owner.get_wrappercache();
+ let scope = cache.get_wrapper();
+ self.wrap_object_shared(cx, scope);
+ }
+
pub fn Append(&mut self, name: DOMString, value: @mut Blob, filename: Option<DOMString>) {
let blob = BlobData {
blob: value,
@@ -35,4 +52,42 @@ impl FormData {
pub fn Append_(&mut self, name: DOMString, value: DOMString) {
self.data.insert(name.to_str(), StringData(value));
}
-} \ No newline at end of file
+}
+
+impl CacheableWrapper for FormData {
+ fn get_wrappercache(&mut self) -> &mut WrapperCache {
+ unsafe {
+ cast::transmute(&self.wrapper)
+ }
+ }
+
+ fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
+ let mut unused = false;
+ FormDataBinding::Wrap(cx, scope, self, &mut unused)
+ }
+}
+
+impl BindingObject for FormData {
+ fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
+ let script_context = task_from_context(cx);
+ unsafe {
+ (*script_context).root_frame.get_ref().window as @mut CacheableWrapper
+ }
+ }
+}
+
+impl DerivedWrapper for FormData {
+ fn wrap(&mut self, _cx: *JSContext, _scope: *JSObject, _vp: *mut JSVal) -> i32 {
+ fail!(~"nyi")
+ }
+
+ fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
+ let obj = self.wrap_object_shared(cx, scope);
+ if obj.is_null() {
+ return 0;
+ } else {
+ unsafe { *vp = RUST_OBJECT_TO_JSVAL(obj) };
+ return 1;
+ }
+ }
+}
diff --git a/src/components/script/dom/htmlcollection.rs b/src/components/script/dom/htmlcollection.rs
index 403469061b8..da0b29e4e40 100644
--- a/src/components/script/dom/htmlcollection.rs
+++ b/src/components/script/dom/htmlcollection.rs
@@ -2,12 +2,15 @@
* 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 dom::bindings::utils::WrapperCache;
+use dom::bindings::codegen::HTMLCollectionBinding;
+use dom::bindings::utils::{CacheableWrapper, BindingObject, WrapperCache};
use dom::bindings::utils::{DOMString, ErrorResult};
use dom::node::{AbstractNode, ScriptView};
+use script_task::{task_from_context, global_script_context};
use js::jsapi::{JSObject, JSContext};
+use std::cast;
use std::ptr;
pub struct HTMLCollection {
@@ -24,6 +27,15 @@ impl HTMLCollection {
collection.init_wrapper();
collection
}
+
+ pub fn init_wrapper(@mut self) {
+ let script_context = global_script_context();
+ let cx = script_context.js_compartment.cx.ptr;
+ let owner = script_context.root_frame.get_ref().window;
+ let cache = owner.get_wrappercache();
+ let scope = cache.get_wrapper();
+ self.wrap_object_shared(cx, scope);
+ }
pub fn Length(&self) -> u32 {
self.elements.len() as u32
@@ -47,3 +59,25 @@ impl HTMLCollection {
self.Item(index)
}
}
+
+impl BindingObject for HTMLCollection {
+ fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
+ let script_context = task_from_context(cx);
+ unsafe {
+ (*script_context).root_frame.get_ref().window as @mut CacheableWrapper
+ }
+ }
+}
+
+impl CacheableWrapper for HTMLCollection {
+ fn get_wrappercache(&mut self) -> &mut WrapperCache {
+ unsafe {
+ cast::transmute(&self.wrapper)
+ }
+ }
+
+ fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
+ let mut unused = false;
+ HTMLCollectionBinding::Wrap(cx, scope, self, &mut unused)
+ }
+}
diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs
index c573f9912fb..1dd916b52b1 100644
--- a/src/components/script/dom/node.rs
+++ b/src/components/script/dom/node.rs
@@ -367,10 +367,10 @@ impl<View> AbstractNode<View> {
pub fn dump_indent(&self, indent: uint) {
let mut s = ~"";
for uint::range(0u, indent) |_i| {
- s += " ";
+ s.push_str(" ");
}
- s += self.debug_str();
+ s.push_str(self.debug_str());
debug!("%s", s);
// FIXME: this should have a pure version?
@@ -427,7 +427,35 @@ impl Node<ScriptView> {
layout_data: None,
}
}
-}
+
+ pub fn getNodeType(&self) -> i32 {
+ match self.type_id {
+ ElementNodeTypeId(_) => 1,
+ TextNodeTypeId => 3,
+ CommentNodeTypeId => 8,
+ DoctypeNodeTypeId => 10
+ }
+ }
+
+ pub fn getNextSibling(&mut self) -> Option<&mut AbstractNode<ScriptView>> {
+ match self.next_sibling {
+ // transmute because the compiler can't deduce that the reference
+ // is safe outside of with_mut_base blocks.
+ Some(ref mut n) => Some(unsafe { cast::transmute(n) }),
+ None => None
+ }
+ }
+
+ pub fn getFirstChild(&mut self) -> Option<&mut AbstractNode<ScriptView>> {
+ match self.first_child {
+ // transmute because the compiler can't deduce that the reference
+ // is safe outside of with_mut_base blocks.
+ Some(ref mut n) => Some(unsafe { cast::transmute(n) }),
+ None => None
+ }
+ }
+ }
+
/// The CSS library requires that DOM nodes be convertible to `*c_void` via the `VoidPtrLike`
/// trait.
diff --git a/src/components/script/dom/window.rs b/src/components/script/dom/window.rs
index 41f99eaa9e9..7c69ea5aee5 100644
--- a/src/components/script/dom/window.rs
+++ b/src/components/script/dom/window.rs
@@ -34,7 +34,7 @@ pub struct Window {
}
impl Drop for Window {
- fn finalize(&self) {
+ fn drop(&self) {
self.timer_chan.send(TimerMessage_Close);
}
}
diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs
index 9540fcc87d4..da3a2c32e75 100644
--- a/src/components/script/html/hubbub_html_parser.rs
+++ b/src/components/script/html/hubbub_html_parser.rs
@@ -105,7 +105,7 @@ fn css_link_listener(to_parent: Chan<Option<Stylesheet>>,
// Send the sheets back in order
// FIXME: Shouldn't wait until after we've recieved CSSTaskExit to start sending these
- do result_vec.consume |_i, port| {
+ for result_vec.iter().advance |port| {
to_parent.send(Some(port.recv()));
}
to_parent.send(None);
@@ -130,7 +130,7 @@ fn js_script_listener(to_parent: Chan<~[~[u8]]>,
loop {
match input_port.recv() {
Payload(data) => {
- buf += data;
+ buf.push_all(data);
}
Done(Ok(*)) => {
result_chan.send(Some(buf));
@@ -292,9 +292,8 @@ pub fn parse_html(url: Url,
debug!("-- attach attrs");
do node.as_mut_element |element| {
- for tag.attributes.each |attr| {
- let &hubbub::Attribute {name: name, value: value, _} = attr;
- element.attrs.push(Attr::new(name, value));
+ for tag.attributes.iter().advance |attr| {
+ element.attrs.push(Attr::new(attr.name.clone(), attr.value.clone()));
}
}
diff --git a/src/components/script/script.rc b/src/components/script/script.rc
index 344ff74ca57..a9f6a5c8a00 100644
--- a/src/components/script/script.rc
+++ b/src/components/script/script.rc
@@ -26,19 +26,13 @@ pub mod dom {
pub mod bindings {
pub mod document;
pub mod element;
- pub mod event;
- pub mod eventtarget;
pub mod node;
pub mod text;
pub mod utils;
pub mod conversions;
pub mod window;
pub mod proxyhandler;
- pub mod clientrect;
- pub mod clientrectlist;
pub mod domparser;
- pub mod htmlcollection;
- pub mod formdata;
pub mod codegen {
pub mod ClientRectBinding;
pub mod ClientRectListBinding;
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs
index e6d2ef28436..8111ccda72d 100644
--- a/src/components/script/script_task.rs
+++ b/src/components/script/script_task.rs
@@ -167,7 +167,7 @@ pub fn task_from_context(js_context: *JSContext) -> *mut ScriptTask {
#[unsafe_destructor]
impl Drop for ScriptTask {
- fn finalize(&self) {
+ fn drop(&self) {
unsafe {
let _ = local_data::local_data_pop(global_script_context_key);
}
@@ -247,7 +247,7 @@ impl ScriptTask {
}
}
- pub fn create<C: ScriptListener + Owned>(id: uint,
+ pub fn create<C: ScriptListener + Send>(id: uint,
compositor: C,
layout_chan: LayoutChan,
script_port: Port<ScriptMsg>,
@@ -356,8 +356,8 @@ impl ScriptTask {
/// The entry point to document loading. Defines bindings, sets up the window and document
/// objects, parses HTML and CSS, and kicks off initial layout.
fn load(&mut self, url: Url) {
- for self.last_loaded_url.iter().advance |&last_loaded_url| {
- if url == last_loaded_url { return; }
+ for self.last_loaded_url.iter().advance |last_loaded_url| {
+ if url == *last_loaded_url { return; }
}
// Define the script DOM bindings.
//
@@ -419,9 +419,9 @@ impl ScriptTask {
self.js_compartment.define_functions(debug_fns);
// Evaluate every script in the document.
- do js_scripts.consume |_, bytes| {
+ for js_scripts.iter().advance |bytes| {
let _ = self.js_context.evaluate_script(self.js_compartment.global_obj,
- bytes,
+ bytes.clone(),
~"???",
1);
}
@@ -501,7 +501,7 @@ impl ScriptTask {
}
/// Sends the given query to layout.
- pub fn query_layout<T: Owned>(&mut self, query: LayoutQuery, response_port: Port<Result<T, ()>>) -> Result<T,()> {
+ pub fn query_layout<T: Send>(&mut self, query: LayoutQuery, response_port: Port<Result<T, ()>>) -> Result<T,()> {
self.join_layout();
self.layout_chan.send(QueryMsg(query));
response_port.recv()
diff --git a/src/components/util/cache.rs b/src/components/util/cache.rs
index 5e35a440088..b5169211172 100644
--- a/src/components/util/cache.rs
+++ b/src/components/util/cache.rs
@@ -143,14 +143,14 @@ impl<K: Clone + Eq, V: Clone> Cache<K,V> for LRUCache<K,V> {
}
fn find(&mut self, key: &K) -> Option<V> {
- match self.entries.position(|&(k, _)| k == *key) {
+ match self.entries.iter().position(|&(ref k, _)| *k == *key) {
Some(pos) => Some(self.touch(pos)),
None => None,
}
}
fn find_or_create(&mut self, key: &K, blk: &fn(&K) -> V) -> V {
- match self.entries.position(|&(k, _)| k == *key) {
+ match self.entries.iter().position(|&(ref k, _)| *k == *key) {
Some(pos) => self.touch(pos),
None => {
let val = blk(key);
diff --git a/src/components/util/time.rs b/src/components/util/time.rs
index ac94abcfb7a..b8c88753974 100644
--- a/src/components/util/time.rs
+++ b/src/components/util/time.rs
@@ -90,7 +90,7 @@ impl ProfilerCategory {
}
priv fn check_order(vec: &[(ProfilerCategory, ~[f64])]) {
- for vec.each |&(category, _)| {
+ for vec.iter().advance |&(category, _)| {
if category != vec[category as uint].first() {
fail!("Enum category does not match bucket index. This is a bug.");
}
@@ -161,7 +161,7 @@ impl Profiler {
let data_len = data.len();
if data_len > 0 {
let (mean, median, min, max) =
- (data.foldl(0f64, |a, b| a + *b) / (data_len as f64),
+ (data.iter().fold(0f64, |a, b| a + *b) / (data_len as f64),
data[data_len / 2],
data.iter().min(),
data.iter().max());
diff --git a/src/components/util/tree.rs b/src/components/util/tree.rs
index 23b8ca80d77..94ceb5e1b36 100644
--- a/src/components/util/tree.rs
+++ b/src/components/util/tree.rs
@@ -152,7 +152,8 @@ impl<NR:TreeNodeRef<N>,N:TreeNode<NR>> TreeUtils for NR {
}
for self.each_child |kid| {
- if !kid.traverse_preorder(callback) {
+ // FIXME: Work around rust#2202. We should be able to pass the callback directly.
+ if !kid.traverse_preorder(|a| callback(a)) {
return false;
}
}
@@ -162,7 +163,8 @@ impl<NR:TreeNodeRef<N>,N:TreeNode<NR>> TreeUtils for NR {
fn traverse_postorder(&self, callback: &fn(NR) -> bool) -> bool {
for self.each_child |kid| {
- if !kid.traverse_postorder(callback) {
+ // FIXME: Work around rust#2202. We should be able to pass the callback directly.
+ if !kid.traverse_postorder(|a| callback(a)) {
return false;
}
}
diff --git a/src/components/util/url.rs b/src/components/util/url.rs
index 01a8f9b13d1..0cb8a32c3ce 100644
--- a/src/components/util/url.rs
+++ b/src/components/util/url.rs
@@ -44,9 +44,10 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
for current_url.path.split_iter('/').advance |p| {
path.push(p.to_str());
}
- let path = path; // FIXME: borrow checker workaround
let path = path.init();
- let path = (path.map(|x| copy *x) + [str_url]).connect("/");
+ let mut path = path.iter().transform(|x| copy *x).collect::<~[~str]>();
+ path.push(str_url);
+ let path = path.connect("/");
current_url.scheme + "://" + current_url.host + path
}
diff --git a/src/platform/linux/rust-fontconfig b/src/platform/linux/rust-fontconfig
-Subproject faca1281aaf112e96ee03041744fe85ac427319
+Subproject 78f84af79eb653fde2d50621fc3631043fa6fa9
diff --git a/src/platform/linux/rust-freetype b/src/platform/linux/rust-freetype
-Subproject 5247c3e97f7eafa336c8a028a3175c3bc3a2d95
+Subproject 980254dd840772c8ee5f37056e7bd9f4d93d537
diff --git a/src/platform/linux/rust-xlib b/src/platform/linux/rust-xlib
-Subproject 788f41a6e924e5c3f9d254d3e5dabf2b3e622f0
+Subproject 641af36389a7592ef0faea2488ec08bd144e9bf
diff --git a/src/platform/macos/rust-cocoa b/src/platform/macos/rust-cocoa
-Subproject 3ef4cf7fdaaaa51026ec546a71426ff03a0899f
+Subproject 23bb17289846dd9486f633c0b5187c7ba333d94
diff --git a/src/platform/macos/rust-core-foundation b/src/platform/macos/rust-core-foundation
-Subproject ea8d2bd026cd91d3fb5fd753677da3fd7d21dba
+Subproject 77e9ed24ca7bb0f9a0b33d7fd888de2905dddcd
diff --git a/src/platform/macos/rust-core-text b/src/platform/macos/rust-core-text
-Subproject 72c7673ac50cc1ffb518de65022fb034df334ed
+Subproject 313e26f9202b44d09043485671bc903786c328e
diff --git a/src/support/azure/rust-azure b/src/support/azure/rust-azure
-Subproject d265202c324d566a52d5946e08ad148dcf06825
+Subproject ba24db51b38c9875e1356f7bc08c13a68307171
diff --git a/src/support/css/rust-css b/src/support/css/rust-css
-Subproject 5e8c30cc69286e68ba9bf843f146a580381bff8
+Subproject 7a584804a98b5731fb53d216c3f059e5a0c7ea5
diff --git a/src/support/glfw/glfw-rs b/src/support/glfw/glfw-rs
-Subproject dc6b77d2df8cb425a55c5ef48f77320de092fa1
+Subproject 8999e447127c8674cdf130a2bd1759d9f94cd6a
diff --git a/src/support/glut/rust-glut b/src/support/glut/rust-glut
-Subproject 42931c8e0894c0d3d70d29abdf16639b30e6bf9
+Subproject 8f253edf62cfadfa18edb773aebd74bd62647ce
diff --git a/src/support/http-client/rust-http-client b/src/support/http-client/rust-http-client
-Subproject d88f23d1541019baaedb350ce275349ad2ca304
+Subproject 17afe7a4b5d40dd3da792cd5e22e1e6b48225f2
diff --git a/src/support/hubbub/rust-hubbub b/src/support/hubbub/rust-hubbub
-Subproject c549e77a677a6f76f8c9a42682d719d4ac20c3f
+Subproject 09a6c29e0a9432d67eeb583324c17766aa1155e
diff --git a/src/support/layers/rust-layers b/src/support/layers/rust-layers
-Subproject 41b967cf1a1bf91227a4e8ee52c82a228eeb7e9
+Subproject a8843ea084262773c31916e3a52c6dacea13515
diff --git a/src/support/netsurfcss/rust-netsurfcss b/src/support/netsurfcss/rust-netsurfcss
-Subproject afdd72f326f720afcfa7cea6005b20924a44157
+Subproject aecdedca9ebef5ce6cf4d2dd38e2c312c0907f1
diff --git a/src/support/opengles/rust-opengles b/src/support/opengles/rust-opengles
-Subproject d7c05e81acb66717f1a86ad67f391c9bc0961bb
+Subproject 17bd4bbc04942e7de9eae76c0f8a76dfcb3dc9f
diff --git a/src/support/spidermonkey/rust-mozjs b/src/support/spidermonkey/rust-mozjs
-Subproject af080e2ab3ca871a6e77339eb752e59b3903b06
+Subproject 26dc2e896a57a28f03be43df46868e1a41a1580
diff --git a/src/support/stb-image/rust-stb-image b/src/support/stb-image/rust-stb-image
-Subproject 577bebc7c14f391cf5faddc16bda194da6a3e7b
+Subproject 86c9525ec4aa886c5afe4ec5202ca3a0d400d15
diff --git a/src/support/wapcaplet/rust-wapcaplet b/src/support/wapcaplet/rust-wapcaplet
-Subproject c726370b54f573f7f5d67619f40b0b92d55919c
+Subproject 5ed1ff9da4301dd3efd7102f3607fd353a09980