mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Rust upgrade.
This commit is contained in:
parent
772c670bea
commit
b7b9197b46
31 changed files with 530 additions and 469 deletions
2
src/rust
2
src/rust
|
@ -1 +1 @@
|
||||||
Subproject commit 0e29e21281512f71d33a87995002bd438c5b42f1
|
Subproject commit e447521c1ca2dbead5b485ddc43060b282840817
|
|
@ -1 +1 @@
|
||||||
Subproject commit 16b5d87d37b2ce377b919de20c6a45fdf9e052dc
|
Subproject commit a8bdb2f58bf415deb5a1bf1407f17bcd09f2d965
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0439b988200eadfcb581b6b488331a9d4c5caba0
|
Subproject commit a583fefac118e354ff5cd3acf575f8267fd07c39
|
|
@ -1 +1 @@
|
||||||
Subproject commit aff506ba29bd34e8980ad7c3286a7cdc4e8207ae
|
Subproject commit 7d67731550afbe7657508ec6e437e2cd18161336
|
|
@ -1 +1 @@
|
||||||
Subproject commit b33e9dbc11895d4e30ac4abde60e2d24a182930e
|
Subproject commit 25e58c3ba2a8aed701553b811dfab639824a6553
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7d1872b89050332e957504a66ee38d73773efaf1
|
Subproject commit 77d9e83b730f8202de56699d1dd6eaeb66fd5e29
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5b39316c0b9f37417a7a5863dcfb03b007bd3634
|
Subproject commit 5af98808471802fe193175adb246bea2eb809fa0
|
|
@ -1 +1 @@
|
||||||
Subproject commit 96e92609d0f250ae3222b9ba99f2e00acc5ec0fb
|
Subproject commit 5efa43df1177da86d0ef1e783650b82a0928634b
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8657c14771908eb8577dfbe0fff5e85e3f1990da
|
Subproject commit bc06cf6a1771c13755051b51c919dddf73b60a5f
|
|
@ -1 +1 @@
|
||||||
Subproject commit b51ce8cca8aa9db6b9a65612b3366cd78457173e
|
Subproject commit 1e89a5e143fc1349a945decb5e0c91ad62356e15
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6653d7ed1163f9007682eb65cd221f258d4d0d5b
|
Subproject commit 26ac8e118161430025d8074259ed05ccef1baf14
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7eb84c523889efc97b96eaf80c82208c07e74423
|
Subproject commit 352c9f8359d196e453c5e2fc8d45785b852668c9
|
|
@ -71,7 +71,8 @@ trait FontTableTagConversions {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FontTableTag : FontTableTagConversions {
|
impl FontTableTag : FontTableTagConversions {
|
||||||
pub pure fn tag_to_str() -> ~str unsafe {
|
pub pure fn tag_to_str() -> ~str {
|
||||||
|
unsafe {
|
||||||
let reversed = str::raw::from_buf_len(cast::transmute(&self), 4);
|
let reversed = str::raw::from_buf_len(cast::transmute(&self), 4);
|
||||||
return str::from_chars([reversed.char_at(3),
|
return str::from_chars([reversed.char_at(3),
|
||||||
reversed.char_at(2),
|
reversed.char_at(2),
|
||||||
|
@ -79,6 +80,7 @@ impl FontTableTag : FontTableTagConversions {
|
||||||
reversed.char_at(0)]);
|
reversed.char_at(0)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
pub type FontTable/& = quartz::font::QuartzFontTable;
|
pub type FontTable/& = quartz::font::QuartzFontTable;
|
||||||
|
|
|
@ -7,8 +7,8 @@ use util::cache::MonoCache;
|
||||||
|
|
||||||
use azure::azure_hl::BackendType;
|
use azure::azure_hl::BackendType;
|
||||||
use core::dvec::DVec;
|
use core::dvec::DVec;
|
||||||
use core::send_map::linear::LinearMap;
|
use core::hashmap::linear::LinearMap;
|
||||||
use core::send_map::linear;
|
use core::hashmap::linear;
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use quartz;
|
use quartz;
|
||||||
|
@ -122,7 +122,7 @@ pub impl FontContext {
|
||||||
// FIXME: Need a find_like() in LinearMap.
|
// FIXME: Need a find_like() in LinearMap.
|
||||||
let family = family.to_str();
|
let family = family.to_str();
|
||||||
debug!("(transform family) searching for `%s`", family);
|
debug!("(transform family) searching for `%s`", family);
|
||||||
match self.generic_fonts.find_ref(&family) {
|
match self.generic_fonts.find(&family) {
|
||||||
None => move family,
|
None => move family,
|
||||||
Some(move mapped_family) => copy *mapped_family
|
Some(move mapped_family) => copy *mapped_family
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use font::{CSSFontWeight, SpecifiedFontStyle, UsedFontStyle};
|
||||||
use native::FontHandle;
|
use native::FontHandle;
|
||||||
|
|
||||||
use dvec::DVec;
|
use dvec::DVec;
|
||||||
use core::send_map::{linear, SendMap};
|
use core::hashmap::linear;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use fontconfig;
|
use fontconfig;
|
||||||
|
@ -46,7 +46,7 @@ pub impl FontList {
|
||||||
let handle = result::unwrap(FontListHandle::new(fctx));
|
let handle = result::unwrap(FontListHandle::new(fctx));
|
||||||
let list = FontList {
|
let list = FontList {
|
||||||
handle: move handle,
|
handle: move handle,
|
||||||
family_map: linear::LinearMap(),
|
family_map: linear::LinearMap::new(),
|
||||||
};
|
};
|
||||||
list.refresh(fctx);
|
list.refresh(fctx);
|
||||||
return move list;
|
return move list;
|
||||||
|
@ -82,7 +82,7 @@ pub impl FontList {
|
||||||
|
|
||||||
priv fn find_family(family_name: &str) -> Option<@FontFamily> {
|
priv fn find_family(family_name: &str) -> Option<@FontFamily> {
|
||||||
// look up canonical name
|
// 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" };
|
let decision = if family.is_some() { "Found" } else { "Couldn't find" };
|
||||||
debug!("FontList: %s font family with name=%s", decision, family_name);
|
debug!("FontList: %s font family with name=%s", decision, family_name);
|
||||||
|
|
|
@ -22,7 +22,7 @@ use self::fontconfig::fontconfig::bindgen::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use core::dvec::DVec;
|
use core::dvec::DVec;
|
||||||
use core::send_map::{linear, SendMap};
|
use core::hashmap::linear;
|
||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
use ptr::Ptr;
|
use ptr::Ptr;
|
||||||
use native;
|
use native;
|
||||||
|
@ -37,7 +37,7 @@ pub impl FontconfigFontListHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_available_families() -> FontFamilyMap {
|
fn get_available_families() -> FontFamilyMap {
|
||||||
let mut family_map : FontFamilyMap = linear::LinearMap();
|
let mut family_map : FontFamilyMap = linear::LinearMap::new();
|
||||||
unsafe {
|
unsafe {
|
||||||
let config = FcConfigGetCurrent();
|
let config = FcConfigGetCurrent();
|
||||||
let fontSet = FcConfigGetFonts(config, FcSetSystem);
|
let fontSet = FcConfigGetFonts(config, FcSetSystem);
|
||||||
|
@ -122,7 +122,8 @@ pub impl FontconfigFontListHandle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path_from_identifier(name: ~str) -> Result<~str, ()> unsafe {
|
pub fn path_from_identifier(name: ~str) -> Result<~str, ()> {
|
||||||
|
unsafe {
|
||||||
let config = FcConfigGetCurrent();
|
let config = FcConfigGetCurrent();
|
||||||
let pattern = FcPatternCreate();
|
let pattern = FcPatternCreate();
|
||||||
let res = do str::as_c_str("family") |FC_FAMILY| {
|
let res = do str::as_c_str("family") |FC_FAMILY| {
|
||||||
|
@ -157,3 +158,4 @@ pub fn path_from_identifier(name: ~str) -> Result<~str, ()> unsafe {
|
||||||
}
|
}
|
||||||
Ok(str::raw::from_buf(file as *u8))
|
Ok(str::raw::from_buf(file as *u8))
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -301,9 +301,11 @@ pub impl FreeTypeFontHandle : FontHandleMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl FreeTypeFontHandle {
|
pub impl FreeTypeFontHandle {
|
||||||
priv fn get_face_rec() -> &self/FT_FaceRec unsafe {
|
priv fn get_face_rec() -> &self/FT_FaceRec {
|
||||||
|
unsafe {
|
||||||
&(*self.face)
|
&(*self.face)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
priv fn font_units_to_au(value: float) -> Au {
|
priv fn font_units_to_au(value: float) -> Au {
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ pub impl FreeTypeFontContextHandle : FontContextHandleMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_font_from_identifier(name: ~str, style: UsedFontStyle)
|
fn create_font_from_identifier(name: ~str, style: UsedFontStyle)
|
||||||
-> Result<FontHandle, ()> unsafe {
|
-> Result<FontHandle, ()> {
|
||||||
debug!("Creating font handle for %s", name);
|
debug!("Creating font handle for %s", name);
|
||||||
do path_from_identifier(name).chain |file_name| {
|
do path_from_identifier(name).chain |file_name| {
|
||||||
debug!("Opening font face %s", file_name);
|
debug!("Opening font face %s", file_name);
|
||||||
|
|
|
@ -3,7 +3,7 @@ use stb_image = stb_image::image;
|
||||||
// FIXME: Images must not be copied every frame. Instead we should atomically
|
// FIXME: Images must not be copied every frame. Instead we should atomically
|
||||||
// reference count them.
|
// 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 {
|
pub fn Image(width: uint, height: uint, depth: uint, data: ~[u8]) -> Image {
|
||||||
stb_image::new_image(width, height, depth, move data)
|
stb_image::new_image(width, height, depth, move data)
|
||||||
|
@ -20,8 +20,8 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
|
||||||
// Can't remember why we do this. Maybe it's what cairo wants
|
// Can't remember why we do this. Maybe it's what cairo wants
|
||||||
const FORCE_DEPTH: uint = 4;
|
const FORCE_DEPTH: uint = 4;
|
||||||
|
|
||||||
do stb_image::load_from_memory_with_depth(buffer, FORCE_DEPTH).map |image| {
|
match stb_image::load_from_memory_with_depth(buffer, FORCE_DEPTH, true) {
|
||||||
|
stb_image::ImageU8(image) => {
|
||||||
assert image.depth == 4;
|
assert image.depth == 4;
|
||||||
// Do color space conversion :(
|
// Do color space conversion :(
|
||||||
let data = do vec::from_fn(image.width * image.height * 4) |i| {
|
let data = do vec::from_fn(image.width * image.height * 4) |i| {
|
||||||
|
@ -38,6 +38,9 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
|
||||||
|
|
||||||
assert image.data.len() == data.len();
|
assert image.data.len() == data.len();
|
||||||
|
|
||||||
Image(image.width, image.height, image.depth, move data)
|
Some(Image(image.width, image.height, image.depth, move data))
|
||||||
|
}
|
||||||
|
stb_image::ImageF32(_image) => fail ~"HDR images not implemented",
|
||||||
|
stb_image::Error => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -416,9 +416,9 @@ impl DetailedGlyphStore {
|
||||||
// Thar be dragons here. You have been warned. (Tips accepted.)
|
// Thar be dragons here. You have been warned. (Tips accepted.)
|
||||||
let mut unsorted_records : ~[DetailedGlyphRecord] = ~[];
|
let mut unsorted_records : ~[DetailedGlyphRecord] = ~[];
|
||||||
core::util::swap(&mut self.detail_lookup, &mut unsorted_records);
|
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);
|
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);
|
core::util::swap(&mut self.detail_lookup, &mut sorted_records);
|
||||||
|
|
||||||
self.lookup_is_sorted = true;
|
self.lookup_is_sorted = true;
|
||||||
|
|
|
@ -77,7 +77,8 @@ pub struct ShapedGlyphEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl ShapedGlyphData {
|
pub impl ShapedGlyphData {
|
||||||
static pure fn new(buffer: *hb_buffer_t) -> ShapedGlyphData unsafe {
|
static pure fn new(buffer: *hb_buffer_t) -> ShapedGlyphData {
|
||||||
|
unsafe {
|
||||||
let glyph_count = 0 as c_uint;
|
let glyph_count = 0 as c_uint;
|
||||||
let glyph_infos = hb_buffer_get_glyph_infos(buffer, ptr::to_unsafe_ptr(&glyph_count));
|
let glyph_infos = hb_buffer_get_glyph_infos(buffer, ptr::to_unsafe_ptr(&glyph_count));
|
||||||
let glyph_count = glyph_count as uint;
|
let glyph_count = glyph_count as uint;
|
||||||
|
@ -93,19 +94,22 @@ pub impl ShapedGlyphData {
|
||||||
pos_infos: pos_infos,
|
pos_infos: pos_infos,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[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;
|
assert i < self.count;
|
||||||
|
|
||||||
let glyph_info_i = ptr::offset(self.glyph_infos, i);
|
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 }
|
pure fn len() -> uint { self.count }
|
||||||
|
|
||||||
// Returns shaped glyph data for one glyph, and updates the y-position of the pen.
|
// 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;
|
assert i < self.count;
|
||||||
|
|
||||||
let glyph_info_i = ptr::offset(self.glyph_infos, i);
|
let glyph_info_i = ptr::offset(self.glyph_infos, i);
|
||||||
|
@ -126,6 +130,7 @@ pub impl ShapedGlyphData {
|
||||||
Some(Point2D(x_offset, y_pos - y_offset))
|
Some(Point2D(x_offset, y_pos - y_offset))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
unsafe {
|
||||||
ShapedGlyphEntry {
|
ShapedGlyphEntry {
|
||||||
cluster: (*glyph_info_i).cluster as uint,
|
cluster: (*glyph_info_i).cluster as uint,
|
||||||
codepoint: (*glyph_info_i).codepoint as GlyphIndex,
|
codepoint: (*glyph_info_i).codepoint as GlyphIndex,
|
||||||
|
@ -134,6 +139,7 @@ pub impl ShapedGlyphData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct HarfbuzzShaper {
|
pub struct HarfbuzzShaper {
|
||||||
font: @Font,
|
font: @Font,
|
||||||
|
@ -443,28 +449,33 @@ extern fn glyph_func(_font: *hb_font_t,
|
||||||
unicode: hb_codepoint_t,
|
unicode: hb_codepoint_t,
|
||||||
_variant_selector: hb_codepoint_t,
|
_variant_selector: hb_codepoint_t,
|
||||||
glyph: *mut 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;
|
let font: *Font = font_data as *Font;
|
||||||
assert font.is_not_null();
|
assert font.is_not_null();
|
||||||
|
unsafe {
|
||||||
return match (*font).glyph_index(unicode as char) {
|
return match (*font).glyph_index(unicode as char) {
|
||||||
Some(g) => { *glyph = g as hb_codepoint_t; true },
|
Some(g) => { *glyph = g as hb_codepoint_t; true },
|
||||||
None => false
|
None => false
|
||||||
} as hb_bool_t;
|
} as hb_bool_t;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern fn glyph_h_advance_func(_font: *hb_font_t,
|
extern fn glyph_h_advance_func(_font: *hb_font_t,
|
||||||
font_data: *c_void,
|
font_data: *c_void,
|
||||||
glyph: hb_codepoint_t,
|
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;
|
let font: *Font = font_data as *Font;
|
||||||
assert font.is_not_null();
|
assert font.is_not_null();
|
||||||
|
|
||||||
|
unsafe {
|
||||||
let advance = (*font).glyph_h_advance(glyph as GlyphIndex);
|
let advance = (*font).glyph_h_advance(glyph as GlyphIndex);
|
||||||
HarfbuzzShaper::float_to_fixed(advance)
|
HarfbuzzShaper::float_to_fixed(advance)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Callback to get a font table out of a font.
|
// 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 {
|
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;
|
let font: *Font = user_data as *Font;
|
||||||
assert font.is_not_null();
|
assert font.is_not_null();
|
||||||
|
|
||||||
|
@ -487,12 +498,13 @@ extern fn get_font_table_func(_face: *hb_face_t, tag: hb_tag_t, user_data: *c_vo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(Issue #197): reuse font table data, which will change the unsound trickery here.
|
// TODO(Issue #197): reuse font table data, which will change the unsound trickery here.
|
||||||
// In particular, we'll need to cast to a boxed, rather than owned, FontTable.
|
// 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.
|
// 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.
|
// this will cause drop to run.
|
||||||
let _wrapper : &~FontTable = cast::transmute(user_data);
|
let _wrapper : &~FontTable = unsafe { cast::transmute(user_data) };
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,9 +153,11 @@ pub fn Content(layout_task: LayoutTask,
|
||||||
content
|
content
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn task_from_context(cx: *JSContext) -> *Content unsafe {
|
pub fn task_from_context(cx: *JSContext) -> *Content {
|
||||||
|
unsafe {
|
||||||
cast::reinterpret_cast(&JS_GetContextPrivate(cx))
|
cast::reinterpret_cast(&JS_GetContextPrivate(cx))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
impl Content {
|
impl Content {
|
||||||
|
|
|
@ -63,7 +63,8 @@ enum Element = int;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
extern fn getDocumentElement(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
|
extern fn getDocumentElement(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
|
||||||
-> JSBool unsafe {
|
-> JSBool {
|
||||||
|
unsafe {
|
||||||
let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
|
let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
|
||||||
if obj.is_null() {
|
if obj.is_null() {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -75,6 +76,7 @@ extern fn getDocumentElement(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
|
||||||
*vp = RUST_OBJECT_TO_JSVAL(node::create(cx, node, scope).ptr);
|
*vp = RUST_OBJECT_TO_JSVAL(node::create(cx, node, scope).ptr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsafe fn unwrap(obj: *JSObject) -> *rust_box<Document> {
|
unsafe fn unwrap(obj: *JSObject) -> *rust_box<Document> {
|
||||||
//TODO: some kind of check if this is a Document object
|
//TODO: some kind of check if this is a Document object
|
||||||
|
|
|
@ -65,7 +65,8 @@ pub fn init(compartment: &bare_compartment) {
|
||||||
|
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
|
extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
|
||||||
-> JSBool unsafe {
|
-> JSBool {
|
||||||
|
unsafe {
|
||||||
let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
|
let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
|
||||||
if obj.is_null() {
|
if obj.is_null() {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -88,7 +89,7 @@ extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVa
|
||||||
}
|
}
|
||||||
_ => fail ~"why is this not an image element?"
|
_ => fail ~"why is this not an image element?"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => fail ~"why is this not an element?"
|
_ => fail ~"why is this not an element?"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -96,10 +97,12 @@ extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVa
|
||||||
(width & (i32::max_value as int)) as libc::c_int);
|
(width & (i32::max_value as int)) as libc::c_int);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
extern fn HTMLImageElement_setWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
|
extern fn HTMLImageElement_setWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
|
||||||
-> JSBool unsafe {
|
-> JSBool {
|
||||||
|
unsafe {
|
||||||
let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
|
let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
|
||||||
if obj.is_null() {
|
if obj.is_null() {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -113,7 +116,7 @@ extern fn HTMLImageElement_setWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVa
|
||||||
~HTMLImageElement(*) => {
|
~HTMLImageElement(*) => {
|
||||||
let arg = ptr::offset(JS_ARGV(cx, cast::reinterpret_cast(&vp)), 0);
|
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))
|
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 image element?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,6 +125,7 @@ extern fn HTMLImageElement_setWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVa
|
||||||
};
|
};
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
extern fn getTagName(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
|
extern fn getTagName(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
|
||||||
|
@ -150,7 +154,7 @@ extern fn getTagName(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[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| {
|
let proto = scope.write(&node, |nd| {
|
||||||
match &nd.kind {
|
match &nd.kind {
|
||||||
&~Element(ref ed) => {
|
&~Element(ref ed) => {
|
||||||
|
|
|
@ -46,7 +46,7 @@ pub fn init(compartment: &bare_compartment) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[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| {
|
do scope.write(&node) |nd| {
|
||||||
match nd.kind {
|
match nd.kind {
|
||||||
~Element(*) => {
|
~Element(*) => {
|
||||||
|
|
|
@ -32,7 +32,8 @@ extern fn alert(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool {
|
||||||
1_i32
|
1_i32
|
||||||
}
|
}
|
||||||
|
|
||||||
extern fn setTimeout(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool unsafe {
|
extern fn setTimeout(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool {
|
||||||
|
unsafe {
|
||||||
let argv = JS_ARGV(cx, vp);
|
let argv = JS_ARGV(cx, vp);
|
||||||
assert (argc >= 2);
|
assert (argc >= 2);
|
||||||
|
|
||||||
|
@ -45,12 +46,15 @@ extern fn setTimeout(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool unsafe
|
||||||
JS_SET_RVAL(cx, vp, JSVAL_NULL);
|
JS_SET_RVAL(cx, vp, JSVAL_NULL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern fn close(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool unsafe {
|
extern fn close(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool {
|
||||||
|
unsafe {
|
||||||
(*unwrap(JS_THIS_OBJECT(cx, vp))).payload.close();
|
(*unwrap(JS_THIS_OBJECT(cx, vp))).payload.close();
|
||||||
JS_SET_RVAL(cx, vp, JSVAL_NULL);
|
JS_SET_RVAL(cx, vp, JSVAL_NULL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsafe fn unwrap(obj: *JSObject) -> *rust_box<Window> {
|
unsafe fn unwrap(obj: *JSObject) -> *rust_box<Window> {
|
||||||
let val = JS_GetReservedSlot(obj, 0);
|
let val = JS_GetReservedSlot(obj, 0);
|
||||||
|
|
|
@ -72,10 +72,12 @@ type ScopeData<T,A> = {
|
||||||
struct ScopeResource<T,A> {
|
struct ScopeResource<T,A> {
|
||||||
d : ScopeData<T,A>,
|
d : ScopeData<T,A>,
|
||||||
|
|
||||||
drop unsafe {
|
drop {
|
||||||
|
unsafe {
|
||||||
for self.d.free_list.each |h| { free_handle(*h); }
|
for self.d.free_list.each |h| { free_handle(*h); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn ScopeResource<T:Owned,A>(d : ScopeData<T,A>) -> ScopeResource<T,A> {
|
fn ScopeResource<T:Owned,A>(d : ScopeData<T,A>) -> ScopeResource<T,A> {
|
||||||
ScopeResource { d: move d }
|
ScopeResource { d: move d }
|
||||||
|
@ -93,15 +95,15 @@ pub enum Handle<T,A> {
|
||||||
|
|
||||||
// Private methods
|
// Private methods
|
||||||
impl<T,A> Handle<T,A> {
|
impl<T,A> Handle<T,A> {
|
||||||
fn read_ptr() -> *T unsafe { (**self).read_ptr }
|
fn read_ptr() -> *T { unsafe { (**self).read_ptr } }
|
||||||
fn write_ptr() -> *mut T unsafe { (**self).write_ptr }
|
fn write_ptr() -> *mut T { unsafe { (**self).write_ptr } }
|
||||||
fn read_aux() -> *A unsafe { (**self).read_aux }
|
fn read_aux() -> *A { unsafe { (**self).read_aux } }
|
||||||
fn next_dirty() -> Handle<T,A> unsafe { (**self).next_dirty }
|
fn next_dirty() -> Handle<T,A> { unsafe { (**self).next_dirty } }
|
||||||
|
|
||||||
fn set_read_ptr(t: *T) unsafe { (**self).read_ptr = t; }
|
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_write_ptr(t: *mut T) { unsafe { (**self).write_ptr = t; } }
|
||||||
fn set_read_aux(t: *A) unsafe { (**self).read_aux = 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_next_dirty(h: Handle<T,A>) { unsafe { (**self).next_dirty = h; } }
|
||||||
|
|
||||||
pure fn is_null() -> bool { (*self).is_null() }
|
pure fn is_null() -> bool { (*self).is_null() }
|
||||||
fn is_not_null() -> bool { (*self).is_not_null() }
|
fn is_not_null() -> bool { (*self).is_not_null() }
|
||||||
|
@ -109,29 +111,37 @@ impl<T,A> Handle<T,A> {
|
||||||
|
|
||||||
impl<T:Owned,A> Handle<T,A> {
|
impl<T:Owned,A> Handle<T,A> {
|
||||||
/// Access the reader's view of the handle's data
|
/// Access the reader's view of the handle's data
|
||||||
fn read<U>(f: fn(&T) -> U) -> U unsafe {
|
fn read<U>(f: fn(&T) -> U) -> U {
|
||||||
|
unsafe {
|
||||||
f(&*self.read_ptr())
|
f(&*self.read_ptr())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// True if auxiliary data is associated with this handle
|
/// True if auxiliary data is associated with this handle
|
||||||
fn has_aux() -> bool unsafe {
|
fn has_aux() -> bool {
|
||||||
|
unsafe {
|
||||||
self.read_aux().is_not_null()
|
self.read_aux().is_not_null()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Set the auxiliary data associated with this handle.
|
/** Set the auxiliary data associated with this handle.
|
||||||
|
|
||||||
**Warning:** the reader is responsible for keeping this data live!
|
**Warning:** the reader is responsible for keeping this data live!
|
||||||
*/
|
*/
|
||||||
fn set_aux(p: @A) unsafe {
|
fn set_aux(p: @A) {
|
||||||
|
unsafe {
|
||||||
(**self).read_aux = ptr::to_unsafe_ptr(&*p);
|
(**self).read_aux = ptr::to_unsafe_ptr(&*p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Access the auxiliary data associated with this handle
|
/// Access the auxiliary data associated with this handle
|
||||||
fn aux<U>(f: fn(&A) -> U) -> U unsafe {
|
fn aux<U>(f: fn(&A) -> U) -> U {
|
||||||
|
unsafe {
|
||||||
assert self.has_aux();
|
assert self.has_aux();
|
||||||
f(&*self.read_aux())
|
f(&*self.read_aux())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl <T: Owned,A> Handle<T,A> : cmp::Eq {
|
impl <T: Owned,A> Handle<T,A> : cmp::Eq {
|
||||||
pure fn eq(&self, other: &Handle<T,A>) -> bool { **self == **other }
|
pure fn eq(&self, other: &Handle<T,A>) -> bool { **self == **other }
|
||||||
|
@ -140,7 +150,8 @@ impl <T: Owned,A> Handle<T,A> : cmp::Eq {
|
||||||
|
|
||||||
// Private methods
|
// Private methods
|
||||||
impl<T: Copy Owned,A> Scope<T,A> {
|
impl<T: Copy Owned,A> Scope<T,A> {
|
||||||
fn clone(v: *T) -> *T unsafe {
|
fn clone(v: *T) -> *T {
|
||||||
|
unsafe {
|
||||||
let n: *mut T =
|
let n: *mut T =
|
||||||
cast::reinterpret_cast(&libc::calloc(sys::size_of::<T>() as size_t, 1u as size_t));
|
cast::reinterpret_cast(&libc::calloc(sys::size_of::<T>() as size_t, 1u as size_t));
|
||||||
|
|
||||||
|
@ -152,6 +163,7 @@ impl<T: Copy Owned,A> Scope<T,A> {
|
||||||
return cast::reinterpret_cast(&n);
|
return cast::reinterpret_cast(&n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsafe fn free<T>(t: *T) {
|
unsafe fn free<T>(t: *T) {
|
||||||
let _x = move *cast::reinterpret_cast::<*T,*mut T>(&t);
|
let _x = move *cast::reinterpret_cast::<*T,*mut T>(&t);
|
||||||
|
@ -195,12 +207,13 @@ impl<T:Copy Owned,A> Scope<T,A> {
|
||||||
self.d.layout_active = true;
|
self.d.layout_active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reader_joined() unsafe {
|
fn reader_joined() {
|
||||||
assert self.d.layout_active;
|
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;
|
let mut handle = self.d.first_dirty;
|
||||||
while (*handle).is_not_null() {
|
while (*handle).is_not_null() {
|
||||||
|
unsafe {
|
||||||
free(handle.read_ptr());
|
free(handle.read_ptr());
|
||||||
|
|
||||||
handle.set_read_ptr(cast::reinterpret_cast(&handle.write_ptr()));
|
handle.set_read_ptr(cast::reinterpret_cast(&handle.write_ptr()));
|
||||||
|
@ -208,6 +221,7 @@ impl<T:Copy Owned,A> Scope<T,A> {
|
||||||
handle.set_next_dirty(null_handle());
|
handle.set_next_dirty(null_handle());
|
||||||
handle = next_handle;
|
handle = next_handle;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
self.d.first_dirty = null_handle();
|
self.d.first_dirty = null_handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,12 +229,15 @@ impl<T:Copy Owned,A> Scope<T,A> {
|
||||||
self.d.layout_active = false;
|
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
|
// Use the write_ptr, which may be more up to date than the read_ptr or may not
|
||||||
|
unsafe {
|
||||||
f(&*h.write_ptr())
|
f(&*h.write_ptr())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn write<U>(h: &Handle<T,A>, f: fn(&T) -> U) -> U unsafe {
|
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_read_ptr = ptr::const_offset(h.read_ptr(), 0);
|
||||||
let const_write_ptr = ptr::const_offset(h.write_ptr(), 0);
|
let const_write_ptr = ptr::const_offset(h.write_ptr(), 0);
|
||||||
if self.d.layout_active && const_read_ptr == const_write_ptr {
|
if self.d.layout_active && const_read_ptr == const_write_ptr {
|
||||||
|
@ -231,10 +248,12 @@ impl<T:Copy Owned,A> Scope<T,A> {
|
||||||
}
|
}
|
||||||
f(&*h.write_ptr())
|
f(&*h.write_ptr())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: This could avoid a deep copy by taking ownership of `v`
|
// FIXME: This could avoid a deep copy by taking ownership of `v`
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
fn handle(v: &T) -> Handle<T,A> unsafe {
|
fn handle(v: &T) -> Handle<T,A> {
|
||||||
|
unsafe {
|
||||||
debug!("vv: %?", *v);
|
debug!("vv: %?", *v);
|
||||||
let d: *HandleData<T,A> =
|
let d: *HandleData<T,A> =
|
||||||
cast::reinterpret_cast(
|
cast::reinterpret_cast(
|
||||||
|
@ -251,6 +270,7 @@ impl<T:Copy Owned,A> Scope<T,A> {
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
|
|
|
@ -76,10 +76,12 @@ impl Node : DebugMethods {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn debug_str(&self) -> ~str unsafe {
|
pure fn debug_str(&self) -> ~str {
|
||||||
|
unsafe {
|
||||||
do self.read |n| { fmt!("%?", n.kind) }
|
do self.read |n| { fmt!("%?", n.kind) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Node {
|
impl Node {
|
||||||
fn is_element(&self) -> bool {
|
fn is_element(&self) -> bool {
|
||||||
|
|
|
@ -28,7 +28,8 @@ pub struct TimerData {
|
||||||
args: DVec<JSVal>,
|
args: DVec<JSVal>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn TimerData(argc: libc::c_uint, argv: *JSVal) -> TimerData unsafe {
|
pub fn TimerData(argc: libc::c_uint, argv: *JSVal) -> TimerData {
|
||||||
|
unsafe {
|
||||||
let data = TimerData {
|
let data = TimerData {
|
||||||
funval : *argv,
|
funval : *argv,
|
||||||
args : DVec(),
|
args : DVec(),
|
||||||
|
@ -42,6 +43,7 @@ pub fn TimerData(argc: libc::c_uint, argv: *JSVal) -> TimerData unsafe {
|
||||||
|
|
||||||
move data
|
move data
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: delayed_send shouldn't require Copy
|
// FIXME: delayed_send shouldn't require Copy
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
|
|
|
@ -164,7 +164,7 @@ fn build_element_kind(tag: &str) -> ~ElementKind {
|
||||||
pub fn parse_html(scope: NodeScope,
|
pub fn parse_html(scope: NodeScope,
|
||||||
url: Url,
|
url: Url,
|
||||||
resource_task: ResourceTask,
|
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.
|
// Spawn a CSS parser to receive links to CSS style sheets.
|
||||||
let (css_port, css_chan): (oldcomm::Port<Option<Stylesheet>>, oldcomm::Chan<CSSMessage>) =
|
let (css_port, css_chan): (oldcomm::Port<Option<Stylesheet>>, oldcomm::Chan<CSSMessage>) =
|
||||||
do spawn_conversation |css_port: oldcomm::Port<CSSMessage>,
|
do spawn_conversation |css_port: oldcomm::Port<CSSMessage>,
|
||||||
|
@ -181,6 +181,7 @@ pub fn parse_html(scope: NodeScope,
|
||||||
|
|
||||||
let (scope, url) = (@copy scope, @move url);
|
let (scope, url) = (@copy scope, @move url);
|
||||||
|
|
||||||
|
unsafe {
|
||||||
// Build the root node.
|
// Build the root node.
|
||||||
let root = scope.new_node(Element(ElementData(~"html", ~HTMLDivElement)));
|
let root = scope.new_node(Element(ElementData(~"html", ~HTMLDivElement)));
|
||||||
debug!("created new node");
|
debug!("created new node");
|
||||||
|
@ -285,9 +286,9 @@ pub fn parse_html(scope: NodeScope,
|
||||||
},
|
},
|
||||||
ref_node: |_node| {},
|
ref_node: |_node| {},
|
||||||
unref_node: |_node| {},
|
unref_node: |_node| {},
|
||||||
append_child: |parent: hubbub::NodeDataPtr, child: hubbub::NodeDataPtr| unsafe {
|
append_child: |parent: hubbub::NodeDataPtr, child: hubbub::NodeDataPtr| {
|
||||||
debug!("append child %x %x", cast::transmute(parent), cast::transmute(child));
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
debug!("append child %x %x", cast::transmute(parent), cast::transmute(child));
|
||||||
let p: Node = cow::wrap(cast::transmute(parent));
|
let p: Node = cow::wrap(cast::transmute(parent));
|
||||||
let c: Node = cow::wrap(cast::transmute(child));
|
let c: Node = cow::wrap(cast::transmute(child));
|
||||||
scope.add_child(p, c);
|
scope.add_child(p, c);
|
||||||
|
@ -310,7 +311,7 @@ pub fn parse_html(scope: NodeScope,
|
||||||
let n: Node = cow::wrap(cast::transmute(node));
|
let n: Node = cow::wrap(cast::transmute(node));
|
||||||
let data = n.read(|read_data| copy *read_data.kind);
|
let data = n.read(|read_data| copy *read_data.kind);
|
||||||
let new_node = scope.new_node(move data);
|
let new_node = scope.new_node(move data);
|
||||||
unsafe { cast::transmute(cow::unwrap(new_node)) }
|
cast::transmute(cow::unwrap(new_node))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reparent_children: |_node, _new_parent| {
|
reparent_children: |_node, _new_parent| {
|
||||||
|
@ -340,7 +341,8 @@ pub fn parse_html(scope: NodeScope,
|
||||||
complete_script: |script| {
|
complete_script: |script| {
|
||||||
// A little function for holding this lint attr
|
// A little function for holding this lint attr
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
fn complete_script(scope: &NodeScope, script: hubbub::NodeDataPtr, url: &Url, js_chan: &oldcomm::Chan<JSMessage>) unsafe {
|
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| {
|
do scope.read(&cow::wrap(cast::transmute(script))) |node_contents| {
|
||||||
match *node_contents.kind {
|
match *node_contents.kind {
|
||||||
Element(ref element) if element.tag_name == ~"script" => {
|
Element(ref element) if element.tag_name == ~"script" => {
|
||||||
|
@ -357,6 +359,7 @@ pub fn parse_html(scope: NodeScope,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
complete_script(scope, script, url, &js_chan);
|
complete_script(scope, script, url, &js_chan);
|
||||||
debug!("complete script");
|
debug!("complete script");
|
||||||
}
|
}
|
||||||
|
@ -383,4 +386,5 @@ pub fn parse_html(scope: NodeScope,
|
||||||
|
|
||||||
return HtmlParserResult { root: root, style_port: css_port, js_port: js_port };
|
return HtmlParserResult { root: root, style_port: css_port, js_port: js_port };
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -323,7 +323,7 @@ priv impl TextRunScanner {
|
||||||
struct LineboxScanner {
|
struct LineboxScanner {
|
||||||
flow: @FlowContext,
|
flow: @FlowContext,
|
||||||
new_boxes: DVec<@RenderBox>,
|
new_boxes: DVec<@RenderBox>,
|
||||||
work_list: DList<@RenderBox>,
|
work_list: @DList<@RenderBox>,
|
||||||
pending_line: {mut range: Range, mut width: Au},
|
pending_line: {mut range: Range, mut width: Au},
|
||||||
line_spans: DVec<Range>,
|
line_spans: DVec<Range>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue