aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
m---------src/rust0
m---------src/rust-azure0
m---------src/rust-cairo0
m---------src/rust-css0
m---------src/rust-glut0
m---------src/rust-http-client0
m---------src/rust-hubbub0
m---------src/rust-mozjs0
m---------src/rust-netsurfcss0
m---------src/rust-opengles0
m---------src/rust-stb-image0
m---------src/rust-wapcaplet0
-rw-r--r--src/servo-gfx/font.rs14
-rw-r--r--src/servo-gfx/font_context.rs6
-rw-r--r--src/servo-gfx/font_list.rs6
-rw-r--r--src/servo-gfx/fontconfig/font_list.rs66
-rw-r--r--src/servo-gfx/freetype_impl/font.rs6
-rw-r--r--src/servo-gfx/freetype_impl/font_context.rs2
-rw-r--r--src/servo-gfx/image/base.rs43
-rw-r--r--src/servo-gfx/text/glyph.rs4
-rw-r--r--src/servo-gfx/text/harfbuzz/shaper.rs116
-rw-r--r--src/servo/content/content_task.rs6
-rw-r--r--src/servo/dom/bindings/document.rs22
-rw-r--r--src/servo/dom/bindings/element.rs98
-rw-r--r--src/servo/dom/bindings/node.rs2
-rw-r--r--src/servo/dom/bindings/window.rs30
-rw-r--r--src/servo/dom/cow.rs136
-rw-r--r--src/servo/dom/node.rs6
-rw-r--r--src/servo/dom/window.rs24
-rw-r--r--src/servo/html/hubbub_html_parser.rs360
-rw-r--r--src/servo/layout/inline.rs2
31 files changed, 505 insertions, 444 deletions
diff --git a/src/rust b/src/rust
-Subproject 0e29e21281512f71d33a87995002bd438c5b42f
+Subproject e447521c1ca2dbead5b485ddc43060b28284081
diff --git a/src/rust-azure b/src/rust-azure
-Subproject 16b5d87d37b2ce377b919de20c6a45fdf9e052d
+Subproject a8bdb2f58bf415deb5a1bf1407f17bcd09f2d96
diff --git a/src/rust-cairo b/src/rust-cairo
-Subproject 0439b988200eadfcb581b6b488331a9d4c5caba
+Subproject a583fefac118e354ff5cd3acf575f8267fd07c3
diff --git a/src/rust-css b/src/rust-css
-Subproject aff506ba29bd34e8980ad7c3286a7cdc4e8207a
+Subproject 7d67731550afbe7657508ec6e437e2cd1816133
diff --git a/src/rust-glut b/src/rust-glut
-Subproject b33e9dbc11895d4e30ac4abde60e2d24a182930
+Subproject 25e58c3ba2a8aed701553b811dfab639824a655
diff --git a/src/rust-http-client b/src/rust-http-client
-Subproject 7d1872b89050332e957504a66ee38d73773efaf
+Subproject 77d9e83b730f8202de56699d1dd6eaeb66fd5e2
diff --git a/src/rust-hubbub b/src/rust-hubbub
-Subproject 5b39316c0b9f37417a7a5863dcfb03b007bd363
+Subproject 5af98808471802fe193175adb246bea2eb809fa
diff --git a/src/rust-mozjs b/src/rust-mozjs
-Subproject 96e92609d0f250ae3222b9ba99f2e00acc5ec0f
+Subproject 5efa43df1177da86d0ef1e783650b82a0928634
diff --git a/src/rust-netsurfcss b/src/rust-netsurfcss
-Subproject 8657c14771908eb8577dfbe0fff5e85e3f1990d
+Subproject bc06cf6a1771c13755051b51c919dddf73b60a5
diff --git a/src/rust-opengles b/src/rust-opengles
-Subproject b51ce8cca8aa9db6b9a65612b3366cd78457173
+Subproject 1e89a5e143fc1349a945decb5e0c91ad62356e1
diff --git a/src/rust-stb-image b/src/rust-stb-image
-Subproject 6653d7ed1163f9007682eb65cd221f258d4d0d5
+Subproject 26ac8e118161430025d8074259ed05ccef1baf1
diff --git a/src/rust-wapcaplet b/src/rust-wapcaplet
-Subproject 7eb84c523889efc97b96eaf80c82208c07e7442
+Subproject 352c9f8359d196e453c5e2fc8d45785b852668c
diff --git a/src/servo-gfx/font.rs b/src/servo-gfx/font.rs
index a87cb5ef77d..eca67d2af0b 100644
--- a/src/servo-gfx/font.rs
+++ b/src/servo-gfx/font.rs
@@ -71,12 +71,14 @@ trait FontTableTagConversions {
}
impl FontTableTag : FontTableTagConversions {
- pub pure fn tag_to_str() -> ~str unsafe {
- let reversed = str::raw::from_buf_len(cast::transmute(&self), 4);
- return str::from_chars([reversed.char_at(3),
- reversed.char_at(2),
- reversed.char_at(1),
- reversed.char_at(0)]);
+ pub pure fn tag_to_str() -> ~str {
+ unsafe {
+ let reversed = str::raw::from_buf_len(cast::transmute(&self), 4);
+ return str::from_chars([reversed.char_at(3),
+ reversed.char_at(2),
+ reversed.char_at(1),
+ reversed.char_at(0)]);
+ }
}
}
diff --git a/src/servo-gfx/font_context.rs b/src/servo-gfx/font_context.rs
index 875da1a8eda..9c353a8d13c 100644
--- a/src/servo-gfx/font_context.rs
+++ b/src/servo-gfx/font_context.rs
@@ -7,8 +7,8 @@ use util::cache::MonoCache;
use azure::azure_hl::BackendType;
use core::dvec::DVec;
-use core::send_map::linear::LinearMap;
-use core::send_map::linear;
+use core::hashmap::linear::LinearMap;
+use core::hashmap::linear;
#[cfg(target_os = "macos")]
use quartz;
@@ -122,7 +122,7 @@ pub impl FontContext {
// FIXME: Need a find_like() in LinearMap.
let family = family.to_str();
debug!("(transform family) searching for `%s`", family);
- match self.generic_fonts.find_ref(&family) {
+ match self.generic_fonts.find(&family) {
None => move family,
Some(move mapped_family) => copy *mapped_family
}
diff --git a/src/servo-gfx/font_list.rs b/src/servo-gfx/font_list.rs
index a3cfaef4e09..ee0513fdf26 100644
--- a/src/servo-gfx/font_list.rs
+++ b/src/servo-gfx/font_list.rs
@@ -2,7 +2,7 @@ use font::{CSSFontWeight, SpecifiedFontStyle, UsedFontStyle};
use native::FontHandle;
use dvec::DVec;
-use core::send_map::{linear, SendMap};
+use core::hashmap::linear;
#[cfg(target_os = "linux")]
use fontconfig;
@@ -46,7 +46,7 @@ pub impl FontList {
let handle = result::unwrap(FontListHandle::new(fctx));
let list = FontList {
handle: move handle,
- family_map: linear::LinearMap(),
+ family_map: linear::LinearMap::new(),
};
list.refresh(fctx);
return move list;
@@ -82,7 +82,7 @@ pub impl FontList {
priv fn find_family(family_name: &str) -> Option<@FontFamily> {
// look up canonical name
- let family = self.family_map.find(&str::from_slice(family_name));
+ let family = self.family_map.find_copy(&str::from_slice(family_name));
let decision = if family.is_some() { "Found" } else { "Couldn't find" };
debug!("FontList: %s font family with name=%s", decision, family_name);
diff --git a/src/servo-gfx/fontconfig/font_list.rs b/src/servo-gfx/fontconfig/font_list.rs
index fb844e3d613..02cb84b4859 100644
--- a/src/servo-gfx/fontconfig/font_list.rs
+++ b/src/servo-gfx/fontconfig/font_list.rs
@@ -22,7 +22,7 @@ use self::fontconfig::fontconfig::bindgen::{
};
use core::dvec::DVec;
-use core::send_map::{linear, SendMap};
+use core::hashmap::linear;
use libc::c_int;
use ptr::Ptr;
use native;
@@ -37,7 +37,7 @@ pub impl FontconfigFontListHandle {
}
fn get_available_families() -> FontFamilyMap {
- let mut family_map : FontFamilyMap = linear::LinearMap();
+ let mut family_map : FontFamilyMap = linear::LinearMap::new();
unsafe {
let config = FcConfigGetCurrent();
let fontSet = FcConfigGetFonts(config, FcSetSystem);
@@ -122,38 +122,40 @@ pub impl FontconfigFontListHandle {
}
}
-pub fn path_from_identifier(name: ~str) -> Result<~str, ()> unsafe {
- let config = FcConfigGetCurrent();
- let pattern = FcPatternCreate();
- let res = do str::as_c_str("family") |FC_FAMILY| {
- do str::as_c_str(name) |family| {
- FcPatternAddString(pattern, FC_FAMILY, family as *FcChar8)
+pub fn path_from_identifier(name: ~str) -> Result<~str, ()> {
+ unsafe {
+ let config = FcConfigGetCurrent();
+ let pattern = FcPatternCreate();
+ let res = do str::as_c_str("family") |FC_FAMILY| {
+ do str::as_c_str(name) |family| {
+ FcPatternAddString(pattern, FC_FAMILY, family as *FcChar8)
+ }
+ };
+ if res != 1 {
+ debug!("adding family to pattern failed");
+ return Err(());
}
- };
- if res != 1 {
- debug!("adding family to pattern failed");
- return Err(());
- }
- if FcConfigSubstitute(config, pattern, FcMatchPattern) != 1 {
- debug!("substitution failed");
- return Err(());
- }
- FcDefaultSubstitute(pattern);
- let result = FcResultNoMatch;
- let result_pattern = FcFontMatch(config, pattern, &result);
- if result != FcResultMatch && result_pattern.is_null() {
- debug!("obtaining match to pattern failed");
- return Err(());
- }
+ if FcConfigSubstitute(config, pattern, FcMatchPattern) != 1 {
+ debug!("substitution failed");
+ return Err(());
+ }
+ FcDefaultSubstitute(pattern);
+ let result = FcResultNoMatch;
+ let result_pattern = FcFontMatch(config, pattern, &result);
+ if result != FcResultMatch && result_pattern.is_null() {
+ debug!("obtaining match to pattern failed");
+ return Err(());
+ }
- let file: *FcChar8 = ptr::null();
- let res = do str::as_c_str("file") |FC_FILE| {
- FcPatternGetString(result_pattern, FC_FILE, 0, &file)
- };
- if res != FcResultMatch {
- debug!("getting filename for font failed");
- return Err(());
+ let file: *FcChar8 = ptr::null();
+ let res = do str::as_c_str("file") |FC_FILE| {
+ FcPatternGetString(result_pattern, FC_FILE, 0, &file)
+ };
+ if res != FcResultMatch {
+ debug!("getting filename for font failed");
+ return Err(());
+ }
+ Ok(str::raw::from_buf(file as *u8))
}
- Ok(str::raw::from_buf(file as *u8))
} \ No newline at end of file
diff --git a/src/servo-gfx/freetype_impl/font.rs b/src/servo-gfx/freetype_impl/font.rs
index 96db4d23bda..58a9a176797 100644
--- a/src/servo-gfx/freetype_impl/font.rs
+++ b/src/servo-gfx/freetype_impl/font.rs
@@ -301,8 +301,10 @@ pub impl FreeTypeFontHandle : FontHandleMethods {
}
pub impl FreeTypeFontHandle {
- priv fn get_face_rec() -> &self/FT_FaceRec unsafe {
- &(*self.face)
+ priv fn get_face_rec() -> &self/FT_FaceRec {
+ unsafe {
+ &(*self.face)
+ }
}
priv fn font_units_to_au(value: float) -> Au {
diff --git a/src/servo-gfx/freetype_impl/font_context.rs b/src/servo-gfx/freetype_impl/font_context.rs
index b8d455996db..d3f9bdc91c5 100644
--- a/src/servo-gfx/freetype_impl/font_context.rs
+++ b/src/servo-gfx/freetype_impl/font_context.rs
@@ -50,7 +50,7 @@ pub impl FreeTypeFontContextHandle : FontContextHandleMethods {
}
fn create_font_from_identifier(name: ~str, style: UsedFontStyle)
- -> Result<FontHandle, ()> unsafe {
+ -> Result<FontHandle, ()> {
debug!("Creating font handle for %s", name);
do path_from_identifier(name).chain |file_name| {
debug!("Opening font face %s", file_name);
diff --git a/src/servo-gfx/image/base.rs b/src/servo-gfx/image/base.rs
index 3028c12c8c0..f29b0f87007 100644
--- a/src/servo-gfx/image/base.rs
+++ b/src/servo-gfx/image/base.rs
@@ -3,7 +3,7 @@ use stb_image = stb_image::image;
// FIXME: Images must not be copied every frame. Instead we should atomically
// reference count them.
-pub type Image = stb_image::Image;
+pub type Image = stb_image::Image<u8>;
pub fn Image(width: uint, height: uint, depth: uint, data: ~[u8]) -> Image {
stb_image::new_image(width, height, depth, move data)
@@ -20,24 +20,27 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
// Can't remember why we do this. Maybe it's what cairo wants
const FORCE_DEPTH: uint = 4;
- do stb_image::load_from_memory_with_depth(buffer, FORCE_DEPTH).map |image| {
-
- assert image.depth == 4;
- // Do color space conversion :(
- let data = do vec::from_fn(image.width * image.height * 4) |i| {
- let color = i % 4;
- let pixel = i / 4;
- match color {
- 0 => image.data[pixel * 4 + 2],
- 1 => image.data[pixel * 4 + 1],
- 2 => image.data[pixel * 4 + 0],
- 3 => 0xffu8,
- _ => fail
- }
- };
-
- assert image.data.len() == data.len();
-
- Image(image.width, image.height, image.depth, move data)
+ match stb_image::load_from_memory_with_depth(buffer, FORCE_DEPTH, true) {
+ stb_image::ImageU8(image) => {
+ assert image.depth == 4;
+ // Do color space conversion :(
+ let data = do vec::from_fn(image.width * image.height * 4) |i| {
+ let color = i % 4;
+ let pixel = i / 4;
+ match color {
+ 0 => image.data[pixel * 4 + 2],
+ 1 => image.data[pixel * 4 + 1],
+ 2 => image.data[pixel * 4 + 0],
+ 3 => 0xffu8,
+ _ => fail
+ }
+ };
+
+ assert image.data.len() == data.len();
+
+ Some(Image(image.width, image.height, image.depth, move data))
+ }
+ stb_image::ImageF32(_image) => fail ~"HDR images not implemented",
+ stb_image::Error => None
}
}
diff --git a/src/servo-gfx/text/glyph.rs b/src/servo-gfx/text/glyph.rs
index ce872bcf9ac..dc05337a0f6 100644
--- a/src/servo-gfx/text/glyph.rs
+++ b/src/servo-gfx/text/glyph.rs
@@ -416,9 +416,9 @@ impl DetailedGlyphStore {
// Thar be dragons here. You have been warned. (Tips accepted.)
let mut unsorted_records : ~[DetailedGlyphRecord] = ~[];
core::util::swap(&mut self.detail_lookup, &mut unsorted_records);
- let mut_records : ~[mut DetailedGlyphRecord] = vec::to_mut(move unsorted_records);
+ let mut_records : ~[mut DetailedGlyphRecord] = vec::cast_to_mut(move unsorted_records);
sort::quick_sort3(mut_records);
- let mut sorted_records = vec::from_mut(move mut_records);
+ let mut sorted_records = vec::cast_from_mut(move mut_records);
core::util::swap(&mut self.detail_lookup, &mut sorted_records);
self.lookup_is_sorted = true;
diff --git a/src/servo-gfx/text/harfbuzz/shaper.rs b/src/servo-gfx/text/harfbuzz/shaper.rs
index d9c7920f62a..ed4afb1b70f 100644
--- a/src/servo-gfx/text/harfbuzz/shaper.rs
+++ b/src/servo-gfx/text/harfbuzz/shaper.rs
@@ -77,35 +77,39 @@ pub struct ShapedGlyphEntry {
}
pub impl ShapedGlyphData {
- static pure fn new(buffer: *hb_buffer_t) -> ShapedGlyphData unsafe {
- let glyph_count = 0 as c_uint;
- let glyph_infos = hb_buffer_get_glyph_infos(buffer, ptr::to_unsafe_ptr(&glyph_count));
- let glyph_count = glyph_count as uint;
- assert glyph_infos.is_not_null();
- let pos_count = 0 as c_uint;
- let pos_infos = hb_buffer_get_glyph_positions(buffer, ptr::to_unsafe_ptr(&pos_count));
- assert pos_infos.is_not_null();
- assert glyph_count == pos_count as uint;
-
- ShapedGlyphData {
- count: glyph_count,
- glyph_infos: glyph_infos,
- pos_infos: pos_infos,
+ static pure fn new(buffer: *hb_buffer_t) -> ShapedGlyphData {
+ unsafe {
+ let glyph_count = 0 as c_uint;
+ let glyph_infos = hb_buffer_get_glyph_infos(buffer, ptr::to_unsafe_ptr(&glyph_count));
+ let glyph_count = glyph_count as uint;
+ assert glyph_infos.is_not_null();
+ let pos_count = 0 as c_uint;
+ let pos_infos = hb_buffer_get_glyph_positions(buffer, ptr::to_unsafe_ptr(&pos_count));
+ assert pos_infos.is_not_null();
+ assert glyph_count == pos_count as uint;
+
+ ShapedGlyphData {
+ count: glyph_count,
+ glyph_infos: glyph_infos,
+ pos_infos: pos_infos,
+ }
}
}
#[inline(always)]
- priv pure fn byte_offset_of_glyph(&const self, i: uint) -> uint unsafe {
+ priv pure fn byte_offset_of_glyph(&const self, i: uint) -> uint {
assert i < self.count;
let glyph_info_i = ptr::offset(self.glyph_infos, i);
- return (*glyph_info_i).cluster as uint;
+ unsafe {
+ (*glyph_info_i).cluster as uint
+ }
}
pure fn len() -> uint { self.count }
// Returns shaped glyph data for one glyph, and updates the y-position of the pen.
- fn get_entry_for_glyph(i: uint, y_pos: &mut Au) -> ShapedGlyphEntry unsafe {
+ fn get_entry_for_glyph(i: uint, y_pos: &mut Au) -> ShapedGlyphEntry {
assert i < self.count;
let glyph_info_i = ptr::offset(self.glyph_infos, i);
@@ -126,11 +130,13 @@ pub impl ShapedGlyphData {
Some(Point2D(x_offset, y_pos - y_offset))
};
- ShapedGlyphEntry {
- cluster: (*glyph_info_i).cluster as uint,
- codepoint: (*glyph_info_i).codepoint as GlyphIndex,
- advance: x_advance,
- offset: move offset,
+ unsafe {
+ ShapedGlyphEntry {
+ cluster: (*glyph_info_i).cluster as uint,
+ codepoint: (*glyph_info_i).codepoint as GlyphIndex,
+ advance: x_advance,
+ offset: move offset,
+ }
}
}
}
@@ -443,47 +449,53 @@ extern fn glyph_func(_font: *hb_font_t,
unicode: hb_codepoint_t,
_variant_selector: hb_codepoint_t,
glyph: *mut hb_codepoint_t,
- _user_data: *c_void) -> hb_bool_t unsafe {
+ _user_data: *c_void) -> hb_bool_t {
let font: *Font = font_data as *Font;
assert font.is_not_null();
- return match (*font).glyph_index(unicode as char) {
- Some(g) => { *glyph = g as hb_codepoint_t; true },
- None => false
- } as hb_bool_t;
+ unsafe {
+ return match (*font).glyph_index(unicode as char) {
+ Some(g) => { *glyph = g as hb_codepoint_t; true },
+ None => false
+ } as hb_bool_t;
+ }
}
extern fn glyph_h_advance_func(_font: *hb_font_t,
font_data: *c_void,
glyph: hb_codepoint_t,
- _user_data: *c_void) -> hb_position_t unsafe {
+ _user_data: *c_void) -> hb_position_t {
let font: *Font = font_data as *Font;
assert font.is_not_null();
- let advance = (*font).glyph_h_advance(glyph as GlyphIndex);
- HarfbuzzShaper::float_to_fixed(advance)
+ unsafe {
+ let advance = (*font).glyph_h_advance(glyph as GlyphIndex);
+ HarfbuzzShaper::float_to_fixed(advance)
+ }
}
// Callback to get a font table out of a font.
-extern fn get_font_table_func(_face: *hb_face_t, tag: hb_tag_t, user_data: *c_void) -> *hb_blob_t unsafe {
- let font: *Font = user_data as *Font;
- assert font.is_not_null();
-
- // TODO(Issue #197): reuse font table data, which will change the unsound trickery here.
- match (*font).get_table_for_tag(tag as FontTableTag) {
- None => return ptr::null(),
- Some(ref font_table) => {
- let skinny_font_table = ~font_table;
- let skinny_font_table_ptr = ptr::to_unsafe_ptr(skinny_font_table);
- let mut blob: *hb_blob_t = ptr::null();
- (*skinny_font_table_ptr).with_buffer(|buf: *u8, len: uint| {
- blob = hb_blob_create(buf as *c_char,
- len as c_uint,
- HB_MEMORY_MODE_READONLY,
- cast::transmute(skinny_font_table_ptr), // private context for below.
- destroy_blob_func); // HarfBuzz calls this when blob not needed.
- });
- assert blob.is_not_null();
- return blob;
+extern fn get_font_table_func(_face: *hb_face_t, tag: hb_tag_t, user_data: *c_void) -> *hb_blob_t {
+ unsafe {
+ let font: *Font = user_data as *Font;
+ assert font.is_not_null();
+
+ // TODO(Issue #197): reuse font table data, which will change the unsound trickery here.
+ match (*font).get_table_for_tag(tag as FontTableTag) {
+ None => return ptr::null(),
+ Some(ref font_table) => {
+ let skinny_font_table = ~font_table;
+ let skinny_font_table_ptr = ptr::to_unsafe_ptr(skinny_font_table);
+ let mut blob: *hb_blob_t = ptr::null();
+ (*skinny_font_table_ptr).with_buffer(|buf: *u8, len: uint| {
+ blob = hb_blob_create(buf as *c_char,
+ len as c_uint,
+ HB_MEMORY_MODE_READONLY,
+ cast::transmute(skinny_font_table_ptr), // private context for below.
+ destroy_blob_func); // HarfBuzz calls this when blob not needed.
+ });
+ assert blob.is_not_null();
+ return blob;
+ }
}
}
}
@@ -492,7 +504,7 @@ extern fn get_font_table_func(_face: *hb_face_t, tag: hb_tag_t, user_data: *c_vo
// In particular, we'll need to cast to a boxed, rather than owned, FontTable.
// even better, should cache the harfbuzz blobs directly instead of recreating a lot.
-extern fn destroy_blob_func(user_data: *c_void) unsafe {
+extern fn destroy_blob_func(user_data: *c_void) {
// this will cause drop to run.
- let _wrapper : &~FontTable = cast::transmute(user_data);
+ let _wrapper : &~FontTable = unsafe { cast::transmute(user_data) };
}
diff --git a/src/servo/content/content_task.rs b/src/servo/content/content_task.rs
index 67cdc0e0c60..3c1d3b189bd 100644
--- a/src/servo/content/content_task.rs
+++ b/src/servo/content/content_task.rs
@@ -153,8 +153,10 @@ pub fn Content(layout_task: LayoutTask,
content
}
-pub fn task_from_context(cx: *JSContext) -> *Content unsafe {
- cast::reinterpret_cast(&JS_GetContextPrivate(cx))
+pub fn task_from_context(cx: *JSContext) -> *Content {
+ unsafe {
+ cast::reinterpret_cast(&JS_GetContextPrivate(cx))
+ }
}
#[allow(non_implicitly_copyable_typarams)]
diff --git a/src/servo/dom/bindings/document.rs b/src/servo/dom/bindings/document.rs
index 9600c384bd3..ced0d0943c5 100644
--- a/src/servo/dom/bindings/document.rs
+++ b/src/servo/dom/bindings/document.rs
@@ -63,17 +63,19 @@ enum Element = int;
}*/
extern fn getDocumentElement(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
- -> JSBool unsafe {
- let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
- if obj.is_null() {
- return 0;
- }
+ -> JSBool {
+ unsafe {
+ let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
+ if obj.is_null() {
+ return 0;
+ }
- let box = unwrap(obj);
- let node = (*box).payload.root;
- let scope = (*box).payload.scope;
- *vp = RUST_OBJECT_TO_JSVAL(node::create(cx, node, scope).ptr);
- return 1;
+ let box = unwrap(obj);
+ let node = (*box).payload.root;
+ let scope = (*box).payload.scope;
+ *vp = RUST_OBJECT_TO_JSVAL(node::create(cx, node, scope).ptr);
+ return 1;
+ }
}
unsafe fn unwrap(obj: *JSObject) -> *rust_box<Document> {
diff --git a/src/servo/dom/bindings/element.rs b/src/servo/dom/bindings/element.rs
index 9dd7e2f725f..2c5ab072e98 100644
--- a/src/servo/dom/bindings/element.rs
+++ b/src/servo/dom/bindings/element.rs
@@ -65,62 +65,66 @@ pub fn init(compartment: &bare_compartment) {
#[allow(non_implicitly_copyable_typarams)]
extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
- -> JSBool unsafe {
- let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
- if obj.is_null() {
- return 0;
- }
+ -> JSBool {
+ unsafe {
+ let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
+ if obj.is_null() {
+ return 0;
+ }
- let bundle = unwrap(obj);
- let node = (*bundle).payload.node;
- let scope = (*bundle).payload.scope;
- let width = scope.write(&node, |nd| {
- match &nd.kind {
- &~Element(ref ed) => {
- match &ed.kind {
- &~HTMLImageElement(*) => {
- let content = task_from_context(cx);
- match (*content).query_layout(layout_task::ContentBox(node)) {
- Ok(rect) => rect.width,
- Err(()) => 0,
+ let bundle = unwrap(obj);
+ let node = (*bundle).payload.node;
+ let scope = (*bundle).payload.scope;
+ let width = scope.write(&node, |nd| {
+ match &nd.kind {
+ &~Element(ref ed) => {
+ match &ed.kind {
+ &~HTMLImageElement(*) => {
+ let content = task_from_context(cx);
+ match (*content).query_layout(layout_task::ContentBox(node)) {
+ Ok(rect) => rect.width,
+ Err(()) => 0,
+ }
+ // TODO: if nothing is being rendered(?), return zero dimensions
}
- // TODO: if nothing is being rendered(?), return zero dimensions
+ _ => fail ~"why is this not an image element?"
}
- _ => fail ~"why is this not an image element?"
}
- },
- _ => fail ~"why is this not an element?"
- }
- });
- *vp = RUST_INT_TO_JSVAL(
- (width & (i32::max_value as int)) as libc::c_int);
- return 1;
+ _ => fail ~"why is this not an element?"
+ }
+ });
+ *vp = RUST_INT_TO_JSVAL(
+ (width & (i32::max_value as int)) as libc::c_int);
+ return 1;
+ }
}
#[allow(non_implicitly_copyable_typarams)]
extern fn HTMLImageElement_setWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
- -> JSBool unsafe {
- let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
- if obj.is_null() {
- return 0;
- }
+ -> JSBool {
+ unsafe {
+ let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
+ if obj.is_null() {
+ return 0;
+ }
- let bundle = unwrap(obj);
- do (*bundle).payload.scope.write(&(*bundle).payload.node) |nd| {
- match nd.kind {
- ~Element(ref ed) => {
- match ed.kind {
- ~HTMLImageElement(*) => {
- let arg = ptr::offset(JS_ARGV(cx, cast::reinterpret_cast(&vp)), 0);
- ed.set_attr(~"width", int::str(RUST_JSVAL_TO_INT(*arg) as int))
- },
- _ => fail ~"why is this not an image element?"
+ let bundle = unwrap(obj);
+ do (*bundle).payload.scope.write(&(*bundle).payload.node) |nd| {
+ match nd.kind {
+ ~Element(ref ed) => {
+ match ed.kind {
+ ~HTMLImageElement(*) => {
+ let arg = ptr::offset(JS_ARGV(cx, cast::reinterpret_cast(&vp)), 0);
+ ed.set_attr(~"width", int::str(RUST_JSVAL_TO_INT(*arg) as int))
+ }
+ _ => fail ~"why is this not an image element?"
+ }
+ }
+ _ => fail ~"why is this not an element?"
}
- }
- _ => fail ~"why is this not an element?"
- }
- };
- return 1;
+ };
+ return 1;
+ }
}
#[allow(non_implicitly_copyable_typarams)]
@@ -150,7 +154,7 @@ extern fn getTagName(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
}
#[allow(non_implicitly_copyable_typarams)]
-pub fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj unsafe {
+pub fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj {
let proto = scope.write(&node, |nd| {
match &nd.kind {
&~Element(ref ed) => {
diff --git a/src/servo/dom/bindings/node.rs b/src/servo/dom/bindings/node.rs
index 393610daa2a..48b230439c5 100644
--- a/src/servo/dom/bindings/node.rs
+++ b/src/servo/dom/bindings/node.rs
@@ -46,7 +46,7 @@ pub fn init(compartment: &bare_compartment) {
}
#[allow(non_implicitly_copyable_typarams)]
-pub fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj unsafe {
+pub fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj {
do scope.write(&node) |nd| {
match nd.kind {
~Element(*) => {
diff --git a/src/servo/dom/bindings/window.rs b/src/servo/dom/bindings/window.rs
index 98b9c44b5b0..1a0ba895a9b 100644
--- a/src/servo/dom/bindings/window.rs
+++ b/src/servo/dom/bindings/window.rs
@@ -32,24 +32,28 @@ extern fn alert(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool {
1_i32
}
-extern fn setTimeout(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool unsafe {
- let argv = JS_ARGV(cx, vp);
- assert (argc >= 2);
+extern fn setTimeout(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool {
+ unsafe {
+ let argv = JS_ARGV(cx, vp);
+ assert (argc >= 2);
- //TODO: don't crash when passed a non-integer value for the timeout
+ //TODO: don't crash when passed a non-integer value for the timeout
- (*unwrap(JS_THIS_OBJECT(cx, vp))).payload.setTimeout(
- RUST_JSVAL_TO_INT(*ptr::offset(argv, 1)) as int,
- argc, argv);
+ (*unwrap(JS_THIS_OBJECT(cx, vp))).payload.setTimeout(
+ RUST_JSVAL_TO_INT(*ptr::offset(argv, 1)) as int,
+ argc, argv);
- JS_SET_RVAL(cx, vp, JSVAL_NULL);
- return 1;
+ JS_SET_RVAL(cx, vp, JSVAL_NULL);
+ return 1;
+ }
}
-extern fn close(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool unsafe {
- (*unwrap(JS_THIS_OBJECT(cx, vp))).payload.close();
- JS_SET_RVAL(cx, vp, JSVAL_NULL);
- return 1;
+extern fn close(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool {
+ unsafe {
+ (*unwrap(JS_THIS_OBJECT(cx, vp))).payload.close();
+ JS_SET_RVAL(cx, vp, JSVAL_NULL);
+ return 1;
+ }
}
unsafe fn unwrap(obj: *JSObject) -> *rust_box<Window> {
diff --git a/src/servo/dom/cow.rs b/src/servo/dom/cow.rs
index b3d00938a68..0f75fd9a96b 100644
--- a/src/servo/dom/cow.rs
+++ b/src/servo/dom/cow.rs
@@ -72,8 +72,10 @@ type ScopeData<T,A> = {
struct ScopeResource<T,A> {
d : ScopeData<T,A>,
- drop unsafe {
- for self.d.free_list.each |h| { free_handle(*h); }
+ drop {
+ unsafe {
+ for self.d.free_list.each |h| { free_handle(*h); }
+ }
}
}
@@ -93,15 +95,15 @@ pub enum Handle<T,A> {
// Private methods
impl<T,A> Handle<T,A> {
- fn read_ptr() -> *T unsafe { (**self).read_ptr }
- fn write_ptr() -> *mut T unsafe { (**self).write_ptr }
- fn read_aux() -> *A unsafe { (**self).read_aux }
- fn next_dirty() -> Handle<T,A> unsafe { (**self).next_dirty }
+ fn read_ptr() -> *T { unsafe { (**self).read_ptr } }
+ fn write_ptr() -> *mut T { unsafe { (**self).write_ptr } }
+ fn read_aux() -> *A { unsafe { (**self).read_aux } }
+ fn next_dirty() -> Handle<T,A> { unsafe { (**self).next_dirty } }
- fn set_read_ptr(t: *T) unsafe { (**self).read_ptr = t; }
- fn set_write_ptr(t: *mut T) unsafe { (**self).write_ptr = t; }
- fn set_read_aux(t: *A) unsafe { (**self).read_aux = t; }
- fn set_next_dirty(h: Handle<T,A>) unsafe { (**self).next_dirty = h; }
+ fn set_read_ptr(t: *T) { unsafe { (**self).read_ptr = t; } }
+ fn set_write_ptr(t: *mut T) { unsafe { (**self).write_ptr = t; } }
+ fn set_read_aux(t: *A) { unsafe { (**self).read_aux = t; } }
+ fn set_next_dirty(h: Handle<T,A>) { unsafe { (**self).next_dirty = h; } }
pure fn is_null() -> bool { (*self).is_null() }
fn is_not_null() -> bool { (*self).is_not_null() }
@@ -109,27 +111,35 @@ impl<T,A> Handle<T,A> {
impl<T:Owned,A> Handle<T,A> {
/// Access the reader's view of the handle's data
- fn read<U>(f: fn(&T) -> U) -> U unsafe {
- f(&*self.read_ptr())
+ fn read<U>(f: fn(&T) -> U) -> U {
+ unsafe {
+ f(&*self.read_ptr())
+ }
}
/// True if auxiliary data is associated with this handle
- fn has_aux() -> bool unsafe {
- self.read_aux().is_not_null()
+ fn has_aux() -> bool {
+ unsafe {
+ self.read_aux().is_not_null()
+ }
}
/** Set the auxiliary data associated with this handle.
**Warning:** the reader is responsible for keeping this data live!
*/
- fn set_aux(p: @A) unsafe {
- (**self).read_aux = ptr::to_unsafe_ptr(&*p);
+ fn set_aux(p: @A) {
+ unsafe {
+ (**self).read_aux = ptr::to_unsafe_ptr(&*p);
+ }
}
/// Access the auxiliary data associated with this handle
- fn aux<U>(f: fn(&A) -> U) -> U unsafe {
- assert self.has_aux();
- f(&*self.read_aux())
+ fn aux<U>(f: fn(&A) -> U) -> U {
+ unsafe {
+ assert self.has_aux();
+ f(&*self.read_aux())
+ }
}
}
@@ -140,16 +150,18 @@ impl <T: Owned,A> Handle<T,A> : cmp::Eq {
// Private methods
impl<T: Copy Owned,A> Scope<T,A> {
- fn clone(v: *T) -> *T unsafe {
- let n: *mut T =
- cast::reinterpret_cast(&libc::calloc(sys::size_of::<T>() as size_t, 1u as size_t));
+ fn clone(v: *T) -> *T {
+ unsafe {
+ let n: *mut T =
+ cast::reinterpret_cast(&libc::calloc(sys::size_of::<T>() as size_t, 1u as size_t));
- // n.b.: this assignment will run the drop glue for <T,A>. *Hopefully* the fact that
- // everything is initialized to NULL by calloc will make this ok. We may have to make the
- // take glue be tolerant of this.
- *n = unsafe{*v};
+ // n.b.: this assignment will run the drop glue for <T,A>. *Hopefully* the fact that
+ // everything is initialized to NULL by calloc will make this ok. We may have to make the
+ // take glue be tolerant of this.
+ *n = unsafe{*v};
- return cast::reinterpret_cast(&n);
+ return cast::reinterpret_cast(&n);
+ }
}
}
@@ -195,18 +207,20 @@ impl<T:Copy Owned,A> Scope<T,A> {
self.d.layout_active = true;
}
- fn reader_joined() unsafe {
+ fn reader_joined() {
assert self.d.layout_active;
- if self.d.first_dirty.is_not_null() {
+ if (/*bad*/copy self.d.first_dirty).is_not_null() {
let mut handle = self.d.first_dirty;
while (*handle).is_not_null() {
- free(handle.read_ptr());
+ unsafe {
+ free(handle.read_ptr());
- handle.set_read_ptr(cast::reinterpret_cast(&handle.write_ptr()));
- let next_handle = handle.next_dirty();
- handle.set_next_dirty(null_handle());
- handle = next_handle;
+ handle.set_read_ptr(cast::reinterpret_cast(&handle.write_ptr()));
+ let next_handle = handle.next_dirty();
+ handle.set_next_dirty(null_handle());
+ handle = next_handle;
+ }
}
self.d.first_dirty = null_handle();
}
@@ -215,40 +229,46 @@ impl<T:Copy Owned,A> Scope<T,A> {
self.d.layout_active = false;
}
- fn read<U>(h: &Handle<T,A>, f: fn(&T) -> U) -> U unsafe {
+ fn read<U>(h: &Handle<T,A>, f: fn(&T) -> U) -> U {
// Use the write_ptr, which may be more up to date than the read_ptr or may not
- f(&*h.write_ptr())
+ unsafe {
+ f(&*h.write_ptr())
+ }
}
- fn write<U>(h: &Handle<T,A>, f: fn(&T) -> U) -> U unsafe {
- let const_read_ptr = ptr::const_offset(h.read_ptr(), 0);
- let const_write_ptr = ptr::const_offset(h.write_ptr(), 0);
- if self.d.layout_active && const_read_ptr == const_write_ptr {
- debug!("marking handle %? as dirty", h);
- h.set_write_ptr(cast::reinterpret_cast(&self.clone(h.read_ptr())));
- h.set_next_dirty(self.d.first_dirty);
- self.d.first_dirty = *h;
+ fn write<U>(h: &Handle<T,A>, f: fn(&T) -> U) -> U {
+ unsafe {
+ let const_read_ptr = ptr::const_offset(h.read_ptr(), 0);
+ let const_write_ptr = ptr::const_offset(h.write_ptr(), 0);
+ if self.d.layout_active && const_read_ptr == const_write_ptr {
+ debug!("marking handle %? as dirty", h);
+ h.set_write_ptr(cast::reinterpret_cast(&self.clone(h.read_ptr())));
+ h.set_next_dirty(self.d.first_dirty);
+ self.d.first_dirty = *h;
+ }
+ f(&*h.write_ptr())
}
- f(&*h.write_ptr())
}
// FIXME: This could avoid a deep copy by taking ownership of `v`
#[allow(non_implicitly_copyable_typarams)]
- fn handle(v: &T) -> Handle<T,A> unsafe {
- debug!("vv: %?", *v);
- let d: *HandleData<T,A> =
- cast::reinterpret_cast(
- &libc::malloc(sys::size_of::<HandleData<T,A>>() as size_t));
- (*d).read_ptr = self.clone(ptr::to_unsafe_ptr(v));
- (*d).write_ptr = cast::reinterpret_cast(&(*d).read_ptr);
- (*d).read_aux = ptr::null();
- (*d).next_dirty = null_handle();
- let h = _Handle(d);
- push(&mut self.d.free_list, h);
- do self.read(&h) |v| {
+ fn handle(v: &T) -> Handle<T,A> {
+ unsafe {
debug!("vv: %?", *v);
+ let d: *HandleData<T,A> =
+ cast::reinterpret_cast(
+ &libc::malloc(sys::size_of::<HandleData<T,A>>() as size_t));
+ (*d).read_ptr = self.clone(ptr::to_unsafe_ptr(v));
+ (*d).write_ptr = cast::reinterpret_cast(&(*d).read_ptr);
+ (*d).read_aux = ptr::null();
+ (*d).next_dirty = null_handle();
+ let h = _Handle(d);
+ push(&mut self.d.free_list, h);
+ do self.read(&h) |v| {
+ debug!("vv: %?", *v);
+ }
+ return h;
}
- return h;
}
}
diff --git a/src/servo/dom/node.rs b/src/servo/dom/node.rs
index 1dcdf937867..ca9d899e0d4 100644
--- a/src/servo/dom/node.rs
+++ b/src/servo/dom/node.rs
@@ -76,8 +76,10 @@ impl Node : DebugMethods {
}
}
- pure fn debug_str(&self) -> ~str unsafe {
- do self.read |n| { fmt!("%?", n.kind) }
+ pure fn debug_str(&self) -> ~str {
+ unsafe {
+ do self.read |n| { fmt!("%?", n.kind) }
+ }
}
}
diff --git a/src/servo/dom/window.rs b/src/servo/dom/window.rs
index a945ee19ebf..d08b949775d 100644
--- a/src/servo/dom/window.rs
+++ b/src/servo/dom/window.rs
@@ -28,19 +28,21 @@ pub struct TimerData {
args: DVec<JSVal>,
}
-pub fn TimerData(argc: libc::c_uint, argv: *JSVal) -> TimerData unsafe {
- let data = TimerData {
- funval : *argv,
- args : DVec(),
- };
+pub fn TimerData(argc: libc::c_uint, argv: *JSVal) -> TimerData {
+ unsafe {
+ let data = TimerData {
+ funval : *argv,
+ args : DVec(),
+ };
- let mut i = 2;
- while i < argc as uint {
- data.args.push(*ptr::offset(argv, i));
- i += 1;
- };
+ let mut i = 2;
+ while i < argc as uint {
+ data.args.push(*ptr::offset(argv, i));
+ i += 1;
+ };
- move data
+ move data
+ }
}
// FIXME: delayed_send shouldn't require Copy
diff --git a/src/servo/html/hubbub_html_parser.rs b/src/servo/html/hubbub_html_parser.rs
index 660f0073bc8..a6ca90a5049 100644
--- a/src/servo/html/hubbub_html_parser.rs
+++ b/src/servo/html/hubbub_html_parser.rs
@@ -164,7 +164,7 @@ fn build_element_kind(tag: &str) -> ~ElementKind {
pub fn parse_html(scope: NodeScope,
url: Url,
resource_task: ResourceTask,
- image_cache_task: ImageCacheTask) -> HtmlParserResult unsafe {
+ image_cache_task: ImageCacheTask) -> HtmlParserResult {
// Spawn a CSS parser to receive links to CSS style sheets.
let (css_port, css_chan): (oldcomm::Port<Option<Stylesheet>>, oldcomm::Chan<CSSMessage>) =
do spawn_conversation |css_port: oldcomm::Port<CSSMessage>,
@@ -181,206 +181,210 @@ pub fn parse_html(scope: NodeScope,
let (scope, url) = (@copy scope, @move url);
- // Build the root node.
- let root = scope.new_node(Element(ElementData(~"html", ~HTMLDivElement)));
- debug!("created new node");
- let parser = hubbub::Parser("UTF-8", false);
- debug!("created parser");
- parser.set_document_node(cast::transmute(cow::unwrap(root)));
- parser.enable_scripting(true);
+ unsafe {
+ // Build the root node.
+ let root = scope.new_node(Element(ElementData(~"html", ~HTMLDivElement)));
+ debug!("created new node");
+ let parser = hubbub::Parser("UTF-8", false);
+ debug!("created parser");
+ parser.set_document_node(cast::transmute(cow::unwrap(root)));
+ parser.enable_scripting(true);
- // Performs various actions necessary after appending has taken place. Currently, this consists
- // of processing inline stylesheets, but in the future it might perform prefetching, etc.
- let append_hook: @fn(Node, Node) = |parent_node, child_node| {
- do scope.read(&parent_node) |parent_node_contents| {
- do scope.read(&child_node) |child_node_contents| {
- match (&parent_node_contents.kind, &child_node_contents.kind) {
- (&~Element(ref element), &~Text(ref data)) => {
- match element.kind {
- ~HTMLStyleElement => {
- debug!("found inline CSS stylesheet");
- let url = url::from_str("http://example.com/"); // FIXME
- let provenance = InlineProvenance(result::unwrap(move url),
- copy *data);
- css_chan.send(CSSTaskNewFile(move provenance));
+ // Performs various actions necessary after appending has taken place. Currently, this consists
+ // of processing inline stylesheets, but in the future it might perform prefetching, etc.
+ let append_hook: @fn(Node, Node) = |parent_node, child_node| {
+ do scope.read(&parent_node) |parent_node_contents| {
+ do scope.read(&child_node) |child_node_contents| {
+ match (&parent_node_contents.kind, &child_node_contents.kind) {
+ (&~Element(ref element), &~Text(ref data)) => {
+ match element.kind {
+ ~HTMLStyleElement => {
+ debug!("found inline CSS stylesheet");
+ let url = url::from_str("http://example.com/"); // FIXME
+ let provenance = InlineProvenance(result::unwrap(move url),
+ copy *data);
+ css_chan.send(CSSTaskNewFile(move provenance));
+ }
+ _ => {} // Nothing to do.
}
- _ => {} // Nothing to do.
- }
+ }
+ _ => {} // Nothing to do.
}
- _ => {} // Nothing to do.
}
}
- }
- };
+ };
- parser.set_tree_handler(@hubbub::TreeHandler {
- create_comment: |data: ~str| {
- debug!("create comment");
- let new_node = scope.new_node(Comment(move data));
- unsafe { cast::transmute(cow::unwrap(new_node)) }
- },
- create_doctype: |doctype: ~hubbub::Doctype| {
- debug!("create doctype");
- // TODO: remove copying here by using struct pattern matching to
- // move all ~strs at once (blocked on Rust #3845, #3846, #3847)
- let public_id = match &doctype.public_id {
- &None => None,
- &Some(ref id) => Some(copy *id)
- };
- let system_id = match &doctype.system_id {
- &None => None,
- &Some(ref id) => Some(copy *id)
- };
- let data = DoctypeData(copy doctype.name, move public_id, move system_id,
- copy doctype.force_quirks);
- let new_node = scope.new_node(Doctype(move data));
- unsafe { cast::transmute(cow::unwrap(new_node)) }
- },
- create_element: |tag: ~hubbub::Tag, move image_cache_task| {
- debug!("create element");
- // TODO: remove copying here by using struct pattern matching to
- // move all ~strs at once (blocked on Rust #3845, #3846, #3847)
- let elem_kind = build_element_kind(tag.name);
- let elem = ElementData(copy tag.name, move elem_kind);
+ parser.set_tree_handler(@hubbub::TreeHandler {
+ create_comment: |data: ~str| {
+ debug!("create comment");
+ let new_node = scope.new_node(Comment(move data));
+ unsafe { cast::transmute(cow::unwrap(new_node)) }
+ },
+ create_doctype: |doctype: ~hubbub::Doctype| {
+ debug!("create doctype");
+ // TODO: remove copying here by using struct pattern matching to
+ // move all ~strs at once (blocked on Rust #3845, #3846, #3847)
+ let public_id = match &doctype.public_id {
+ &None => None,
+ &Some(ref id) => Some(copy *id)
+ };
+ let system_id = match &doctype.system_id {
+ &None => None,
+ &Some(ref id) => Some(copy *id)
+ };
+ let data = DoctypeData(copy doctype.name, move public_id, move system_id,
+ copy doctype.force_quirks);
+ let new_node = scope.new_node(Doctype(move data));
+ unsafe { cast::transmute(cow::unwrap(new_node)) }
+ },
+ create_element: |tag: ~hubbub::Tag, move image_cache_task| {
+ debug!("create element");
+ // TODO: remove copying here by using struct pattern matching to
+ // move all ~strs at once (blocked on Rust #3845, #3846, #3847)
+ let elem_kind = build_element_kind(tag.name);
+ let elem = ElementData(copy tag.name, move elem_kind);
- debug!("-- attach attrs");
- for tag.attributes.each |attr| {
- elem.attrs.push(~Attr(copy attr.name, copy attr.value));
- }
+ debug!("-- attach attrs");
+ for tag.attributes.each |attr| {
+ elem.attrs.push(~Attr(copy attr.name, copy attr.value));
+ }
- // Spawn additional parsing, network loads, etc. from tag and attrs
- match elem.kind {
- //Handle CSS style sheets from <link> elements
- ~HTMLLinkElement => {
- match (elem.get_attr(~"rel"), elem.get_attr(~"href")) {
- (Some(move rel), Some(move href)) => {
- if rel == ~"stylesheet" {
- debug!("found CSS stylesheet: %s", href);
- css_chan.send(CSSTaskNewFile(UrlProvenance(make_url(move href,
- Some(copy *url)))));
+ // Spawn additional parsing, network loads, etc. from tag and attrs
+ match elem.kind {
+ //Handle CSS style sheets from <link> elements
+ ~HTMLLinkElement => {
+ match (elem.get_attr(~"rel"), elem.get_attr(~"href")) {
+ (Some(move rel), Some(move href)) => {
+ if rel == ~"stylesheet" {
+ debug!("found CSS stylesheet: %s", href);
+ css_chan.send(CSSTaskNewFile(UrlProvenance(make_url(move href,
+ Some(copy *url)))));
+ }
}
+ _ => {}
+ }
+ },
+ ~HTMLImageElement(ref d) => {
+ do elem.get_attr(~"src").iter |img_url_str| {
+ let img_url = make_url(copy *img_url_str, Some(copy *url));
+ d.image = Some(copy img_url);
+ // inform the image cache to load this, but don't store a handle.
+ // TODO (Issue #84): don't prefetch if we are within a <noscript> tag.
+ image_cache_task.send(image_cache_task::Prefetch(move img_url));
}
- _ => {}
- }
- },
- ~HTMLImageElement(ref d) => {
- do elem.get_attr(~"src").iter |img_url_str| {
- let img_url = make_url(copy *img_url_str, Some(copy *url));
- d.image = Some(copy img_url);
- // inform the image cache to load this, but don't store a handle.
- // TODO (Issue #84): don't prefetch if we are within a <noscript> tag.
- image_cache_task.send(image_cache_task::Prefetch(move img_url));
}
+ //TODO (Issue #86): handle inline styles ('style' attr)
+ _ => {}
}
- //TODO (Issue #86): handle inline styles ('style' attr)
- _ => {}
- }
- let node = scope.new_node(Element(move elem));
- unsafe { cast::transmute(cow::unwrap(node)) }
- },
- create_text: |data: ~str| {
- debug!("create text");
- let new_node = scope.new_node(Text(move data));
- unsafe { cast::transmute(cow::unwrap(new_node)) }
- },
- ref_node: |_node| {},
- unref_node: |_node| {},
- append_child: |parent: hubbub::NodeDataPtr, child: hubbub::NodeDataPtr| unsafe {
- debug!("append child %x %x", cast::transmute(parent), cast::transmute(child));
- unsafe {
- let p: Node = cow::wrap(cast::transmute(parent));
- let c: Node = cow::wrap(cast::transmute(child));
- scope.add_child(p, c);
- append_hook(p, c);
- }
- child
- },
- insert_before: |_parent, _child| {
- debug!("insert before");
- 0u
- },
- remove_child: |_parent, _child| {
- debug!("remove child");
- 0u
- },
- clone_node: |node, deep| {
- debug!("clone node");
- unsafe {
- if deep { error!("-- deep clone unimplemented"); }
- let n: Node = cow::wrap(cast::transmute(node));
- let data = n.read(|read_data| copy *read_data.kind);
- let new_node = scope.new_node(move data);
+ let node = scope.new_node(Element(move elem));
+ unsafe { cast::transmute(cow::unwrap(node)) }
+ },
+ create_text: |data: ~str| {
+ debug!("create text");
+ let new_node = scope.new_node(Text(move data));
unsafe { cast::transmute(cow::unwrap(new_node)) }
- }
- },
- reparent_children: |_node, _new_parent| {
- debug!("reparent children");
- 0u
- },
- get_parent: |_node, _element_only| {
- debug!("get parent");
- 0u
- },
- has_children: |_node| {
- debug!("has children");
- false
- },
- form_associate: |_form, _node| {
- debug!("form associate");
- },
- add_attributes: |_node, _attributes| {
- debug!("add attributes");
- },
- set_quirks_mode: |_mode| {
- debug!("set quirks mode");
- },
- encoding_change: |_encname| {
- debug!("encoding change");
- },
- complete_script: |script| {
- // A little function for holding this lint attr
- #[allow(non_implicitly_copyable_typarams)]
- fn complete_script(scope: &NodeScope, script: hubbub::NodeDataPtr, url: &Url, js_chan: &oldcomm::Chan<JSMessage>) unsafe {
- do scope.read(&cow::wrap(cast::transmute(script))) |node_contents| {
- match *node_contents.kind {
- Element(ref element) if element.tag_name == ~"script" => {
- match element.get_attr(~"src") {
- Some(move src) => {
- debug!("found script: %s", src);
- let new_url = make_url(move src, Some(copy *url));
- js_chan.send(JSTaskNewFile(move new_url));
+ },
+ ref_node: |_node| {},
+ unref_node: |_node| {},
+ append_child: |parent: hubbub::NodeDataPtr, child: hubbub::NodeDataPtr| {
+ unsafe {
+ debug!("append child %x %x", cast::transmute(parent), cast::transmute(child));
+ let p: Node = cow::wrap(cast::transmute(parent));
+ let c: Node = cow::wrap(cast::transmute(child));
+ scope.add_child(p, c);
+ append_hook(p, c);
+ }
+ child
+ },
+ insert_before: |_parent, _child| {
+ debug!("insert before");
+ 0u
+ },
+ remove_child: |_parent, _child| {
+ debug!("remove child");
+ 0u
+ },
+ clone_node: |node, deep| {
+ debug!("clone node");
+ unsafe {
+ if deep { error!("-- deep clone unimplemented"); }
+ let n: Node = cow::wrap(cast::transmute(node));
+ let data = n.read(|read_data| copy *read_data.kind);
+ let new_node = scope.new_node(move data);
+ cast::transmute(cow::unwrap(new_node))
+ }
+ },
+ reparent_children: |_node, _new_parent| {
+ debug!("reparent children");
+ 0u
+ },
+ get_parent: |_node, _element_only| {
+ debug!("get parent");
+ 0u
+ },
+ has_children: |_node| {
+ debug!("has children");
+ false
+ },
+ form_associate: |_form, _node| {
+ debug!("form associate");
+ },
+ add_attributes: |_node, _attributes| {
+ debug!("add attributes");
+ },
+ set_quirks_mode: |_mode| {
+ debug!("set quirks mode");
+ },
+ encoding_change: |_encname| {
+ debug!("encoding change");
+ },
+ complete_script: |script| {
+ // A little function for holding this lint attr
+ #[allow(non_implicitly_copyable_typarams)]
+ fn complete_script(scope: &NodeScope, script: hubbub::NodeDataPtr, url: &Url, js_chan: &oldcomm::Chan<JSMessage>) {
+ unsafe {
+ do scope.read(&cow::wrap(cast::transmute(script))) |node_contents| {
+ match *node_contents.kind {
+ Element(ref element) if element.tag_name == ~"script" => {
+ match element.get_attr(~"src") {
+ Some(move src) => {
+ debug!("found script: %s", src);
+ let new_url = make_url(move src, Some(copy *url));
+ js_chan.send(JSTaskNewFile(move new_url));
+ }
+ None => {}
+ }
}
- None => {}
+ _ => {}
}
}
- _ => {}
}
}
+ complete_script(scope, script, url, &js_chan);
+ debug!("complete script");
}
- complete_script(scope, script, url, &js_chan);
- debug!("complete script");
- }
- });
- debug!("set tree handler");
+ });
+ debug!("set tree handler");
- let input_port = Port();
- resource_task.send(Load(copy *url, input_port.chan()));
- debug!("loaded page");
- loop {
- match input_port.recv() {
- Payload(data) => {
- debug!("received data");
- parser.parse_chunk(data);
- }
- Done(*) => {
- break;
+ let input_port = Port();
+ resource_task.send(Load(copy *url, input_port.chan()));
+ debug!("loaded page");
+ loop {
+ match input_port.recv() {
+ Payload(data) => {
+ debug!("received data");
+ parser.parse_chunk(data);
+ }
+ Done(*) => {
+ break;
+ }
}
}
- }
- css_chan.send(CSSTaskExit);
- js_chan.send(JSTaskExit);
+ css_chan.send(CSSTaskExit);
+ js_chan.send(JSTaskExit);
- return HtmlParserResult { root: root, style_port: css_port, js_port: js_port };
+ return HtmlParserResult { root: root, style_port: css_port, js_port: js_port };
+ }
}
diff --git a/src/servo/layout/inline.rs b/src/servo/layout/inline.rs
index 8d93d912785..3fa5ea0b586 100644
--- a/src/servo/layout/inline.rs
+++ b/src/servo/layout/inline.rs
@@ -323,7 +323,7 @@ priv impl TextRunScanner {
struct LineboxScanner {
flow: @FlowContext,
new_boxes: DVec<@RenderBox>,
- work_list: DList<@RenderBox>,
+ work_list: @DList<@RenderBox>,
pending_line: {mut range: Range, mut width: Au},
line_spans: DVec<Range>,
}