diff --git a/src/compiler/rust b/src/compiler/rust index 0ac3e023d86..d39cec65b02 160000 --- a/src/compiler/rust +++ b/src/compiler/rust @@ -1 +1 @@ -Subproject commit 0ac3e023d86fa84ed38bca3d34003b494fd28acf +Subproject commit d39cec65b025ad4c6de50e778ffd1177279b5b3d diff --git a/src/components/gfx/text/shaping/harfbuzz.rs b/src/components/gfx/text/shaping/harfbuzz.rs index cfc6630a49b..824ccc73e3e 100644 --- a/src/components/gfx/text/shaping/harfbuzz.rs +++ b/src/components/gfx/text/shaping/harfbuzz.rs @@ -13,6 +13,7 @@ use servo_util::range::Range; use text::util::{float_to_fixed, fixed_to_float, fixed_to_rounded_int}; use std::cast::transmute; +use std::char; use std::libc::{c_uint, c_int, c_void, c_char}; use std::ptr; use std::ptr::null; @@ -493,7 +494,7 @@ extern fn glyph_func(_: *hb_font_t, assert!(font.is_not_null()); unsafe { - match (*font).glyph_index(unicode as char) { + match (*font).glyph_index(char::from_u32(unicode).unwrap()) { Some(g) => { *glyph = g as hb_codepoint_t; true as hb_bool_t diff --git a/src/components/gfx/text/util.rs b/src/components/gfx/text/util.rs index 13e8e369926..16482a5bd0a 100644 --- a/src/components/gfx/text/util.rs +++ b/src/components/gfx/text/util.rs @@ -114,6 +114,10 @@ pub fn fixed_to_rounded_int(before: int, f: i32) -> int { /* Generate a 32-bit TrueType tag from its 4 characters */ pub fn true_type_tag(a: char, b: char, c: char, d: char) -> u32 { + let a = a as u32; + let b = b as u32; + let c = c as u32; + let d = d as u32; (a << 24 | b << 16 | c << 8 | d) as u32 } diff --git a/src/components/main/constellation.rs b/src/components/main/constellation.rs index 391fb175fd8..7ae71478306 100644 --- a/src/components/main/constellation.rs +++ b/src/components/main/constellation.rs @@ -655,7 +655,7 @@ impl Constellation { // Find the pending frame change whose new pipeline id is pipeline_id. // If it is not found, it simply means that this pipeline will not receive // permission to paint. - let pending_index = do self.pending_frames.rposition |frame_change| { + let pending_index = do self.pending_frames.iter().rposition |frame_change| { frame_change.after.pipeline.id == pipeline_id }; for &pending_index in pending_index.iter() { diff --git a/src/components/main/platform/common/glfw_windowing.rs b/src/components/main/platform/common/glfw_windowing.rs index b589258f88c..ceef183301f 100644 --- a/src/components/main/platform/common/glfw_windowing.rs +++ b/src/components/main/platform/common/glfw_windowing.rs @@ -12,6 +12,7 @@ use windowing::{Forward, Back}; use alert::{Alert, AlertMethods}; use std::libc::c_int; +use std::local_data; use geom::point::Point2D; use geom::size::Size2D; use servo_msg::compositor_msg::{IdleRenderState, RenderState, RenderingRenderState}; @@ -34,6 +35,7 @@ impl ApplicationMethods for Application { impl Drop for Application { fn drop(&self) { glfw::terminate(); + drop_local_window(); } } @@ -76,15 +78,15 @@ impl WindowMethods for Window { throbber_frame: 0, }; - let event_queue = window.event_queue; + install_local_window(window); // Register event handlers. do window.glfw_window.set_framebuffer_size_callback |_win, width, height| { - event_queue.push(ResizeWindowEvent(width as uint, height as uint)) + local_window().event_queue.push(ResizeWindowEvent(width as uint, height as uint)) } do window.glfw_window.set_key_callback |_win, key, _scancode, action, mods| { if action == glfw::PRESS { - window.handle_key(key, mods) + local_window().handle_key(key, mods) } } do window.glfw_window.set_mouse_button_callback |win, button, action, _mods| { @@ -96,7 +98,7 @@ impl WindowMethods for Window { let x = x as f32 * hidpi; let y = y as f32 * hidpi; if button < 3 { - window.handle_mouse(button, action, x as i32, y as i32); + local_window().handle_mouse(button, action, x as i32, y as i32); } } do window.glfw_window.set_scroll_callback |win, x_offset, y_offset| { @@ -111,7 +113,7 @@ impl WindowMethods for Window { let x = x as f32 * hidpi; let y = y as f32 * hidpi; - event_queue.push(ScrollWindowEvent(Point2D(dx, dy), Point2D(x as i32, y as i32))); + local_window().event_queue.push(ScrollWindowEvent(Point2D(dx, dy), Point2D(x as i32, y as i32))); } window @@ -196,7 +198,8 @@ impl Window { } /// Helper function to handle keyboard events. - fn handle_key(&self, key: c_int, mods: c_int) { + fn handle_key(&self, key: c_int, mods: glfw::KeyMods) { + let mods = *mods; match key { glfw::KEY_ESCAPE => self.glfw_window.set_should_close(true), glfw::KEY_L if mods & glfw::MOD_CONTROL != 0 => self.load_url(), // Ctrl+L @@ -258,3 +261,16 @@ impl Window { } } +static TLS_KEY: local_data::Key<@mut Window> = &local_data::Key; + +fn install_local_window(window: @mut Window) { + local_data::set(TLS_KEY, window); +} + +fn drop_local_window() { + local_data::pop(TLS_KEY); +} + +fn local_window() -> @mut Window { + local_data::get(TLS_KEY, |v| *v.unwrap()) +} diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 1f9bd685ce7..00e4736bca7 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -1068,7 +1068,7 @@ for (uint32_t i = 0; i < length; ++i) { return handleDefault( conversionCode, ("static data: [u8, ..%s] = [ %s ];\n" - "%s = str(str::from_bytes(data));" % + "%s = str(str::from_utf8(data));" % (len(defaultValue.value) + 1, ", ".join(["'" + char + "' as u8" for char in defaultValue.value] + ["0"]), varName))) @@ -1268,7 +1268,10 @@ for (uint32_t i = 0; i < length; ++i) { " %s = %s;\n" "}" % (dataLoc, defaultStr))).define() - return (template, declType, None, isOptional, "0 as %s" % typeName) + if typeName != "bool": + return (template, declType, None, isOptional, "0 as %s" % typeName) + else: + return (template, declType, None, isOptional, "false") def instantiateJSToNativeConversionTemplate(templateTuple, replacements, argcAndIndex=None): @@ -1458,7 +1461,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode, if not haveSuccessCode: return wrapCall + ";\n" + "return if (*vp).v != 0 { 1 } else { 0 };" failureCode = "return 0;" - str = ("if !(%s as bool) {\n" + + str = ("if !(%s != 0) {\n" + CGIndenter(CGGeneric(failureCode)).define() + "\n" + "}\n" + successCode) % (wrapCall) @@ -1550,7 +1553,7 @@ for (uint32_t i = 0; i < length; ++i) { else: #wrap = "WrapObject(cx, ${obj}, %s, %s${jsvalPtr})" % (result, getIID) if descriptor.pointerType == '': - wrap = "(%s.wrap(cx, ${obj}, ${jsvalPtr}) as bool)" % result + wrap = "(%s.wrap(cx, ${obj}, ${jsvalPtr}) != 0)" % result else: wrap = "if WrapNewBindingObject(cx, ${obj}, %s as @mut CacheableWrapper, ${jsvalPtr}) { 1 } else { 0 };" % result wrappingCode += wrapAndSetPtr(wrap) @@ -4477,7 +4480,7 @@ class CGDictionary(CGThing): if dealWithOptional: replacements["declName"] = "(" + replacements["declName"] + ".Value())" if member.defaultValue: - replacements["haveValue"] = "found as bool" + replacements["haveValue"] = "found != 0" # 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 diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs index caed0ef6ac5..6adedbfad3d 100644 --- a/src/components/script/dom/bindings/utils.rs +++ b/src/components/script/dom/bindings/utils.rs @@ -603,24 +603,24 @@ impl WrapperCache { #[fixed_stack_segment] pub fn WrapNewBindingObject(cx: *JSContext, scope: *JSObject, value: @mut CacheableWrapper, - vp: *mut JSVal) -> bool { + vp: *mut JSVal) -> JSBool { unsafe { let cache = value.get_wrappercache(); let obj = cache.get_wrapper(); if obj.is_not_null() /*&& js::GetObjectCompartment(obj) == js::GetObjectCompartment(scope)*/ { *vp = RUST_OBJECT_TO_JSVAL(obj); - return true; + return 1; // JS_TRUE } let obj = value.wrap_object_shared(cx, scope); if obj.is_null() { - return false; + return 0; // JS_FALSE } // MOZ_ASSERT(js::IsObjectInContextCompartment(scope, cx)); cache.set_wrapper(obj); *vp = RUST_OBJECT_TO_JSVAL(obj); - return JS_WrapValue(cx, cast::transmute(vp)) != 0; + return JS_WrapValue(cx, cast::transmute(vp)); } } diff --git a/src/support/css/rust-cssparser b/src/support/css/rust-cssparser index 38d1caae638..a41aec5f184 160000 --- a/src/support/css/rust-cssparser +++ b/src/support/css/rust-cssparser @@ -1 +1 @@ -Subproject commit 38d1caae638b28bbfbbbc988b0b841e973345243 +Subproject commit a41aec5f184a9e587ad675d34b5da518d58c083d diff --git a/src/support/glfw/glfw-rs b/src/support/glfw/glfw-rs index 49ae834012a..a459a449134 160000 --- a/src/support/glfw/glfw-rs +++ b/src/support/glfw/glfw-rs @@ -1 +1 @@ -Subproject commit 49ae834012a9875dfbc6c42206aa083b69a2aade +Subproject commit a459a4491340f33bec7b09e33750106bfab864c9 diff --git a/src/support/http/rust-http b/src/support/http/rust-http index 908adf0241b..a391c127b00 160000 --- a/src/support/http/rust-http +++ b/src/support/http/rust-http @@ -1 +1 @@ -Subproject commit 908adf0241bb56aa28289c3e9faaaad79cc6def6 +Subproject commit a391c127b00128b81127621720d2e361c8d9070e diff --git a/src/support/opengles/rust-opengles b/src/support/opengles/rust-opengles index 6286216e162..2079b5f8da8 160000 --- a/src/support/opengles/rust-opengles +++ b/src/support/opengles/rust-opengles @@ -1 +1 @@ -Subproject commit 6286216e162319c049e3aa7c8435478668bb06d2 +Subproject commit 2079b5f8da888eca65ef0e61d0a9438c794f2d98 diff --git a/src/test/harness/contenttest/contenttest.rs b/src/test/harness/contenttest/contenttest.rs index f5d3154ffbb..80714d5ad4f 100644 --- a/src/test/harness/contenttest/contenttest.rs +++ b/src/test/harness/contenttest/contenttest.rs @@ -83,7 +83,7 @@ fn make_test(file: ~str) -> TestDescAndFn { fn run_test(file: ~str) { let infile = ~"file://" + os::make_absolute(&Path(file)).to_str(); let res = run::process_output("./servo", [infile]); - let out = str::from_bytes(res.output); + let out = str::from_utf8(res.output); io::print(out); let lines: ~[&str] = out.split_iter('\n').collect(); for &line in lines.iter() {