Library changes

This commit is contained in:
Keegan McAllister 2013-08-09 13:24:10 -07:00
parent ffe60ea027
commit be061a9aa0
45 changed files with 167 additions and 183 deletions

View file

@ -23,7 +23,7 @@ use std::cast::transmute_region;
use geom::{Point2D, Rect, Size2D, SideOffsets2D}; use geom::{Point2D, Rect, Size2D, SideOffsets2D};
use servo_net::image::base::Image; use servo_net::image::base::Image;
use servo_util::range::Range; use servo_util::range::Range;
use extra::arc::ARC; use extra::arc::Arc;
/// A list of rendering operations to be performed. /// A list of rendering operations to be performed.
pub struct DisplayList<E> { pub struct DisplayList<E> {
@ -93,7 +93,7 @@ pub struct TextDisplayItem<E> {
/// Renders an image. /// Renders an image.
pub struct ImageDisplayItem<E> { pub struct ImageDisplayItem<E> {
base: BaseDisplayItem<E>, base: BaseDisplayItem<E>,
image: ARC<~Image>, image: Arc<~Image>,
} }
/// Renders a border. /// Renders a border.

View file

@ -10,7 +10,6 @@ use platform::font::{FontHandle, FontTable};
use render_context::RenderContext; use render_context::RenderContext;
use servo_util::range::Range; use servo_util::range::Range;
use std::cast; use std::cast;
use std::result;
use std::ptr; use std::ptr;
use std::str; use std::str;
use std::vec; use std::vec;
@ -18,7 +17,7 @@ use servo_util::cache::{Cache, HashCache};
use text::glyph::{GlyphStore, GlyphIndex}; use text::glyph::{GlyphStore, GlyphIndex};
use text::shaping::ShaperMethods; use text::shaping::ShaperMethods;
use text::{Shaper, TextRun}; use text::{Shaper, TextRun};
use extra::arc::ARC; use extra::arc::Arc;
use azure::{AzFloat, AzScaledFontRef}; use azure::{AzFloat, AzScaledFontRef};
use azure::scaled_font::ScaledFont; use azure::scaled_font::ScaledFont;
@ -240,7 +239,7 @@ pub struct Font {
metrics: FontMetrics, metrics: FontMetrics,
backend: BackendType, backend: BackendType,
profiler_chan: ProfilerChan, profiler_chan: ProfilerChan,
shape_cache: HashCache<~str, ARC<GlyphStore>>, shape_cache: HashCache<~str, Arc<GlyphStore>>,
} }
impl Font { impl Font {
@ -252,9 +251,9 @@ impl Font {
-> Result<@mut Font, ()> { -> Result<@mut Font, ()> {
let handle = FontHandleMethods::new_from_buffer(&ctx.handle, buffer, style); let handle = FontHandleMethods::new_from_buffer(&ctx.handle, buffer, style);
let handle: FontHandle = if handle.is_ok() { let handle: FontHandle = if handle.is_ok() {
result::unwrap(handle) handle.unwrap()
} else { } else {
return Err(handle.get_err()); return Err(handle.unwrap_err());
}; };
let metrics = handle.get_metrics(); let metrics = handle.get_metrics();
@ -394,7 +393,7 @@ impl Font {
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| {
let glyph_advance = glyph.advance_(); let glyph_advance = glyph.advance_();
let glyph_offset = glyph.offset().get_or_default(Au::zero_point()); let glyph_offset = glyph.offset().unwrap_or_default(Au::zero_point());
let azglyph = struct__AzGlyph { let azglyph = struct__AzGlyph {
mIndex: glyph.index() as uint32_t, mIndex: glyph.index() as uint32_t,
@ -450,13 +449,13 @@ impl Font {
RunMetrics::new(advance, self.metrics.ascent, self.metrics.descent) RunMetrics::new(advance, self.metrics.ascent, self.metrics.descent)
} }
pub fn shape_text(@mut self, text: ~str, is_whitespace: bool) -> ARC<GlyphStore> { pub fn shape_text(@mut self, text: ~str, is_whitespace: bool) -> Arc<GlyphStore> {
do profile(time::LayoutShapingCategory, self.profiler_chan.clone()) { do profile(time::LayoutShapingCategory, self.profiler_chan.clone()) {
let shaper = self.get_shaper(); let shaper = self.get_shaper();
do self.shape_cache.find_or_create(&text) |txt| { do self.shape_cache.find_or_create(&text) |txt| {
let mut glyphs = GlyphStore::new(text.char_len(), is_whitespace); let mut glyphs = GlyphStore::new(text.char_len(), is_whitespace);
shaper.shape_text(*txt, &mut glyphs); shaper.shape_text(*txt, &mut glyphs);
ARC(glyphs) Arc::new(glyphs)
} }
} }
} }

View file

@ -14,7 +14,6 @@ use platform::font_context::FontContextHandle;
use azure::azure_hl::BackendType; use azure::azure_hl::BackendType;
use std::hashmap::HashMap; use std::hashmap::HashMap;
use std::result;
// TODO(Rust #3934): creating lots of new dummy styles is a workaround // TODO(Rust #3934): creating lots of new dummy styles is a workaround
// for not being able to store symbolic enums in top-level constants. // for not being able to store symbolic enums in top-level constants.
@ -189,13 +188,13 @@ impl<'self> FontContext {
&SelectorPlatformIdentifier(ref identifier) => { &SelectorPlatformIdentifier(ref identifier) => {
let result_handle = self.handle.create_font_from_identifier((*identifier).clone(), let result_handle = self.handle.create_font_from_identifier((*identifier).clone(),
desc.style.clone()); desc.style.clone());
result::chain(result_handle, |handle| { do result_handle.chain |handle| {
Ok(Font::new_from_adopted_handle(self, Ok(Font::new_from_adopted_handle(self,
handle, handle,
&desc.style, &desc.style,
self.backend, self.backend,
self.profiler_chan.clone())) self.profiler_chan.clone()))
}) }
} }
}; };
} }

View file

@ -68,18 +68,18 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts {
}; };
let tile_size: uint = match getopts::opt_maybe_str(&opt_match, "s") { let tile_size: uint = match getopts::opt_maybe_str(&opt_match, "s") {
Some(tile_size_str) => uint::from_str(tile_size_str).get(), Some(tile_size_str) => uint::from_str(tile_size_str).unwrap(),
None => 512, None => 512,
}; };
let n_render_threads: uint = match getopts::opt_maybe_str(&opt_match, "t") { let n_render_threads: uint = match getopts::opt_maybe_str(&opt_match, "t") {
Some(n_render_threads_str) => uint::from_str(n_render_threads_str).get(), Some(n_render_threads_str) => uint::from_str(n_render_threads_str).unwrap(),
None => 1, // FIXME: Number of cores. None => 1, // FIXME: Number of cores.
}; };
// if only flag is present, default to 5 second period // if only flag is present, default to 5 second period
let profiler_period = do getopts::opt_default(&opt_match, "p", "5").map |period| { let profiler_period = do getopts::opt_default(&opt_match, "p", "5").map |period| {
float::from_str(*period).get() float::from_str(*period).unwrap()
}; };
let exit_after_load = getopts::opt_present(&opt_match, "x"); let exit_after_load = getopts::opt_present(&opt_match, "x");

View file

@ -262,7 +262,7 @@ impl<'self> FontHandle {
let mut face: FT_Face = ptr::null(); let mut face: FT_Face = ptr::null();
let face_index = 0 as FT_Long; let face_index = 0 as FT_Long;
do str::as_c_str(file) |file_str| { do file.as_c_str |file_str| {
FT_New_Face(ft_ctx, file_str, FT_New_Face(ft_ctx, file_str,
face_index, ptr::to_mut_unsafe_ptr(&mut face)); face_index, ptr::to_mut_unsafe_ptr(&mut face));
} }
@ -289,7 +289,7 @@ impl<'self> FontHandle {
let mut face: FT_Face = ptr::null(); let mut face: FT_Face = ptr::null();
let face_index = 0 as FT_Long; let face_index = 0 as FT_Long;
do str::as_c_str(file) |file_str| { do file.as_c_str |file_str| {
FT_New_Face(ft_ctx, file_str, FT_New_Face(ft_ctx, file_str,
face_index, ptr::to_mut_unsafe_ptr(&mut face)); face_index, ptr::to_mut_unsafe_ptr(&mut face));
} }

View file

@ -29,7 +29,6 @@ use std::libc;
use std::libc::c_int; use std::libc::c_int;
use std::ptr; use std::ptr;
use std::str; use std::str;
use std::uint;
pub struct FontListHandle { pub struct FontListHandle {
fctx: FontContextHandle, fctx: FontContextHandle,
@ -49,7 +48,7 @@ impl FontListHandle {
let font = (*fontSet).fonts.offset(i); let font = (*fontSet).fonts.offset(i);
let family: *FcChar8 = ptr::null(); let family: *FcChar8 = ptr::null();
let mut v: c_int = 0; let mut v: c_int = 0;
do str::as_c_str("family") |FC_FAMILY| { do "family".as_c_str |FC_FAMILY| {
while FcPatternGetString(*font, FC_FAMILY, v, &family) == FcResultMatch { while FcPatternGetString(*font, FC_FAMILY, v, &family) == FcResultMatch {
let family_name = str::raw::from_buf(family as *u8); let family_name = str::raw::from_buf(family as *u8);
debug!("Creating new FontFamily for family: %s", family_name); debug!("Creating new FontFamily for family: %s", family_name);
@ -71,8 +70,8 @@ impl FontListHandle {
let font_set_array_ptr = ptr::to_unsafe_ptr(&font_set); let font_set_array_ptr = ptr::to_unsafe_ptr(&font_set);
let pattern = FcPatternCreate(); let pattern = FcPatternCreate();
assert!(pattern.is_not_null()); assert!(pattern.is_not_null());
do str::as_c_str("family") |FC_FAMILY| { do "family".as_c_str |FC_FAMILY| {
do str::as_c_str(family.family_name) |family_name| { do family.family_name.as_c_str |family_name| {
let ok = FcPatternAddString(pattern, FC_FAMILY, family_name as *FcChar8); let ok = FcPatternAddString(pattern, FC_FAMILY, family_name as *FcChar8);
assert!(ok != 0); assert!(ok != 0);
} }
@ -81,10 +80,10 @@ impl FontListHandle {
let object_set = FcObjectSetCreate(); let object_set = FcObjectSetCreate();
assert!(object_set.is_not_null()); assert!(object_set.is_not_null());
do str::as_c_str("file") |FC_FILE| { do "file".as_c_str |FC_FILE| {
FcObjectSetAdd(object_set, FC_FILE); FcObjectSetAdd(object_set, FC_FILE);
} }
do str::as_c_str("index") |FC_INDEX| { do "index".as_c_str |FC_INDEX| {
FcObjectSetAdd(object_set, FC_INDEX); FcObjectSetAdd(object_set, FC_INDEX);
} }
@ -94,7 +93,7 @@ impl FontListHandle {
for uint::range(0, (*matches).nfont as uint) |i| { for uint::range(0, (*matches).nfont as uint) |i| {
let font = (*matches).fonts.offset(i); let font = (*matches).fonts.offset(i);
let file = do str::as_c_str("file") |FC_FILE| { let file = do "file".as_c_str |FC_FILE| {
let file: *FcChar8 = ptr::null(); let file: *FcChar8 = ptr::null();
if FcPatternGetString(*font, FC_FILE, 0, &file) == FcResultMatch { if FcPatternGetString(*font, FC_FILE, 0, &file) == FcResultMatch {
str::raw::from_c_str(file as *libc::c_char) str::raw::from_c_str(file as *libc::c_char)
@ -102,7 +101,7 @@ impl FontListHandle {
fail!(); fail!();
} }
}; };
let index = do str::as_c_str("index") |FC_INDEX| { let index = do "index".as_c_str |FC_INDEX| {
let index: libc::c_int = 0; let index: libc::c_int = 0;
if FcPatternGetInteger(*font, FC_INDEX, 0, &index) == FcResultMatch { if FcPatternGetInteger(*font, FC_INDEX, 0, &index) == FcResultMatch {
index index
@ -151,8 +150,8 @@ pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, (
let config = FcConfigGetCurrent(); let config = FcConfigGetCurrent();
let wrapper = AutoPattern { pattern: FcPatternCreate() }; let wrapper = AutoPattern { pattern: FcPatternCreate() };
let pattern = wrapper.pattern; let pattern = wrapper.pattern;
let res = do str::as_c_str("family") |FC_FAMILY| { let res = do "family".as_c_str |FC_FAMILY| {
do str::as_c_str(name) |family| { do name.as_c_str |family| {
FcPatternAddString(pattern, FC_FAMILY, family as *FcChar8) FcPatternAddString(pattern, FC_FAMILY, family as *FcChar8)
} }
}; };
@ -162,7 +161,7 @@ pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, (
} }
if style.italic { if style.italic {
let res = do str::as_c_str("slant") |FC_SLANT| { let res = do "slant".as_c_str |FC_SLANT| {
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC) FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC)
}; };
if res != 1 { if res != 1 {
@ -171,7 +170,7 @@ pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, (
} }
} }
if style.weight.is_bold() { if style.weight.is_bold() {
let res = do str::as_c_str("weight") |FC_WEIGHT| { let res = do "weight".as_c_str |FC_WEIGHT| {
FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD) FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD)
}; };
if res != 1 { if res != 1 {
@ -194,7 +193,7 @@ pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, (
} }
let file: *FcChar8 = ptr::null(); let file: *FcChar8 = ptr::null();
let res = do str::as_c_str("file") |FC_FILE| { let res = do "file".as_c_str |FC_FILE| {
FcPatternGetString(result_pattern, FC_FILE, 0, &file) FcPatternGetString(result_pattern, FC_FILE, 0, &file)
}; };
if res != FcResultMatch { if res != FcResultMatch {

View file

@ -16,7 +16,6 @@ use core_text::font_descriptor::CTFontDescriptorRef;
use core_text; use core_text;
use std::hashmap::HashMap; use std::hashmap::HashMap;
use std::result;
pub struct FontListHandle { pub struct FontListHandle {
fctx: FontContextHandle, fctx: FontContextHandle,
@ -49,7 +48,7 @@ impl FontListHandle {
for family_collection.get_descriptors().each |descref: &CTFontDescriptorRef| { for family_collection.get_descriptors().each |descref: &CTFontDescriptorRef| {
let desc = CFWrapper::wrap_shared(*descref); let desc = CFWrapper::wrap_shared(*descref);
let font = core_text::font::new_from_descriptor(&desc, 0.0); let font = core_text::font::new_from_descriptor(&desc, 0.0);
let handle = result::unwrap(FontHandle::new_from_CTFont(&self.fctx, font)); let handle = FontHandle::new_from_CTFont(&self.fctx, font).unwrap();
debug!("Creating new FontEntry for face: %s", handle.face_name()); debug!("Creating new FontEntry for face: %s", handle.face_name());
let entry = @FontEntry::new(handle); let entry = @FontEntry::new(handle);

View file

@ -16,7 +16,7 @@ use geom::rect::Rect;
use geom::size::Size2D; use geom::size::Size2D;
use geom::side_offsets::SideOffsets2D; use geom::side_offsets::SideOffsets2D;
use servo_net::image::base::Image; use servo_net::image::base::Image;
use extra::arc::ARC; use extra::arc::Arc;
pub struct RenderContext<'self> { pub struct RenderContext<'self> {
canvas: &'self LayerBuffer, canvas: &'self LayerBuffer,
@ -77,7 +77,7 @@ impl<'self> RenderContext<'self> {
self.canvas.draw_target.stroke_line(start, end, &pattern, &stroke_opts, &draw_opts); self.canvas.draw_target.stroke_line(start, end, &pattern, &stroke_opts, &draw_opts);
} }
pub fn draw_image(&self, bounds: Rect<Au>, image: ARC<~Image>) { pub fn draw_image(&self, bounds: Rect<Au>, image: Arc<~Image>) {
let image = image.get(); let image = image.get();
let size = Size2D(image.width as i32, image.height as i32); let size = Size2D(image.width as i32, image.height as i32);
let stride = image.width * 4; let stride = image.width * 4;

View file

@ -88,7 +88,7 @@ priv struct RenderTask<C> {
/// Permission to send paint messages to the compositor /// Permission to send paint messages to the compositor
paint_permission: bool, paint_permission: bool,
/// Cached copy of last layers rendered /// Cached copy of last layers rendered
last_paint_msg: Option<(arc::ARC<LayerBufferSet>, Size2D<uint>)>, last_paint_msg: Option<(arc::Arc<LayerBufferSet>, Size2D<uint>)>,
} }
impl<C: RenderListener + Send> RenderTask<C> { impl<C: RenderListener + Send> RenderTask<C> {
@ -231,7 +231,7 @@ impl<C: RenderListener + Send> RenderTask<C> {
let layer_buffer_set = LayerBufferSet { let layer_buffer_set = LayerBufferSet {
buffers: new_buffers, buffers: new_buffers,
}; };
let layer_buffer_set = arc::ARC(layer_buffer_set); let layer_buffer_set = arc::Arc::new(layer_buffer_set);
debug!("render_task: returning surface"); debug!("render_task: returning surface");
if self.paint_permission { if self.paint_permission {

View file

@ -16,7 +16,6 @@ use std::cast::transmute;
use std::libc::{c_uint, c_int, c_void, c_char}; use std::libc::{c_uint, c_int, c_void, c_char};
use std::ptr; use std::ptr;
use std::ptr::null; use std::ptr::null;
use std::str;
use std::uint; use std::uint;
use std::util::ignore; use std::util::ignore;
use std::vec; use std::vec;
@ -86,7 +85,7 @@ impl ShapedGlyphData {
fn byte_offset_of_glyph(&self, i: uint) -> uint { fn byte_offset_of_glyph(&self, i: uint) -> uint {
assert!(i < self.count); assert!(i < self.count);
let glyph_info_i = ptr::offset(self.glyph_infos, i); let glyph_info_i = ptr::offset(self.glyph_infos, i as int);
unsafe { unsafe {
(*glyph_info_i).cluster as uint (*glyph_info_i).cluster as uint
} }
@ -101,8 +100,8 @@ impl ShapedGlyphData {
assert!(i < self.count); assert!(i < self.count);
unsafe { unsafe {
let glyph_info_i = ptr::offset(self.glyph_infos, i); let glyph_info_i = ptr::offset(self.glyph_infos, i as int);
let pos_info_i = ptr::offset(self.pos_infos, i); let pos_info_i = ptr::offset(self.pos_infos, i as int);
let x_offset = Shaper::fixed_to_float((*pos_info_i).x_offset); let x_offset = Shaper::fixed_to_float((*pos_info_i).x_offset);
let y_offset = Shaper::fixed_to_float((*pos_info_i).y_offset); let y_offset = Shaper::fixed_to_float((*pos_info_i).y_offset);
let x_advance = Shaper::fixed_to_float((*pos_info_i).x_advance); let x_advance = Shaper::fixed_to_float((*pos_info_i).x_advance);
@ -216,8 +215,8 @@ impl ShaperMethods for Shaper {
let hb_buffer: *hb_buffer_t = hb_buffer_create(); let hb_buffer: *hb_buffer_t = hb_buffer_create();
hb_buffer_set_direction(hb_buffer, HB_DIRECTION_LTR); hb_buffer_set_direction(hb_buffer, HB_DIRECTION_LTR);
// Using as_buf because it never does a copy - we don't need the trailing null // Using as_imm_buf because it never does a copy - we don't need the trailing null
do str::as_buf(text) |ctext: *u8, _: uint| { do text.as_imm_buf |ctext: *u8, _: uint| {
hb_buffer_add_utf8(hb_buffer, hb_buffer_add_utf8(hb_buffer,
ctext as *c_char, ctext as *c_char,
text.len() as c_int, text.len() as c_int,

View file

@ -7,22 +7,22 @@ use geometry::Au;
use text::glyph::GlyphStore; use text::glyph::GlyphStore;
use font::{Font, FontDescriptor, RunMetrics}; use font::{Font, FontDescriptor, RunMetrics};
use servo_util::range::Range; use servo_util::range::Range;
use extra::arc::ARC; use extra::arc::Arc;
/// A text run. /// A text run.
pub struct TextRun { pub struct TextRun {
text: ~str, text: ~str,
font: @mut Font, font: @mut Font,
underline: bool, underline: bool,
glyphs: ~[ARC<GlyphStore>], glyphs: ~[Arc<GlyphStore>],
} }
/// This is a hack until TextRuns are normally sendable, or we instead use ARC<TextRun> everywhere. /// This is a hack until TextRuns are normally sendable, or we instead use Arc<TextRun> everywhere.
pub struct SendableTextRun { pub struct SendableTextRun {
text: ~str, text: ~str,
font: FontDescriptor, font: FontDescriptor,
underline: bool, underline: bool,
priv glyphs: ~[ARC<GlyphStore>], priv glyphs: ~[Arc<GlyphStore>],
} }
impl SendableTextRun { impl SendableTextRun {
@ -58,7 +58,7 @@ impl<'self> TextRun {
self.font.teardown(); self.font.teardown();
} }
pub fn break_and_shape(font: @mut Font, text: &str) -> ~[ARC<GlyphStore>] { pub fn break_and_shape(font: @mut Font, text: &str) -> ~[Arc<GlyphStore>] {
// TODO(Issue #230): do a better job. See Gecko's LineBreaker. // TODO(Issue #230): do a better job. See Gecko's LineBreaker.
let mut glyphs = ~[]; let mut glyphs = ~[];
@ -128,7 +128,7 @@ impl<'self> TextRun {
} }
} }
pub fn glyphs(&'self self) -> &'self ~[ARC<GlyphStore>] { &self.glyphs } pub fn glyphs(&'self self) -> &'self ~[Arc<GlyphStore>] { &self.glyphs }
pub fn range_is_trimmable_whitespace(&self, range: &Range) -> bool { pub fn range_is_trimmable_whitespace(&self, range: &Range) -> bool {
for self.iter_slices_for_range(range) |slice_glyphs, _, _| { for self.iter_slices_for_range(range) |slice_glyphs, _, _| {

View file

@ -313,7 +313,7 @@ impl CompositorLayer {
texture_layer.manager = @buffer.draw_target.clone() as @TextureManager; texture_layer.manager = @buffer.draw_target.clone() as @TextureManager;
// Move on to the next sibling. // Move on to the next sibling.
do current_layer_child.get().with_common |common| { do current_layer_child.unwrap().with_common |common| {
common.next_sibling common.next_sibling
} }
} }

View file

@ -80,7 +80,7 @@ impl RenderListener for CompositorChan {
port.recv() port.recv()
} }
fn paint(&self, id: PipelineId, layer_buffer_set: arc::ARC<LayerBufferSet>) { fn paint(&self, id: PipelineId, layer_buffer_set: arc::Arc<LayerBufferSet>) {
self.chan.send(Paint(id, layer_buffer_set)) self.chan.send(Paint(id, layer_buffer_set))
} }
@ -136,7 +136,7 @@ pub enum Msg {
DeleteLayer(PipelineId), DeleteLayer(PipelineId),
/// Requests that the compositor paint the given layer buffer set for the given page size. /// Requests that the compositor paint the given layer buffer set for the given page size.
Paint(PipelineId, arc::ARC<LayerBufferSet>), Paint(PipelineId, arc::Arc<LayerBufferSet>),
/// Alerts the compositor to the current status of page loading. /// Alerts the compositor to the current status of page loading.
ChangeReadyState(ReadyState), ChangeReadyState(ReadyState),
/// Alerts the compositor to the current status of rendering. /// Alerts the compositor to the current status of rendering.

View file

@ -4,8 +4,6 @@
use compositing::{CompositorChan, SetIds}; use compositing::{CompositorChan, SetIds};
use extra::net::url;
use std::cell::Cell; use std::cell::Cell;
use std::comm; use std::comm;
use std::comm::Port; use std::comm::Port;
@ -169,17 +167,17 @@ impl NavigationContext {
* when it is known that there exists either a previous page or a next page. */ * when it is known that there exists either a previous page or a next page. */
pub fn back(&mut self) -> @mut FrameTree { pub fn back(&mut self) -> @mut FrameTree {
self.next.push(self.current.swap_unwrap()); self.next.push(self.current.take_unwrap());
self.current = Some(self.previous.pop()); self.current = Some(self.previous.pop());
debug!("previous: %? next: %? current: %?", self.previous, self.next, *self.current.get_ref()); debug!("previous: %? next: %? current: %?", self.previous, self.next, *self.current.get_ref());
self.current.get() self.current.unwrap()
} }
pub fn forward(&mut self) -> @mut FrameTree { pub fn forward(&mut self) -> @mut FrameTree {
self.previous.push(self.current.swap_unwrap()); self.previous.push(self.current.take_unwrap());
self.current = Some(self.next.pop()); self.current = Some(self.next.pop());
debug!("previous: %? next: %? current: %?", self.previous, self.next, *self.current.get_ref()); debug!("previous: %? next: %? current: %?", self.previous, self.next, *self.current.get_ref());
self.current.get() self.current.unwrap()
} }
/// Loads a new set of page frames, returning all evicted frame trees /// Loads a new set of page frames, returning all evicted frame trees
@ -187,7 +185,7 @@ impl NavigationContext {
debug!("navigating to %?", frame_tree); debug!("navigating to %?", frame_tree);
let evicted = replace(&mut self.next, ~[]); let evicted = replace(&mut self.next, ~[]);
if self.current.is_some() { if self.current.is_some() {
self.previous.push(self.current.swap_unwrap()); self.previous.push(self.current.take_unwrap());
} }
self.current = Some(frame_tree); self.current = Some(frame_tree);
evicted evicted
@ -405,7 +403,7 @@ impl Constellation {
// If there is already a pending page (self.pending_frames), it will not be overridden; // If there is already a pending page (self.pending_frames), it will not be overridden;
// However, if the id is not encompassed by another change, it will be. // However, if the id is not encompassed by another change, it will be.
LoadUrlMsg(source_id, url, size_future) => { LoadUrlMsg(source_id, url, size_future) => {
debug!("received message to load %s", url::to_str(&url)); debug!("received message to load %s", url.to_str());
// Make sure no pending page would be overridden. // Make sure no pending page would be overridden.
let source_frame = self.current_frame().get_ref().find_mut(source_id).expect( let source_frame = self.current_frame().get_ref().find_mut(source_id).expect(
"Constellation: received a LoadUrlMsg from a pipeline_id associated "Constellation: received a LoadUrlMsg from a pipeline_id associated
@ -530,13 +528,13 @@ impl Constellation {
// Create the next frame tree that will be given to the compositor // Create the next frame tree that will be given to the compositor
let next_frame_tree = match to_add.parent { let next_frame_tree = match to_add.parent {
None => to_add, // to_add is the root None => to_add, // to_add is the root
Some(_parent) => @mut (*self.current_frame().get()).clone(), Some(_parent) => @mut (*self.current_frame().unwrap()).clone(),
}; };
// If there are frames to revoke permission from, do so now. // If there are frames to revoke permission from, do so now.
match frame_change.before { match frame_change.before {
Some(revoke_id) => { Some(revoke_id) => {
let current_frame = self.current_frame().get(); let current_frame = self.current_frame().unwrap();
let to_revoke = current_frame.find_mut(revoke_id).expect( let to_revoke = current_frame.find_mut(revoke_id).expect(
"Constellation: pending frame change refers to an old "Constellation: pending frame change refers to an old

View file

@ -65,7 +65,7 @@ impl<'self> NodeUtil<'self> for AbstractNode<LayoutView> {
if !self.has_layout_data() { if !self.has_layout_data() {
return default; return default;
} }
self.layout_data().restyle_damage.get_or_default(default) self.layout_data().restyle_damage.unwrap_or_default(default)
} }
/// Set the restyle damage field. /// Set the restyle damage field.

View file

@ -2,10 +2,9 @@
* 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 extra::net::url::Url; use extra::url::Url;
use url_from_str = extra::net::url::from_str;
use std::cell::Cell; use std::cell::Cell;
use std::result; use std::FromStr;
use newcss::stylesheet::Stylesheet; use newcss::stylesheet::Stylesheet;
use newcss::select::SelectCtx; use newcss::select::SelectCtx;
use newcss::types::OriginUA; use newcss::types::OriginUA;
@ -29,7 +28,7 @@ fn servo_default_style() -> Stylesheet {
} }
fn default_url(name: &str) -> Url { fn default_url(name: &str) -> Url {
result::unwrap(url_from_str(fmt!("http://%s", name))) FromStr::from_str(fmt!("http://%s", name)).unwrap()
} }
fn style_stream(style: &str) -> DataStream { fn style_stream(style: &str) -> DataStream {

View file

@ -38,7 +38,7 @@ use script::dom::node::{AbstractNode, LayoutView};
use servo_net::image::holder::ImageHolder; use servo_net::image::holder::ImageHolder;
use servo_net::local_image_cache::LocalImageCache; use servo_net::local_image_cache::LocalImageCache;
use servo_util::range::*; use servo_util::range::*;
use extra::net::url::Url; use extra::url::Url;
/// Render boxes (`struct RenderBox`) are the leaves of the layout tree. They cannot position /// Render boxes (`struct RenderBox`) are the leaves of the layout tree. They cannot position
/// themselves. In general, render boxes do not have a simple correspondence with CSS boxes as in /// themselves. In general, render boxes do not have a simple correspondence with CSS boxes as in
@ -433,7 +433,7 @@ impl RenderBox {
ImageRenderBoxClass(image_box) => { ImageRenderBoxClass(image_box) => {
// TODO: Consult the CSS `width` property as well as margins and borders. // TODO: Consult the CSS `width` property as well as margins and borders.
// TODO: If the image isn't available, consult `width`. // TODO: If the image isn't available, consult `width`.
Au::from_px(image_box.image.get_size().get_or_default(Size2D(0, 0)).width) Au::from_px(image_box.image.get_size().unwrap_or_default(Size2D(0, 0)).width)
} }
TextRenderBoxClass(text_box) => { TextRenderBoxClass(text_box) => {
@ -454,7 +454,7 @@ impl RenderBox {
GenericRenderBoxClass(*) => Au(0), GenericRenderBoxClass(*) => Au(0),
ImageRenderBoxClass(image_box) => { ImageRenderBoxClass(image_box) => {
Au::from_px(image_box.image.get_size().get_or_default(Size2D(0, 0)).width) Au::from_px(image_box.image.get_size().unwrap_or_default(Size2D(0, 0)).width)
} }
TextRenderBoxClass(text_box) => { TextRenderBoxClass(text_box) => {

View file

@ -403,22 +403,22 @@ impl LayoutTreeBuilder {
// Floats // Floats
(CSSDisplayBlock, BlockFlow(_), _) | (CSSDisplayBlock, BlockFlow(_), _) |
(CSSDisplayBlock, FloatFlow(_), _) if !is_float.is_none() => { (CSSDisplayBlock, FloatFlow(_), _) if !is_float.is_none() => {
self.create_child_generator(node, parent_generator, Flow_Float(is_float.get())) self.create_child_generator(node, parent_generator, Flow_Float(is_float.unwrap()))
} }
// If we're placing a float after an inline, append the float to the inline flow, // If we're placing a float after an inline, append the float to the inline flow,
// then continue building from the inline flow in case there are more inlines // then continue building from the inline flow in case there are more inlines
// afterward. // afterward.
(CSSDisplayBlock, _, Some(InlineFlow(_))) if !is_float.is_none() => { (CSSDisplayBlock, _, Some(InlineFlow(_))) if !is_float.is_none() => {
let float_generator = self.create_child_generator(node, let float_generator = self.create_child_generator(node,
sibling_generator.get(), sibling_generator.unwrap(),
Flow_Float(is_float.get())); Flow_Float(is_float.unwrap()));
return Some((float_generator, sibling_generator.get())); return Some((float_generator, sibling_generator.unwrap()));
} }
// This is a catch-all case for when: // This is a catch-all case for when:
// a) sibling_flow is None // a) sibling_flow is None
// b) sibling_flow is a BlockFlow // b) sibling_flow is a BlockFlow
(CSSDisplayBlock, InlineFlow(_), _) if !is_float.is_none() => { (CSSDisplayBlock, InlineFlow(_), _) if !is_float.is_none() => {
self.create_child_generator(node, parent_generator, Flow_Float(is_float.get())) self.create_child_generator(node, parent_generator, Flow_Float(is_float.unwrap()))
} }
(CSSDisplayBlock, BlockFlow(info), _) => match (info.is_root, node.parent_node()) { (CSSDisplayBlock, BlockFlow(info), _) => match (info.is_root, node.parent_node()) {

View file

@ -300,7 +300,7 @@ impl FloatContextBase{
f_data.bounds.origin.x + f_data.bounds.size.width > left && f_data.bounds.origin.x + f_data.bounds.size.width > left &&
f_data.bounds.origin.x < left + width { f_data.bounds.origin.x < left + width {
let new_y = f_data.bounds.origin.y; let new_y = f_data.bounds.origin.y;
max_height = Some(min(max_height.get_or_default(new_y), new_y)); max_height = Some(min(max_height.unwrap_or_default(new_y), new_y));
} }
} }
} }
@ -340,7 +340,7 @@ impl FloatContextBase{
let height = self.max_height_for_bounds(rect.origin.x, let height = self.max_height_for_bounds(rect.origin.x,
rect.origin.y, rect.origin.y,
rect.size.width); rect.size.width);
let height = height.get_or_default(Au(max_value)); let height = height.unwrap_or_default(Au(max_value));
return match info.f_type { return match info.f_type {
FloatLeft => Rect(Point2D(rect.origin.x, float_y), FloatLeft => Rect(Point2D(rect.origin.x, float_y),
Size2D(rect.size.width, height)), Size2D(rect.size.width, height)),

View file

@ -22,7 +22,8 @@ use newcss::units::{Em, Px, Pt};
use newcss::values::{CSSLineHeightNormal, CSSLineHeightNumber, CSSLineHeightLength, CSSLineHeightPercentage}; use newcss::values::{CSSLineHeightNormal, CSSLineHeightNumber, CSSLineHeightLength, CSSLineHeightPercentage};
use servo_util::range::Range; use servo_util::range::Range;
use servo_util::tree::{TreeNodeRef, TreeUtils}; use servo_util::tree::{TreeNodeRef, TreeUtils};
use extra::deque::Deque; use extra::container::Deque;
use extra::ringbuf::RingBuf;
/* /*
Lineboxes are represented as offsets into the child list, rather than Lineboxes are represented as offsets into the child list, rather than
@ -62,7 +63,7 @@ struct LineboxScanner {
flow: FlowContext, flow: FlowContext,
floats: FloatContext, floats: FloatContext,
new_boxes: ~[RenderBox], new_boxes: ~[RenderBox],
work_list: @mut Deque<RenderBox>, work_list: @mut RingBuf<RenderBox>,
pending_line: LineBox, pending_line: LineBox,
lines: ~[LineBox], lines: ~[LineBox],
cur_y: Au, cur_y: Au,
@ -76,7 +77,7 @@ impl LineboxScanner {
flow: inline, flow: inline,
floats: float_ctx, floats: float_ctx,
new_boxes: ~[], new_boxes: ~[],
work_list: @mut Deque::new(), work_list: @mut RingBuf::new(),
pending_line: LineBox { pending_line: LineBox {
range: Range::empty(), range: Range::empty(),
bounds: Rect(Point2D(Au(0), Au(0)), Size2D(Au(0), Au(0))), bounds: Rect(Point2D(Au(0), Au(0)), Size2D(Au(0), Au(0))),
@ -122,7 +123,7 @@ impl LineboxScanner {
debug!("LineboxScanner: Working with box from box list: b%d", box.id()); debug!("LineboxScanner: Working with box from box list: b%d", box.id());
box box
} else { } else {
let box = self.work_list.pop_front(); let box = self.work_list.pop_front().unwrap();
debug!("LineboxScanner: Working with box from work list: b%d", box.id()); debug!("LineboxScanner: Working with box from work list: b%d", box.id());
box box
}; };
@ -176,7 +177,7 @@ impl LineboxScanner {
match box { match box {
ImageRenderBoxClass(image_box) => { ImageRenderBoxClass(image_box) => {
let size = image_box.image.get_size(); let size = image_box.image.get_size();
let height = Au::from_px(size.get_or_default(Size2D(0, 0)).height); let height = Au::from_px(size.unwrap_or_default(Size2D(0, 0)).height);
image_box.base.position.size.height = height; image_box.base.position.size.height = height;
debug!("box_height: found image height: %?", height); debug!("box_height: found image height: %?", height);
height height
@ -360,11 +361,11 @@ impl LineboxScanner {
self.pending_line.green_zone = next_green_zone; self.pending_line.green_zone = next_green_zone;
assert!(!line_is_empty, "Non-terminating line breaking"); assert!(!line_is_empty, "Non-terminating line breaking");
self.work_list.add_front(in_box); self.work_list.push_front(in_box);
return true; return true;
} else { } else {
debug!("LineboxScanner: case=adding box collides vertically with floats: breaking line"); debug!("LineboxScanner: case=adding box collides vertically with floats: breaking line");
self.work_list.add_front(in_box); self.work_list.push_front(in_box);
return false; return false;
} }
} }
@ -407,7 +408,7 @@ impl LineboxScanner {
match (left, right) { match (left, right) {
(Some(left_box), Some(right_box)) => { (Some(left_box), Some(right_box)) => {
self.push_box_to_line(left_box); self.push_box_to_line(left_box);
self.work_list.add_front(right_box); self.work_list.push_front(right_box);
} }
(Some(left_box), None) => self.push_box_to_line(left_box), (Some(left_box), None) => self.push_box_to_line(left_box),
(None, Some(right_box)) => self.push_box_to_line(right_box), (None, Some(right_box)) => self.push_box_to_line(right_box),
@ -423,7 +424,7 @@ impl LineboxScanner {
match (left, right) { match (left, right) {
(Some(left_box), Some(right_box)) => { (Some(left_box), Some(right_box)) => {
self.push_box_to_line(left_box); self.push_box_to_line(left_box);
self.work_list.add_front(right_box); self.work_list.push_front(right_box);
} }
(Some(left_box), None) => { (Some(left_box), None) => {
self.push_box_to_line(left_box); self.push_box_to_line(left_box);
@ -438,7 +439,7 @@ impl LineboxScanner {
return true; return true;
} else { } else {
debug!("LineboxScanner: case=split box didn't fit, not appending and deferring original box."); debug!("LineboxScanner: case=split box didn't fit, not appending and deferring original box.");
self.work_list.add_front(in_box); self.work_list.push_front(in_box);
return false; return false;
} }
} }
@ -553,7 +554,7 @@ impl InlineFlowData {
match box { match box {
ImageRenderBoxClass(image_box) => { ImageRenderBoxClass(image_box) => {
let size = image_box.image.get_size(); let size = image_box.image.get_size();
let width = Au::from_px(size.get_or_default(Size2D(0, 0)).width); let width = Au::from_px(size.unwrap_or_default(Size2D(0, 0)).width);
image_box.base.position.size.width = width; image_box.base.position.size.width = width;
} }
TextRenderBoxClass(_) => { TextRenderBoxClass(_) => {
@ -671,7 +672,7 @@ impl InlineFlowData {
match cur_box { match cur_box {
ImageRenderBoxClass(image_box) => { ImageRenderBoxClass(image_box) => {
let size = image_box.image.get_size(); let size = image_box.image.get_size();
let height = Au::from_px(size.get_or_default(Size2D(0, 0)).height); let height = Au::from_px(size.unwrap_or_default(Size2D(0, 0)).height);
image_box.base.position.size.height = height; image_box.base.position.size.height = height;
image_box.base.position.translate(&Point2D(Au(0), -height)) image_box.base.position.translate(&Point2D(Au(0), -height))

View file

@ -44,7 +44,7 @@ use servo_net::local_image_cache::LocalImageCache;
use servo_util::tree::{TreeNodeRef, TreeUtils}; use servo_util::tree::{TreeNodeRef, TreeUtils};
use servo_util::time::{ProfilerChan, profile}; use servo_util::time::{ProfilerChan, profile};
use servo_util::time; use servo_util::time;
use extra::net::url::Url; use extra::url::Url;
struct LayoutTask { struct LayoutTask {
id: PipelineId, id: PipelineId,

View file

@ -241,7 +241,7 @@ impl TextRunScanner {
} }
do in_boxes[i].with_base |base| { do in_boxes[i].with_base |base| {
let new_box = @mut adapt_textbox_with_range(*base, run.get(), range); let new_box = @mut adapt_textbox_with_range(*base, run.unwrap(), range);
out_boxes.push(TextRenderBoxClass(new_box)); out_boxes.push(TextRenderBoxClass(new_box));
} }
} }

View file

@ -2,7 +2,7 @@
* 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 extra::net::url::Url; use extra::url::Url;
use compositing::CompositorChan; use compositing::CompositorChan;
use gfx::render_task::{RenderChan, RenderTask}; use gfx::render_task::{RenderChan, RenderTask};
use gfx::render_task::{PaintPermissionGranted, PaintPermissionRevoked}; use gfx::render_task::{PaintPermissionGranted, PaintPermissionRevoked};

View file

@ -61,7 +61,7 @@ pub trait RenderListener {
fn new_layer(&self, PipelineId, Size2D<uint>); fn new_layer(&self, PipelineId, Size2D<uint>);
fn resize_layer(&self, PipelineId, Size2D<uint>); fn resize_layer(&self, PipelineId, Size2D<uint>);
fn delete_layer(&self, PipelineId); fn delete_layer(&self, PipelineId);
fn paint(&self, id: PipelineId, layer_buffer_set: arc::ARC<LayerBufferSet>); fn paint(&self, id: PipelineId, layer_buffer_set: arc::Arc<LayerBufferSet>);
fn set_render_state(&self, render_state: RenderState); fn set_render_state(&self, render_state: RenderState);
} }

View file

@ -6,7 +6,7 @@
/// coupling between these two components /// coupling between these two components
use std::comm::{Chan, SharedChan}; use std::comm::{Chan, SharedChan};
use extra::net::url::Url; use extra::url::Url;
use extra::future::Future; use extra::future::Future;
use geom::size::Size2D; use geom::size::Size2D;

View file

@ -8,18 +8,18 @@ use local_image_cache::LocalImageCache;
use std::util::replace; use std::util::replace;
use geom::size::Size2D; use geom::size::Size2D;
use extra::net::url::Url; use extra::url::Url;
use extra::arc::ARC; use extra::arc::Arc;
// FIXME: Nasty coupling here This will be a problem if we want to factor out image handling from // FIXME: Nasty coupling here This will be a problem if we want to factor out image handling from
// the network stack. This should probably be factored out into an interface and use dependency // the network stack. This should probably be factored out into an interface and use dependency
// injection. // injection.
/// A struct to store image data. The image will be loaded once the first time it is requested, /// A struct to store image data. The image will be loaded once the first time it is requested,
/// and an ARC will be stored. Clones of this ARC are given out on demand. /// and an Arc will be stored. Clones of this Arc are given out on demand.
pub struct ImageHolder { pub struct ImageHolder {
url: Url, url: Url,
image: Option<ARC<~Image>>, image: Option<Arc<~Image>>,
cached_size: Size2D<int>, cached_size: Size2D<int>,
local_image_cache: @mut LocalImageCache, local_image_cache: @mut LocalImageCache,
} }
@ -65,7 +65,7 @@ impl ImageHolder {
} }
} }
pub fn get_image(&mut self) -> Option<ARC<~Image>> { pub fn get_image(&mut self) -> Option<Arc<~Image>> {
debug!("get_image() %?", self.url); debug!("get_image() %?", self.url);
// If this is the first time we've called this function, load // If this is the first time we've called this function, load

View file

@ -13,8 +13,8 @@ use std::task::spawn;
use std::to_str::ToStr; use std::to_str::ToStr;
use std::util::replace; use std::util::replace;
use std::result; use std::result;
use extra::arc::ARC; use extra::arc::Arc;
use extra::net::url::Url; use extra::url::Url;
pub enum Msg { pub enum Msg {
/// Tell the cache that we may need a particular image soon. Must be posted /// Tell the cache that we may need a particular image soon. Must be posted
@ -29,7 +29,7 @@ pub enum Msg {
Decode(Url), Decode(Url),
/// Used by the decoder tasks to post decoded images back to the cache /// Used by the decoder tasks to post decoded images back to the cache
priv StoreImage(Url, Option<ARC<~Image>>), priv StoreImage(Url, Option<Arc<~Image>>),
/// Request an Image object for a URL. If the image is not is not immediately /// Request an Image object for a URL. If the image is not is not immediately
/// available then ImageNotReady is returned. /// available then ImageNotReady is returned.
@ -46,7 +46,7 @@ pub enum Msg {
} }
pub enum ImageResponseMsg { pub enum ImageResponseMsg {
ImageReady(ARC<~Image>), ImageReady(Arc<~Image>),
ImageNotReady, ImageNotReady,
ImageFailed ImageFailed
} }
@ -163,7 +163,7 @@ enum ImageState {
Prefetching(AfterPrefetch), Prefetching(AfterPrefetch),
Prefetched(@Cell<~[u8]>), Prefetched(@Cell<~[u8]>),
Decoding, Decoding,
Decoded(@ARC<~Image>), Decoded(@Arc<~Image>),
Failed Failed
} }
@ -257,7 +257,7 @@ impl ImageCache {
let image = load_image_data(url.clone(), resource_task.clone()); let image = load_image_data(url.clone(), resource_task.clone());
let result = if image.is_ok() { let result = if image.is_ok() {
Ok(Cell::new(result::unwrap(image))) Ok(Cell::new(image.unwrap()))
} else { } else {
Err(()) Err(())
}; };
@ -329,7 +329,7 @@ impl ImageCache {
debug!("image_cache_task: started image decode for %s", url.to_str()); debug!("image_cache_task: started image decode for %s", url.to_str());
let image = decode(data); let image = decode(data);
let image = if image.is_some() { let image = if image.is_some() {
Some(ARC(~image.unwrap())) Some(Arc::new(~image.unwrap()))
} else { } else {
None None
}; };
@ -346,7 +346,7 @@ impl ImageCache {
} }
} }
priv fn store_image(&self, url: Url, image: Option<ARC<~Image>>) { priv fn store_image(&self, url: Url, image: Option<Arc<~Image>>) {
match self.get_state(url.clone()) { match self.get_state(url.clone()) {
Decoding => { Decoding => {

View file

@ -15,7 +15,7 @@ use std::comm;
use std::comm::Port; use std::comm::Port;
use std::task; use std::task;
use servo_util::url::{UrlMap, url_map}; use servo_util::url::{UrlMap, url_map};
use extra::net::url::Url; use extra::url::Url;
pub fn LocalImageCache(image_cache_task: ImageCacheTask) -> LocalImageCache { pub fn LocalImageCache(image_cache_task: ImageCacheTask) -> LocalImageCache {
LocalImageCache { LocalImageCache {
@ -109,7 +109,7 @@ impl LocalImageCache {
// on the image to load and triggering layout // on the image to load and triggering layout
let image_cache_task = self.image_cache_task.clone(); let image_cache_task = self.image_cache_task.clone();
assert!(self.on_image_available.is_some()); assert!(self.on_image_available.is_some());
let on_image_available = self.on_image_available.get()(); let on_image_available = self.on_image_available.unwrap()();
let url = (*url).clone(); let url = (*url).clone();
do task::spawn { do task::spawn {
let (response_port, response_chan) = comm::stream(); let (response_port, response_chan) = comm::stream();

View file

@ -9,7 +9,7 @@ use http_loader;
use std::cell::Cell; use std::cell::Cell;
use std::comm::{Chan, Port, SharedChan}; use std::comm::{Chan, Port, SharedChan};
use extra::net::url::{Url, to_str}; use extra::url::Url;
use util::spawn_listener; use util::spawn_listener;
pub enum ControlMsg { pub enum ControlMsg {
@ -94,7 +94,7 @@ impl ResourceManager {
match self.get_loader_factory(&url) { match self.get_loader_factory(&url) {
Some(loader_factory) => { Some(loader_factory) => {
debug!("resource_task: loading url: %s", to_str(&url)); debug!("resource_task: loading url: %s", url.to_str());
loader_factory(url, progress_chan); loader_factory(url, progress_chan);
} }
None => { None => {

View file

@ -1044,7 +1044,7 @@ for (uint32_t i = 0; i < length; ++i) {
# "if (!ConvertJSValueToString(cx, ${val}, ${valPtr}, %s, %s, %s)) {\n" # "if (!ConvertJSValueToString(cx, ${val}, ${valPtr}, %s, %s, %s)) {\n"
# " return false;\n" # " return false;\n"
# "}" % (nullBehavior, undefinedBehavior, varName)) # "}" % (nullBehavior, undefinedBehavior, varName))
strval = "str(strval.get())" strval = "str(strval.unwrap())"
if isOptional: if isOptional:
strval = "Some(%s)" % strval strval = "Some(%s)" % strval
conversionCode = ( conversionCode = (
@ -1114,7 +1114,7 @@ for (uint32_t i = 0; i < length; ++i) {
" if result.is_err() {\n" " if result.is_err() {\n"
"%(handleInvalidEnumValueCode)s" "%(handleInvalidEnumValueCode)s"
" }\n" " }\n"
" let index = result.get();\n" " let index = result.unwrap();\n"
" ${declName} = cast::transmute(index); //XXXjdm need some range checks up in here\n" " ${declName} = cast::transmute(index); //XXXjdm need some range checks up in here\n"
"}" % { "enumtype" : enum, "}" % { "enumtype" : enum,
"values" : enum + "Values::strings", "values" : enum + "Values::strings",
@ -1511,7 +1511,7 @@ for (uint32_t i = 0; i < length; ++i) {
wrappingCode = ("if %s.is_none() {\n" % (result) + wrappingCode = ("if %s.is_none() {\n" % (result) +
CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define() + "\n" + CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define() + "\n" +
"}\n" + "}\n" +
"let mut %s = %s.get();\n" % (result, result)) "let mut %s = %s.unwrap();\n" % (result, result))
else: else:
wrappingCode = "" wrappingCode = ""
if (not descriptor.interface.isExternal() and if (not descriptor.interface.isExternal() and
@ -2746,10 +2746,10 @@ class CGGetPerInterfaceObject(CGAbstractMethod):
}*/ }*/
/* Check to see whether the interface objects are already installed */ /* Check to see whether the interface objects are already installed */
let protoOrIfaceArray: *mut *JSObject = cast::transmute(GetProtoOrIfaceArray(aGlobal)); let protoOrIfaceArray: *mut *JSObject = cast::transmute(GetProtoOrIfaceArray(aGlobal));
let cachedObject: *JSObject = *protoOrIfaceArray.offset(%s as uint); let cachedObject: *JSObject = *protoOrIfaceArray.offset(%s as int);
if cachedObject.is_null() { if cachedObject.is_null() {
let tmp: *JSObject = CreateInterfaceObjects(aCx, aGlobal, aReceiver); let tmp: *JSObject = CreateInterfaceObjects(aCx, aGlobal, aReceiver);
*protoOrIfaceArray.offset(%s as uint) = tmp; *protoOrIfaceArray.offset(%s as int) = tmp;
tmp tmp
} else { } else {
cachedObject cachedObject
@ -3623,7 +3623,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
templateValues = {'jsvalRef': '(*desc).value', 'jsvalPtr': 'ptr::to_mut_unsafe_ptr(&mut (*desc).value)', templateValues = {'jsvalRef': '(*desc).value', 'jsvalPtr': 'ptr::to_mut_unsafe_ptr(&mut (*desc).value)',
'obj': 'proxy', 'successCode': fillDescriptor} 'obj': 'proxy', 'successCode': fillDescriptor}
get = ("if index.is_some() {\n" + get = ("if index.is_some() {\n" +
" let index = index.get();\n" + " let index = index.unwrap();\n" +
" let this: *%s = UnwrapProxy(proxy);\n" + " let this: *%s = UnwrapProxy(proxy);\n" +
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" +
"}\n") % (self.descriptor.concreteType) "}\n") % (self.descriptor.concreteType)
@ -3632,7 +3632,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
setOrIndexedGet += "if set != 0 {\n" setOrIndexedGet += "if set != 0 {\n"
if indexedSetter: if indexedSetter:
setOrIndexedGet += (" if index.is_some() {\n" + setOrIndexedGet += (" if index.is_some() {\n" +
" let index = index.get();\n") " let index = index.unwrap();\n")
if not 'IndexedCreator' in self.descriptor.operations: if not 'IndexedCreator' in self.descriptor.operations:
# FIXME need to check that this is a 'supported property index' # FIXME need to check that this is a 'supported property index'
assert False assert False
@ -3677,7 +3677,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
" if strval.is_err() {\n" + " if strval.is_err() {\n" +
" return 0;\n" + " return 0;\n" +
" }\n" + " }\n" +
" let name = str(strval.get());\n" + " let name = str(strval.unwrap());\n" +
"\n" + "\n" +
" let this: *%s = UnwrapProxy(proxy);\n" + " let this: *%s = UnwrapProxy(proxy);\n" +
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "\n" + CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "\n" +
@ -3721,7 +3721,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
raise TypeError("Can't handle creator that's different from the setter") raise TypeError("Can't handle creator that's different from the setter")
set += ("let index = GetArrayIndexFromId(cx, id);\n" + set += ("let index = GetArrayIndexFromId(cx, id);\n" +
"if index.is_some() {\n" + "if index.is_some() {\n" +
" let index = index.get();\n" + " let index = index.unwrap();\n" +
" let this: *%s = UnwrapProxy(proxy);\n" + " let this: *%s = UnwrapProxy(proxy);\n" +
CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() + CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() +
" return 1;\n" + " return 1;\n" +
@ -3746,7 +3746,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
" if strval.is_err() {\n" + " if strval.is_err() {\n" +
" return 0;\n" + " return 0;\n" +
" }\n" + " }\n" +
" let name = str(strval.get());\n" + " let name = str(strval.unwrap());\n" +
"\n" + "\n" +
" let this: *%s = UnwrapProxy(proxy);\n" + " let this: *%s = UnwrapProxy(proxy);\n" +
CGIndenter(CGProxyNamedSetter(self.descriptor)).define() + "\n" + CGIndenter(CGProxyNamedSetter(self.descriptor)).define() + "\n" +
@ -3762,7 +3762,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
" if strval.is_err() {\n" + " if strval.is_err() {\n" +
" return 0;\n" + " return 0;\n" +
" }\n" + " }\n" +
" let name = str(strval.get());\n" + " let name = str(strval.unwrap());\n" +
" let this: %%s = UnwrapProxy(proxy);\n" + " let this: %%s = UnwrapProxy(proxy);\n" +
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
" if (found) {\n" " if (found) {\n"
@ -3787,7 +3787,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
if indexedGetter: if indexedGetter:
indexed = ("let index = GetArrayIndexFromId(cx, id);\n" + indexed = ("let index = GetArrayIndexFromId(cx, id);\n" +
"if index.is_some() {\n" + "if index.is_some() {\n" +
" let index = index.get();\n" + " let index = index.unwrap();\n" +
" let this: *%s = UnwrapProxy(proxy);\n" + " let this: *%s = UnwrapProxy(proxy);\n" +
CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" +
" *bp = found as JSBool;\n" + " *bp = found as JSBool;\n" +
@ -3808,7 +3808,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
" if strval.is_err() {\n" + " if strval.is_err() {\n" +
" return 0;\n" + " return 0;\n" +
" }\n" + " }\n" +
" let name = str(strval.get());\n" + " let name = str(strval.unwrap());\n" +
"\n" + "\n" +
" let this: *%s = UnwrapProxy(proxy);\n" + " let this: *%s = UnwrapProxy(proxy);\n" +
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + "\n" + CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + "\n" +
@ -3861,7 +3861,7 @@ if expando.is_not_null() {
if indexedGetter: if indexedGetter:
getIndexedOrExpando = ("let index = GetArrayIndexFromId(cx, id);\n" + getIndexedOrExpando = ("let index = GetArrayIndexFromId(cx, id);\n" +
"if index.is_some() {\n" + "if index.is_some() {\n" +
" let index = index.get();\n" + " let index = index.unwrap();\n" +
" let this = UnwrapProxy(proxy);\n" + " let this = UnwrapProxy(proxy);\n" +
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define()) CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define())
getIndexedOrExpando += """ getIndexedOrExpando += """
@ -3935,7 +3935,7 @@ class CGDOMJSProxyHandler_obj_toString(CGAbstractExternMethod):
JSString* jsresult; JSString* jsresult;
return xpc_qsStringToJsstring(cx, result, &jsresult) ? jsresult : NULL;""" return xpc_qsStringToJsstring(cx, result, &jsresult) ? jsresult : NULL;"""
return """ do str::as_c_str("%s") |s| { return """ do "%s".as_c_str |s| {
_obj_toString(cx, s) _obj_toString(cx, s)
}""" % self.descriptor.name }""" % self.descriptor.name
@ -4461,9 +4461,9 @@ class CGDictionary(CGThing):
# NOTE: jsids are per-runtime, so don't use them in workers # NOTE: jsids are per-runtime, so don't use them in workers
if True or self.workers: #XXXjdm hack until 'static mut' exists for global jsids if True or self.workers: #XXXjdm hack until 'static mut' exists for global jsids
propName = member.identifier.name propName = member.identifier.name
propCheck = ('str::as_c_str("%s", |s| { JS_HasProperty(cx, RUST_JSVAL_TO_OBJECT(val), s, ptr::to_unsafe_ptr(&found)) })' % propCheck = ('"%s".as_c_str(|s| { JS_HasProperty(cx, RUST_JSVAL_TO_OBJECT(val), s, ptr::to_unsafe_ptr(&found)) })' %
propName) propName)
propGet = ('str::as_c_str("%s", |s| { JS_GetProperty(cx, RUST_JSVAL_TO_OBJECT(val), s, ptr::to_unsafe_ptr(&temp)) })' % propGet = ('"%s".as_c_str(|s| { JS_GetProperty(cx, RUST_JSVAL_TO_OBJECT(val), s, ptr::to_unsafe_ptr(&temp)) })' %
propName) propName)
else: else:
propId = self.makeIdName(member.identifier.name); propId = self.makeIdName(member.identifier.name);

View file

@ -21,8 +21,6 @@ use std::libc::c_uint;
use std::comm; use std::comm;
use std::ptr; use std::ptr;
use std::ptr::null; use std::ptr::null;
use std::result;
use std::str;
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};
@ -49,14 +47,14 @@ pub extern fn trace(tracer: *mut JSTracer, obj: *JSObject) {
return; return;
} }
error!("tracing %s", name); error!("tracing %s", name);
let mut node = node.get(); let mut node = node.unwrap();
let cache = node.get_wrappercache(); let cache = node.get_wrappercache();
let wrapper = cache.get_wrapper(); let wrapper = cache.get_wrapper();
assert!(wrapper.is_not_null()); assert!(wrapper.is_not_null());
unsafe { unsafe {
(*tracer).debugPrinter = ptr::null(); (*tracer).debugPrinter = ptr::null();
(*tracer).debugPrintIndex = -1; (*tracer).debugPrintIndex = -1;
do str::as_c_str(name) |name| { do name.as_c_str |name| {
(*tracer).debugPrintArg = name as *libc::c_void; (*tracer).debugPrintArg = name as *libc::c_void;
JS_CallTracer(cast::transmute(tracer), wrapper, JSTRACE_OBJECT as u32); JS_CallTracer(cast::transmute(tracer), wrapper, JSTRACE_OBJECT as u32);
} }
@ -194,14 +192,14 @@ extern fn setAttribute(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool {
if strval.is_err() { if strval.is_err() {
return 0; return 0;
} }
arg0 = str(strval.get()); arg0 = str(strval.unwrap());
let arg1: DOMString; let arg1: DOMString;
let strval = jsval_to_str(cx, (*argv.offset(1))); let strval = jsval_to_str(cx, (*argv.offset(1)));
if strval.is_err() { if strval.is_err() {
return 0; return 0;
} }
arg1 = str(strval.get()); arg1 = str(strval.unwrap());
do node.as_mut_element |elem| { do node.as_mut_element |elem| {
elem.set_attr(&arg0, &arg1); elem.set_attr(&arg0, &arg1);
@ -293,9 +291,9 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> jsobj {
//XXXjdm the parent should probably be the node parent instead of the global //XXXjdm the parent should probably be the node parent instead of the global
//TODO error checking //TODO error checking
let compartment = utils::get_compartment(cx); let compartment = utils::get_compartment(cx);
let obj = result::unwrap(compartment.new_object_with_proto(~"GenericElementInstance", let obj = compartment.new_object_with_proto(~"GenericElementInstance",
proto, proto,
compartment.global_obj.ptr)); compartment.global_obj.ptr).unwrap();
let cache = node.get_wrappercache(); let cache = node.get_wrappercache();
assert!(cache.get_wrapper().is_null()); assert!(cache.get_wrapper().is_null());

View file

@ -16,7 +16,6 @@ use js::rust::{Compartment, jsobj};
use std::cast; use std::cast;
use std::libc; use std::libc;
use std::result;
extern fn finalize_text(_fop: *JSFreeOp, obj: *JSObject) { extern fn finalize_text(_fop: *JSFreeOp, obj: *JSObject) {
debug!("text finalize: %?!", obj as uint); debug!("text finalize: %?!", obj as uint);
@ -79,9 +78,9 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> jsobj {
//XXXjdm the parent should probably be the node parent instead of the global //XXXjdm the parent should probably be the node parent instead of the global
//TODO error checking //TODO error checking
let compartment = utils::get_compartment(cx); let compartment = utils::get_compartment(cx);
let obj = result::unwrap(compartment.new_object_with_proto(instance, let obj = compartment.new_object_with_proto(instance,
proto, proto,
compartment.global_obj.ptr)); compartment.global_obj.ptr).unwrap();
let cache = node.get_wrappercache(); let cache = node.get_wrappercache();
assert!(cache.get_wrapper().is_null()); assert!(cache.get_wrapper().is_null());

View file

@ -13,7 +13,6 @@ use std::hashmap::HashMap;
use std::libc; use std::libc;
use std::ptr; use std::ptr;
use std::ptr::{null, to_unsafe_ptr}; use std::ptr::{null, to_unsafe_ptr};
use std::result;
use std::str; use std::str;
use std::uint; use std::uint;
use std::unstable::intrinsics; use std::unstable::intrinsics;
@ -85,7 +84,7 @@ extern fn InterfaceObjectToString(cx: *JSContext, _argc: uint, vp: *mut JSVal) -
return 0; return 0;
} }
let name = jsval_to_str(cx, *v).get(); let name = jsval_to_str(cx, *v).unwrap();
let retval = str(~"function " + name + "() {\n [native code]\n}"); let retval = str(~"function " + name + "() {\n [native code]\n}");
*vp = domstring_to_jsval(cx, &retval); *vp = domstring_to_jsval(cx, &retval);
return 1; return 1;
@ -216,10 +215,10 @@ pub unsafe fn domstring_to_jsval(cx: *JSContext, string: &DOMString) -> JSVal {
JSVAL_NULL JSVAL_NULL
} }
&str(ref s) => { &str(ref s) => {
str::as_buf(*s, |buf, len| { do s.as_imm_buf |buf, len| {
let cbuf = cast::transmute(buf); let cbuf = cast::transmute(buf);
RUST_STRING_TO_JSVAL(JS_NewStringCopyN(cx, cbuf, len as libc::size_t)) RUST_STRING_TO_JSVAL(JS_NewStringCopyN(cx, cbuf, len as libc::size_t))
}) }
} }
} }
} }
@ -322,13 +321,13 @@ pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: @mut
compartment.register_class(prototype_jsclass(name.to_owned())); compartment.register_class(prototype_jsclass(name.to_owned()));
//TODO error checking //TODO error checking
let obj = result::unwrap( let obj = (
match proto { match proto {
Some(s) => compartment.new_object_with_proto(name.to_owned(), Some(s) => compartment.new_object_with_proto(name.to_owned(),
s, s,
compartment.global_obj.ptr), compartment.global_obj.ptr),
None => compartment.new_object(name.to_owned(), null(), compartment.global_obj.ptr) None => compartment.new_object(name.to_owned(), null(), compartment.global_obj.ptr)
}); }).unwrap();
unsafe { unsafe {
compartment.define_property(name.to_owned(), RUST_OBJECT_TO_JSVAL(obj.ptr), compartment.define_property(name.to_owned(), RUST_OBJECT_TO_JSVAL(obj.ptr),
@ -456,7 +455,7 @@ pub fn CreateInterfaceObjects2(cx: *JSContext, global: *JSObject, receiver: *JSO
let mut interface = ptr::null(); let mut interface = ptr::null();
if constructorClass.is_not_null() || constructor.is_not_null() { if constructorClass.is_not_null() || constructor.is_not_null() {
interface = do str::as_c_str(name) |s| { interface = do name.as_c_str |s| {
CreateInterfaceObject(cx, global, receiver, constructorClass, CreateInterfaceObject(cx, global, receiver, constructorClass,
constructor, ctorNargs, proto, constructor, ctorNargs, proto,
staticMethods, constants, s) staticMethods, constants, s)
@ -508,7 +507,7 @@ fn CreateInterfaceObject(cx: *JSContext, global: *JSObject, receiver: *JSObject,
} }
if constructorClass.is_not_null() { if constructorClass.is_not_null() {
let toString = do str::as_c_str("toString") |s| { let toString = do "toString".as_c_str |s| {
DefineFunctionWithReserved(cx, constructor, s, DefineFunctionWithReserved(cx, constructor, s,
InterfaceObjectToString, InterfaceObjectToString,
0, 0) 0, 0)

View file

@ -10,7 +10,6 @@ use js::jsapi::{JSObject, JSContext, JSVal};
use js::glue::RUST_OBJECT_TO_JSVAL; use js::glue::RUST_OBJECT_TO_JSVAL;
use std::cast; use std::cast;
use std::f32;
pub struct ClientRect { pub struct ClientRect {
wrapper: WrapperCache, wrapper: WrapperCache,
@ -54,11 +53,11 @@ impl ClientRect {
} }
pub fn Width(&self) -> f32 { pub fn Width(&self) -> f32 {
f32::abs(self.right - self.left) (self.right - self.left).abs()
} }
pub fn Height(&self) -> f32 { pub fn Height(&self) -> f32 {
f32::abs(self.bottom - self.top) (self.bottom - self.top).abs()
} }
} }

View file

@ -47,7 +47,7 @@ use js::jsapi::{JSContext, JSObject};
use std::cell::Cell; use std::cell::Cell;
use std::comm; use std::comm;
use std::str::eq_slice; use std::str::eq_slice;
use extra::net::url; use std::FromStr;
pub struct Element { pub struct Element {
parent: Node<ScriptView>, parent: Node<ScriptView>,
@ -279,7 +279,7 @@ impl<'self> Element {
if "style" == name { if "style" == name {
self.style_attribute = Some( self.style_attribute = Some(
Stylesheet::from_attribute( Stylesheet::from_attribute(
url::from_str("http://www.example.com/").unwrap(), FromStr::from_str("http://www.example.com/").unwrap(),
value.get_ref())); value.get_ref()));
} }
@ -290,8 +290,8 @@ impl<'self> Element {
} }
fn get_scope_and_cx(&self) -> (*JSObject, *JSContext) { fn get_scope_and_cx(&self) -> (*JSObject, *JSContext) {
let doc = self.parent.owner_doc.get(); let doc = self.parent.owner_doc.unwrap();
let win = doc.with_base(|doc| doc.window.get()); let win = doc.with_base(|doc| doc.window.unwrap());
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr}; let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
let cache = win.get_wrappercache(); let cache = win.get_wrappercache();
let scope = cache.get_wrapper(); let scope = cache.get_wrapper();
@ -419,7 +419,7 @@ impl Element {
debug!("no document"); debug!("no document");
None None
} }
}.get(); }.unwrap();
ClientRectList::new(rects, cx, scope) ClientRectList::new(rects, cx, scope)
} }

View file

@ -39,7 +39,7 @@ impl FormData {
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,
name: filename.get_or_default(str(~"default")) name: filename.unwrap_or_default(str(~"default"))
}; };
self.data.insert(name.to_str(), blob); self.data.insert(name.to_str(), blob);
} }

View file

@ -11,7 +11,7 @@ use geom::size::Size2D;
use servo_msg::constellation_msg::SubpageId; use servo_msg::constellation_msg::SubpageId;
use std::comm::ChanOne; use std::comm::ChanOne;
use extra::net::url::Url; use extra::url::Url;
pub struct HTMLIFrameElement { pub struct HTMLIFrameElement {
parent: HTMLElement, parent: HTMLElement,

View file

@ -4,7 +4,7 @@
use dom::bindings::utils::{DOMString, null_string, ErrorResult}; use dom::bindings::utils::{DOMString, null_string, ErrorResult};
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use extra::net::url::Url; use extra::url::Url;
pub struct HTMLImageElement { pub struct HTMLImageElement {
parent: HTMLElement, parent: HTMLElement,

View file

@ -250,7 +250,7 @@ impl<'self, View> AbstractNode<View> {
/// allowed to call this. This is wildly unsafe and is therefore marked as such. /// allowed to call this. This is wildly unsafe and is therefore marked as such.
pub unsafe fn unsafe_layout_data<T>(self) -> @mut T { pub unsafe fn unsafe_layout_data<T>(self) -> @mut T {
do self.with_base |base| { do self.with_base |base| {
transmute(base.layout_data.get()) transmute(base.layout_data.unwrap())
} }
} }
/// Returns true if this node has layout data and false otherwise. /// Returns true if this node has layout data and false otherwise.

View file

@ -19,7 +19,6 @@ use js::{JSVAL_NULL, JSPROP_ENUMERATE};
use std::cast; use std::cast;
use std::comm; use std::comm;
use std::comm::Chan; use std::comm::Chan;
use std::int;
use std::io; use std::io;
use std::ptr; use std::ptr;
use js::jsapi::JSVal; use js::jsapi::JSVal;
@ -68,7 +67,7 @@ impl Window {
pub fn Document(&self) -> AbstractDocument { pub fn Document(&self) -> AbstractDocument {
unsafe { unsafe {
(*self.page).frame.get().document (*self.page).frame.unwrap().document
} }
} }

View file

@ -11,7 +11,7 @@ use std::task;
use newcss::stylesheet::Stylesheet; use newcss::stylesheet::Stylesheet;
use newcss::util::DataStream; use newcss::util::DataStream;
use servo_net::resource_task::{ResourceTask, ProgressMsg, Load, Payload, Done}; use servo_net::resource_task::{ResourceTask, ProgressMsg, Load, Payload, Done};
use extra::net::url::Url; use extra::url::Url;
/// Where a style sheet comes from. /// Where a style sheet comes from.
pub enum StylesheetProvenance { pub enum StylesheetProvenance {

View file

@ -56,8 +56,8 @@ use std::cell::Cell;
use std::comm; use std::comm;
use std::comm::{Chan, Port, SharedChan}; use std::comm::{Chan, Port, SharedChan};
use std::str::eq_slice; use std::str::eq_slice;
use std::result;
use std::task; use std::task;
use std::from_str::FromStr;
use hubbub::hubbub; use hubbub::hubbub;
use servo_msg::constellation_msg::SubpageId; use servo_msg::constellation_msg::SubpageId;
use servo_net::image_cache_task::ImageCacheTask; use servo_net::image_cache_task::ImageCacheTask;
@ -65,8 +65,7 @@ use servo_net::image_cache_task;
use servo_net::resource_task::{Done, Load, Payload, ResourceTask}; use servo_net::resource_task::{Done, Load, Payload, ResourceTask};
use servo_util::tree::TreeUtils; use servo_util::tree::TreeUtils;
use servo_util::url::make_url; use servo_util::url::make_url;
use extra::net::url::Url; use extra::url::Url;
use extra::net::url;
use extra::future::{Future, from_port}; use extra::future::{Future, from_port};
use geom::size::Size2D; use geom::size::Size2D;
@ -498,7 +497,7 @@ pub fn parse_html(cx: *JSContext,
// We've reached the end of a <style> so we can submit all the text to the parser. // We've reached the end of a <style> so we can submit all the text to the parser.
unsafe { unsafe {
let style: AbstractNode<ScriptView> = NodeWrapping::from_hubbub_node(style); let style: AbstractNode<ScriptView> = NodeWrapping::from_hubbub_node(style);
let url = url::from_str("http://example.com/"); // FIXME let url = FromStr::from_str("http://example.com/"); // FIXME
let url_cell = Cell::new(url); let url_cell = Cell::new(url);
let mut data = ~[]; let mut data = ~[];
@ -511,7 +510,7 @@ pub fn parse_html(cx: *JSContext,
} }
debug!("data = %?", data); debug!("data = %?", data);
let provenance = InlineProvenance(result::unwrap(url_cell.take()), data.concat()); let provenance = InlineProvenance(url_cell.take().unwrap(), data.concat());
css_chan3.send(CSSTaskNewFile(provenance)); css_chan3.send(CSSTaskNewFile(provenance));
} }
}, },

View file

@ -14,7 +14,7 @@ use geom::size::Size2D;
use geom::point::Point2D; use geom::point::Point2D;
use gfx::geometry::Au; use gfx::geometry::Au;
use newcss::stylesheet::Stylesheet; use newcss::stylesheet::Stylesheet;
use extra::net::url::Url; use extra::url::Url;
/// Asynchronous messages that script can send to layout. /// Asynchronous messages that script can send to layout.
/// ///

View file

@ -29,7 +29,7 @@ use newcss::stylesheet::Stylesheet;
use std::cell::Cell; use std::cell::Cell;
use std::comm; use std::comm;
use std::comm::{Port, SharedChan, Select2}; use std::comm::{Port, SharedChan};
use std::io::read_whole_file; use std::io::read_whole_file;
use std::ptr::null; use std::ptr::null;
use std::task::{SingleThreaded, task}; use std::task::{SingleThreaded, task};
@ -50,8 +50,7 @@ use servo_net::image_cache_task::ImageCacheTask;
use servo_net::resource_task::ResourceTask; use servo_net::resource_task::ResourceTask;
use servo_util::tree::TreeNodeRef; use servo_util::tree::TreeNodeRef;
use servo_util::url::make_url; use servo_util::url::make_url;
use extra::net::url::Url; use extra::url::Url;
use extra::net::url;
use extra::future::{from_value, Future}; use extra::future::{from_value, Future};
/// Messages used to control the script task. /// Messages used to control the script task.
@ -485,14 +484,14 @@ impl ScriptTask {
/// Handles a request to execute a script. /// Handles a request to execute a script.
fn handle_execute_msg(&mut self, id: PipelineId, url: Url) { fn handle_execute_msg(&mut self, id: PipelineId, url: Url) {
debug!("script: Received url `%s` to execute", url::to_str(&url)); debug!("script: Received url `%s` to execute", url.to_str());
let page_tree = self.page_tree.find(id).expect("ScriptTask: received fire timer msg for a let page_tree = self.page_tree.find(id).expect("ScriptTask: received fire timer msg for a
pipeline ID not associated with this script task. This is a bug."); pipeline ID not associated with this script task. This is a bug.");
let js_info = page_tree.page.js_info.get_ref(); let js_info = page_tree.page.js_info.get_ref();
match read_whole_file(&Path(url.path)) { match read_whole_file(&Path(url.path)) {
Err(msg) => println(fmt!("Error opening %s: %s", url::to_str(&url), msg)), Err(msg) => println(fmt!("Error opening %s: %s", url.to_str(), msg)),
Ok(bytes) => { Ok(bytes) => {
js_info.js_compartment.define_functions(debug_fns); js_info.js_compartment.define_functions(debug_fns);
@ -558,7 +557,7 @@ impl ScriptTask {
fn handle_exit_msg(&mut self) { fn handle_exit_msg(&mut self) {
for self.page_tree.iter().advance |page| { for self.page_tree.iter().advance |page| {
page.join_layout(); page.join_layout();
do page.frame.get().document.with_mut_base |doc| { do page.frame.unwrap().document.with_mut_base |doc| {
doc.teardown(); doc.teardown();
} }
page.layout_chan.send(layout_interface::ExitMsg); page.layout_chan.send(layout_interface::ExitMsg);
@ -661,7 +660,7 @@ impl ScriptTask {
// Receive the JavaScript scripts. // Receive the JavaScript scripts.
assert!(js_scripts.is_some()); assert!(js_scripts.is_some());
let js_scripts = js_scripts.swap_unwrap(); let js_scripts = js_scripts.take_unwrap();
debug!("js_scripts: %?", js_scripts); debug!("js_scripts: %?", js_scripts);
// Perform the initial reflow. // Perform the initial reflow.

View file

@ -2,11 +2,10 @@
* 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 extra::net::url; use extra::url;
use extra::net::url::Url; use extra::url::Url;
use std::hashmap::HashMap; use std::hashmap::HashMap;
use std::os; use std::os;
use std::result;
/** /**
Create a URL object from a string. Does various helpful browsery things like Create a URL object from a string. Does various helpful browsery things like
@ -19,7 +18,7 @@ Create a URL object from a string. Does various helpful browsery things like
*/ */
pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url { pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
let schm = url::get_scheme(str_url); let schm = url::get_scheme(str_url);
let str_url = if result::is_err(&schm) { let str_url = if schm.is_err() {
if current_url.is_none() { if current_url.is_none() {
// Assume we've been given a file path. If it's absolute just return // Assume we've been given a file path. If it's absolute just return
// it, otherwise make it absolute with the cwd. // it, otherwise make it absolute with the cwd.
@ -29,7 +28,7 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
~"file://" + os::getcwd().push(str_url).to_str() ~"file://" + os::getcwd().push(str_url).to_str()
} }
} else { } else {
let current_url = current_url.get(); let current_url = current_url.unwrap();
debug!("make_url: current_url: %?", current_url); debug!("make_url: current_url: %?", current_url);
if str_url.starts_with("//") { if str_url.starts_with("//") {
current_url.scheme + ":" + str_url current_url.scheme + ":" + str_url
@ -56,7 +55,7 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
}; };
// FIXME: Need to handle errors // FIXME: Need to handle errors
url::from_str(str_url).get() url::from_str(str_url).unwrap()
} }
mod make_url_tests { mod make_url_tests {