mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update to latest Rust.
This commit is contained in:
parent
e0e5e1a2a7
commit
870db39836
75 changed files with 539 additions and 626 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit f348465283d6cd85b69bcdc1711d14985d154c39
|
Subproject commit 5aa0ca9b2eb28166d9ab2e86557a5b1f84230b46
|
|
@ -48,7 +48,7 @@ impl<E> DisplayList<E> {
|
||||||
/// Draws the display list into the given render context.
|
/// Draws the display list into the given render context.
|
||||||
pub fn draw_into_context(&self, render_context: &RenderContext) {
|
pub fn draw_into_context(&self, render_context: &RenderContext) {
|
||||||
debug!("Beginning display list.");
|
debug!("Beginning display list.");
|
||||||
for self.list.each |item| {
|
for self.list.iter().advance |item| {
|
||||||
// FIXME(Issue #150): crashes
|
// FIXME(Issue #150): crashes
|
||||||
//debug!("drawing %?", *item);
|
//debug!("drawing %?", *item);
|
||||||
item.draw_into_context(render_context)
|
item.draw_into_context(render_context)
|
||||||
|
|
|
@ -389,7 +389,7 @@ impl Font {
|
||||||
|
|
||||||
let mut origin = copy baseline_origin;
|
let mut origin = copy baseline_origin;
|
||||||
let mut azglyphs = ~[];
|
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 run.iter_slices_for_range(range) |glyphs, _offset, slice_range| {
|
||||||
for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| {
|
for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| {
|
||||||
|
@ -433,7 +433,7 @@ impl Font {
|
||||||
let mut advance = Au(0);
|
let mut advance = Au(0);
|
||||||
for run.iter_slices_for_range(range) |glyphs, _offset, slice_range| {
|
for run.iter_slices_for_range(range) |glyphs, _offset, slice_range| {
|
||||||
for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| {
|
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)
|
RunMetrics::new(advance, self.metrics.ascent, self.metrics.descent)
|
||||||
|
@ -445,7 +445,7 @@ impl Font {
|
||||||
-> RunMetrics {
|
-> RunMetrics {
|
||||||
let mut advance = Au(0);
|
let mut advance = Au(0);
|
||||||
for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| {
|
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)
|
RunMetrics::new(advance, self.metrics.ascent, self.metrics.descent)
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ impl FontFamily {
|
||||||
// TODO(Issue #190): if not in the fast path above, do
|
// TODO(Issue #190): if not in the fast path above, do
|
||||||
// expensive matching of weights, etc.
|
// expensive matching of weights, etc.
|
||||||
let this: &mut FontFamily = self; // FIXME: borrow checker workaround
|
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()) &&
|
if (style.weight.is_bold() == entry.is_bold()) &&
|
||||||
(style.italic == entry.is_italic()) {
|
(style.italic == entry.is_italic()) {
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ use freetype::tt_os2::TT_OS2;
|
||||||
use std::cast;
|
use std::cast;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::vec;
|
|
||||||
|
|
||||||
fn float_to_fixed_ft(f: float) -> i32 {
|
fn float_to_fixed_ft(f: float) -> i32 {
|
||||||
float_to_fixed(6, f)
|
float_to_fixed(6, f)
|
||||||
|
@ -63,7 +62,7 @@ pub struct FontHandle {
|
||||||
|
|
||||||
#[unsafe_destructor]
|
#[unsafe_destructor]
|
||||||
impl Drop for FontHandle {
|
impl Drop for FontHandle {
|
||||||
fn finalize(&self) {
|
fn drop(&self) {
|
||||||
assert!(self.face.is_not_null());
|
assert!(self.face.is_not_null());
|
||||||
unsafe {
|
unsafe {
|
||||||
if !FT_Done_Face(self.face).succeeded() {
|
if !FT_Done_Face(self.face).succeeded() {
|
||||||
|
@ -81,7 +80,7 @@ impl FontHandleMethods for FontHandle {
|
||||||
let ft_ctx: FT_Library = fctx.ctx.ctx;
|
let ft_ctx: FT_Library = fctx.ctx.ctx;
|
||||||
if ft_ctx.is_null() { return Err(()); }
|
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)
|
create_face_from_buffer(ft_ctx, bytes, len, style.pt_size)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ struct FreeTypeLibraryHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for FreeTypeLibraryHandle {
|
impl Drop for FreeTypeLibraryHandle {
|
||||||
fn finalize(&self) {
|
fn drop(&self) {
|
||||||
assert!(self.ctx.is_not_null());
|
assert!(self.ctx.is_not_null());
|
||||||
unsafe {
|
unsafe {
|
||||||
FT_Done_FreeType(self.ctx);
|
FT_Done_FreeType(self.ctx);
|
||||||
|
|
|
@ -139,7 +139,7 @@ struct AutoPattern {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for AutoPattern {
|
impl Drop for AutoPattern {
|
||||||
fn finalize(&self) {
|
fn drop(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
FcPatternDestroy(self.pattern);
|
FcPatternDestroy(self.pattern);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ use core_text::font_descriptor::{kCTFontDefaultOrientation};
|
||||||
use core_text;
|
use core_text;
|
||||||
|
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::vec;
|
|
||||||
|
|
||||||
pub struct FontTable {
|
pub struct FontTable {
|
||||||
data: CFData,
|
data: CFData,
|
||||||
|
@ -37,7 +36,7 @@ pub struct FontTable {
|
||||||
|
|
||||||
// Noncopyable.
|
// Noncopyable.
|
||||||
impl Drop for FontTable {
|
impl Drop for FontTable {
|
||||||
fn finalize(&self) {}
|
fn drop(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FontTable {
|
impl FontTable {
|
||||||
|
@ -80,9 +79,9 @@ impl FontHandle {
|
||||||
impl FontHandleMethods for FontHandle {
|
impl FontHandleMethods for FontHandle {
|
||||||
fn new_from_buffer(_: &FontContextHandle, buf: ~[u8], style: &SpecifiedFontStyle)
|
fn new_from_buffer(_: &FontContextHandle, buf: ~[u8], style: &SpecifiedFontStyle)
|
||||||
-> Result<FontHandle, ()> {
|
-> 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)
|
core_graphics::data_provider::new_from_buffer(cbuf, len)
|
||||||
});
|
};
|
||||||
|
|
||||||
let cgfont = core_graphics::font::create_with_data_provider(&fontprov);
|
let cgfont = core_graphics::font::create_with_data_provider(&fontprov);
|
||||||
let ctfont = core_text::font::new_from_CGFont(&cgfont, style.pt_size);
|
let ctfont = core_text::font::new_from_CGFont(&cgfont, style.pt_size);
|
||||||
|
|
|
@ -75,7 +75,7 @@ priv struct RenderTask<C> {
|
||||||
last_paint_msg: Option<(arc::ARC<LayerBufferSet>, Size2D<uint>)>,
|
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,
|
pub fn create(id: uint,
|
||||||
port: Port<Msg>,
|
port: Port<Msg>,
|
||||||
compositor: C,
|
compositor: C,
|
||||||
|
|
|
@ -347,7 +347,7 @@ impl<'self> DetailedGlyphStore {
|
||||||
// FIXME: Is this right? --pcwalton
|
// FIXME: Is this right? --pcwalton
|
||||||
// TODO: should fix this somewhere else
|
// TODO: should fix this somewhere else
|
||||||
if count == 0 {
|
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());
|
assert!((count as uint) <= self.detail_buffer.len());
|
||||||
|
@ -365,7 +365,7 @@ impl<'self> DetailedGlyphStore {
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
assert!(i + (count as uint) <= self.detail_buffer.len());
|
assert!(i + (count as uint) <= self.detail_buffer.len());
|
||||||
// return a slice into the buffer
|
// 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| {
|
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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -643,9 +644,10 @@ impl<'self> GlyphStore {
|
||||||
true
|
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| {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ impl ShapedGlyphData {
|
||||||
} else {
|
} else {
|
||||||
// adjust the pen..
|
// adjust the pen..
|
||||||
if y_advance > Au(0) {
|
if y_advance > Au(0) {
|
||||||
*y_pos -= y_advance;
|
*y_pos = *y_pos - y_advance;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(Point2D(x_offset, *y_pos - y_offset))
|
Some(Point2D(x_offset, *y_pos - y_offset))
|
||||||
|
@ -143,7 +143,7 @@ pub struct Shaper {
|
||||||
|
|
||||||
#[unsafe_destructor]
|
#[unsafe_destructor]
|
||||||
impl Drop for Shaper {
|
impl Drop for Shaper {
|
||||||
fn finalize(&self) {
|
fn drop(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!(self.hb_face.is_not_null());
|
assert!(self.hb_face.is_not_null());
|
||||||
hb_face_destroy(self.hb_face);
|
hb_face_destroy(self.hb_face);
|
||||||
|
|
|
@ -123,7 +123,7 @@ impl<'self> TextRun {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn char_len(&self) -> uint {
|
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()
|
len + slice_glyphs.get().char_len()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ impl<'self> TextRun {
|
||||||
f: &fn(&GlyphStore, uint, &Range) -> bool)
|
f: &fn(&GlyphStore, uint, &Range) -> bool)
|
||||||
-> bool {
|
-> bool {
|
||||||
let mut offset = 0;
|
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.
|
// Determine the range of this slice that we need.
|
||||||
let slice_range = Range::new(offset, slice_glyphs.get().char_len());
|
let slice_range = Range::new(offset, slice_glyphs.get().char_len());
|
||||||
let mut char_range = range.intersect(&slice_range);
|
let mut char_range = range.intersect(&slice_range);
|
||||||
|
|
|
@ -205,7 +205,7 @@ impl Constellation {
|
||||||
}
|
}
|
||||||
|
|
||||||
ExitMsg(sender) => {
|
ExitMsg(sender) => {
|
||||||
for self.pipelines.each |_, pipeline| {
|
for self.pipelines.iter().advance |(_, pipeline)| {
|
||||||
pipeline.exit();
|
pipeline.exit();
|
||||||
}
|
}
|
||||||
self.image_cache_task.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
|
// Don't navigate on Navigate type, because that is handled by forward/back
|
||||||
match pipeline.navigation_type.get() {
|
match pipeline.navigation_type.get() {
|
||||||
constellation_msg::Load => {
|
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
|
/* FIXME(tkuehn): the following code causes a segfault
|
||||||
for evicted.iter().advance |id| {
|
for evicted.iter().advance |id| {
|
||||||
self.pipelines.get(id).exit();
|
self.pipelines.get(id).exit();
|
||||||
|
|
|
@ -254,9 +254,9 @@ impl BlockFlowData {
|
||||||
for self.box.iter().advance |&box| {
|
for self.box.iter().advance |&box| {
|
||||||
do box.with_model |model| {
|
do box.with_model |model| {
|
||||||
top_offset = model.margin.top + model.border.top + model.padding.top;
|
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();
|
left_offset = model.offset();
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(eatkinson): the translation here is probably
|
// TODO(eatkinson): the translation here is probably
|
||||||
|
@ -284,8 +284,8 @@ impl BlockFlowData {
|
||||||
for BlockFlow(self).each_child |kid| {
|
for BlockFlow(self).each_child |kid| {
|
||||||
do kid.with_mut_base |child_node| {
|
do kid.with_mut_base |child_node| {
|
||||||
child_node.position.origin.y = cur_y;
|
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 {
|
let height = if self.is_root {
|
||||||
|
@ -304,7 +304,7 @@ impl BlockFlowData {
|
||||||
base.model.border.top + base.model.border.bottom;
|
base.model.border.top + base.model.border.bottom;
|
||||||
base.position.size.height = height + noncontent_height;
|
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;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ use extra::net::url::Url;
|
||||||
/// A box's type influences how its styles are interpreted during layout. For example, replaced
|
/// 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
|
/// 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.
|
/// types of boxes may also contain custom data; for example, text boxes contain text.
|
||||||
|
#[deriving(Clone)]
|
||||||
pub enum RenderBox {
|
pub enum RenderBox {
|
||||||
GenericRenderBoxClass(@mut RenderBoxBase),
|
GenericRenderBoxClass(@mut RenderBoxBase),
|
||||||
ImageRenderBoxClass(@mut ImageRenderBox),
|
ImageRenderBoxClass(@mut ImageRenderBox),
|
||||||
|
@ -308,7 +309,7 @@ impl RenderBox {
|
||||||
left_range.shift_by(slice_range.length() as int);
|
left_range.shift_by(slice_range.length() as int);
|
||||||
} else {
|
} else {
|
||||||
debug!("split_to_width: case=enlarging span");
|
debug!("split_to_width: case=enlarging span");
|
||||||
remaining_width -= advance;
|
remaining_width = remaining_width - advance;
|
||||||
left_range.extend_by(slice_range.length() as int);
|
left_range.extend_by(slice_range.length() as int);
|
||||||
}
|
}
|
||||||
} else { // The advance is more than the remaining width.
|
} else { // The advance is more than the remaining width.
|
||||||
|
@ -840,10 +841,10 @@ impl RenderBox {
|
||||||
pub fn dump_indent(&self, indent: uint) {
|
pub fn dump_indent(&self, indent: uint) {
|
||||||
let mut string = ~"";
|
let mut string = ~"";
|
||||||
for uint::range(0u, indent) |_i| {
|
for uint::range(0u, indent) |_i| {
|
||||||
string += " ";
|
string.push_str(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
string += self.debug_str();
|
string.push_str(self.debug_str());
|
||||||
debug!("%s", string);
|
debug!("%s", string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,4 +864,61 @@ impl RenderBox {
|
||||||
|
|
||||||
fmt!("box b%?: %s", self.id(), representation)
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,15 +164,15 @@ impl FloatFlowData {
|
||||||
for self.box.iter().advance |&box| {
|
for self.box.iter().advance |&box| {
|
||||||
do box.with_model |model| {
|
do box.with_model |model| {
|
||||||
top_offset = model.margin.top + model.border.top + model.padding.top;
|
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| {
|
for FloatFlow(self).each_child |kid| {
|
||||||
do kid.with_mut_base |child_node| {
|
do kid.with_mut_base |child_node| {
|
||||||
child_node.position.origin.y = cur_y;
|
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;
|
let mut height = cur_y - top_offset;
|
||||||
|
@ -187,7 +187,7 @@ impl FloatFlowData {
|
||||||
base.model.border.top + base.model.border.bottom;
|
base.model.border.top + base.model.border.bottom;
|
||||||
base.position.size.height = height + noncontent_height;
|
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;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ impl FloatContextBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
fn translate(&mut self, trans: Point2D<Au>) {
|
fn translate(&mut self, trans: Point2D<Au>) {
|
||||||
self.offset += trans;
|
self.offset = self.offset + trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn last_float_pos(&self) -> Point2D<Au> {
|
fn last_float_pos(&self) -> Point2D<Au> {
|
||||||
|
@ -144,12 +144,16 @@ impl FloatContextBase{
|
||||||
let top = top - self.offset.y;
|
let top = top - self.offset.y;
|
||||||
|
|
||||||
// Relevant dimensions for the right-most left float
|
// 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
|
// 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.
|
// Find the float collisions for the given vertical range.
|
||||||
for self.float_data.each |float| {
|
for self.float_data.iter().advance |float| {
|
||||||
match *float{
|
match *float{
|
||||||
None => (),
|
None => (),
|
||||||
Some(data) => {
|
Some(data) => {
|
||||||
|
|
|
@ -314,25 +314,25 @@ impl<'self> FlowContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actual methods that do not require much flow-specific logic
|
// 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 {
|
match *self {
|
||||||
BlockFlow(block) => {
|
BlockFlow(block) => {
|
||||||
let block = &mut *block;
|
let block = &mut *block;
|
||||||
do block.box.map_default(copy seed) |box| {
|
do block.box.map_default(seed.clone()) |box| {
|
||||||
cb(copy seed, *box)
|
cb(seed.clone(), *box)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InlineFlow(inline) => {
|
InlineFlow(inline) => {
|
||||||
let inline = &mut *inline;
|
let inline = &mut *inline;
|
||||||
do inline.boxes.foldl(seed) |acc, box| {
|
do inline.boxes.iter().fold(seed) |acc, box| {
|
||||||
cb(copy *acc, *box)
|
cb(acc.clone(), *box)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => fail!(fmt!("Don't know how to iterate node's RenderBoxes for %?", self)),
|
_ => 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>,
|
node: AbstractNode<LayoutView>,
|
||||||
seed: B,
|
seed: B,
|
||||||
callback: &fn(a: B, RenderBox) -> B)
|
callback: &fn(a: B, RenderBox) -> B)
|
||||||
|
@ -394,10 +394,10 @@ impl<'self> FlowContext {
|
||||||
pub fn dump_indent(&self, indent: uint) {
|
pub fn dump_indent(&self, indent: uint) {
|
||||||
let mut s = ~"|";
|
let mut s = ~"|";
|
||||||
for uint::range(0, indent) |_i| {
|
for uint::range(0, indent) |_i| {
|
||||||
s += "---- ";
|
s.push_str("---- ");
|
||||||
}
|
}
|
||||||
|
|
||||||
s += self.debug_str();
|
s.push_str(self.debug_str());
|
||||||
debug!("%s", s);
|
debug!("%s", s);
|
||||||
|
|
||||||
// FIXME: this should have a pure/const version?
|
// FIXME: this should have a pure/const version?
|
||||||
|
@ -409,10 +409,10 @@ impl<'self> FlowContext {
|
||||||
pub fn debug_str(&self) -> ~str {
|
pub fn debug_str(&self) -> ~str {
|
||||||
let repr = match *self {
|
let repr = match *self {
|
||||||
InlineFlow(inline) => {
|
InlineFlow(inline) => {
|
||||||
let mut s = inline.boxes.foldl(~"InlineFlow(children=", |s, box| {
|
let mut s = inline.boxes.iter().fold(~"InlineFlow(children=", |s, box| {
|
||||||
fmt!("%s b%d", *s, box.id())
|
fmt!("%s b%d", s, box.id())
|
||||||
});
|
});
|
||||||
s += ")";
|
s.push_str(")");
|
||||||
s
|
s
|
||||||
},
|
},
|
||||||
BlockFlow(block) => {
|
BlockFlow(block) => {
|
||||||
|
|
|
@ -169,8 +169,8 @@ impl LineboxScanner {
|
||||||
for line_range.eachi |i| {
|
for line_range.eachi |i| {
|
||||||
do self.new_boxes[i].with_mut_base |base| {
|
do self.new_boxes[i].with_mut_base |base| {
|
||||||
base.position.origin.x = offset_x;
|
base.position.origin.x = offset_x;
|
||||||
offset_x += base.position.size.width;
|
offset_x = offset_x + base.position.size.width;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CSSTextAlignCenter => {
|
CSSTextAlignCenter => {
|
||||||
|
@ -178,8 +178,8 @@ impl LineboxScanner {
|
||||||
for line_range.eachi |i| {
|
for line_range.eachi |i| {
|
||||||
do self.new_boxes[i].with_mut_base |base| {
|
do self.new_boxes[i].with_mut_base |base| {
|
||||||
base.position.origin.x = offset_x;
|
base.position.origin.x = offset_x;
|
||||||
offset_x += base.position.size.width;
|
offset_x = offset_x + base.position.size.width;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CSSTextAlignRight => {
|
CSSTextAlignRight => {
|
||||||
|
@ -187,8 +187,8 @@ impl LineboxScanner {
|
||||||
for line_range.eachi |i| {
|
for line_range.eachi |i| {
|
||||||
do self.new_boxes[i].with_mut_base |base| {
|
do self.new_boxes[i].with_mut_base |base| {
|
||||||
base.position.origin.x = offset_x;
|
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.reset(self.new_boxes.len(), 0);
|
||||||
}
|
}
|
||||||
self.pending_line.range.extend_by(1);
|
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);
|
self.new_boxes.push(box);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ impl InlineFlowData {
|
||||||
|
|
||||||
pub fn teardown(&mut self) {
|
pub fn teardown(&mut self) {
|
||||||
self.common.teardown();
|
self.common.teardown();
|
||||||
for self.boxes.each |box| {
|
for self.boxes.iter().advance |box| {
|
||||||
box.teardown();
|
box.teardown();
|
||||||
}
|
}
|
||||||
self.boxes = ~[];
|
self.boxes = ~[];
|
||||||
|
@ -362,7 +362,7 @@ impl InlineFlowData {
|
||||||
let mut min_width = Au(0);
|
let mut min_width = Au(0);
|
||||||
let mut pref_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());
|
debug!("FlowContext[%d]: measuring %s", self.common.id, box.debug_str());
|
||||||
min_width = Au::max(min_width, box.get_min_width(ctx));
|
min_width = Au::max(min_width, box.get_min_width(ctx));
|
||||||
pref_width = Au::max(pref_width, box.get_pref_width(ctx));
|
pref_width = Au::max(pref_width, box.get_pref_width(ctx));
|
||||||
|
@ -383,7 +383,7 @@ impl InlineFlowData {
|
||||||
// `RenderBox`.
|
// `RenderBox`.
|
||||||
{
|
{
|
||||||
let this = &mut *self;
|
let this = &mut *self;
|
||||||
for this.boxes.each |&box| {
|
for this.boxes.iter().advance |&box| {
|
||||||
match box {
|
match box {
|
||||||
ImageRenderBoxClass(image_box) => {
|
ImageRenderBoxClass(image_box) => {
|
||||||
let size = image_box.image.get_size();
|
let size = image_box.image.get_size();
|
||||||
|
@ -439,7 +439,7 @@ impl InlineFlowData {
|
||||||
|
|
||||||
let mut cur_y = Au(0);
|
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);
|
debug!("assign_height_inline: processing line %u with box span: %?", i, line_span);
|
||||||
|
|
||||||
// These coordinates are relative to the left baseline.
|
// 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.
|
} // End of `lines.each` loop.
|
||||||
|
|
||||||
self.common.position.size.height = cur_y;
|
self.common.position.size.height = cur_y;
|
||||||
|
@ -554,7 +554,7 @@ impl InlineFlowData {
|
||||||
self.common.id,
|
self.common.id,
|
||||||
self.boxes.len());
|
self.boxes.len());
|
||||||
|
|
||||||
for self.boxes.each |box| {
|
for self.boxes.iter().advance |box| {
|
||||||
box.build_display_list(builder, dirty, offset, list)
|
box.build_display_list(builder, dirty, offset, list)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,16 +4,8 @@
|
||||||
|
|
||||||
//! Borders, padding, and margins.
|
//! Borders, padding, and margins.
|
||||||
|
|
||||||
use layout::display_list_builder::{ExtraDisplayListData, ToGfxColor};
|
|
||||||
use layout::box::RenderBox;
|
|
||||||
|
|
||||||
use std::cell::Cell;
|
|
||||||
use std::num::Zero;
|
use std::num::Zero;
|
||||||
use geom::point::Point2D;
|
|
||||||
use geom::rect::Rect;
|
|
||||||
use geom::size::Size2D;
|
|
||||||
use geom::side_offsets::SideOffsets2D;
|
use geom::side_offsets::SideOffsets2D;
|
||||||
use gfx::display_list::{BaseDisplayItem, BorderDisplayItem, BorderDisplayItemClass, DisplayList};
|
|
||||||
use gfx::geometry::Au;
|
use gfx::geometry::Au;
|
||||||
use newcss::complete::CompleteStyle;
|
use newcss::complete::CompleteStyle;
|
||||||
use newcss::units::{Em, Pt, Px};
|
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -249,13 +249,13 @@ impl TextRunScanner {
|
||||||
} // End of match.
|
} // End of match.
|
||||||
|
|
||||||
debug!("--- In boxes: ---");
|
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!("%u --> %s", i, box.debug_str());
|
||||||
}
|
}
|
||||||
debug!("------------------");
|
debug!("------------------");
|
||||||
|
|
||||||
debug!("--- Out boxes: ---");
|
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!("%u --> %s", i, box.debug_str());
|
||||||
}
|
}
|
||||||
debug!("------------------");
|
debug!("------------------");
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl ElementMapping {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn each(&self, callback: &fn(nr: &NodeRange) -> bool) -> bool {
|
pub fn each(&self, callback: &fn(nr: &NodeRange) -> bool) -> bool {
|
||||||
for self.entries.each |nr| {
|
for self.entries.iter().advance |nr| {
|
||||||
if !callback(nr) {
|
if !callback(nr) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ impl ElementMapping {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn eachi(&self, callback: &fn(i: uint, nr: &NodeRange) -> bool) -> bool {
|
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) {
|
if !callback(i, nr) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ impl ElementMapping {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn eachi_mut(&self, callback: &fn(i: uint, nr: &NodeRange) -> bool) -> bool {
|
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) {
|
if !callback(i, nr) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -61,19 +61,19 @@ impl ElementMapping {
|
||||||
let entries = &mut self.entries;
|
let entries = &mut self.entries;
|
||||||
|
|
||||||
debug!("--- Old boxes: ---");
|
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!("%u --> %s", i, box.debug_str());
|
||||||
}
|
}
|
||||||
debug!("------------------");
|
debug!("------------------");
|
||||||
|
|
||||||
debug!("--- New boxes: ---");
|
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!("%u --> %s", i, box.debug_str());
|
||||||
}
|
}
|
||||||
debug!("------------------");
|
debug!("------------------");
|
||||||
|
|
||||||
debug!("--- Elem ranges before repair: ---");
|
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!("%u: %? --> %s", i, nr.range, nr.node.debug_str());
|
||||||
}
|
}
|
||||||
debug!("----------------------------------");
|
debug!("----------------------------------");
|
||||||
|
@ -126,7 +126,7 @@ impl ElementMapping {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug!("--- Elem ranges after repair: ---");
|
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!("%u: %? --> %s", i, nr.range, nr.node.debug_str());
|
||||||
}
|
}
|
||||||
debug!("----------------------------------");
|
debug!("----------------------------------");
|
||||||
|
|
|
@ -93,8 +93,8 @@ impl Pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reload(&self) {
|
pub fn reload(&self) {
|
||||||
for self.url.iter().advance |&url| {
|
for self.url.iter().advance |url| {
|
||||||
self.script_chan.send(LoadMsg(url));
|
self.script_chan.send(LoadMsg(url.clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
//! A windowing implementation using GLFW.
|
//! 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::{ResizeCallback, ScrollCallback, WindowMethods, WindowMouseEvent, WindowClickEvent};
|
||||||
use windowing::{WindowMouseDownEvent, WindowMouseUpEvent, ZoomCallback, Forward, Back, NavigationCallback};
|
use windowing::{WindowMouseDownEvent, WindowMouseUpEvent, ZoomCallback, Forward, Back, NavigationCallback};
|
||||||
|
|
||||||
|
@ -24,15 +24,14 @@ pub struct Application;
|
||||||
|
|
||||||
impl ApplicationMethods for Application {
|
impl ApplicationMethods for Application {
|
||||||
pub fn new() -> Application {
|
pub fn new() -> Application {
|
||||||
glfw::private::WindowDataMap::init();
|
glfw::init();
|
||||||
unsafe { glfw::ll::glfwInit(); }
|
|
||||||
Application
|
Application
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Application {
|
impl Drop for Application {
|
||||||
fn finalize(&self) {
|
fn drop(&self) {
|
||||||
unsafe { glfw::ll::glfwTerminate(); }
|
glfw::terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +39,6 @@ impl Drop for Application {
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
glfw_window: glfw::Window,
|
glfw_window: glfw::Window,
|
||||||
|
|
||||||
composite_callback: Option<CompositeCallback>,
|
|
||||||
resize_callback: Option<ResizeCallback>,
|
resize_callback: Option<ResizeCallback>,
|
||||||
load_url_callback: Option<LoadUrlCallback>,
|
load_url_callback: Option<LoadUrlCallback>,
|
||||||
mouse_callback: Option<MouseCallback>,
|
mouse_callback: Option<MouseCallback>,
|
||||||
|
@ -69,7 +67,6 @@ impl WindowMethods<Application> for Window {
|
||||||
let window = @mut Window {
|
let window = @mut Window {
|
||||||
glfw_window: glfw_window,
|
glfw_window: glfw_window,
|
||||||
|
|
||||||
composite_callback: None,
|
|
||||||
resize_callback: None,
|
resize_callback: None,
|
||||||
load_url_callback: None,
|
load_url_callback: None,
|
||||||
mouse_callback: None,
|
mouse_callback: None,
|
||||||
|
@ -94,14 +91,6 @@ impl WindowMethods<Application> for Window {
|
||||||
Some(callback) => callback(width as uint, height as uint),
|
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| {
|
do window.glfw_window.set_key_callback |_win, key, _scancode, action, mods| {
|
||||||
if action == glfw::PRESS {
|
if action == glfw::PRESS {
|
||||||
window.handle_key(key, mods)
|
window.handle_key(key, mods)
|
||||||
|
@ -134,11 +123,6 @@ impl WindowMethods<Application> for Window {
|
||||||
self.glfw_window.swap_buffers();
|
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.
|
/// Registers a callback to run when a resize event occurs.
|
||||||
pub fn set_resize_callback(&mut self, new_resize_callback: ResizeCallback) {
|
pub fn set_resize_callback(&mut self, new_resize_callback: ResizeCallback) {
|
||||||
self.resize_callback = Some(new_resize_callback)
|
self.resize_callback = Some(new_resize_callback)
|
||||||
|
|
|
@ -47,9 +47,6 @@ impl WindowingMethods<Application> for Window {
|
||||||
(*self).flush();
|
(*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.
|
/// Registers a callback to run when a resize event occurs.
|
||||||
pub fn set_resize_callback(&mut self, _: ResizeCallback) {}
|
pub fn set_resize_callback(&mut self, _: ResizeCallback) {}
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ fn run(opts: &Opts) {
|
||||||
profiler_chan.clone());
|
profiler_chan.clone());
|
||||||
|
|
||||||
// Send the URL command to the constellation.
|
// 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)))
|
constellation_chan.send(LoadUrlMsg(make_url(copy *filename, None)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::comm;
|
||||||
use std::comm::{Chan, Port};
|
use std::comm::{Chan, Port};
|
||||||
use std::task;
|
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();
|
let (setup_po, setup_ch) = comm::stream();
|
||||||
do task::spawn {
|
do task::spawn {
|
||||||
let (po, ch) = comm::stream();
|
let (po, ch) = comm::stream();
|
||||||
|
@ -17,7 +17,7 @@ pub fn spawn_listener<A: Owned>(f: ~fn(Port<A>)) -> Chan<A> {
|
||||||
setup_po.recv()
|
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 (from_child, to_parent) = comm::stream();
|
||||||
let to_parent = Cell::new(to_parent);
|
let to_parent = Cell::new(to_parent);
|
||||||
let to_child = do spawn_listener |from_parent| {
|
let to_child = do spawn_listener |from_parent| {
|
||||||
|
|
|
@ -19,9 +19,6 @@ pub enum WindowNavigateMsg {
|
||||||
Back,
|
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.
|
/// Type of the function that is called when the window is resized.
|
||||||
pub type ResizeCallback = @fn(uint, uint);
|
pub type ResizeCallback = @fn(uint, uint);
|
||||||
|
|
||||||
|
@ -53,8 +50,6 @@ pub trait WindowMethods<A> {
|
||||||
/// Presents the window to the screen (perhaps by page flipping).
|
/// Presents the window to the screen (perhaps by page flipping).
|
||||||
pub fn present(&mut self);
|
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.
|
/// Registers a callback to run when a resize event occurs.
|
||||||
pub fn set_resize_callback(&mut self, new_resize_callback: ResizeCallback);
|
pub fn set_resize_callback(&mut self, new_resize_callback: ResizeCallback);
|
||||||
/// Registers a callback to run when a new URL is to be loaded.
|
/// Registers a callback to run when a new URL is to be loaded.
|
||||||
|
|
|
@ -179,7 +179,7 @@ impl ImageCache {
|
||||||
loop {
|
loop {
|
||||||
let msg = self.port.recv();
|
let msg = self.port.recv();
|
||||||
|
|
||||||
for msg_handlers.each |handler| {
|
for msg_handlers.iter().advance |handler| {
|
||||||
(*handler)(&msg)
|
(*handler)(&msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ impl ImageCache {
|
||||||
priv fn purge_waiters(&self, url: Url, f: &fn() -> ImageResponseMsg) {
|
priv fn purge_waiters(&self, url: Url, f: &fn() -> ImageResponseMsg) {
|
||||||
match self.wait_map.pop(&url) {
|
match self.wait_map.pop(&url) {
|
||||||
Some(waiters) => {
|
Some(waiters) => {
|
||||||
for waiters.each |response| {
|
for waiters.iter().advance |response| {
|
||||||
response.send(f());
|
response.send(f());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -444,7 +444,7 @@ fn load_image_data(url: Url, resource_task: ResourceTask) -> Result<~[u8], ()> {
|
||||||
loop {
|
loop {
|
||||||
match response_port.recv() {
|
match response_port.recv() {
|
||||||
resource_task::Payload(data) => {
|
resource_task::Payload(data) => {
|
||||||
image_data += data;
|
image_data.push_all(data);
|
||||||
}
|
}
|
||||||
resource_task::Done(result::Ok(*)) => {
|
resource_task::Done(result::Ok(*)) => {
|
||||||
return Ok(image_data);
|
return Ok(image_data);
|
||||||
|
|
|
@ -105,7 +105,7 @@ impl ResourceManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_loader_factory(&self, url: &Url) -> Option<LoaderTask> {
|
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 {
|
match *scheme_loader {
|
||||||
(ref scheme, ref loader_factory) => {
|
(ref scheme, ref loader_factory) => {
|
||||||
if (*scheme) == url.scheme {
|
if (*scheme) == url.scheme {
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::comm;
|
||||||
use std::comm::{Chan, Port};
|
use std::comm::{Chan, Port};
|
||||||
use std::task;
|
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();
|
let (setup_port, setup_chan) = comm::stream();
|
||||||
do task::spawn {
|
do task::spawn {
|
||||||
let (port, chan) = comm::stream();
|
let (port, chan) = comm::stream();
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2153,7 +2153,7 @@ class CGImports(CGWrapper):
|
||||||
# TODO imports to cover descriptors, etc.
|
# TODO imports to cover descriptors, etc.
|
||||||
|
|
||||||
def _useString(imports):
|
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,
|
CGWrapper.__init__(self, child,
|
||||||
declarePre=_useString(sorted(declareImports)))
|
declarePre=_useString(sorted(declareImports)))
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ use std::cast;
|
||||||
use std::libc;
|
use std::libc;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::vec;
|
|
||||||
use dom::bindings::utils::{DOMString, rust_box, squirrel_away, str};
|
use dom::bindings::utils::{DOMString, rust_box, squirrel_away, str};
|
||||||
use dom::bindings::utils::{WrapperCache, DerivedWrapper};
|
use dom::bindings::utils::{WrapperCache, DerivedWrapper};
|
||||||
use dom::bindings::utils::{jsval_to_str, WrapNewBindingObject, CacheableWrapper};
|
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()},
|
getter: JSPropertyOpWrapper {op: null(), info: null()},
|
||||||
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
|
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
|
||||||
compartment.global_props.push(attrs);
|
compartment.global_props.push(attrs);
|
||||||
vec::as_imm_buf(*attrs, |specs, _len| {
|
do attrs.as_imm_buf |specs, _len| {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!(JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs) == 1);
|
assert!(JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs) == 1);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
let methods = @~[JSFunctionSpec {name: compartment.add_name(~"getElementsByTagName"),
|
let methods = @~[JSFunctionSpec {name: compartment.add_name(~"getElementsByTagName"),
|
||||||
call: JSNativeWrapper {op: getElementsByTagName, info: null()},
|
call: JSNativeWrapper {op: getElementsByTagName, info: null()},
|
||||||
|
@ -118,11 +117,11 @@ pub fn init(compartment: @mut Compartment) {
|
||||||
nargs: 0,
|
nargs: 0,
|
||||||
flags: 0,
|
flags: 0,
|
||||||
selfHostedName: null()}];
|
selfHostedName: null()}];
|
||||||
vec::as_imm_buf(*methods, |fns, _len| {
|
do methods.as_imm_buf |fns, _len| {
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_DefineFunctions(compartment.cx.ptr, obj.ptr, fns);
|
JS_DefineFunctions(compartment.cx.ptr, obj.ptr, fns);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
compartment.register_class(utils::instance_jsclass(~"DocumentInstance",
|
compartment.register_class(utils::instance_jsclass(~"DocumentInstance",
|
||||||
finalize,
|
finalize,
|
||||||
|
|
|
@ -21,7 +21,6 @@ use std::ptr;
|
||||||
use std::ptr::null;
|
use std::ptr::null;
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::vec;
|
|
||||||
use js::glue::*;
|
use js::glue::*;
|
||||||
use js::jsapi::*;
|
use js::jsapi::*;
|
||||||
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, JSFreeOp, JSPropertySpec};
|
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,
|
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
|
||||||
getter: JSPropertyOpWrapper {op: null(), info: null()},
|
getter: JSPropertyOpWrapper {op: null(), info: null()},
|
||||||
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
|
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
|
||||||
vec::push(&mut compartment.global_props, attrs);
|
compartment.global_props.push(attrs);
|
||||||
vec::as_imm_buf(*attrs, |specs, _len| {
|
do attrs.as_imm_buf |specs, _len| {
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs);
|
JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
let methods = @~[JSFunctionSpec {name: compartment.add_name(~"getClientRects"),
|
let methods = @~[JSFunctionSpec {name: compartment.add_name(~"getClientRects"),
|
||||||
call: JSNativeWrapper {op: getClientRects, info: null()},
|
call: JSNativeWrapper {op: getClientRects, info: null()},
|
||||||
|
@ -111,11 +110,11 @@ pub fn init(compartment: @mut Compartment) {
|
||||||
nargs: 0,
|
nargs: 0,
|
||||||
flags: 0,
|
flags: 0,
|
||||||
selfHostedName: null()}];
|
selfHostedName: null()}];
|
||||||
vec::as_imm_buf(*methods, |fns, _len| {
|
do methods.as_imm_buf |fns, _len| {
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_DefineFunctions(compartment.cx.ptr, obj.ptr, fns);
|
JS_DefineFunctions(compartment.cx.ptr, obj.ptr, fns);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
compartment.register_class(utils::instance_jsclass(~"GenericElementInstance",
|
compartment.register_class(utils::instance_jsclass(~"GenericElementInstance",
|
||||||
finalize, trace));
|
finalize, trace));
|
||||||
|
@ -137,12 +136,12 @@ pub fn init(compartment: @mut Compartment) {
|
||||||
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
|
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
|
||||||
getter: JSPropertyOpWrapper {op: null(), info: null()},
|
getter: JSPropertyOpWrapper {op: null(), info: null()},
|
||||||
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
|
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
|
||||||
vec::push(&mut compartment.global_props, attrs);
|
compartment.global_props.push(attrs);
|
||||||
vec::as_imm_buf(*attrs, |specs, _len| {
|
do attrs.as_imm_buf |specs, _len| {
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs);
|
JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern fn getClientRects(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool {
|
extern fn getClientRects(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool {
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -13,7 +13,6 @@ use std::cast;
|
||||||
use std::libc::c_uint;
|
use std::libc::c_uint;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::ptr::null;
|
use std::ptr::null;
|
||||||
use std::vec;
|
|
||||||
use js::jsapi::*;
|
use js::jsapi::*;
|
||||||
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, JSPropertySpec};
|
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, JSPropertySpec};
|
||||||
use js::jsapi::{JSPropertyOpWrapper, JSStrictPropertyOpWrapper};
|
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,
|
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
|
||||||
getter: JSPropertyOpWrapper {op: null(), info: null()},
|
getter: JSPropertyOpWrapper {op: null(), info: null()},
|
||||||
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
|
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
|
||||||
vec::push(&mut compartment.global_props, attrs);
|
compartment.global_props.push(attrs);
|
||||||
vec::as_imm_buf(*attrs, |specs, _len| {
|
do attrs.as_imm_buf |specs, _len| {
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs);
|
JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
|
@ -121,35 +120,6 @@ extern fn getNextSibling(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBoo
|
||||||
return 1;
|
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 {
|
extern fn getNodeType(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let obj = JS_THIS_OBJECT(cx, cast::transmute(vp));
|
let obj = JS_THIS_OBJECT(cx, cast::transmute(vp));
|
||||||
|
|
|
@ -13,8 +13,8 @@ use std::ptr;
|
||||||
use std::ptr::{null, to_unsafe_ptr};
|
use std::ptr::{null, to_unsafe_ptr};
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::sys;
|
|
||||||
use std::uint;
|
use std::uint;
|
||||||
|
use std::unstable::intrinsics;
|
||||||
use js::glue::*;
|
use js::glue::*;
|
||||||
use js::glue::{DefineFunctionWithReserved, GetObjectJSClass, RUST_OBJECT_TO_JSVAL};
|
use js::glue::{DefineFunctionWithReserved, GetObjectJSClass, RUST_OBJECT_TO_JSVAL};
|
||||||
use js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB, ENUMERATE_STUB, CONVERT_STUB, RESOLVE_STUB};
|
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> {
|
pub struct rust_box<T> {
|
||||||
rc: uint,
|
rc: uint,
|
||||||
td: *sys::TypeDesc,
|
td: *intrinsics::TyDesc,
|
||||||
next: *(),
|
next: *(),
|
||||||
prev: *(),
|
prev: *(),
|
||||||
payload: T
|
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 {
|
extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *JSVal, bp: *mut JSBool) -> JSBool {
|
||||||
//XXXjdm this is totally broken for non-object values
|
//XXXjdm this is totally broken for non-object values
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut o = RUST_JSVAL_TO_OBJECT(unsafe {*v});
|
let mut o = RUST_JSVAL_TO_OBJECT(*v);
|
||||||
let obj = unsafe {*obj};
|
let obj = *obj;
|
||||||
unsafe { *bp = 0; }
|
*bp = 0;
|
||||||
while o.is_not_null() {
|
while o.is_not_null() {
|
||||||
if o == obj {
|
if o == obj {
|
||||||
unsafe { *bp = 1; }
|
*bp = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
o = JS_GetPrototype(o);
|
o = JS_GetPrototype(o);
|
||||||
|
@ -718,7 +718,7 @@ pub fn XrayResolveProperty(cx: *JSContext,
|
||||||
unsafe {
|
unsafe {
|
||||||
match attributes {
|
match attributes {
|
||||||
Some(attrs) => {
|
Some(attrs) => {
|
||||||
for attrs.each |&elem| {
|
for attrs.iter().advance |&elem| {
|
||||||
let (attr, attr_id) = elem;
|
let (attr, attr_id) = elem;
|
||||||
if attr_id == JSID_VOID || attr_id != id {
|
if attr_id == JSID_VOID || attr_id != id {
|
||||||
loop;
|
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 {
|
pub fn InitIds(cx: *JSContext, specs: &[JSPropertySpec], ids: &mut [jsid]) -> bool {
|
||||||
let mut rval = true;
|
let mut rval = true;
|
||||||
for specs.eachi |i, spec| {
|
for specs.iter().enumerate().advance |(i, spec)| {
|
||||||
if spec.name.is_null() == true {
|
if spec.name.is_null() == true {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -830,7 +830,7 @@ pub fn FindEnumStringIndex(cx: *JSContext,
|
||||||
if chars.is_null() {
|
if chars.is_null() {
|
||||||
return Err(());
|
return Err(());
|
||||||
}
|
}
|
||||||
for values.eachi |i, value| {
|
for values.iter().enumerate().advance |(i, value)| {
|
||||||
if value.length != length as uint {
|
if value.length != length as uint {
|
||||||
loop;
|
loop;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,14 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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;
|
use std::f32;
|
||||||
|
|
||||||
pub struct ClientRect {
|
pub struct ClientRect {
|
||||||
|
@ -27,6 +33,15 @@ impl ClientRect {
|
||||||
rect
|
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 {
|
pub fn Top(&self) -> f32 {
|
||||||
self.top
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,8 +2,14 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::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 {
|
pub struct ClientRectList {
|
||||||
wrapper: WrapperCache,
|
wrapper: WrapperCache,
|
||||||
|
@ -20,6 +26,15 @@ impl ClientRectList {
|
||||||
list
|
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 {
|
pub fn Length(&self) -> u32 {
|
||||||
self.rects.len() as u32
|
self.rects.len() as u32
|
||||||
}
|
}
|
||||||
|
@ -37,3 +52,25 @@ impl ClientRectList {
|
||||||
self.Item(index)
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,9 +5,16 @@
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use dom::bindings::codegen::EventBinding;
|
use dom::bindings::codegen::EventBinding;
|
||||||
|
use dom::bindings::utils::{CacheableWrapper, BindingObject, DerivedWrapper};
|
||||||
use dom::bindings::utils::{DOMString, ErrorResult, WrapperCache};
|
use dom::bindings::utils::{DOMString, ErrorResult, WrapperCache};
|
||||||
|
use script_task::{task_from_context, global_script_context};
|
||||||
|
|
||||||
use geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
|
use js::glue::RUST_OBJECT_TO_JSVAL;
|
||||||
|
use js::jsapi::{JSObject, JSContext, JSVal};
|
||||||
|
|
||||||
|
use std::cast;
|
||||||
|
|
||||||
|
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
ResizeEvent(uint, uint),
|
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 {
|
pub fn EventPhase(&self) -> u16 {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
@ -101,3 +117,39 @@ impl Event_ {
|
||||||
@mut Event_::new(type_)
|
@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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,14 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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 {
|
pub struct EventTarget {
|
||||||
wrapper: WrapperCache
|
wrapper: WrapperCache
|
||||||
|
@ -14,4 +21,51 @@ impl EventTarget {
|
||||||
wrapper: WrapperCache::new()
|
wrapper: WrapperCache::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,8 +2,16 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::utils::{WrapperCache, DOMString, str};
|
||||||
|
use dom::bindings::codegen::FormDataBinding;
|
||||||
use dom::blob::Blob;
|
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;
|
use std::hashmap::HashMap;
|
||||||
|
|
||||||
enum FormDatum {
|
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>) {
|
pub fn Append(&mut self, name: DOMString, value: @mut Blob, filename: Option<DOMString>) {
|
||||||
let blob = BlobData {
|
let blob = BlobData {
|
||||||
blob: value,
|
blob: value,
|
||||||
|
@ -35,4 +52,42 @@ impl FormData {
|
||||||
pub fn Append_(&mut self, name: DOMString, value: DOMString) {
|
pub fn Append_(&mut self, name: DOMString, value: DOMString) {
|
||||||
self.data.insert(name.to_str(), StringData(value));
|
self.data.insert(name.to_str(), StringData(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,12 +2,15 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::bindings::utils::{DOMString, ErrorResult};
|
||||||
use dom::node::{AbstractNode, ScriptView};
|
use dom::node::{AbstractNode, ScriptView};
|
||||||
|
use script_task::{task_from_context, global_script_context};
|
||||||
|
|
||||||
use js::jsapi::{JSObject, JSContext};
|
use js::jsapi::{JSObject, JSContext};
|
||||||
|
|
||||||
|
use std::cast;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
pub struct HTMLCollection {
|
pub struct HTMLCollection {
|
||||||
|
@ -24,6 +27,15 @@ impl HTMLCollection {
|
||||||
collection.init_wrapper();
|
collection.init_wrapper();
|
||||||
collection
|
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 {
|
pub fn Length(&self) -> u32 {
|
||||||
self.elements.len() as u32
|
self.elements.len() as u32
|
||||||
|
@ -47,3 +59,25 @@ impl HTMLCollection {
|
||||||
self.Item(index)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -367,10 +367,10 @@ impl<View> AbstractNode<View> {
|
||||||
pub fn dump_indent(&self, indent: uint) {
|
pub fn dump_indent(&self, indent: uint) {
|
||||||
let mut s = ~"";
|
let mut s = ~"";
|
||||||
for uint::range(0u, indent) |_i| {
|
for uint::range(0u, indent) |_i| {
|
||||||
s += " ";
|
s.push_str(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
s += self.debug_str();
|
s.push_str(self.debug_str());
|
||||||
debug!("%s", s);
|
debug!("%s", s);
|
||||||
|
|
||||||
// FIXME: this should have a pure version?
|
// FIXME: this should have a pure version?
|
||||||
|
@ -427,7 +427,35 @@ impl Node<ScriptView> {
|
||||||
layout_data: None,
|
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`
|
/// The CSS library requires that DOM nodes be convertible to `*c_void` via the `VoidPtrLike`
|
||||||
/// trait.
|
/// trait.
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub struct Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Window {
|
impl Drop for Window {
|
||||||
fn finalize(&self) {
|
fn drop(&self) {
|
||||||
self.timer_chan.send(TimerMessage_Close);
|
self.timer_chan.send(TimerMessage_Close);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ fn css_link_listener(to_parent: Chan<Option<Stylesheet>>,
|
||||||
|
|
||||||
// Send the sheets back in order
|
// Send the sheets back in order
|
||||||
// FIXME: Shouldn't wait until after we've recieved CSSTaskExit to start sending these
|
// 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(Some(port.recv()));
|
||||||
}
|
}
|
||||||
to_parent.send(None);
|
to_parent.send(None);
|
||||||
|
@ -130,7 +130,7 @@ fn js_script_listener(to_parent: Chan<~[~[u8]]>,
|
||||||
loop {
|
loop {
|
||||||
match input_port.recv() {
|
match input_port.recv() {
|
||||||
Payload(data) => {
|
Payload(data) => {
|
||||||
buf += data;
|
buf.push_all(data);
|
||||||
}
|
}
|
||||||
Done(Ok(*)) => {
|
Done(Ok(*)) => {
|
||||||
result_chan.send(Some(buf));
|
result_chan.send(Some(buf));
|
||||||
|
@ -292,9 +292,8 @@ pub fn parse_html(url: Url,
|
||||||
|
|
||||||
debug!("-- attach attrs");
|
debug!("-- attach attrs");
|
||||||
do node.as_mut_element |element| {
|
do node.as_mut_element |element| {
|
||||||
for tag.attributes.each |attr| {
|
for tag.attributes.iter().advance |attr| {
|
||||||
let &hubbub::Attribute {name: name, value: value, _} = attr;
|
element.attrs.push(Attr::new(attr.name.clone(), attr.value.clone()));
|
||||||
element.attrs.push(Attr::new(name, value));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,19 +26,13 @@ pub mod dom {
|
||||||
pub mod bindings {
|
pub mod bindings {
|
||||||
pub mod document;
|
pub mod document;
|
||||||
pub mod element;
|
pub mod element;
|
||||||
pub mod event;
|
|
||||||
pub mod eventtarget;
|
|
||||||
pub mod node;
|
pub mod node;
|
||||||
pub mod text;
|
pub mod text;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
pub mod conversions;
|
pub mod conversions;
|
||||||
pub mod window;
|
pub mod window;
|
||||||
pub mod proxyhandler;
|
pub mod proxyhandler;
|
||||||
pub mod clientrect;
|
|
||||||
pub mod clientrectlist;
|
|
||||||
pub mod domparser;
|
pub mod domparser;
|
||||||
pub mod htmlcollection;
|
|
||||||
pub mod formdata;
|
|
||||||
pub mod codegen {
|
pub mod codegen {
|
||||||
pub mod ClientRectBinding;
|
pub mod ClientRectBinding;
|
||||||
pub mod ClientRectListBinding;
|
pub mod ClientRectListBinding;
|
||||||
|
|
|
@ -167,7 +167,7 @@ pub fn task_from_context(js_context: *JSContext) -> *mut ScriptTask {
|
||||||
|
|
||||||
#[unsafe_destructor]
|
#[unsafe_destructor]
|
||||||
impl Drop for ScriptTask {
|
impl Drop for ScriptTask {
|
||||||
fn finalize(&self) {
|
fn drop(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let _ = local_data::local_data_pop(global_script_context_key);
|
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,
|
compositor: C,
|
||||||
layout_chan: LayoutChan,
|
layout_chan: LayoutChan,
|
||||||
script_port: Port<ScriptMsg>,
|
script_port: Port<ScriptMsg>,
|
||||||
|
@ -356,8 +356,8 @@ impl ScriptTask {
|
||||||
/// The entry point to document loading. Defines bindings, sets up the window and document
|
/// The entry point to document loading. Defines bindings, sets up the window and document
|
||||||
/// objects, parses HTML and CSS, and kicks off initial layout.
|
/// objects, parses HTML and CSS, and kicks off initial layout.
|
||||||
fn load(&mut self, url: Url) {
|
fn load(&mut self, url: Url) {
|
||||||
for self.last_loaded_url.iter().advance |&last_loaded_url| {
|
for self.last_loaded_url.iter().advance |last_loaded_url| {
|
||||||
if url == last_loaded_url { return; }
|
if url == *last_loaded_url { return; }
|
||||||
}
|
}
|
||||||
// Define the script DOM bindings.
|
// Define the script DOM bindings.
|
||||||
//
|
//
|
||||||
|
@ -419,9 +419,9 @@ impl ScriptTask {
|
||||||
self.js_compartment.define_functions(debug_fns);
|
self.js_compartment.define_functions(debug_fns);
|
||||||
|
|
||||||
// Evaluate every script in the document.
|
// 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,
|
let _ = self.js_context.evaluate_script(self.js_compartment.global_obj,
|
||||||
bytes,
|
bytes.clone(),
|
||||||
~"???",
|
~"???",
|
||||||
1);
|
1);
|
||||||
}
|
}
|
||||||
|
@ -501,7 +501,7 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends the given query to layout.
|
/// 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.join_layout();
|
||||||
self.layout_chan.send(QueryMsg(query));
|
self.layout_chan.send(QueryMsg(query));
|
||||||
response_port.recv()
|
response_port.recv()
|
||||||
|
|
|
@ -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> {
|
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)),
|
Some(pos) => Some(self.touch(pos)),
|
||||||
None => None,
|
None => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_or_create(&mut self, key: &K, blk: &fn(&K) -> V) -> V {
|
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),
|
Some(pos) => self.touch(pos),
|
||||||
None => {
|
None => {
|
||||||
let val = blk(key);
|
let val = blk(key);
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl ProfilerCategory {
|
||||||
}
|
}
|
||||||
|
|
||||||
priv fn check_order(vec: &[(ProfilerCategory, ~[f64])]) {
|
priv fn check_order(vec: &[(ProfilerCategory, ~[f64])]) {
|
||||||
for vec.each |&(category, _)| {
|
for vec.iter().advance |&(category, _)| {
|
||||||
if category != vec[category as uint].first() {
|
if category != vec[category as uint].first() {
|
||||||
fail!("Enum category does not match bucket index. This is a bug.");
|
fail!("Enum category does not match bucket index. This is a bug.");
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ impl Profiler {
|
||||||
let data_len = data.len();
|
let data_len = data.len();
|
||||||
if data_len > 0 {
|
if data_len > 0 {
|
||||||
let (mean, median, min, max) =
|
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[data_len / 2],
|
||||||
data.iter().min(),
|
data.iter().min(),
|
||||||
data.iter().max());
|
data.iter().max());
|
||||||
|
|
|
@ -152,7 +152,8 @@ impl<NR:TreeNodeRef<N>,N:TreeNode<NR>> TreeUtils for NR {
|
||||||
}
|
}
|
||||||
|
|
||||||
for self.each_child |kid| {
|
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;
|
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 {
|
fn traverse_postorder(&self, callback: &fn(NR) -> bool) -> bool {
|
||||||
for self.each_child |kid| {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,10 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
|
||||||
for current_url.path.split_iter('/').advance |p| {
|
for current_url.path.split_iter('/').advance |p| {
|
||||||
path.push(p.to_str());
|
path.push(p.to_str());
|
||||||
}
|
}
|
||||||
let path = path; // FIXME: borrow checker workaround
|
|
||||||
let path = path.init();
|
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
|
current_url.scheme + "://" + current_url.host + path
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit faca1281aaf112e96ee03041744fe85ac4273192
|
Subproject commit 78f84af79eb653fde2d50621fc3631043fa6fa9e
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5247c3e97f7eafa336c8a028a3175c3bc3a2d95a
|
Subproject commit 980254dd840772c8ee5f37056e7bd9f4d93d5377
|
|
@ -1 +1 @@
|
||||||
Subproject commit 788f41a6e924e5c3f9d254d3e5dabf2b3e622f00
|
Subproject commit 641af36389a7592ef0faea2488ec08bd144e9bfe
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3ef4cf7fdaaaa51026ec546a71426ff03a0899fd
|
Subproject commit 23bb17289846dd9486f633c0b5187c7ba333d943
|
|
@ -1 +1 @@
|
||||||
Subproject commit ea8d2bd026cd91d3fb5fd753677da3fd7d21dbab
|
Subproject commit 77e9ed24ca7bb0f9a0b33d7fd888de2905dddcd4
|
|
@ -1 +1 @@
|
||||||
Subproject commit 72c7673ac50cc1ffb518de65022fb034df334ed9
|
Subproject commit 313e26f9202b44d09043485671bc903786c328e7
|
|
@ -1 +1 @@
|
||||||
Subproject commit d265202c324d566a52d5946e08ad148dcf068252
|
Subproject commit ba24db51b38c9875e1356f7bc08c13a683071710
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5e8c30cc69286e68ba9bf843f146a580381bff83
|
Subproject commit 7a584804a98b5731fb53d216c3f059e5a0c7ea5c
|
|
@ -1 +1 @@
|
||||||
Subproject commit dc6b77d2df8cb425a55c5ef48f77320de092fa19
|
Subproject commit 8999e447127c8674cdf130a2bd1759d9f94cd6ad
|
|
@ -1 +1 @@
|
||||||
Subproject commit 42931c8e0894c0d3d70d29abdf16639b30e6bf92
|
Subproject commit 8f253edf62cfadfa18edb773aebd74bd62647ce4
|
|
@ -1 +1 @@
|
||||||
Subproject commit d88f23d1541019baaedb350ce275349ad2ca304e
|
Subproject commit 17afe7a4b5d40dd3da792cd5e22e1e6b48225f21
|
|
@ -1 +1 @@
|
||||||
Subproject commit c549e77a677a6f76f8c9a42682d719d4ac20c3fc
|
Subproject commit 09a6c29e0a9432d67eeb583324c17766aa1155e3
|
|
@ -1 +1 @@
|
||||||
Subproject commit 41b967cf1a1bf91227a4e8ee52c82a228eeb7e94
|
Subproject commit a8843ea084262773c31916e3a52c6dacea135153
|
|
@ -1 +1 @@
|
||||||
Subproject commit afdd72f326f720afcfa7cea6005b20924a441570
|
Subproject commit aecdedca9ebef5ce6cf4d2dd38e2c312c0907f1d
|
|
@ -1 +1 @@
|
||||||
Subproject commit d7c05e81acb66717f1a86ad67f391c9bc0961bbf
|
Subproject commit 17bd4bbc04942e7de9eae76c0f8a76dfcb3dc9fc
|
|
@ -1 +1 @@
|
||||||
Subproject commit af080e2ab3ca871a6e77339eb752e59b3903b068
|
Subproject commit 26dc2e896a57a28f03be43df46868e1a41a15807
|
|
@ -1 +1 @@
|
||||||
Subproject commit 577bebc7c14f391cf5faddc16bda194da6a3e7b6
|
Subproject commit 86c9525ec4aa886c5afe4ec5202ca3a0d400d155
|
|
@ -1 +1 @@
|
||||||
Subproject commit c726370b54f573f7f5d67619f40b0b92d55919c7
|
Subproject commit 5ed1ff9da4301dd3efd7102f3607fd353a099804
|
Loading…
Add table
Add a link
Reference in a new issue