diff options
140 files changed, 2515 insertions, 1097 deletions
diff --git a/Cargo.lock b/Cargo.lock index 196a7a553c6..e7fef7e37a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -400,8 +400,6 @@ dependencies = [ "plugins 0.0.1", "profile_traits 0.0.1", "script_traits 0.0.1", - "serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", "servo_config 0.0.1", "servo_geometry 0.0.1", "servo_url 0.0.1", @@ -674,6 +672,7 @@ dependencies = [ "servo_geometry 0.0.1", "servo_url 0.0.1", "style_traits 0.0.1", + "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)", "x11 2.11.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -904,7 +903,7 @@ dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "selectors 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "servo_url 0.0.1", "style 0.0.1", "style_traits 0.0.1", @@ -1037,6 +1036,7 @@ dependencies = [ "servo_url 0.0.1", "style_traits 0.0.1", "user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "x11 2.11.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1310,7 +1310,6 @@ dependencies = [ "gfx 0.0.1", "gfx_traits 0.0.1", "heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever-atoms 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1325,11 +1324,10 @@ dependencies = [ "rayon 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "script_layout_interface 0.0.1", "script_traits 0.0.1", - "selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "selectors 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", - "servo_atoms 0.0.1", "servo_config 0.0.1", "servo_geometry 0.0.1", "servo_url 0.0.1", @@ -1358,7 +1356,6 @@ dependencies = [ "gfx 0.0.1", "gfx_traits 0.0.1", "heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "layout 0.0.1", "layout_traits 0.0.1", @@ -1373,7 +1370,7 @@ dependencies = [ "script 0.0.1", "script_layout_interface 0.0.1", "script_traits 0.0.1", - "selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "selectors 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "servo_config 0.0.1", @@ -1662,7 +1659,6 @@ dependencies = [ name = "net" version = "0.0.1" dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "brotli 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "content-blocker 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "cookie 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1684,8 +1680,6 @@ dependencies = [ "plugins 0.0.1", "profile_traits 0.0.1", "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", "servo_config 0.0.1", "servo_url 0.0.1", "threadpool 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2017,15 +2011,6 @@ dependencies = [ ] [[package]] -name = "phf_macros" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "phf_generator 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)", - "phf_shared 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "phf_shared" version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2296,7 +2281,8 @@ dependencies = [ "open 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)", - "phf_macros 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)", + "phf_codegen 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)", + "phf_shared 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", "profile_traits 0.0.1", "range 0.0.1", @@ -2306,8 +2292,9 @@ dependencies = [ "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "script_layout_interface 0.0.1", "script_traits 0.0.1", - "selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "selectors 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "servo_atoms 0.0.1", "servo_config 0.0.1", "servo_geometry 0.0.1", @@ -2333,7 +2320,6 @@ version = "0.0.1" dependencies = [ "app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "canvas_traits 0.0.1", "cssparser 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2350,8 +2336,7 @@ dependencies = [ "profile_traits 0.0.1", "range 0.0.1", "script_traits 0.0.1", - "selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "servo_atoms 0.0.1", + "selectors 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "servo_url 0.0.1", "style 0.0.1", ] @@ -2401,7 +2386,7 @@ dependencies = [ [[package]] name = "selectors" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2484,7 +2469,6 @@ dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "net_tests 0.0.1", "net_traits_tests 0.0.1", - "phf_macros 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)", "plugin_compiletest 0.0.1", "profile_tests 0.0.1", "script_tests 0.0.1", @@ -2591,7 +2575,6 @@ dependencies = [ name = "servo_config" version = "0.0.1" dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2777,7 +2760,7 @@ dependencies = [ "rayon 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "selectors 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", "servo_atoms 0.0.1", @@ -2803,7 +2786,7 @@ dependencies = [ "parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "selectors 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "servo_atoms 0.0.1", "servo_config 0.0.1", "servo_url 0.0.1", @@ -2840,7 +2823,7 @@ dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "selectors 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "servo_url 0.0.1", "style 0.0.1", "style_traits 0.0.1", @@ -3547,7 +3530,6 @@ dependencies = [ "checksum phf 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "0c6afb2057bb5f846a7b75703f90bc1cef4970c35209f712925db7768e999202" "checksum phf_codegen 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "6b63f121bf9a128f2172a65d8313a8e0e79d63874eeb4b4b7d82e6dda6b62f7c" "checksum phf_generator 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "50ffbd7970f75afa083c5dd7b6830c97b72b81579c7a92d8134ef2ee6c0c7eb0" -"checksum phf_macros 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "619b2c128703c63376de760377600b924fc0257487f51bc156f596cf8762e497" "checksum phf_shared 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "286385a0e50d4147bce15b2c19f0cf84c395b0e061aaf840898a7bf664c2cfb7" "checksum pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8cee804ecc7eaf201a4a207241472cc870e825206f6c031e3ee2a72fa425f2fa" "checksum pnacl-build-helper 1.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "61c9231d31aea845007443d62fcbb58bb6949ab9c18081ee1e09920e0cf1118b" @@ -3569,7 +3551,7 @@ dependencies = [ "checksum rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "237546c689f20bb44980270c73c3b9edd0891c1be49cc1274406134a66d3957b" "checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" "checksum scoped_threadpool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3ef399c8893e8cb7aa9696e895427fab3a6bf265977bb96e126f24ddd2cda85a" -"checksum selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75b127ac14249f6ce720277f6a163b3837706e9dc1ad4e2948db55f262f11a97" +"checksum selectors 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "966334243238d1ef939c51576c55ffd3fd32245bd603a45f9dfdb3439a26e9a7" "checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" "checksum semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2d5b7638a1f03815d94e88cb3b3c08e87f0db4d683ef499d1836aaf70a45623f" "checksum serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "793aa8d4a777e46a68bbf88998cd957e638427ba5bfb0de22c92ff277b65bd21" diff --git a/components/canvas/lib.rs b/components/canvas/lib.rs index 10470167372..70143d80a86 100644 --- a/components/canvas/lib.rs +++ b/components/canvas/lib.rs @@ -9,7 +9,6 @@ extern crate azure; extern crate canvas_traits; -extern crate core; extern crate cssparser; extern crate euclid; extern crate gleam; diff --git a/components/canvas_traits/lib.rs b/components/canvas_traits/lib.rs index 50d431b9a6d..6b66f659802 100644 --- a/components/canvas_traits/lib.rs +++ b/components/canvas_traits/lib.rs @@ -9,13 +9,11 @@ #![deny(unsafe_code)] -extern crate core; extern crate cssparser; extern crate euclid; extern crate heapsize; #[macro_use] extern crate heapsize_derive; extern crate ipc_channel; -extern crate serde; #[macro_use] extern crate serde_derive; extern crate webrender_traits; diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index 6f7e8e04c91..15270b393cf 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -21,8 +21,6 @@ net_traits = {path = "../net_traits"} plugins = {path = "../plugins"} profile_traits = {path = "../profile_traits"} script_traits = {path = "../script_traits"} -serde = "0.8" -serde_derive = "0.8" servo_config = {path = "../config", features = ["servo"]} servo_geometry = {path = "../geometry", features = ["servo"]} servo_url = {path = "../url", features = ["servo"]} diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index ea0da5168e5..6d00a31a944 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -39,7 +39,7 @@ use style_traits::viewport::ViewportConstraints; use time::{precise_time_ns, precise_time_s}; use touch::{TouchHandler, TouchAction}; use webrender; -use webrender_traits::{self, ScrollEventPhase, ServoScrollRootId, LayoutPoint}; +use webrender_traits::{self, ScrollEventPhase, ServoScrollRootId, LayoutPoint, ScrollLocation}; use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg}; #[derive(Debug, PartialEq)] @@ -227,8 +227,8 @@ pub struct IOCompositor<Window: WindowMethods> { struct ScrollZoomEvent { /// Change the pinch zoom level by this factor magnification: f32, - /// Scroll by this offset - delta: TypedPoint2D<f32, DevicePixel>, + /// Scroll by this offset, or to Start or End + scroll_location: ScrollLocation, /// Apply changes to the frame at this location cursor: TypedPoint2D<i32, DevicePixel>, /// The scroll event phase. @@ -1037,7 +1037,10 @@ impl<Window: WindowMethods> IOCompositor<Window> { match self.touch_handler.on_touch_move(identifier, point) { TouchAction::Scroll(delta) => { match point.cast() { - Some(point) => self.on_scroll_window_event(delta, point), + Some(point) => self.on_scroll_window_event(ScrollLocation::Delta( + webrender_traits::LayerPoint::from_untyped( + &delta.to_untyped())), + point), None => error!("Point cast failed."), } } @@ -1045,7 +1048,8 @@ impl<Window: WindowMethods> IOCompositor<Window> { let cursor = TypedPoint2D::new(-1, -1); // Make sure this hits the base layer. self.pending_scroll_zoom_events.push(ScrollZoomEvent { magnification: magnification, - delta: scroll_delta, + scroll_location: ScrollLocation::Delta(webrender_traits::LayerPoint::from_untyped( + &scroll_delta.to_untyped())), cursor: cursor, phase: ScrollEventPhase::Move(true), event_count: 1, @@ -1106,7 +1110,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { } fn on_scroll_window_event(&mut self, - delta: TypedPoint2D<f32, DevicePixel>, + scroll_location: ScrollLocation, cursor: TypedPoint2D<i32, DevicePixel>) { let event_phase = match (self.scroll_in_progress, self.in_scroll_transaction) { (false, None) => ScrollEventPhase::Start, @@ -1117,7 +1121,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { self.in_scroll_transaction = Some(Instant::now()); self.pending_scroll_zoom_events.push(ScrollZoomEvent { magnification: 1.0, - delta: delta, + scroll_location: scroll_location, cursor: cursor, phase: event_phase, event_count: 1, @@ -1125,12 +1129,12 @@ impl<Window: WindowMethods> IOCompositor<Window> { } fn on_scroll_start_window_event(&mut self, - delta: TypedPoint2D<f32, DevicePixel>, + scroll_location: ScrollLocation, cursor: TypedPoint2D<i32, DevicePixel>) { self.scroll_in_progress = true; self.pending_scroll_zoom_events.push(ScrollZoomEvent { magnification: 1.0, - delta: delta, + scroll_location: scroll_location, cursor: cursor, phase: ScrollEventPhase::Start, event_count: 1, @@ -1138,12 +1142,12 @@ impl<Window: WindowMethods> IOCompositor<Window> { } fn on_scroll_end_window_event(&mut self, - delta: TypedPoint2D<f32, DevicePixel>, + scroll_location: ScrollLocation, cursor: TypedPoint2D<i32, DevicePixel>) { self.scroll_in_progress = false; self.pending_scroll_zoom_events.push(ScrollZoomEvent { magnification: 1.0, - delta: delta, + scroll_location: scroll_location, cursor: cursor, phase: ScrollEventPhase::End, event_count: 1, @@ -1156,14 +1160,34 @@ impl<Window: WindowMethods> IOCompositor<Window> { // Batch up all scroll events into one, or else we'll do way too much painting. let mut last_combined_event: Option<ScrollZoomEvent> = None; for scroll_event in self.pending_scroll_zoom_events.drain(..) { - let this_delta = scroll_event.delta; let this_cursor = scroll_event.cursor; + + let this_delta = match scroll_event.scroll_location { + ScrollLocation::Delta(delta) => delta, + ScrollLocation::Start | ScrollLocation::End => { + // If this is an event which is scrolling to the start or end of the page, + // disregard other pending events and exit the loop. + last_combined_event = Some(scroll_event); + break; + } + }; + if let Some(combined_event) = last_combined_event { if combined_event.phase != scroll_event.phase { - let delta = (combined_event.delta / self.scale).to_untyped(); + let combined_delta = match combined_event.scroll_location { + ScrollLocation::Delta(delta) => delta, + ScrollLocation::Start | ScrollLocation::End => { + // If this is an event which is scrolling to the start or end of the page, + // disregard other pending events and exit the loop. + last_combined_event = Some(scroll_event); + break; + } + }; + let delta = (TypedPoint2D::from_untyped(&combined_delta.to_untyped()) / self.scale) + .to_untyped(); + let delta = webrender_traits::LayerPoint::from_untyped(&delta); let cursor = (combined_event.cursor.to_f32() / self.scale).to_untyped(); - let delta = webrender_traits::LayerPoint::from_untyped(&delta); let location = webrender_traits::ScrollLocation::Delta(delta); let cursor = webrender_traits::WorldPoint::from_untyped(&cursor); self.webrender_api.scroll(location, cursor, combined_event.phase); @@ -1175,7 +1199,8 @@ impl<Window: WindowMethods> IOCompositor<Window> { (last_combined_event @ &mut None, _) => { *last_combined_event = Some(ScrollZoomEvent { magnification: scroll_event.magnification, - delta: this_delta, + scroll_location: ScrollLocation::Delta(webrender_traits::LayerPoint::from_untyped( + &this_delta.to_untyped())), cursor: this_cursor, phase: scroll_event.phase, event_count: 1, @@ -1187,30 +1212,41 @@ impl<Window: WindowMethods> IOCompositor<Window> { // fling. This causes events to get bunched up occasionally, causing // nasty-looking "pops". To mitigate this, during a fling we average // deltas instead of summing them. - let old_event_count = - ScaleFactor::new(last_combined_event.event_count as f32); - last_combined_event.event_count += 1; - let new_event_count = - ScaleFactor::new(last_combined_event.event_count as f32); - last_combined_event.delta = - (last_combined_event.delta * old_event_count + this_delta) / - new_event_count; + if let ScrollLocation::Delta(delta) = last_combined_event.scroll_location { + let old_event_count = + ScaleFactor::new(last_combined_event.event_count as f32); + last_combined_event.event_count += 1; + let new_event_count = + ScaleFactor::new(last_combined_event.event_count as f32); + last_combined_event.scroll_location = ScrollLocation::Delta( + (delta * old_event_count + this_delta) / + new_event_count); + } } (&mut Some(ref mut last_combined_event), _) => { - last_combined_event.delta = last_combined_event.delta + this_delta; - last_combined_event.event_count += 1 + if let ScrollLocation::Delta(delta) = last_combined_event.scroll_location { + last_combined_event.scroll_location = ScrollLocation::Delta(delta + this_delta); + last_combined_event.event_count += 1 + } } } } // TODO(gw): Support zoom (WR issue #28). if let Some(combined_event) = last_combined_event { - let delta = (combined_event.delta / self.scale).to_untyped(); - let delta = webrender_traits::LayoutPoint::from_untyped(&delta); + let scroll_location = match combined_event.scroll_location { + ScrollLocation::Delta(delta) => { + let scaled_delta = (TypedPoint2D::from_untyped(&delta.to_untyped()) / self.scale) + .to_untyped(); + let calculated_delta = webrender_traits::LayoutPoint::from_untyped(&scaled_delta); + ScrollLocation::Delta(calculated_delta) + }, + // Leave ScrollLocation unchanged if it is Start or End location. + sl @ ScrollLocation::Start | sl @ ScrollLocation::End => sl, + }; let cursor = (combined_event.cursor.to_f32() / self.scale).to_untyped(); - let location = webrender_traits::ScrollLocation::Delta(delta); let cursor = webrender_traits::WorldPoint::from_untyped(&cursor); - self.webrender_api.scroll(location, cursor, combined_event.phase); + self.webrender_api.scroll(scroll_location, cursor, combined_event.phase); self.waiting_for_results_of_scroll = true } @@ -1305,7 +1341,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { fn on_pinch_zoom_window_event(&mut self, magnification: f32) { self.pending_scroll_zoom_events.push(ScrollZoomEvent { magnification: magnification, - delta: TypedPoint2D::zero(), // TODO: Scroll to keep the center in view? + scroll_location: ScrollLocation::Delta(TypedPoint2D::zero()), // TODO: Scroll to keep the center in view? cursor: TypedPoint2D::new(-1, -1), // Make sure this hits the base layer. phase: ScrollEventPhase::Move(true), event_count: 1, @@ -1703,6 +1739,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { } } + /// Why we performed a composite. This is used for debugging. #[derive(Copy, Clone, PartialEq, Debug)] pub enum CompositingReason { diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs index 25acc550c2a..8c7d2991959 100644 --- a/components/compositing/lib.rs +++ b/components/compositing/lib.rs @@ -17,11 +17,8 @@ extern crate ipc_channel; extern crate log; extern crate msg; extern crate net_traits; -#[macro_use] extern crate profile_traits; extern crate script_traits; -#[macro_use] -extern crate serde_derive; extern crate servo_config; extern crate servo_geometry; extern crate servo_url; diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index ca34aeddd5b..39b117c85b6 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -16,6 +16,7 @@ use servo_geometry::ScreenPx; use servo_url::ServoUrl; use std::fmt::{Debug, Error, Formatter}; use style_traits::cursor::Cursor; +use webrender_traits::ScrollLocation; #[derive(Clone)] pub enum MouseWindowEvent { @@ -62,7 +63,7 @@ pub enum WindowEvent { Touch(TouchEventType, TouchId, TypedPoint2D<f32, DevicePixel>), /// Sent when the user scrolls. The first point is the delta and the second point is the /// origin. - Scroll(TypedPoint2D<f32, DevicePixel>, TypedPoint2D<i32, DevicePixel>, TouchEventType), + Scroll(ScrollLocation, TypedPoint2D<i32, DevicePixel>, TouchEventType), /// Sent when the user zooms. Zoom(f32), /// Simulated "pinch zoom" gesture for non-touch platforms (e.g. ctrl-scrollwheel). diff --git a/components/config/Cargo.toml b/components/config/Cargo.toml index 4ced19a84a1..5775e3ce58d 100644 --- a/components/config/Cargo.toml +++ b/components/config/Cargo.toml @@ -14,7 +14,6 @@ path = "lib.rs" servo = ["serde", "serde_derive", "url/heap_size", "url/serde", "plugins"] [dependencies] -bitflags = "0.7" euclid = "0.10.1" getopts = "0.2.11" lazy_static = "0.2" diff --git a/components/config/lib.rs b/components/config/lib.rs index 507f4ad044c..f7ba7e5f0ca 100644 --- a/components/config/lib.rs +++ b/components/config/lib.rs @@ -7,15 +7,12 @@ #![deny(unsafe_code)] -#[allow(unused_extern_crates)] #[macro_use] extern crate bitflags; -extern crate core; extern crate euclid; extern crate getopts; -#[allow(unused_extern_crates)] #[macro_use] extern crate lazy_static; +#[macro_use] extern crate lazy_static; #[macro_use] extern crate log; extern crate num_cpus; extern crate rustc_serialize; -#[cfg(feature = "servo")] extern crate serde; #[cfg(feature = "servo")] #[macro_use] extern crate serde_derive; extern crate servo_geometry; extern crate servo_url; diff --git a/components/constellation/lib.rs b/components/constellation/lib.rs index 6c983dbdf62..92417412887 100644 --- a/components/constellation/lib.rs +++ b/components/constellation/lib.rs @@ -29,10 +29,8 @@ extern crate log; extern crate msg; extern crate net_traits; extern crate offscreen_gl_context; -#[macro_use] extern crate profile_traits; extern crate script_traits; -extern crate serde; #[macro_use] extern crate serde_derive; extern crate servo_config; diff --git a/components/constellation/timer_scheduler.rs b/components/constellation/timer_scheduler.rs index 1578da7a951..832773f0d71 100644 --- a/components/constellation/timer_scheduler.rs +++ b/components/constellation/timer_scheduler.rs @@ -39,7 +39,7 @@ impl PartialEq for ScheduledEvent { impl TimerScheduler { pub fn start() -> IpcSender<TimerEventRequest> { - let (req_ipc_sender, req_ipc_receiver) = ipc::channel().unwrap(); + let (req_ipc_sender, req_ipc_receiver) = ipc::channel().expect("Channel creation failed."); let (req_sender, req_receiver) = mpsc::sync_channel(1); // We could do this much more directly with recv_timeout @@ -92,7 +92,7 @@ impl TimerScheduler { // This thread can terminate if the req_ipc_sender is dropped. warn!("TimerScheduler thread terminated."); }) - .unwrap() + .expect("Thread creation failed.") .thread() .clone(); @@ -105,13 +105,13 @@ impl TimerScheduler { .name(String::from("TimerProxy")) .spawn(move || { while let Ok(req) = req_ipc_receiver.recv() { - req_sender.send(req).unwrap(); + let _ = req_sender.send(req); timeout_thread.unpark(); } // This thread can terminate if the req_ipc_sender is dropped. warn!("TimerProxy thread terminated."); }) - .unwrap(); + .expect("Thread creation failed."); // Return the IPC sender req_ipc_sender diff --git a/components/devtools/actors/network_event.rs b/components/devtools/actors/network_event.rs index 1383a5b24d8..f4f513159aa 100644 --- a/components/devtools/actors/network_event.rs +++ b/components/devtools/actors/network_event.rs @@ -6,8 +6,6 @@ //! (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webconsole.js). //! Handles interaction with the remote web console on network events (HTTP requests, responses) in Servo. -extern crate hyper; - use actor::{Actor, ActorMessageStatus, ActorRegistry}; use devtools_traits::HttpRequest as DevtoolsHttpRequest; use devtools_traits::HttpResponse as DevtoolsHttpResponse; diff --git a/components/devtools_traits/lib.rs b/components/devtools_traits/lib.rs index b8969354753..87f78b08b54 100644 --- a/components/devtools_traits/lib.rs +++ b/components/devtools_traits/lib.rs @@ -12,7 +12,6 @@ #![allow(non_snake_case)] #![deny(unsafe_code)] -#[allow(unused_extern_crates)] #[macro_use] extern crate bitflags; extern crate heapsize; @@ -20,7 +19,6 @@ extern crate heapsize; extern crate hyper; extern crate ipc_channel; extern crate msg; -extern crate serde; #[macro_use] extern crate serde_derive; extern crate servo_url; extern crate time; diff --git a/components/geometry/lib.rs b/components/geometry/lib.rs index 52fcd420c0e..ddca8d71972 100644 --- a/components/geometry/lib.rs +++ b/components/geometry/lib.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ extern crate app_units; -#[macro_use] extern crate euclid; +extern crate euclid; #[macro_use] extern crate heapsize; use app_units::{Au, MAX_AU}; diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs index ccde43b2b73..a52014d7f7c 100644 --- a/components/gfx/lib.rs +++ b/components/gfx/lib.rs @@ -15,9 +15,7 @@ #![deny(unsafe_code)] -extern crate alloc; extern crate app_units; -#[allow(unused_extern_crates)] #[macro_use] extern crate bitflags; @@ -48,7 +46,6 @@ extern crate harfbuzz_sys as harfbuzz; extern crate heapsize; #[macro_use] extern crate heapsize_derive; extern crate ipc_channel; -#[allow(unused_extern_crates)] #[macro_use] extern crate lazy_static; extern crate libc; @@ -57,8 +54,8 @@ extern crate log; extern crate msg; extern crate net_traits; extern crate ordered_float; -#[macro_use] extern crate range; +#[cfg(target_os = "macos")] extern crate serde; #[macro_use] extern crate serde_derive; diff --git a/components/gfx/platform/freetype/font.rs b/components/gfx/platform/freetype/font.rs index 144c63ea159..02460d93dc8 100644 --- a/components/gfx/platform/freetype/font.rs +++ b/components/gfx/platform/freetype/font.rs @@ -2,8 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -extern crate freetype; - use app_units::Au; use font::{FontHandleMethods, FontMetrics, FontTableMethods}; use font::{FontTableTag, FractionalPixel, GPOS, GSUB, KERN}; diff --git a/components/gfx/platform/freetype/font_context.rs b/components/gfx/platform/freetype/font_context.rs index 86643ae348b..7b462798d6b 100644 --- a/components/gfx/platform/freetype/font_context.rs +++ b/components/gfx/platform/freetype/font_context.rs @@ -2,7 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use alloc::heap; +extern crate alloc; + use freetype::freetype::FT_Add_Default_Modules; use freetype::freetype::FT_Done_Library; use freetype::freetype::FT_Library; @@ -10,6 +11,7 @@ use freetype::freetype::FT_Memory; use freetype::freetype::FT_MemoryRec_; use freetype::freetype::FT_New_Library; use heapsize::{HeapSizeOf, heap_size_of}; +use self::alloc::heap; use std::os::raw::{c_long, c_void}; use std::ptr; use std::rc::Rc; diff --git a/components/gfx/platform/freetype/font_list.rs b/components/gfx/platform/freetype/font_list.rs index eaf909dce90..1b87a18221d 100644 --- a/components/gfx/platform/freetype/font_list.rs +++ b/components/gfx/platform/freetype/font_list.rs @@ -2,9 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -extern crate fontconfig; -extern crate freetype; - use fontconfig::fontconfig::{FcChar8, FcResultMatch, FcSetSystem}; use fontconfig::fontconfig::{FcConfigGetCurrent, FcConfigGetFonts, FcConfigSubstitute}; use fontconfig::fontconfig::{FcDefaultSubstitute, FcFontMatch, FcNameParse, FcPatternGetString}; diff --git a/components/gfx/platform/macos/font.rs b/components/gfx/platform/macos/font.rs index adbaccf3c50..8fb867a2f5c 100644 --- a/components/gfx/platform/macos/font.rs +++ b/components/gfx/platform/macos/font.rs @@ -4,10 +4,6 @@ /// Implementation of Quartz (CoreGraphics) fonts. -extern crate core_foundation; -extern crate core_graphics; -extern crate core_text; - use app_units::Au; use byteorder::{BigEndian, ByteOrder}; use core_foundation::base::CFIndex; diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs index 30ab09ba103..a23c8e012bc 100644 --- a/components/gfx_traits/lib.rs +++ b/components/gfx_traits/lib.rs @@ -14,7 +14,6 @@ extern crate heapsize; #[macro_use] extern crate heapsize_derive; #[macro_use] extern crate range; -extern crate serde; #[macro_use] extern crate serde_derive; diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index eb1c968b581..5642459c940 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -20,7 +20,6 @@ fnv = "1.0" gfx = {path = "../gfx"} gfx_traits = {path = "../gfx_traits"} heapsize = "0.3.0" -heapsize_derive = "0.1" html5ever-atoms = "0.1" ipc-channel = "0.5" libc = "0.2" @@ -35,12 +34,11 @@ range = {path = "../range"} rayon = "0.6" script_layout_interface = {path = "../script_layout_interface"} script_traits = {path = "../script_traits"} -selectors = "0.15" +selectors = "0.15.1" serde = "0.8" serde_derive = "0.8" servo_geometry = {path = "../geometry"} serde_json = "0.8" -servo_atoms = {path = "../atoms"} servo_config = {path = "../config"} servo_url = {path = "../url"} smallvec = "0.1" diff --git a/components/layout/block.rs b/components/layout/block.rs index a4eb30ce606..7859cb9a9f8 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -567,7 +567,7 @@ impl BlockFlow { } else { BlockType::FloatNonReplaced } - } else if self.is_inline_block() { + } else if self.is_inline_block_or_inline_flex() { if self.fragment.is_replaced() { BlockType::InlineBlockReplaced } else { @@ -1558,8 +1558,9 @@ impl BlockFlow { debug_assert_eq!(self.fragment.margin_box_inline_size(), self.base.position.size.inline); } - fn is_inline_block(&self) -> bool { - self.fragment.style().get_box().display == display::T::inline_block + fn is_inline_block_or_inline_flex(&self) -> bool { + self.fragment.style().get_box().display == display::T::inline_block || + self.fragment.style().get_box().display == display::T::inline_flex } /// Computes the content portion (only) of the intrinsic inline sizes of this flow. This is diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 6671a07b4ad..95603f8dea7 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -937,9 +937,14 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> ConstructionResult::ConstructionItem(construction_item) } - fn build_fragment_for_inline_block(&mut self, node: &ConcreteThreadSafeLayoutNode) - -> ConstructionResult { - let block_flow_result = self.build_flow_for_block(node, None); + /// Build the fragment for an inline-block or inline-flex, based on the `display` flag + fn build_fragment_for_inline_block_or_inline_flex(&mut self, node: &ConcreteThreadSafeLayoutNode, + display: display::T) -> ConstructionResult { + let block_flow_result = match display { + display::T::inline_block => self.build_flow_for_block(node, None), + display::T::inline_flex => self.build_flow_for_flex(node, None), + _ => panic!("The flag should be inline-block or inline-flex") + }; let (block_flow, abs_descendants) = match block_flow_result { ConstructionResult::Flow(block_flow, abs_descendants) => (block_flow, abs_descendants), _ => unreachable!() @@ -1548,7 +1553,8 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS // Inline-block items contribute inline fragment construction results. (display::T::inline_block, float::T::none, _) => { - let construction_result = self.build_fragment_for_inline_block(node); + let construction_result = self.build_fragment_for_inline_block_or_inline_flex(node, + display::T::inline_block); self.set_flow_construction_result(node, construction_result) } @@ -1597,6 +1603,12 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS self.set_flow_construction_result(node, construction_result) } + (display::T::inline_flex, _, _) => { + let construction_result = self.build_fragment_for_inline_block_or_inline_flex(node, + display::T::inline_flex); + self.set_flow_construction_result(node, construction_result) + } + // Block flows that are not floated contribute block flow construction results. // // TODO(pcwalton): Make this only trigger for blocks and handle the other `display` diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 8a086d34320..d255b030963 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -1151,6 +1151,7 @@ impl InlineFlow { match (display_value, vertical_align_value) { (display::T::inline, vertical_align::T::top) | (display::T::block, vertical_align::T::top) | + (display::T::inline_flex, vertical_align::T::top) | (display::T::inline_block, vertical_align::T::top) if inline_metrics.space_above_baseline >= Au(0) => { *largest_block_size_for_top_fragments = max( @@ -1159,6 +1160,7 @@ impl InlineFlow { } (display::T::inline, vertical_align::T::bottom) | (display::T::block, vertical_align::T::bottom) | + (display::T::inline_flex, vertical_align::T::bottom) | (display::T::inline_block, vertical_align::T::bottom) if inline_metrics.space_below_baseline >= Au(0) => { *largest_block_size_for_bottom_fragments = max( diff --git a/components/layout/lib.rs b/components/layout/lib.rs index 8c8e8633fa0..bd71724c790 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -16,7 +16,6 @@ extern crate app_units; extern crate atomic_refcell; -#[allow(unused_extern_crates)] #[macro_use] extern crate bitflags; extern crate canvas_traits; @@ -27,7 +26,6 @@ extern crate fnv; extern crate gfx; extern crate gfx_traits; extern crate heapsize; -#[macro_use] extern crate heapsize_derive; #[macro_use] extern crate html5ever_atoms; extern crate ipc_channel; extern crate libc; @@ -37,7 +35,6 @@ extern crate msg; extern crate net_traits; extern crate ordered_float; extern crate parking_lot; -#[macro_use] extern crate profile_traits; #[macro_use] extern crate range; @@ -48,7 +45,6 @@ extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; -#[macro_use] extern crate servo_atoms; extern crate servo_config; extern crate servo_geometry; extern crate servo_url; diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 4f40a94e28e..01800ce3487 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -766,7 +766,13 @@ fn initial_computed_inline_size(block: &mut BlockFlow, containing_block_inline_size); match inline_size_from_style { MaybeAuto::Auto => { - MaybeAuto::Specified(min(containing_block_inline_size, preferred_width_of_all_columns)) + if preferred_width_of_all_columns + table_border_padding <= containing_block_inline_size { + MaybeAuto::Specified(preferred_width_of_all_columns + table_border_padding) + } else if minimum_width_of_all_columns > containing_block_inline_size { + MaybeAuto::Specified(minimum_width_of_all_columns) + } else { + MaybeAuto::Auto + } } MaybeAuto::Specified(inline_size_from_style) => { MaybeAuto::Specified(max(inline_size_from_style - table_border_padding, diff --git a/components/layout_thread/Cargo.toml b/components/layout_thread/Cargo.toml index e90892cf805..5cc708d3208 100644 --- a/components/layout_thread/Cargo.toml +++ b/components/layout_thread/Cargo.toml @@ -16,7 +16,6 @@ fnv = "1.0" gfx = {path = "../gfx"} gfx_traits = {path = "../gfx_traits"} heapsize = "0.3.0" -heapsize_derive = "0.1" ipc-channel = "0.5" layout = {path = "../layout"} layout_traits = {path = "../layout_traits"} @@ -31,7 +30,7 @@ rayon = "0.6" script = {path = "../script"} script_layout_interface = {path = "../script_layout_interface"} script_traits = {path = "../script_traits"} -selectors = "0.15" +selectors = "0.15.1" serde_derive = "0.8" serde_json = "0.8" servo_config = {path = "../config"} diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index c641a23dcd0..19c86f64fff 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -12,18 +12,15 @@ #![plugin(plugins)] extern crate app_units; -extern crate core; extern crate euclid; extern crate fnv; extern crate gfx; extern crate gfx_traits; extern crate heapsize; -#[macro_use] extern crate heapsize_derive; extern crate ipc_channel; #[macro_use] extern crate layout; extern crate layout_traits; -#[allow(unused_extern_crates)] #[macro_use] extern crate lazy_static; #[macro_use] diff --git a/components/msg/lib.rs b/components/msg/lib.rs index 5e87d8b021f..6257340c385 100644 --- a/components/msg/lib.rs +++ b/components/msg/lib.rs @@ -7,12 +7,10 @@ #![deny(unsafe_code)] -#[allow(unused_extern_crates)] #[macro_use] extern crate bitflags; extern crate heapsize; #[macro_use] extern crate heapsize_derive; -extern crate serde; #[macro_use] extern crate serde_derive; extern crate webrender_traits; diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml index e1e57257cb5..993467a7ecd 100644 --- a/components/net/Cargo.toml +++ b/components/net/Cargo.toml @@ -10,7 +10,6 @@ name = "net" path = "lib.rs" [dependencies] -bitflags = "0.7" brotli = "1.0.6" content-blocker = "0.2.1" cookie = {version = "0.2.5", features = ["serialize-rustc"]} @@ -32,8 +31,6 @@ openssl-verify = "0.1" plugins = {path = "../plugins"} profile_traits = {path = "../profile_traits"} rustc-serialize = "0.3" -serde = "0.8" -serde_derive = "0.8" servo_config = {path = "../config"} servo_url = {path = "../url"} threadpool = "1.0" diff --git a/components/net/lib.rs b/components/net/lib.rs index 57ff2af1a0e..082627067a8 100644 --- a/components/net/lib.rs +++ b/components/net/lib.rs @@ -9,8 +9,6 @@ #![deny(unsafe_code)] -#[macro_use] -extern crate bitflags; extern crate brotli; extern crate content_blocker as content_blocker_parser; extern crate cookie as cookie_rs; @@ -32,8 +30,6 @@ extern crate openssl; extern crate openssl_verify; extern crate profile_traits; extern crate rustc_serialize; -#[macro_use] -extern crate serde_derive; extern crate servo_config; extern crate servo_url; extern crate threadpool; diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs index 5ba5f61e3c7..b80be222bb6 100644 --- a/components/net_traits/lib.rs +++ b/components/net_traits/lib.rs @@ -16,7 +16,6 @@ extern crate hyper; extern crate hyper_serde; extern crate image as piston_image; extern crate ipc_channel; -#[allow(unused_extern_crates)] #[macro_use] extern crate lazy_static; #[macro_use] diff --git a/components/plugins/lib.rs b/components/plugins/lib.rs index ee559ecbda0..a8efe9ab1fb 100644 --- a/components/plugins/lib.rs +++ b/components/plugins/lib.rs @@ -23,7 +23,6 @@ extern crate clippy_lints; #[macro_use] extern crate rustc; extern crate rustc_plugin; -#[macro_use] extern crate syntax; use rustc_plugin::Registry; diff --git a/components/profile/lib.rs b/components/profile/lib.rs index dbcb5bff514..a2a4d3da449 100644 --- a/components/profile/lib.rs +++ b/components/profile/lib.rs @@ -22,7 +22,6 @@ extern crate log; extern crate profile_traits; #[cfg(target_os = "linux")] extern crate regex; -extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; diff --git a/components/profile_traits/lib.rs b/components/profile_traits/lib.rs index f82460d2744..ed042262f31 100644 --- a/components/profile_traits/lib.rs +++ b/components/profile_traits/lib.rs @@ -15,7 +15,6 @@ extern crate ipc_channel; #[macro_use] extern crate log; -extern crate serde; #[macro_use] extern crate serde_derive; extern crate servo_config; diff --git a/components/range/lib.rs b/components/range/lib.rs index d3554477140..ddf2eb6d09d 100644 --- a/components/range/lib.rs +++ b/components/range/lib.rs @@ -10,7 +10,6 @@ extern crate heapsize; #[macro_use] extern crate heapsize_derive; extern crate num_traits; extern crate rustc_serialize; -extern crate serde; #[macro_use] extern crate serde_derive; diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 22b75316bd8..bb34846065d 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -16,6 +16,9 @@ debugmozjs = ['js/debugmozjs'] [build-dependencies] cmake = "0.1" +phf_codegen = "0.7.18" +phf_shared = "0.7.18" +serde_json = "0.8" [target.'cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))'.dependencies] tinyfiledialogs = "2.5.9" @@ -57,7 +60,6 @@ offscreen_gl_context = "0.5.0" open = "1.1.1" parking_lot = "0.3" phf = "0.7.18" -phf_macros = "0.7.18" plugins = {path = "../plugins"} profile_traits = {path = "../profile_traits"} range = {path = "../range"} @@ -67,7 +69,7 @@ regex = "0.2" rustc-serialize = "0.3" script_layout_interface = {path = "../script_layout_interface"} script_traits = {path = "../script_traits"} -selectors = "0.15" +selectors = "0.15.1" serde = "0.8" servo_atoms = {path = "../atoms"} servo_config = {path = "../config", features = ["servo"] } diff --git a/components/script/build.rs b/components/script/build.rs index 019a55f25a6..189ce765e01 100644 --- a/components/script/build.rs +++ b/components/script/build.rs @@ -3,7 +3,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ extern crate cmake; +extern crate phf_codegen; +extern crate phf_shared; +extern crate serde_json; + +use serde_json::Value; use std::env; +use std::fmt; +use std::fs::File; +use std::io::Write; +use std::path::PathBuf; use std::time::Instant; fn main() { @@ -34,4 +43,33 @@ fn main() { build.build(); println!("Binding generation completed in {}s", start.elapsed().as_secs()); + + let json = PathBuf::from(env::var("OUT_DIR").unwrap()).join("build").join("InterfaceObjectMapData.json"); + let json: Value = serde_json::from_reader(File::open(&json).unwrap()).unwrap(); + let mut map = phf_codegen::Map::new(); + for (key, value) in json.as_object().unwrap() { + map.entry(Bytes(key), value.as_str().unwrap()); + } + let phf = PathBuf::from(env::var("OUT_DIR").unwrap()).join("InterfaceObjectMapPhf.rs"); + let mut phf = File::create(&phf).unwrap(); + write!(&mut phf, "pub static MAP: phf::Map<&'static [u8], unsafe fn(*mut JSContext, HandleObject)> = ").unwrap(); + map.build(&mut phf).unwrap(); + write!(&mut phf, ";\n").unwrap(); +} + +#[derive(Eq, PartialEq, Hash)] +struct Bytes<'a>(&'a str); + +impl<'a> fmt::Debug for Bytes<'a> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("b\"")?; + formatter.write_str(self.0)?; + formatter.write_str("\" as &'static [u8]") + } +} + +impl<'a> phf_shared::PhfHash for Bytes<'a> { + fn phf_hash<H: std::hash::Hasher>(&self, hasher: &mut H) { + self.0.as_bytes().phf_hash(hasher) + } } diff --git a/components/script/dom/beforeunloadevent.rs b/components/script/dom/beforeunloadevent.rs index d9162002016..3787bb5b62d 100644 --- a/components/script/dom/beforeunloadevent.rs +++ b/components/script/dom/beforeunloadevent.rs @@ -13,7 +13,7 @@ use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; -use dom::globalscope::GlobalScope; +use dom::window::Window; use servo_atoms::Atom; // https://html.spec.whatwg.org/multipage/#beforeunloadevent @@ -31,17 +31,17 @@ impl BeforeUnloadEvent { } } - pub fn new_uninitialized(global: &GlobalScope) -> Root<BeforeUnloadEvent> { + pub fn new_uninitialized(window: &Window) -> Root<BeforeUnloadEvent> { reflect_dom_object(box BeforeUnloadEvent::new_inherited(), - global, + window, BeforeUnloadEventBinding::Wrap) } - pub fn new(global: &GlobalScope, + pub fn new(window: &Window, type_: Atom, bubbles: EventBubbles, cancelable: EventCancelable) -> Root<BeforeUnloadEvent> { - let ev = BeforeUnloadEvent::new_uninitialized(global); + let ev = BeforeUnloadEvent::new_uninitialized(window); { let event = ev.upcast::<Event>(); event.init_event(type_, bool::from(bubbles), diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 7c084f32400..093f402fa47 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -6840,6 +6840,15 @@ class GlobalGenRoots(): ], "\n")), pre="pub flags Globals: u8 {\n", post="\n}") globals_ = CGWrapper(CGIndenter(global_flags), pre="bitflags! {\n", post="\n}") + phf = CGGeneric("include!(concat!(env!(\"OUT_DIR\"), \"/InterfaceObjectMapPhf.rs\"));") + + return CGList([ + CGGeneric(AUTOGENERATED_WARNING_COMMENT), + CGList([imports, globals_, phf], "\n\n") + ]) + + @staticmethod + def InterfaceObjectMapData(config): pairs = [] for d in config.getDescriptors(hasInterfaceObject=True, isInline=False): binding = toBindingNamespace(d.name) @@ -6848,19 +6857,13 @@ class GlobalGenRoots(): pairs.append((ctor.identifier.name, binding, binding)) pairs.sort(key=operator.itemgetter(0)) mappings = [ - CGGeneric('b"%s" => codegen::Bindings::%s::%s::DefineDOMInterface as unsafe fn(_, _),' % pair) + CGGeneric('"%s": "codegen::Bindings::%s::%s::DefineDOMInterface as unsafe fn(_, _)"' % pair) for pair in pairs ] - mapType = "phf::Map<&'static [u8], unsafe fn(*mut JSContext, HandleObject)>" - phf = CGWrapper( - CGIndenter(CGList(mappings, "\n")), - pre="pub static MAP: %s = phf_map! {\n" % mapType, - post="\n};\n") - - return CGList([ - CGGeneric(AUTOGENERATED_WARNING_COMMENT), - CGList([imports, globals_, phf], "\n\n") - ]) + return CGWrapper( + CGList(mappings, ",\n"), + pre="{\n", + post="\n}\n") @staticmethod def PrototypeList(config): diff --git a/components/script/dom/bindings/codegen/GlobalGen.py b/components/script/dom/bindings/codegen/GlobalGen.py index 8f122f52bd1..966e4bdbcd2 100644 --- a/components/script/dom/bindings/codegen/GlobalGen.py +++ b/components/script/dom/bindings/codegen/GlobalGen.py @@ -76,6 +76,7 @@ def main(): ('PrototypeList', 'PrototypeList.rs'), ('RegisterBindings', 'RegisterBindings.rs'), ('InterfaceObjectMap', 'InterfaceObjectMap.rs'), + ('InterfaceObjectMapData', 'InterfaceObjectMapData.json'), ('InterfaceTypes', 'InterfaceTypes.rs'), ('InheritTypes', 'InheritTypes.rs'), ('Bindings', os.path.join('Bindings', 'mod.rs')), diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 5f12675226a..6d268823d77 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -577,7 +577,7 @@ unsafe impl JSTraceable for RwLock<MediaList> { } /// Holds a set of JSTraceables that need to be rooted -pub struct RootedTraceableSet { +struct RootedTraceableSet { set: Vec<*const JSTraceable>, } diff --git a/components/script/dom/cssstylesheet.rs b/components/script/dom/cssstylesheet.rs index 908cfad2cd5..d0f6ed869c3 100644 --- a/components/script/dom/cssstylesheet.rs +++ b/components/script/dom/cssstylesheet.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::Bindings::CSSStyleSheetBinding; use dom::bindings::codegen::Bindings::CSSStyleSheetBinding::CSSStyleSheetMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; -use dom::bindings::error::{ErrorResult, Fallible}; +use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{reflect_dom_object, DomObject}; use dom::bindings::str::DOMString; @@ -13,6 +13,7 @@ use dom::cssrulelist::{CSSRuleList, RulesSource}; use dom::element::Element; use dom::stylesheet::StyleSheet; use dom::window::Window; +use std::cell::Cell; use std::sync::Arc; use style::stylesheets::Stylesheet as StyleStyleSheet; @@ -23,6 +24,7 @@ pub struct CSSStyleSheet { rulelist: MutNullableJS<CSSRuleList>, #[ignore_heap_size_of = "Arc"] style_stylesheet: Arc<StyleStyleSheet>, + origin_clean: Cell<bool>, } impl CSSStyleSheet { @@ -36,6 +38,7 @@ impl CSSStyleSheet { owner: JS::from_ref(owner), rulelist: MutNullableJS::new(None), style_stylesheet: stylesheet, + origin_clean: Cell::new(true), } } @@ -71,25 +74,34 @@ impl CSSStyleSheet { pub fn style_stylesheet(&self) -> &StyleStyleSheet { &self.style_stylesheet } + + pub fn set_origin_clean(&self, origin_clean: bool) { + self.origin_clean.set(origin_clean); + } } impl CSSStyleSheetMethods for CSSStyleSheet { // https://drafts.csswg.org/cssom/#dom-cssstylesheet-cssrules - fn CssRules(&self) -> Root<CSSRuleList> { - // XXXManishearth check origin clean flag - // https://github.com/servo/servo/issues/14327 - self.rulelist() + fn GetCssRules(&self) -> Fallible<Root<CSSRuleList>> { + if !self.origin_clean.get() { + return Err(Error::Security); + } + Ok(self.rulelist()) } // https://drafts.csswg.org/cssom/#dom-cssstylesheet-insertrule fn InsertRule(&self, rule: DOMString, index: u32) -> Fallible<u32> { - // XXXManishearth check origin clean flag + if !self.origin_clean.get() { + return Err(Error::Security); + } self.rulelist().insert_rule(&rule, index, /* nested */ false) } // https://drafts.csswg.org/cssom/#dom-cssstylesheet-deleterule fn DeleteRule(&self, index: u32) -> ErrorResult { - // XXXManishearth check origin clean flag + if !self.origin_clean.get() { + return Err(Error::Security); + } self.rulelist().remove_rule(index) } } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 65f106192bd..6bf8c841d4d 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -7,6 +7,7 @@ use devtools_traits::ScriptToDevtoolsControlMsg; use document_loader::{DocumentLoader, LoadType}; use dom::activation::{ActivationSource, synthetic_click_activation}; use dom::attr::Attr; +use dom::beforeunloadevent::BeforeUnloadEvent; use dom::bindings::callback::ExceptionHandling; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; @@ -40,8 +41,7 @@ use dom::documenttype::DocumentType; use dom::domimplementation::DOMImplementation; use dom::element::{Element, ElementCreator, ElementPerformFullscreenEnter, ElementPerformFullscreenExit}; use dom::errorevent::ErrorEvent; -use dom::event::{Event, EventBubbles, EventCancelable, EventDefault}; -use dom::eventdispatcher::EventStatus; +use dom::event::{Event, EventBubbles, EventCancelable, EventDefault, EventStatus}; use dom::eventtarget::EventTarget; use dom::focusevent::FocusEvent; use dom::forcetouchevent::ForceTouchEvent; @@ -229,7 +229,7 @@ pub struct Document { /// https://html.spec.whatwg.org/multipage/#list-of-scripts-that-will-execute-in-order-as-soon-as-possible asap_in_order_scripts_list: PendingInOrderScriptVec, /// https://html.spec.whatwg.org/multipage/#set-of-scripts-that-will-execute-as-soon-as-possible - asap_scripts_set: DOMRefCell<VecDeque<PendingScript>>, + asap_scripts_set: DOMRefCell<Vec<JS<HTMLScriptElement>>>, /// https://html.spec.whatwg.org/multipage/#concept-n-noscript /// True if scripting is enabled for all scripts in this document scripting_enabled: Cell<bool>, @@ -1539,48 +1539,71 @@ impl Document { loader.fetch_async(load, request, fetch_target); } + // https://html.spec.whatwg.org/multipage/#the-end + // https://html.spec.whatwg.org/multipage/#delay-the-load-event pub fn finish_load(&self, load: LoadType) { + // This does not delay the load event anymore. debug!("Document got finish_load: {:?}", load); - // The parser might need the loader, so restrict the lifetime of the borrow. - { - let mut loader = self.loader.borrow_mut(); - loader.finish_load(&load); - } + self.loader.borrow_mut().finish_load(&load); + + match load { + LoadType::Stylesheet(_) => { + // A stylesheet finishing to load may unblock any pending + // parsing-blocking script or deferred script. + self.process_pending_parsing_blocking_script(); - if let LoadType::Script(_) = load { - self.process_deferred_scripts(); - self.process_asap_scripts(); + // Step 3. + self.process_deferred_scripts(); + }, + LoadType::PageSource(_) => { + // Deferred scripts have to wait for page to finish loading, + // this is the first opportunity to process them. + + // Step 3. + self.process_deferred_scripts(); + }, + _ => {}, } - if let Some(parser) = self.get_current_parser() { - let ready_to_be_executed = match self.pending_parsing_blocking_script.borrow_mut().as_mut() { - Some(pending) => { - if self.script_blocking_stylesheets_count.get() > 0 { - return; - } - if let Some(pair) = pending.take_result() { - Some(pair) - } else { - return; - } - }, - None => None, - }; - if let Some((element, result)) = ready_to_be_executed { - *self.pending_parsing_blocking_script.borrow_mut() = None; - parser.resume_with_pending_parsing_blocking_script(&element, result); - } + // Step 4 is in another castle, namely at the end of + // process_deferred_scripts. + + // Step 5 can be found in asap_script_loaded and + // asap_in_order_script_loaded. + + if self.loader.borrow().is_blocked() { + // Step 6. + return; } - if !self.loader.borrow().is_blocked() && !self.loader.borrow().events_inhibited() { - self.loader.borrow_mut().inhibit_events(); - // Schedule a task to fire a "load" event. - debug!("Document loads are complete."); - let handler = box DocumentProgressHandler::new(Trusted::new(self)); - self.window.dom_manipulation_task_source().queue(handler, self.window.upcast()).unwrap(); + // The rest will ever run only once per document. + if self.loader.borrow().events_inhibited() { + return; } + self.loader.borrow_mut().inhibit_events(); + + // Step 7. + debug!("Document loads are complete."); + let handler = box DocumentProgressHandler::new(Trusted::new(self)); + self.window.dom_manipulation_task_source().queue(handler, self.window.upcast()).unwrap(); + + // Step 8. + // TODO: pageshow event. + + // Step 9. + // TODO: pending application cache download process tasks. + + // Step 10. + // TODO: printing steps. + + // Step 11. + // TODO: ready for post-load tasks. + + // Step 12. + // TODO: completely loaded. } + // https://html.spec.whatwg.org/multipage/#pending-parsing-blocking-script pub fn set_pending_parsing_blocking_script(&self, script: &HTMLScriptElement, load: Option<ScriptResult>) { @@ -1588,65 +1611,82 @@ impl Document { *self.pending_parsing_blocking_script.borrow_mut() = Some(PendingScript::new_with_load(script, load)); } + // https://html.spec.whatwg.org/multipage/#pending-parsing-blocking-script pub fn has_pending_parsing_blocking_script(&self) -> bool { self.pending_parsing_blocking_script.borrow().is_some() } /// https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.d. pub fn pending_parsing_blocking_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) { - let mut blocking_script = self.pending_parsing_blocking_script.borrow_mut(); - let entry = blocking_script.as_mut().unwrap(); - assert!(&*entry.element == element); - entry.loaded(result); + { + let mut blocking_script = self.pending_parsing_blocking_script.borrow_mut(); + let entry = blocking_script.as_mut().unwrap(); + assert!(&*entry.element == element); + entry.loaded(result); + } + self.process_pending_parsing_blocking_script(); } + fn process_pending_parsing_blocking_script(&self) { + if self.script_blocking_stylesheets_count.get() > 0 { + return; + } + let pair = self.pending_parsing_blocking_script + .borrow_mut() + .as_mut() + .and_then(PendingScript::take_result); + if let Some((element, result)) = pair { + *self.pending_parsing_blocking_script.borrow_mut() = None; + self.get_current_parser().unwrap().resume_with_pending_parsing_blocking_script(&element, result); + } + } + + // https://html.spec.whatwg.org/multipage/#set-of-scripts-that-will-execute-as-soon-as-possible pub fn add_asap_script(&self, script: &HTMLScriptElement) { - self.asap_scripts_set.borrow_mut().push_back(PendingScript::new(script)); + self.asap_scripts_set.borrow_mut().push(JS::from_ref(script)); } - /// https://html.spec.whatwg.org/multipage/#the-end step 3. + /// https://html.spec.whatwg.org/multipage/#the-end step 5. /// https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.d. pub fn asap_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) { - let mut scripts = self.asap_scripts_set.borrow_mut(); - let idx = scripts.iter().position(|entry| &*entry.element == element).unwrap(); - scripts.swap(0, idx); - scripts[0].loaded(result); + { + let mut scripts = self.asap_scripts_set.borrow_mut(); + let idx = scripts.iter().position(|entry| &**entry == element).unwrap(); + scripts.swap_remove(idx); + } + element.execute(result); } + // https://html.spec.whatwg.org/multipage/#list-of-scripts-that-will-execute-in-order-as-soon-as-possible pub fn push_asap_in_order_script(&self, script: &HTMLScriptElement) { self.asap_in_order_scripts_list.push(script); } - /// https://html.spec.whatwg.org/multipage/#the-end step 3. + /// https://html.spec.whatwg.org/multipage/#the-end step 5. /// https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.c. pub fn asap_in_order_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) { self.asap_in_order_scripts_list.loaded(element, result); - } - - fn process_asap_scripts(&self) { - let pair = self.asap_scripts_set.borrow_mut().front_mut().and_then(PendingScript::take_result); - if let Some((element, result)) = pair { - self.asap_scripts_set.borrow_mut().pop_front(); - element.execute(result); - } while let Some((element, result)) = self.asap_in_order_scripts_list.take_next_ready_to_be_executed() { element.execute(result); } } + // https://html.spec.whatwg.org/multipage/#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing pub fn add_deferred_script(&self, script: &HTMLScriptElement) { self.deferred_scripts.push(script); } + /// https://html.spec.whatwg.org/multipage/#the-end step 3. /// https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.d. pub fn deferred_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) { self.deferred_scripts.loaded(element, result); + self.process_deferred_scripts(); } /// https://html.spec.whatwg.org/multipage/#the-end step 3. - pub fn process_deferred_scripts(&self) { + fn process_deferred_scripts(&self) { if self.ready_state.get() != DocumentReadyState::Interactive { return; } @@ -1667,6 +1707,7 @@ impl Document { } } + // https://html.spec.whatwg.org/multipage/#the-end step 4. pub fn maybe_dispatch_dom_content_loaded(&self) { if self.domcontentloaded_dispatched.get() { return; @@ -1677,6 +1718,7 @@ impl Document { update_with_current_time_ms(&self.dom_content_loaded_event_start); + // Step 4.1. let window = self.window(); window.dom_manipulation_task_source().queue_event(self.upcast(), atom!("DOMContentLoaded"), EventBubbles::Bubbles, EventCancelable::NotCancelable, window); @@ -1685,6 +1727,9 @@ impl Document { ReflowQueryType::NoQuery, ReflowReason::DOMContentLoaded); update_with_current_time_ms(&self.dom_content_loaded_event_end); + + // Step 4.2. + // TODO: client message queue. } pub fn notify_constellation_load(&self) { @@ -2558,6 +2603,8 @@ impl DocumentMethods for Document { fn CreateEvent(&self, mut interface: DOMString) -> Fallible<Root<Event>> { interface.make_ascii_lowercase(); match &*interface { + "beforeunloadevent" => + Ok(Root::upcast(BeforeUnloadEvent::new_uninitialized(&self.window))), "closeevent" => Ok(Root::upcast(CloseEvent::new_uninitialized(self.window.upcast()))), "customevent" => @@ -2567,9 +2614,9 @@ impl DocumentMethods for Document { "events" | "event" | "htmlevents" | "svgevents" => Ok(Event::new_uninitialized(&self.window.upcast())), "focusevent" => - Ok(Root::upcast(FocusEvent::new_uninitialized(self.window.upcast()))), + Ok(Root::upcast(FocusEvent::new_uninitialized(&self.window))), "hashchangeevent" => - Ok(Root::upcast(HashChangeEvent::new_uninitialized(&self.window.upcast()))), + Ok(Root::upcast(HashChangeEvent::new_uninitialized(&self.window))), "keyboardevent" => Ok(Root::upcast(KeyboardEvent::new_uninitialized(&self.window))), "messageevent" => @@ -2577,9 +2624,9 @@ impl DocumentMethods for Document { "mouseevent" | "mouseevents" => Ok(Root::upcast(MouseEvent::new_uninitialized(&self.window))), "pagetransitionevent" => - Ok(Root::upcast(PageTransitionEvent::new_uninitialized(self.window.upcast()))), + Ok(Root::upcast(PageTransitionEvent::new_uninitialized(&self.window))), "popstateevent" => - Ok(Root::upcast(PopStateEvent::new_uninitialized(self.window.upcast()))), + Ok(Root::upcast(PopStateEvent::new_uninitialized(&self.window))), "progressevent" => Ok(Root::upcast(ProgressEvent::new_uninitialized(self.window.upcast()))), "storageevent" => { diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index fa3b9bfae6b..2d3c2afe460 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -2,103 +2,29 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use devtools_traits::{TimelineMarker, TimelineMarkerType}; +use dom::bindings::callback::ExceptionHandling; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::EventBinding; use dom::bindings::codegen::Bindings::EventBinding::{EventConstants, EventMethods}; use dom::bindings::error::Fallible; -use dom::bindings::js::{MutNullableJS, Root}; +use dom::bindings::inheritance::Castable; +use dom::bindings::js::{JS, MutNullableJS, Root, RootedReference}; use dom::bindings::refcounted::Trusted; -use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; -use dom::eventdispatcher::EventStatus; -use dom::eventtarget::EventTarget; +use dom::document::Document; +use dom::eventtarget::{CompiledEventListener, EventTarget, ListenerPhase}; use dom::globalscope::GlobalScope; +use dom::node::Node; +use dom::virtualmethods::vtable_for; +use dom::window::Window; use script_thread::Runnable; use servo_atoms::Atom; use std::cell::Cell; use std::default::Default; use time; -#[derive(JSTraceable, Copy, Clone, Debug, PartialEq, Eq)] -#[repr(u16)] -#[derive(HeapSizeOf)] -pub enum EventPhase { - None = EventConstants::NONE, - Capturing = EventConstants::CAPTURING_PHASE, - AtTarget = EventConstants::AT_TARGET, - Bubbling = EventConstants::BUBBLING_PHASE, -} - -#[derive(PartialEq, HeapSizeOf, Copy, Clone)] -pub enum EventBubbles { - Bubbles, - DoesNotBubble -} - -impl From<EventBubbles> for bool { - fn from(bubbles: EventBubbles) -> Self { - match bubbles { - EventBubbles::Bubbles => true, - EventBubbles::DoesNotBubble => false - } - } -} - -impl From<bool> for EventBubbles { - fn from(boolean: bool) -> Self { - match boolean { - true => EventBubbles::Bubbles, - false => EventBubbles::DoesNotBubble - } - } -} - -#[derive(PartialEq, HeapSizeOf, Copy, Clone)] -pub enum EventCancelable { - Cancelable, - NotCancelable -} - -impl From<EventCancelable> for bool { - fn from(bubbles: EventCancelable) -> Self { - match bubbles { - EventCancelable::Cancelable => true, - EventCancelable::NotCancelable => false - } - } -} - -impl From<bool> for EventCancelable { - fn from(boolean: bool) -> Self { - match boolean { - true => EventCancelable::Cancelable, - false => EventCancelable::NotCancelable - } - } -} - -/// An enum to indicate whether the default action of an event is allowed. -/// -/// This should've been a bool. Instead, it's an enum, because, aside from the allowed/canceled -/// states, we also need something to stop the event from being handled again (without cancelling -/// the event entirely). For example, an Up/Down `KeyEvent` inside a `textarea` element will -/// trigger the cursor to go up/down if the text inside the element spans multiple lines. This enum -/// helps us to prevent such events from being [sent to the constellation][msg] where it will be -/// handled once again for page scrolling (which is definitely not what we'd want). -/// -/// [msg]: https://doc.servo.org/script_traits/enum.ConstellationMsg.html#variant.KeyEvent -/// -#[derive(JSTraceable, HeapSizeOf, Copy, Clone, PartialEq)] -pub enum EventDefault { - /// The default action of the event is allowed (constructor's default) - Allowed, - /// The default action has been prevented by calling `PreventDefault` - Prevented, - /// The event has been handled somewhere in the DOM, and it should be prevented from being - /// re-handled elsewhere. This doesn't affect the judgement of `DefaultPrevented` - Handled, -} - #[dom_struct] pub struct Event { reflector_: Reflector, @@ -176,46 +102,74 @@ impl Event { self.cancelable.set(cancelable); } - pub fn status(&self) -> EventStatus { - match self.DefaultPrevented() { - true => EventStatus::Canceled, - false => EventStatus::NotCanceled - } - } + // https://dom.spec.whatwg.org/#concept-event-dispatch + pub fn dispatch(&self, + target: &EventTarget, + target_override: Option<&EventTarget>) + -> EventStatus { + assert!(!self.dispatching()); + assert!(self.initialized()); + assert_eq!(self.phase.get(), EventPhase::None); + assert!(self.GetCurrentTarget().is_none()); - #[inline] - pub fn set_current_target(&self, val: &EventTarget) { - self.current_target.set(Some(val)); - } + // Step 1. + self.dispatching.set(true); - #[inline] - pub fn set_target(&self, val: &EventTarget) { - self.target.set(Some(val)); - } + // Step 2. + self.target.set(Some(target_override.unwrap_or(target))); - #[inline] - pub fn phase(&self) -> EventPhase { - self.phase.get() - } + if self.stop_propagation.get() { + // If the event's stop propagation flag is set, we can skip everything because + // it prevents the calls of the invoke algorithm in the spec. - #[inline] - pub fn set_phase(&self, val: EventPhase) { - self.phase.set(val) - } + // Step 10-12. + self.clear_dispatching_flags(); - #[inline] - pub fn stop_propagation(&self) -> bool { - self.stop_propagation.get() - } + // Step 14. + return self.status(); + } - #[inline] - pub fn stop_immediate(&self) -> bool { - self.stop_immediate.get() + // Step 3. The "invoke" algorithm is only used on `target` separately, + // so we don't put it in the path. + rooted_vec!(let mut event_path); + + // Step 4. + if let Some(target_node) = target.downcast::<Node>() { + for ancestor in target_node.ancestors() { + event_path.push(JS::from_ref(ancestor.upcast::<EventTarget>())); + } + let top_most_ancestor_or_target = + Root::from_ref(event_path.r().last().cloned().unwrap_or(target)); + if let Some(document) = Root::downcast::<Document>(top_most_ancestor_or_target) { + if self.type_() != atom!("load") && document.browsing_context().is_some() { + event_path.push(JS::from_ref(document.window().upcast())); + } + } + } + + // Steps 5-9. In a separate function to short-circuit various things easily. + dispatch_to_listeners(self, target, event_path.r()); + + // Default action. + if let Some(target) = self.GetTarget() { + if let Some(node) = target.downcast::<Node>() { + let vtable = vtable_for(&node); + vtable.handle_event(self); + } + } + + // Step 10-12. + self.clear_dispatching_flags(); + + // Step 14. + self.status() } - #[inline] - pub fn bubbles(&self) -> bool { - self.bubbles.get() + pub fn status(&self) -> EventStatus { + match self.DefaultPrevented() { + true => EventStatus::Canceled, + false => EventStatus::NotCanceled + } } #[inline] @@ -224,21 +178,14 @@ impl Event { } #[inline] - // https://dom.spec.whatwg.org/#concept-event-dispatch Step 1. - pub fn mark_as_dispatching(&self) { - assert!(!self.dispatching.get()); - self.dispatching.set(true); - } - - #[inline] // https://dom.spec.whatwg.org/#concept-event-dispatch Steps 10-12. - pub fn clear_dispatching_flags(&self) { + fn clear_dispatching_flags(&self) { assert!(self.dispatching.get()); self.dispatching.set(false); self.stop_propagation.set(false); self.stop_immediate.set(false); - self.set_phase(EventPhase::None); + self.phase.set(EventPhase::None); self.current_target.set(None); } @@ -261,6 +208,16 @@ impl Event { pub fn get_cancel_state(&self) -> EventDefault { self.canceled.get() } + + pub fn set_trusted(&self, trusted: bool) { + self.trusted.set(trusted); + } + + // https://html.spec.whatwg.org/multipage/#fire-a-simple-event + pub fn fire(&self, target: &EventTarget) -> EventStatus { + self.set_trusted(true); + target.dispatch_event(self) + } } impl EventMethods for Event { @@ -336,19 +293,92 @@ impl EventMethods for Event { } } +#[derive(PartialEq, HeapSizeOf, Copy, Clone)] +pub enum EventBubbles { + Bubbles, + DoesNotBubble +} -impl Event { - pub fn set_trusted(&self, trusted: bool) { - self.trusted.set(trusted); +impl From<bool> for EventBubbles { + fn from(boolean: bool) -> Self { + match boolean { + true => EventBubbles::Bubbles, + false => EventBubbles::DoesNotBubble + } } +} - // https://html.spec.whatwg.org/multipage/#fire-a-simple-event - pub fn fire(&self, target: &EventTarget) -> EventStatus { - self.set_trusted(true); - target.dispatch_event(self) +impl From<EventBubbles> for bool { + fn from(bubbles: EventBubbles) -> Self { + match bubbles { + EventBubbles::Bubbles => true, + EventBubbles::DoesNotBubble => false + } } } +#[derive(PartialEq, HeapSizeOf, Copy, Clone)] +pub enum EventCancelable { + Cancelable, + NotCancelable +} + +impl From<bool> for EventCancelable { + fn from(boolean: bool) -> Self { + match boolean { + true => EventCancelable::Cancelable, + false => EventCancelable::NotCancelable + } + } +} + +impl From<EventCancelable> for bool { + fn from(bubbles: EventCancelable) -> Self { + match bubbles { + EventCancelable::Cancelable => true, + EventCancelable::NotCancelable => false + } + } +} + +#[derive(JSTraceable, Copy, Clone, Debug, PartialEq, Eq)] +#[repr(u16)] +#[derive(HeapSizeOf)] +pub enum EventPhase { + None = EventConstants::NONE, + Capturing = EventConstants::CAPTURING_PHASE, + AtTarget = EventConstants::AT_TARGET, + Bubbling = EventConstants::BUBBLING_PHASE, +} + +/// An enum to indicate whether the default action of an event is allowed. +/// +/// This should've been a bool. Instead, it's an enum, because, aside from the allowed/canceled +/// states, we also need something to stop the event from being handled again (without cancelling +/// the event entirely). For example, an Up/Down `KeyEvent` inside a `textarea` element will +/// trigger the cursor to go up/down if the text inside the element spans multiple lines. This enum +/// helps us to prevent such events from being [sent to the constellation][msg] where it will be +/// handled once again for page scrolling (which is definitely not what we'd want). +/// +/// [msg]: https://doc.servo.org/script_traits/enum.ConstellationMsg.html#variant.KeyEvent +/// +#[derive(JSTraceable, HeapSizeOf, Copy, Clone, PartialEq)] +pub enum EventDefault { + /// The default action of the event is allowed (constructor's default) + Allowed, + /// The default action has been prevented by calling `PreventDefault` + Prevented, + /// The event has been handled somewhere in the DOM, and it should be prevented from being + /// re-handled elsewhere. This doesn't affect the judgement of `DefaultPrevented` + Handled, +} + +#[derive(PartialEq)] +pub enum EventStatus { + Canceled, + NotCanceled +} + // https://dom.spec.whatwg.org/#concept-event-fire pub struct EventRunnable { pub target: Trusted<EventTarget>, @@ -382,3 +412,116 @@ impl Runnable for SimpleEventRunnable { target.fire_event(self.name); } } + +// See dispatch_event. +// https://dom.spec.whatwg.org/#concept-event-dispatch +fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&EventTarget]) { + assert!(!event.stop_propagation.get()); + assert!(!event.stop_immediate.get()); + + let window = match Root::downcast::<Window>(target.global()) { + Some(window) => { + if window.need_emit_timeline_marker(TimelineMarkerType::DOMEvent) { + Some(window) + } else { + None + } + }, + _ => None, + }; + + // Step 5. + event.phase.set(EventPhase::Capturing); + + // Step 6. + for object in event_path.iter().rev() { + invoke(window.r(), object, event, Some(ListenerPhase::Capturing)); + if event.stop_propagation.get() { + return; + } + } + assert!(!event.stop_propagation.get()); + assert!(!event.stop_immediate.get()); + + // Step 7. + event.phase.set(EventPhase::AtTarget); + + // Step 8. + invoke(window.r(), target, event, None); + if event.stop_propagation.get() { + return; + } + assert!(!event.stop_propagation.get()); + assert!(!event.stop_immediate.get()); + + if !event.bubbles.get() { + return; + } + + // Step 9.1. + event.phase.set(EventPhase::Bubbling); + + // Step 9.2. + for object in event_path { + invoke(window.r(), object, event, Some(ListenerPhase::Bubbling)); + if event.stop_propagation.get() { + return; + } + } +} + +// https://dom.spec.whatwg.org/#concept-event-listener-invoke +fn invoke(window: Option<&Window>, + object: &EventTarget, + event: &Event, + specific_listener_phase: Option<ListenerPhase>) { + // Step 1. + assert!(!event.stop_propagation.get()); + + // Steps 2-3. + let listeners = object.get_listeners_for(&event.type_(), specific_listener_phase); + + // Step 4. + event.current_target.set(Some(object)); + + // Step 5. + inner_invoke(window, object, event, &listeners); + + // TODO: step 6. +} + +// https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke +fn inner_invoke(window: Option<&Window>, + object: &EventTarget, + event: &Event, + listeners: &[CompiledEventListener]) + -> bool { + // Step 1. + let mut found = false; + + // Step 2. + for listener in listeners { + // Steps 2.1 and 2.3-2.4 are not done because `listeners` contain only the + // relevant ones for this invoke call during the dispatch algorithm. + + // Step 2.2. + found = true; + + // TODO: step 2.5. + + // Step 2.6. + let marker = TimelineMarker::start("DOMEvent".to_owned()); + listener.call_or_handle_event(object, event, ExceptionHandling::Report); + if let Some(window) = window { + window.emit_timeline_marker(marker.end()); + } + if event.stop_immediate.get() { + return found; + } + + // TODO: step 2.7. + } + + // Step 3. + found +} diff --git a/components/script/dom/eventdispatcher.rs b/components/script/dom/eventdispatcher.rs deleted file mode 100644 index bdec56532dc..00000000000 --- a/components/script/dom/eventdispatcher.rs +++ /dev/null @@ -1,223 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use devtools_traits::{StartedTimelineMarker, TimelineMarker, TimelineMarkerType}; -use dom::bindings::callback::ExceptionHandling::Report; -use dom::bindings::codegen::Bindings::EventBinding::EventMethods; -use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root, RootedReference}; -use dom::bindings::reflector::DomObject; -use dom::document::Document; -use dom::event::{Event, EventPhase}; -use dom::eventtarget::{CompiledEventListener, EventTarget, ListenerPhase}; -use dom::node::Node; -use dom::virtualmethods::vtable_for; -use dom::window::Window; - -struct AutoDOMEventMarker { - window: Root<Window>, - marker: Option<StartedTimelineMarker>, -} - -impl AutoDOMEventMarker { - fn new(window: &Window) -> AutoDOMEventMarker { - AutoDOMEventMarker { - window: Root::from_ref(window), - marker: Some(TimelineMarker::start("DOMEvent".to_owned())), - } - } -} - -impl Drop for AutoDOMEventMarker { - fn drop(&mut self) { - self.window.emit_timeline_marker(self.marker.take().unwrap().end()); - } -} - -fn handle_event(window: Option<&Window>, listener: &CompiledEventListener, - current_target: &EventTarget, event: &Event) { - let _marker; - if let Some(window) = window { - _marker = AutoDOMEventMarker::new(window); - } - - listener.call_or_handle_event(current_target, event, Report); -} - -// See dispatch_event. -// https://dom.spec.whatwg.org/#concept-event-dispatch -fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&EventTarget]) { - assert!(!event.stop_propagation()); - assert!(!event.stop_immediate()); - - let window = match Root::downcast::<Window>(target.global()) { - Some(window) => { - if window.need_emit_timeline_marker(TimelineMarkerType::DOMEvent) { - Some(window) - } else { - None - } - }, - _ => None, - }; - - // Step 5. - event.set_phase(EventPhase::Capturing); - - // Step 6. - for object in event_path.iter().rev() { - invoke(window.r(), object, event, Some(ListenerPhase::Capturing)); - if event.stop_propagation() { - return; - } - } - assert!(!event.stop_propagation()); - assert!(!event.stop_immediate()); - - // Step 7. - event.set_phase(EventPhase::AtTarget); - - // Step 8. - invoke(window.r(), target, event, None); - if event.stop_propagation() { - return; - } - assert!(!event.stop_propagation()); - assert!(!event.stop_immediate()); - - if !event.bubbles() { - return; - } - - // Step 9.1. - event.set_phase(EventPhase::Bubbling); - - // Step 9.2. - for object in event_path { - invoke(window.r(), object, event, Some(ListenerPhase::Bubbling)); - if event.stop_propagation() { - return; - } - } -} - -#[derive(PartialEq)] -pub enum EventStatus { - Canceled, - NotCanceled -} - -// https://dom.spec.whatwg.org/#concept-event-dispatch -pub fn dispatch_event(target: &EventTarget, - target_override: Option<&EventTarget>, - event: &Event) -> EventStatus { - assert!(!event.dispatching()); - assert!(event.initialized()); - assert_eq!(event.phase(), EventPhase::None); - assert!(event.GetCurrentTarget().is_none()); - - // Step 1. - event.mark_as_dispatching(); - - // Step 2. - event.set_target(target_override.unwrap_or(target)); - - if event.stop_propagation() { - // If the event's stop propagation flag is set, we can skip everything because - // it prevents the calls of the invoke algorithm in the spec. - - // Step 10-12. - event.clear_dispatching_flags(); - - // Step 14. - return event.status(); - } - - // Step 3. The "invoke" algorithm is only used on `target` separately, - // so we don't put it in the path. - rooted_vec!(let mut event_path); - - // Step 4. - if let Some(target_node) = target.downcast::<Node>() { - for ancestor in target_node.ancestors() { - event_path.push(JS::from_ref(ancestor.upcast::<EventTarget>())); - } - let top_most_ancestor_or_target = - Root::from_ref(event_path.r().last().cloned().unwrap_or(target)); - if let Some(document) = Root::downcast::<Document>(top_most_ancestor_or_target) { - if event.type_() != atom!("load") && document.browsing_context().is_some() { - event_path.push(JS::from_ref(document.window().upcast())); - } - } - } - - // Steps 5-9. In a separate function to short-circuit various things easily. - dispatch_to_listeners(event, target, event_path.r()); - - // Default action. - if let Some(target) = event.GetTarget() { - if let Some(node) = target.downcast::<Node>() { - let vtable = vtable_for(&node); - vtable.handle_event(event); - } - } - - // Step 10-12. - event.clear_dispatching_flags(); - - // Step 14. - event.status() -} - -// https://dom.spec.whatwg.org/#concept-event-listener-invoke -fn invoke(window: Option<&Window>, - object: &EventTarget, - event: &Event, - specific_listener_phase: Option<ListenerPhase>) { - // Step 1. - assert!(!event.stop_propagation()); - - // Steps 2-3. - let listeners = object.get_listeners_for(&event.type_(), specific_listener_phase); - - // Step 4. - event.set_current_target(object); - - // Step 5. - inner_invoke(window, object, event, &listeners); - - // TODO: step 6. -} - -// https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke -fn inner_invoke(window: Option<&Window>, - object: &EventTarget, - event: &Event, - listeners: &[CompiledEventListener]) - -> bool { - // Step 1. - let mut found = false; - - // Step 2. - for listener in listeners { - // Steps 2.1 and 2.3-2.4 are not done because `listeners` contain only the - // relevant ones for this invoke call during the dispatch algorithm. - - // Step 2.2. - found = true; - - // TODO: step 2.5. - - // Step 2.6. - handle_event(window, listener, object, event); - if event.stop_immediate() { - return found; - } - - // TODO: step 2.7. - } - - // Step 3. - found -} diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index 1023b97600f..15790d7ce53 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -22,8 +22,7 @@ use dom::bindings::reflector::{DomObject, Reflector}; use dom::bindings::str::DOMString; use dom::element::Element; use dom::errorevent::ErrorEvent; -use dom::event::{Event, EventBubbles, EventCancelable}; -use dom::eventdispatcher::{EventStatus, dispatch_event}; +use dom::event::{Event, EventBubbles, EventCancelable, EventStatus}; use dom::node::document_from_node; use dom::virtualmethods::VirtualMethods; use dom::window::Window; @@ -300,11 +299,11 @@ impl EventTarget { pub fn dispatch_event_with_target(&self, target: &EventTarget, event: &Event) -> EventStatus { - dispatch_event(self, Some(target), event) + event.dispatch(self, Some(target)) } pub fn dispatch_event(&self, event: &Event) -> EventStatus { - dispatch_event(self, None, event) + event.dispatch(self, None) } /// https://html.spec.whatwg.org/multipage/#event-handler-attributes:event-handlers-11 diff --git a/components/script/dom/filereader.rs b/components/script/dom/filereader.rs index 9b5c39b013c..039d516db6e 100644 --- a/components/script/dom/filereader.rs +++ b/components/script/dom/filereader.rs @@ -27,7 +27,7 @@ use js::jsapi::Heap; use js::jsapi::JSAutoCompartment; use js::jsapi::JSContext; use js::jsval::{self, JSVal}; -use js::typedarray::Uint8Array; +use js::typedarray::ArrayBuffer; use rustc_serialize::base64::{CharacterSet, Config, Newline, ToBase64}; use script_thread::RunnableWrapper; use servo_atoms::Atom; @@ -269,7 +269,7 @@ impl FileReader { cx: *mut JSContext, _: ReadMetaData, bytes: &[u8]) { unsafe { rooted!(in(cx) let mut array_buffer = ptr::null_mut()); - assert!(Uint8Array::create(cx, bytes.len() as u32, Some(bytes), array_buffer.handle_mut()).is_ok()); + assert!(ArrayBuffer::create(cx, bytes.len() as u32, Some(bytes), array_buffer.handle_mut()).is_ok()); *result.borrow_mut() = Some(FileReaderResult::ArrayBuffer(Heap::default())); diff --git a/components/script/dom/focusevent.rs b/components/script/dom/focusevent.rs index c7e48531479..6ffed30e857 100644 --- a/components/script/dom/focusevent.rs +++ b/components/script/dom/focusevent.rs @@ -12,7 +12,6 @@ use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::{EventBubbles, EventCancelable}; use dom::eventtarget::EventTarget; -use dom::globalscope::GlobalScope; use dom::uievent::UIEvent; use dom::window::Window; use std::default::Default; @@ -31,9 +30,9 @@ impl FocusEvent { } } - pub fn new_uninitialized(global: &GlobalScope) -> Root<FocusEvent> { + pub fn new_uninitialized(window: &Window) -> Root<FocusEvent> { reflect_dom_object(box FocusEvent::new_inherited(), - global, + window, FocusEventBinding::Wrap) } @@ -44,7 +43,7 @@ impl FocusEvent { view: Option<&Window>, detail: i32, related_target: Option<&EventTarget>) -> Root<FocusEvent> { - let ev = FocusEvent::new_uninitialized(window.upcast()); + let ev = FocusEvent::new_uninitialized(window); ev.upcast::<UIEvent>().InitUIEvent(type_, bool::from(can_bubble), bool::from(cancelable), diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 7a9e5074266..f513d4285ad 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -15,8 +15,7 @@ use dom::bindings::str::DOMString; use dom::crypto::Crypto; use dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope; use dom::errorevent::ErrorEvent; -use dom::event::{Event, EventBubbles, EventCancelable}; -use dom::eventdispatcher::EventStatus; +use dom::event::{Event, EventBubbles, EventCancelable, EventStatus}; use dom::eventtarget::EventTarget; use dom::window::Window; use dom::workerglobalscope::WorkerGlobalScope; diff --git a/components/script/dom/hashchangeevent.rs b/components/script/dom/hashchangeevent.rs index b93b7a93631..cd4b2b0a71f 100644 --- a/components/script/dom/hashchangeevent.rs +++ b/components/script/dom/hashchangeevent.rs @@ -11,7 +11,7 @@ use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::{DOMString, USVString}; use dom::event::Event; -use dom::globalscope::GlobalScope; +use dom::window::Window; use servo_atoms::Atom; // https://html.spec.whatwg.org/multipage/#hashchangeevent @@ -31,13 +31,13 @@ impl HashChangeEvent { } } - pub fn new_uninitialized(global: &GlobalScope) -> Root<HashChangeEvent> { + pub fn new_uninitialized(window: &Window) -> Root<HashChangeEvent> { reflect_dom_object(box HashChangeEvent::new_inherited(String::new(), String::new()), - global, + window, HashChangeEventBinding::Wrap) } - pub fn new(global: &GlobalScope, + pub fn new(window: &Window, type_: Atom, bubbles: bool, cancelable: bool, @@ -45,7 +45,7 @@ impl HashChangeEvent { new_url: String) -> Root<HashChangeEvent> { let ev = reflect_dom_object(box HashChangeEvent::new_inherited(old_url, new_url), - global, + window, HashChangeEventBinding::Wrap); { let event = ev.upcast::<Event>(); @@ -54,11 +54,11 @@ impl HashChangeEvent { ev } - pub fn Constructor(global: &GlobalScope, + pub fn Constructor(window: &Window, type_: DOMString, init: &HashChangeEventBinding::HashChangeEventInit) -> Fallible<Root<HashChangeEvent>> { - Ok(HashChangeEvent::new(global, + Ok(HashChangeEvent::new(window, Atom::from(type_), init.parent.bubbles, init.parent.cancelable, diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 674db5c8a0c..4db3949d4f9 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -18,7 +18,7 @@ use dom::element::{AttributeMutation, Element, ElementCreator}; use dom::element::{cors_setting_for_element, reflect_cross_origin_attribute, set_cross_origin_attribute}; use dom::globalscope::GlobalScope; use dom::htmlelement::HTMLElement; -use dom::node::{Node, document_from_node, window_from_node}; +use dom::node::{Node, UnbindContext, document_from_node, window_from_node}; use dom::stylesheet::StyleSheet as DOMStyleSheet; use dom::virtualmethods::VirtualMethods; use html5ever_atoms::LocalName; @@ -37,6 +37,15 @@ use stylesheet_loader::{StylesheetLoader, StylesheetContextSource, StylesheetOwn unsafe_no_jsmanaged_fields!(Stylesheet); +#[derive(JSTraceable, PartialEq, Clone, Copy, HeapSizeOf)] +pub struct RequestGenerationId(u32); + +impl RequestGenerationId { + fn increment(self) -> RequestGenerationId { + RequestGenerationId(self.0 + 1) + } +} + #[dom_struct] pub struct HTMLLinkElement { htmlelement: HTMLElement, @@ -52,6 +61,8 @@ pub struct HTMLLinkElement { pending_loads: Cell<u32>, /// Whether any of the loads have failed. any_failed_load: Cell<bool>, + /// A monotonically increasing counter that keeps track of which stylesheet to apply. + request_generation_id: Cell<RequestGenerationId>, } impl HTMLLinkElement { @@ -65,6 +76,7 @@ impl HTMLLinkElement { cssom_stylesheet: MutNullableJS::new(None), pending_loads: Cell::new(0), any_failed_load: Cell::new(false), + request_generation_id: Cell::new(RequestGenerationId(0)), } } @@ -78,12 +90,15 @@ impl HTMLLinkElement { HTMLLinkElementBinding::Wrap) } + pub fn get_request_generation_id(&self) -> RequestGenerationId { + self.request_generation_id.get() + } + pub fn set_stylesheet(&self, s: Arc<Stylesheet>) { - assert!(self.stylesheet.borrow().is_none()); + assert!(self.stylesheet.borrow().is_none()); // Useful for catching timing issues. *self.stylesheet.borrow_mut() = Some(s); } - pub fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> { self.stylesheet.borrow().clone() } @@ -213,6 +228,15 @@ impl VirtualMethods for HTMLLinkElement { } } } + + fn unbind_from_tree(&self, context: &UnbindContext) { + if let Some(ref s) = self.super_type() { + s.unbind_from_tree(context); + } + + let document = document_from_node(self); + document.invalidate_stylesheets(); + } } @@ -260,6 +284,8 @@ impl HTMLLinkElement { None => "", }; + self.request_generation_id.set(self.request_generation_id.get().increment()); + // TODO: #8085 - Don't load external stylesheets if the node's mq // doesn't match. let loader = StylesheetLoader::for_element(self.upcast()); @@ -319,6 +345,12 @@ impl StylesheetOwner for HTMLLinkElement { None } + + fn set_origin_clean(&self, origin_clean: bool) { + if let Some(stylesheet) = self.get_cssom_stylesheet() { + stylesheet.set_origin_clean(origin_clean); + } + } } impl HTMLLinkElementMethods for HTMLLinkElement { diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 42b4a4d149a..e1e8dabac7b 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -17,8 +17,7 @@ use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element, ElementCreator}; use dom::element::{cors_setting_for_element, reflect_cross_origin_attribute, set_cross_origin_attribute}; -use dom::event::{Event, EventBubbles, EventCancelable}; -use dom::eventdispatcher::EventStatus; +use dom::event::{Event, EventBubbles, EventCancelable, EventStatus}; use dom::globalscope::GlobalScope; use dom::htmlelement::HTMLElement; use dom::node::{ChildrenMutation, CloneChildrenFlag, Node}; diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 35da9bb6368..285c8af3087 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -15,7 +15,7 @@ use dom::document::Document; use dom::element::{Element, ElementCreator}; use dom::eventtarget::EventTarget; use dom::htmlelement::HTMLElement; -use dom::node::{ChildrenMutation, Node, document_from_node, window_from_node}; +use dom::node::{ChildrenMutation, Node, UnbindContext, document_from_node, window_from_node}; use dom::stylesheet::StyleSheet as DOMStyleSheet; use dom::virtualmethods::VirtualMethods; use html5ever_atoms::LocalName; @@ -161,6 +161,15 @@ impl VirtualMethods for HTMLStyleElement { self.parse_own_css(); } } + + fn unbind_from_tree(&self, context: &UnbindContext) { + if let Some(ref s) = self.super_type() { + s.unbind_from_tree(context); + } + + let doc = document_from_node(self); + doc.invalidate_stylesheets(); + } } impl StylesheetOwner for HTMLStyleElement { @@ -191,6 +200,12 @@ impl StylesheetOwner for HTMLStyleElement { fn referrer_policy(&self) -> Option<ReferrerPolicy> { None } + + fn set_origin_clean(&self, origin_clean: bool) { + if let Some(stylesheet) = self.get_cssom_stylesheet() { + stylesheet.set_origin_clean(origin_clean); + } + } } diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index 0fd610ed46b..5de594a5195 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -276,7 +276,6 @@ pub mod domtokenlist; pub mod element; pub mod errorevent; pub mod event; -pub mod eventdispatcher; pub mod eventsource; pub mod eventtarget; pub mod extendableevent; diff --git a/components/script/dom/pagetransitionevent.rs b/components/script/dom/pagetransitionevent.rs index b40f6c1ab39..e76a6444d4c 100644 --- a/components/script/dom/pagetransitionevent.rs +++ b/components/script/dom/pagetransitionevent.rs @@ -11,7 +11,7 @@ use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::Event; -use dom::globalscope::GlobalScope; +use dom::window::Window; use servo_atoms::Atom; use std::cell::Cell; @@ -30,19 +30,19 @@ impl PageTransitionEvent { } } - pub fn new_uninitialized(global: &GlobalScope) -> Root<PageTransitionEvent> { + pub fn new_uninitialized(window: &Window) -> Root<PageTransitionEvent> { reflect_dom_object(box PageTransitionEvent::new_inherited(), - global, + window, PageTransitionEventBinding::Wrap) } - pub fn new(global: &GlobalScope, + pub fn new(window: &Window, type_: Atom, bubbles: bool, cancelable: bool, persisted: bool) -> Root<PageTransitionEvent> { - let ev = PageTransitionEvent::new_uninitialized(global); + let ev = PageTransitionEvent::new_uninitialized(window); ev.persisted.set(persisted); { let event = ev.upcast::<Event>(); @@ -51,11 +51,11 @@ impl PageTransitionEvent { ev } - pub fn Constructor(global: &GlobalScope, + pub fn Constructor(window: &Window, type_: DOMString, init: &PageTransitionEventBinding::PageTransitionEventInit) -> Fallible<Root<PageTransitionEvent>> { - Ok(PageTransitionEvent::new(global, + Ok(PageTransitionEvent::new(window, Atom::from(type_), init.parent.bubbles, init.parent.cancelable, diff --git a/components/script/dom/popstateevent.rs b/components/script/dom/popstateevent.rs index 44183f7483f..fde05e30394 100644 --- a/components/script/dom/popstateevent.rs +++ b/components/script/dom/popstateevent.rs @@ -11,7 +11,7 @@ use dom::bindings::js::{MutHeapJSVal, Root}; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::Event; -use dom::globalscope::GlobalScope; +use dom::window::Window; use js::jsapi::{HandleValue, JSContext}; use js::jsval::JSVal; use servo_atoms::Atom; @@ -32,19 +32,19 @@ impl PopStateEvent { } } - pub fn new_uninitialized(global: &GlobalScope) -> Root<PopStateEvent> { + pub fn new_uninitialized(window: &Window) -> Root<PopStateEvent> { reflect_dom_object(box PopStateEvent::new_inherited(), - global, + window, PopStateEventBinding::Wrap) } - pub fn new(global: &GlobalScope, + pub fn new(window: &Window, type_: Atom, bubbles: bool, cancelable: bool, state: HandleValue) -> Root<PopStateEvent> { - let ev = PopStateEvent::new_uninitialized(global); + let ev = PopStateEvent::new_uninitialized(window); ev.state.set(state.get()); { let event = ev.upcast::<Event>(); @@ -54,11 +54,11 @@ impl PopStateEvent { } #[allow(unsafe_code)] - pub fn Constructor(global: &GlobalScope, + pub fn Constructor(window: &Window, type_: DOMString, init: &PopStateEventBinding::PopStateEventInit) -> Fallible<Root<PopStateEvent>> { - Ok(PopStateEvent::new(global, + Ok(PopStateEvent::new(window, Atom::from(type_), init.parent.bubbles, init.parent.cancelable, diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs index 30a5c5948a2..b75fd7352c5 100644 --- a/components/script/dom/servoparser/mod.rs +++ b/components/script/dom/servoparser/mod.rs @@ -359,9 +359,8 @@ impl ServoParser { window.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::FirstLoad); } - // Steps 3-12 are in other castles, namely process_deferred_scripts and finish_load. + // Steps 3-12 are in another castle, namely finish_load. let url = self.tokenizer.borrow().url().clone(); - self.document.process_deferred_scripts(); self.document.finish_load(LoadType::PageSource(url)); } } diff --git a/components/script/dom/transitionevent.rs b/components/script/dom/transitionevent.rs index cc17e77eae1..4630ec70bc0 100644 --- a/components/script/dom/transitionevent.rs +++ b/components/script/dom/transitionevent.rs @@ -12,7 +12,6 @@ use dom::bindings::num::Finite; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::Event; -use dom::globalscope::GlobalScope; use dom::window::Window; use servo_atoms::Atom; @@ -25,7 +24,7 @@ pub struct TransitionEvent { } impl TransitionEvent { - pub fn new_inherited(init: &TransitionEventInit) -> TransitionEvent { + fn new_inherited(init: &TransitionEventInit) -> TransitionEvent { TransitionEvent { event: Event::new_inherited(), property_name: Atom::from(init.propertyName.clone()), @@ -34,11 +33,11 @@ impl TransitionEvent { } } - pub fn new(global: &GlobalScope, + pub fn new(window: &Window, type_: Atom, init: &TransitionEventInit) -> Root<TransitionEvent> { let ev = reflect_dom_object(box TransitionEvent::new_inherited(init), - global, + window, TransitionEventBinding::Wrap); { let event = ev.upcast::<Event>(); @@ -50,8 +49,7 @@ impl TransitionEvent { pub fn Constructor(window: &Window, type_: DOMString, init: &TransitionEventInit) -> Fallible<Root<TransitionEvent>> { - let global = window.upcast::<GlobalScope>(); - Ok(TransitionEvent::new(global, Atom::from(type_), init)) + Ok(TransitionEvent::new(window, Atom::from(type_), init)) } } diff --git a/components/script/dom/webidls/BeforeUnloadEvent.webidl b/components/script/dom/webidls/BeforeUnloadEvent.webidl index 74b0cd8e62c..71fe9396d48 100644 --- a/components/script/dom/webidls/BeforeUnloadEvent.webidl +++ b/components/script/dom/webidls/BeforeUnloadEvent.webidl @@ -6,7 +6,7 @@ * https://html.spec.whatwg.org/multipage/#beforeunloadevent */ -[Exposed=(Window,Worker)] +[Exposed=Window] interface BeforeUnloadEvent : Event { attribute DOMString returnValue; }; diff --git a/components/script/dom/webidls/CSSStyleSheet.webidl b/components/script/dom/webidls/CSSStyleSheet.webidl index 6fba0cf983a..c616c9d2a10 100644 --- a/components/script/dom/webidls/CSSStyleSheet.webidl +++ b/components/script/dom/webidls/CSSStyleSheet.webidl @@ -6,7 +6,7 @@ [Exposed=Window] interface CSSStyleSheet : StyleSheet { // readonly attribute CSSRule? ownerRule; - [SameObject] readonly attribute CSSRuleList cssRules; + [Throws, SameObject] readonly attribute CSSRuleList cssRules; [Throws] unsigned long insertRule(DOMString rule, unsigned long index); [Throws] void deleteRule(unsigned long index); }; diff --git a/components/script/dom/webidls/FocusEvent.webidl b/components/script/dom/webidls/FocusEvent.webidl index 42e560b72b4..14ec3ae67e9 100644 --- a/components/script/dom/webidls/FocusEvent.webidl +++ b/components/script/dom/webidls/FocusEvent.webidl @@ -3,7 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://w3c.github.io/uievents/#interface-FocusEvent -[Constructor(DOMString typeArg, optional FocusEventInit focusEventInitDict)] +[Constructor(DOMString typeArg, optional FocusEventInit focusEventInitDict), + Exposed=Window] interface FocusEvent : UIEvent { readonly attribute EventTarget? relatedTarget; }; diff --git a/components/script/dom/webidls/HashChangeEvent.webidl b/components/script/dom/webidls/HashChangeEvent.webidl index d34400c7ccc..3d81e8ad383 100644 --- a/components/script/dom/webidls/HashChangeEvent.webidl +++ b/components/script/dom/webidls/HashChangeEvent.webidl @@ -3,7 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://html.spec.whatwg.org/multipage/#hashchangeevent -[Constructor(DOMString type, optional HashChangeEventInit eventInitDict), Exposed=(Window,Worker)] +[Constructor(DOMString type, optional HashChangeEventInit eventInitDict), + Exposed=Window] interface HashChangeEvent : Event { readonly attribute USVString oldURL; readonly attribute USVString newURL; diff --git a/components/script/dom/webidls/Location.webidl b/components/script/dom/webidls/Location.webidl index 431ab87d5e5..d611a20b883 100644 --- a/components/script/dom/webidls/Location.webidl +++ b/components/script/dom/webidls/Location.webidl @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://html.spec.whatwg.org/multipage/#location -[Exposed=(Window,Worker), Unforgeable] interface Location { +[Exposed=Window, Unforgeable] interface Location { /*stringifier*/ attribute USVString href; readonly attribute USVString origin; attribute USVString protocol; diff --git a/components/script/dom/webidls/MouseEvent.webidl b/components/script/dom/webidls/MouseEvent.webidl index c95739429a8..e9f7a31db48 100644 --- a/components/script/dom/webidls/MouseEvent.webidl +++ b/components/script/dom/webidls/MouseEvent.webidl @@ -3,7 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://w3c.github.io/uievents/#interface-mouseevent -[Constructor(DOMString typeArg, optional MouseEventInit mouseEventInitDict)] +[Constructor(DOMString typeArg, optional MouseEventInit mouseEventInitDict), + Exposed=Window] interface MouseEvent : UIEvent { readonly attribute long screenX; readonly attribute long screenY; diff --git a/components/script/dom/webidls/PageTransitionEvent.webidl b/components/script/dom/webidls/PageTransitionEvent.webidl index 3f3ed0b797a..a23f3099bad 100644 --- a/components/script/dom/webidls/PageTransitionEvent.webidl +++ b/components/script/dom/webidls/PageTransitionEvent.webidl @@ -3,7 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://html.spec.whatwg.org/multipage/#the-pagetransitionevent-interface -[Constructor(DOMString type, optional PageTransitionEventInit eventInitDict), Exposed=(Window,Worker)] +[Constructor(DOMString type, optional PageTransitionEventInit eventInitDict), + Exposed=Window] interface PageTransitionEvent : Event { readonly attribute boolean persisted; }; diff --git a/components/script/dom/webidls/PopStateEvent.webidl b/components/script/dom/webidls/PopStateEvent.webidl index f5052df597f..4508cac6288 100644 --- a/components/script/dom/webidls/PopStateEvent.webidl +++ b/components/script/dom/webidls/PopStateEvent.webidl @@ -3,7 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://html.spec.whatwg.org/multipage/#the-popstateevent-interface -[Constructor(DOMString type, optional PopStateEventInit eventInitDict), Exposed=(Window,Worker)] +[Constructor(DOMString type, optional PopStateEventInit eventInitDict), + Exposed=Window] interface PopStateEvent : Event { readonly attribute any state; }; diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 2d6581b9e43..18b3a441d68 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -17,8 +17,7 @@ use dom::bindings::str::DOMString; use dom::bindings::structuredclone::StructuredCloneData; use dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope; use dom::errorevent::ErrorEvent; -use dom::event::{Event, EventBubbles, EventCancelable}; -use dom::eventdispatcher::EventStatus; +use dom::event::{Event, EventBubbles, EventCancelable, EventStatus}; use dom::eventtarget::EventTarget; use dom::globalscope::GlobalScope; use dom::messageevent::MessageEvent; diff --git a/components/script/lib.rs b/components/script/lib.rs index f1fbe6f99c5..15d1d2d322b 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -23,14 +23,12 @@ #![doc = "The script crate contains all matters DOM."] -#![plugin(phf_macros)] #![plugin(plugins)] extern crate angle; extern crate app_units; extern crate atomic_refcell; extern crate audio_video_metadata; -#[allow(unused_extern_crates)] #[macro_use] extern crate bitflags; extern crate bluetooth_traits; @@ -83,7 +81,7 @@ extern crate script_traits; extern crate selectors; extern crate serde; #[macro_use] extern crate servo_atoms; -#[macro_use] extern crate servo_config; +extern crate servo_config; extern crate servo_geometry; extern crate servo_rand; extern crate servo_url; @@ -95,7 +93,6 @@ extern crate time; #[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))] extern crate tinyfiledialogs; extern crate url; -#[macro_use] extern crate uuid; extern crate webrender_traits; extern crate websocket; diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index ce02d763699..57cdd7044c4 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1624,7 +1624,7 @@ impl ScriptThread { // FIXME: Handle pseudo-elements properly pseudoElement: DOMString::new() }; - let transition_event = TransitionEvent::new(window.upcast(), + let transition_event = TransitionEvent::new(&window, atom!("transitionend"), &init); transition_event.upcast::<Event>().fire(node.upcast()); diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs index 25b06e31de9..cdc93c9808b 100644 --- a/components/script/stylesheet_loader.rs +++ b/components/script/stylesheet_loader.rs @@ -10,7 +10,7 @@ use dom::document::Document; use dom::element::Element; use dom::eventtarget::EventTarget; use dom::htmlelement::HTMLElement; -use dom::htmllinkelement::HTMLLinkElement; +use dom::htmllinkelement::{RequestGenerationId, HTMLLinkElement}; use dom::node::{document_from_node, window_from_node}; use encoding::EncodingRef; use encoding::all::UTF_8; @@ -19,7 +19,7 @@ use hyper::mime::{Mime, TopLevel, SubLevel}; use hyper_serde::Serde; use ipc_channel::ipc; use ipc_channel::router::ROUTER; -use net_traits::{FetchResponseListener, FetchMetadata, Metadata, NetworkError, ReferrerPolicy}; +use net_traits::{FetchResponseListener, FetchMetadata, FilteredMetadata, Metadata, NetworkError, ReferrerPolicy}; use net_traits::request::{CorsSettings, CredentialsMode, Destination, RequestInit, RequestMode, Type as RequestType}; use network_listener::{NetworkListener, PreInvoke}; use parking_lot::RwLock; @@ -47,6 +47,9 @@ pub trait StylesheetOwner { /// Returns None if there are still pending loads, or whether any load has /// failed since the loads started. fn load_finished(&self, successful: bool) -> Option<bool>; + + /// Sets origin_clean flag. + fn set_origin_clean(&self, origin_clean: bool); } pub enum StylesheetContextSource { @@ -81,6 +84,10 @@ pub struct StylesheetContext { data: Vec<u8>, /// The node document for elem when the load was initiated. document: Trusted<Document>, + origin_clean: bool, + /// A token which must match the generation id of the `HTMLLinkElement` for it to load the stylesheet. + /// This is ignored for `HTMLStyleElement` and imports. + request_generation_id: Option<RequestGenerationId>, } impl PreInvoke for StylesheetContext {} @@ -92,6 +99,16 @@ impl FetchResponseListener for StylesheetContext { fn process_response(&mut self, metadata: Result<FetchMetadata, NetworkError>) { + if let Ok(FetchMetadata::Filtered { ref filtered, .. }) = metadata { + match *filtered { + FilteredMetadata::Opaque | + FilteredMetadata::OpaqueRedirect => { + self.origin_clean = false; + }, + _ => {}, + } + } + self.metadata = metadata.ok().map(|m| { match m { FetchMetadata::Unfiltered(m) => m, @@ -129,24 +146,30 @@ impl FetchResponseListener for StylesheetContext { let loader = StylesheetLoader::for_element(&elem); match self.source { StylesheetContextSource::LinkElement { ref mut media, .. } => { - let sheet = - Arc::new(Stylesheet::from_bytes(&data, final_url, - protocol_encoding_label, - Some(environment_encoding), - Origin::Author, - media.take().unwrap(), - Some(&loader), - win.css_error_reporter(), - ParserContextExtraData::default())); - if elem.downcast::<HTMLLinkElement>().unwrap().is_alternate() { - sheet.set_disabled(true); + let link = elem.downcast::<HTMLLinkElement>().unwrap(); + // We must first check whether the generations of the context and the element match up, + // else we risk applying the wrong stylesheet when responses come out-of-order. + let is_stylesheet_load_applicable = + self.request_generation_id.map_or(true, |gen| gen == link.get_request_generation_id()); + if is_stylesheet_load_applicable { + let sheet = + Arc::new(Stylesheet::from_bytes(&data, final_url, + protocol_encoding_label, + Some(environment_encoding), + Origin::Author, + media.take().unwrap(), + Some(&loader), + win.css_error_reporter(), + ParserContextExtraData::default())); + + if link.is_alternate() { + sheet.set_disabled(true); + } + + link.set_stylesheet(sheet.clone()); + + win.layout_chan().send(Msg::AddStylesheet(sheet)).unwrap(); } - elem.downcast::<HTMLLinkElement>() - .unwrap() - .set_stylesheet(sheet.clone()); - - let win = window_from_node(&*elem); - win.layout_chan().send(Msg::AddStylesheet(sheet)).unwrap(); } StylesheetContextSource::Import(ref import) => { let import = import.read(); @@ -169,6 +192,7 @@ impl FetchResponseListener for StylesheetContext { let owner = elem.upcast::<Element>().as_stylesheet_owner() .expect("Stylesheet not loaded by <style> or <link> element!"); + owner.set_origin_clean(self.origin_clean); if owner.parser_inserted() { document.decrement_script_blocking_stylesheet_count(); } @@ -200,12 +224,16 @@ impl<'a> StylesheetLoader<'a> { integrity_metadata: String) { let url = source.url(); let document = document_from_node(self.elem); + let gen = self.elem.downcast::<HTMLLinkElement>() + .map(HTMLLinkElement::get_request_generation_id); let context = Arc::new(Mutex::new(StylesheetContext { elem: Trusted::new(&*self.elem), source: source, metadata: None, data: vec![], document: Trusted::new(&*document), + origin_clean: true, + request_generation_id: gen, })); let (action_sender, action_receiver) = ipc::channel().unwrap(); diff --git a/components/script/test.rs b/components/script/test.rs index 83523c47817..9aeff2a22a5 100644 --- a/components/script/test.rs +++ b/components/script/test.rs @@ -9,6 +9,7 @@ pub use dom::headers::normalize_value; pub use dom::bindings::cell::DOMRefCell; pub use dom::bindings::js::JS; pub use dom::node::Node; +pub use dom::bindings::refcounted::TrustedPromise; pub mod area { pub use dom::htmlareaelement::{Area, Shape}; diff --git a/components/script_layout_interface/Cargo.toml b/components/script_layout_interface/Cargo.toml index f6cf201d1e7..c75279af06c 100644 --- a/components/script_layout_interface/Cargo.toml +++ b/components/script_layout_interface/Cargo.toml @@ -12,7 +12,6 @@ path = "lib.rs" [dependencies] app_units = "0.3" atomic_refcell = "0.1" -bitflags = "0.7" canvas_traits = {path = "../canvas_traits"} cssparser = {version = "0.7", features = ["heap_size", "serde-serialization"]} euclid = "0.10.1" @@ -29,7 +28,6 @@ plugins = {path = "../plugins"} profile_traits = {path = "../profile_traits"} range = {path = "../range"} script_traits = {path = "../script_traits"} -selectors = "0.15" -servo_atoms = {path = "../atoms"} +selectors = "0.15.1" servo_url = {path = "../url"} style = {path = "../style"} diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs index e1e2b726697..d5bebc8b2d3 100644 --- a/components/script_layout_interface/lib.rs +++ b/components/script_layout_interface/lib.rs @@ -14,9 +14,6 @@ extern crate app_units; extern crate atomic_refcell; -#[allow(unused_extern_crates)] -#[macro_use] -extern crate bitflags; extern crate canvas_traits; extern crate core; extern crate cssparser; @@ -35,7 +32,6 @@ extern crate profile_traits; extern crate range; extern crate script_traits; extern crate selectors; -#[macro_use] extern crate servo_atoms; extern crate servo_url; extern crate style; diff --git a/components/servo/lib.rs b/components/servo/lib.rs index c0f702de9fd..c7005629652 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -20,7 +20,6 @@ extern crate env_logger; #[cfg(not(target_os = "windows"))] extern crate gaol; -#[macro_use] extern crate gleam; extern crate log; diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index b6bce7e6e3c..ca3d1881c87 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -46,7 +46,7 @@ phf = "0.7.20" quickersort = "2.0.0" rayon = "0.6" rustc-serialize = "0.3" -selectors = "0.15" +selectors = "0.15.1" serde = {version = "0.8", optional = true} serde_derive = {version = "0.8", optional = true} servo_atoms = {path = "../atoms", optional = true} diff --git a/components/style/build.rs b/components/style/build.rs index fb8d4a5e5f9..0e1e9b290e0 100644 --- a/components/style/build.rs +++ b/components/style/build.rs @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#[cfg(feature = "gecko")] #[macro_use] extern crate lazy_static; #[cfg(feature = "bindgen")] diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index 65c892f92ee..ee986f3ab9d 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -388,10 +388,15 @@ mod bindings { "StyleTransition", "mozilla::UniquePtr", "mozilla::DefaultDelete", + + // bindgen can't find these + "mozilla::binding_danger::TErrorResult", + "mozilla::binding_danger::AssertAndSuppressCleanupPolicy", ]; let opaque_types = [ "std::pair__PCCP", "std::namespace::atomic___base", "std::atomic__My_base", + "std::atomic___base", "nsAString_internal_char_traits", "nsAString_internal_incompatible_char_type", "nsACString_internal_char_traits", diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index b2c57195b90..342baa002f1 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -8,7 +8,7 @@ use app_units::Au; use cssparser::{CssStringWriter, Parser, Token}; use euclid::Size2D; use gecko_bindings::bindings; -use gecko_bindings::structs::{nsCSSValue, nsCSSUnit, nsStringBuffer, nsresult}; +use gecko_bindings::structs::{nsCSSValue, nsCSSUnit, nsStringBuffer}; use gecko_bindings::structs::{nsMediaExpression_Range, nsMediaFeature}; use gecko_bindings::structs::{nsMediaFeature_ValueType, nsMediaFeature_RangeType, nsMediaFeature_RequirementFlags}; use gecko_bindings::structs::RawGeckoPresContextOwned; @@ -460,21 +460,12 @@ impl Expression { /// Returns whether this media query evaluates to true for the given device. pub fn matches(&self, device: &Device) -> bool { let mut css_value = nsCSSValue::null(); - let result = unsafe { + unsafe { (self.feature.mGetter.unwrap())(device.pres_context, self.feature, &mut css_value) }; - if result != nsresult::NS_OK { - // FIXME(emilio): This doesn't seem possible from reading gecko - // code, probably we should just clean up that function and return - // void. - error!("Media feature getter errored: {:?}, {:?}", - result, Atom::from(unsafe { *self.feature.mName })); - return false; - } - let value = match MediaExpressionValue::from_css_value(self, &css_value) { Some(v) => v, None => return false, diff --git a/components/style/gecko_bindings/structs_debug.rs b/components/style/gecko_bindings/structs_debug.rs index 05e522645bd..a9f87d0299e 100644 --- a/components/style/gecko_bindings/structs_debug.rs +++ b/components/style/gecko_bindings/structs_debug.rs @@ -994,7 +994,6 @@ pub mod root { pub const NS_STYLE_DISPLAY_MODE_BROWSER: ::std::os::raw::c_uint = 0; pub const NS_STYLE_DISPLAY_MODE_MINIMAL_UI: ::std::os::raw::c_uint = 1; pub const NS_STYLE_DISPLAY_MODE_STANDALONE: ::std::os::raw::c_uint = 2; - pub const NS_STYLE_DISPLAY_MODE_FULLSCREEN: ::std::os::raw::c_uint = 3; pub const NS_STYLE_INHERIT_MASK: ::std::os::raw::c_uint = 16777215; pub const NS_STYLE_HAS_TEXT_DECORATION_LINES: ::std::os::raw::c_uint = 16777216; @@ -1455,7 +1454,6 @@ pub mod root { * conceptual! */ #[repr(C)] - #[derive(Debug, Copy, Clone)] pub struct Pair<A, B> { pub _address: u8, pub _phantom_0: ::std::marker::PhantomData<A>, @@ -1627,6 +1625,10 @@ pub mod root { pub mod dom { #[allow(unused_imports)] use self::super::super::super::root; + pub mod binding_detail { + #[allow(unused_imports)] + use self::super::super::super::super::root; + } #[repr(C)] #[derive(Debug, Copy)] pub struct AllOwningUnionBase { @@ -1837,6 +1839,18 @@ pub mod root { eRethrowExceptions = 2, } #[repr(C)] + #[derive(Debug)] + pub struct CallbackObject_JSObjectsDropper { + pub mHolder: root::RefPtr<root::mozilla::dom::CallbackObject>, + } + #[test] + fn bindgen_test_layout_CallbackObject_JSObjectsDropper() { + assert_eq!(::std::mem::size_of::<CallbackObject_JSObjectsDropper>() + , 8usize); + assert_eq!(::std::mem::align_of::<CallbackObject_JSObjectsDropper>() + , 8usize); + } + #[repr(C)] #[derive(Debug, Copy)] pub struct CallbackObject_FastCallbackConstructor { pub _address: u8, @@ -1862,7 +1876,7 @@ pub mod root { pub mAsyncStack: [u64; 4usize], pub mAsyncStackSetter: [u64; 7usize], pub mAc: [u64; 4usize], - pub mErrorResult: *mut [u64; 4usize], + pub mErrorResult: *mut root::mozilla::ErrorResult, pub mExceptionHandling: root::mozilla::dom::CallbackObject_ExceptionHandling, pub mIsMainThread: bool, } @@ -2459,6 +2473,131 @@ pub mod root { } #[repr(C)] #[derive(Debug, Copy)] + pub struct ErrorResult { + pub _bindgen_opaque_blob: [u64; 4usize], + } + pub type ErrorResult_BaseErrorResult = + root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::AssertAndSuppressCleanupPolicy>; + #[test] + fn bindgen_test_layout_ErrorResult() { + assert_eq!(::std::mem::size_of::<ErrorResult>() , 32usize); + assert_eq!(::std::mem::align_of::<ErrorResult>() , 8usize); + } + impl Clone for ErrorResult { + fn clone(&self) -> Self { *self } + } + pub mod binding_danger { + #[allow(unused_imports)] + use self::super::super::super::root; + /** + * Templated implementation class for various ErrorResult-like things. The + * instantiations differ only in terms of their cleanup policies (used in the + * destructor), which they can specify via the template argument. Note that + * this means it's safe to reinterpret_cast between the instantiations unless + * you plan to invoke the destructor through such a cast pointer. + * + * A cleanup policy consists of two booleans: whether to assert that we've been + * reported or suppressed, and whether to then go ahead and suppress the + * exception. + */ + #[repr(C)] + #[derive(Debug)] + pub struct TErrorResult<CleanupPolicy> { + pub mResult: root::nsresult, + pub __bindgen_anon_1: root::mozilla::binding_danger::TErrorResult__bindgen_ty_1<CleanupPolicy>, + pub mMightHaveUnreportedJSException: bool, + pub mUnionState: root::mozilla::binding_danger::TErrorResult_UnionState, + pub _mOwningThread: root::nsAutoOwningThread, + pub _phantom_0: ::std::marker::PhantomData<CleanupPolicy>, + } + pub const TErrorResult_UnionState_HasDOMExceptionInfo: + root::mozilla::binding_danger::TErrorResult_UnionState = + TErrorResult_UnionState::HasMessage; + pub const TErrorResult_UnionState_HasJSException: + root::mozilla::binding_danger::TErrorResult_UnionState = + TErrorResult_UnionState::HasMessage; + pub const TErrorResult_UnionState_HasNothing: + root::mozilla::binding_danger::TErrorResult_UnionState = + TErrorResult_UnionState::HasMessage; + #[repr(i32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum TErrorResult_UnionState { HasMessage = 0, } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct TErrorResult_Message<CleanupPolicy> { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<CleanupPolicy>, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct TErrorResult_DOMExceptionInfo<CleanupPolicy> { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<CleanupPolicy>, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct TErrorResult__bindgen_ty_1<CleanupPolicy> { + pub mMessage: root::__BindgenUnionField<*mut root::mozilla::binding_danger::TErrorResult_Message<CleanupPolicy>>, + pub mJSException: root::__BindgenUnionField<root::JS::Value>, + pub mDOMExceptionInfo: root::__BindgenUnionField<*mut root::mozilla::binding_danger::TErrorResult_DOMExceptionInfo<CleanupPolicy>>, + pub bindgen_union_field: u64, + pub _phantom_0: ::std::marker::PhantomData<CleanupPolicy>, + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct JustAssertCleanupPolicy { + pub _address: u8, + } + pub const JustAssertCleanupPolicy_assertHandled: bool = true; + pub const JustAssertCleanupPolicy_suppress: bool = false; + #[test] + fn bindgen_test_layout_JustAssertCleanupPolicy() { + assert_eq!(::std::mem::size_of::<JustAssertCleanupPolicy>() , + 1usize); + assert_eq!(::std::mem::align_of::<JustAssertCleanupPolicy>() , + 1usize); + } + impl Clone for JustAssertCleanupPolicy { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct AssertAndSuppressCleanupPolicy { + pub _address: u8, + } + pub const AssertAndSuppressCleanupPolicy_assertHandled: bool = + true; + pub const AssertAndSuppressCleanupPolicy_suppress: bool = true; + #[test] + fn bindgen_test_layout_AssertAndSuppressCleanupPolicy() { + assert_eq!(::std::mem::size_of::<AssertAndSuppressCleanupPolicy>() + , 1usize); + assert_eq!(::std::mem::align_of::<AssertAndSuppressCleanupPolicy>() + , 1usize); + } + impl Clone for AssertAndSuppressCleanupPolicy { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct JustSuppressCleanupPolicy { + pub _address: u8, + } + pub const JustSuppressCleanupPolicy_assertHandled: bool = false; + pub const JustSuppressCleanupPolicy_suppress: bool = true; + #[test] + fn bindgen_test_layout_JustSuppressCleanupPolicy() { + assert_eq!(::std::mem::size_of::<JustSuppressCleanupPolicy>() + , 1usize); + assert_eq!(::std::mem::align_of::<JustSuppressCleanupPolicy>() + , 1usize); + } + impl Clone for JustSuppressCleanupPolicy { + fn clone(&self) -> Self { *self } + } + } + #[repr(C)] + #[derive(Debug, Copy)] pub struct ShortcutKeyCandidate { pub _address: u8, } @@ -2694,6 +2833,7 @@ pub mod root { pub mParsingMode: root::mozilla::css::SheetParsingMode, pub mType: root::StyleBackendType, pub mDisabled: bool, + pub mDocumentAssociationMode: root::mozilla::StyleSheet_DocumentAssociationMode, } pub type StyleSheet_HasThreadSafeRefCnt = root::mozilla::FalseType; #[repr(C)] @@ -2711,6 +2851,12 @@ pub mod root { impl Clone for StyleSheet_cycleCollection { fn clone(&self) -> Self { *self } } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleSheet_DocumentAssociationMode { + OwnedByDocument = 0, + NotOwnedByDocument = 1, + } extern "C" { #[link_name = "_ZN7mozilla10StyleSheet21_cycleCollectorGlobalE"] pub static mut StyleSheet__cycleCollectorGlobal: @@ -2718,7 +2864,7 @@ pub mod root { } #[test] fn bindgen_test_layout_StyleSheet() { - assert_eq!(::std::mem::size_of::<StyleSheet>() , 96usize); + assert_eq!(::std::mem::size_of::<StyleSheet>() , 104usize); assert_eq!(::std::mem::align_of::<StyleSheet>() , 8usize); } #[repr(C)] @@ -3145,7 +3291,7 @@ pub mod root { } #[repr(u8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] - pub enum StyleShapeRadius { FarthestSide = 0, ClosestSide = 1, } + pub enum StyleShapeRadius { ClosestSide = 0, FarthestSide = 1, } #[repr(u8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum StyleShapeSourceType { @@ -3431,7 +3577,7 @@ pub mod root { #[derive(Debug)] pub struct PropertyStyleAnimationValuePair { pub mProperty: root::nsCSSPropertyID, - pub mValue: [u64; 2usize], + pub mValue: root::mozilla::StyleAnimationValue, pub mServoValue: root::RefPtr<root::RawServoAnimationValue>, } #[test] @@ -3723,6 +3869,112 @@ pub mod root { root::mozilla::StyleShapeSource<root::mozilla::StyleGeometryBox>; pub type StyleShapeOutside = root::mozilla::StyleShapeSource<root::mozilla::StyleShapeOutsideShapeBox>; + /** + * Utility class to handle animated style values + */ + #[repr(C)] + #[derive(Debug, Copy)] + pub struct StyleAnimationValue { + pub _bindgen_opaque_blob: [u64; 2usize], + } + #[repr(u32)] + /** + * The types and values for the values that we extract and animate. + */ + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleAnimationValue_Unit { + eUnit_Null = 0, + eUnit_Normal = 1, + eUnit_Auto = 2, + eUnit_None = 3, + eUnit_Enumerated = 4, + eUnit_Visibility = 5, + eUnit_Integer = 6, + eUnit_Coord = 7, + eUnit_Percent = 8, + eUnit_Float = 9, + eUnit_Color = 10, + eUnit_CurrentColor = 11, + eUnit_ComplexColor = 12, + eUnit_Calc = 13, + eUnit_ObjectPosition = 14, + eUnit_URL = 15, + eUnit_DiscreteCSSValue = 16, + eUnit_CSSValuePair = 17, + eUnit_CSSValueTriplet = 18, + eUnit_CSSRect = 19, + eUnit_Dasharray = 20, + eUnit_Shadow = 21, + eUnit_Shape = 22, + eUnit_Filter = 23, + eUnit_Transform = 24, + eUnit_BackgroundPositionCoord = 25, + eUnit_CSSValuePairList = 26, + eUnit_UnparsedString = 27, + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct StyleAnimationValue__bindgen_ty_1 { + pub mInt: root::__BindgenUnionField<i32>, + pub mCoord: root::__BindgenUnionField<root::nscoord>, + pub mFloat: root::__BindgenUnionField<f32>, + pub mCSSValue: root::__BindgenUnionField<*mut root::nsCSSValue>, + pub mCSSValuePair: root::__BindgenUnionField<*mut root::nsCSSValuePair>, + pub mCSSValueTriplet: root::__BindgenUnionField<*mut root::nsCSSValueTriplet>, + pub mCSSRect: root::__BindgenUnionField<*mut root::nsCSSRect>, + pub mCSSValueArray: root::__BindgenUnionField<*mut root::nsCSSValue_Array>, + pub mCSSValueList: root::__BindgenUnionField<*mut root::nsCSSValueList>, + pub mCSSValueSharedList: root::__BindgenUnionField<*mut root::nsCSSValueSharedList>, + pub mCSSValuePairList: root::__BindgenUnionField<*mut root::nsCSSValuePairList>, + pub mString: root::__BindgenUnionField<*mut root::nsStringBuffer>, + pub mComplexColor: root::__BindgenUnionField<*mut root::mozilla::css::ComplexColorValue>, + pub bindgen_union_field: u64, + } + #[test] + fn bindgen_test_layout_StyleAnimationValue__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<StyleAnimationValue__bindgen_ty_1>() + , 8usize); + assert_eq!(::std::mem::align_of::<StyleAnimationValue__bindgen_ty_1>() + , 8usize); + } + impl Clone for StyleAnimationValue__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleAnimationValue_IntegerConstructorType { + IntegerConstructor = 0, + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleAnimationValue_CoordConstructorType { + CoordConstructor = 0, + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleAnimationValue_PercentConstructorType { + PercentConstructor = 0, + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleAnimationValue_FloatConstructorType { + FloatConstructor = 0, + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleAnimationValue_ColorConstructorType { + ColorConstructor = 0, + } + #[test] + fn bindgen_test_layout_StyleAnimationValue() { + assert_eq!(::std::mem::size_of::<StyleAnimationValue>() , + 16usize); + assert_eq!(::std::mem::align_of::<StyleAnimationValue>() , + 8usize); + } + impl Clone for StyleAnimationValue { + fn clone(&self) -> Self { *self } + } #[test] fn __bindgen_test_layout_template_2() { assert_eq!(::std::mem::size_of::<root::mozilla::StyleShapeSource<root::mozilla::StyleGeometryBox>>() @@ -3761,24 +4013,52 @@ pub mod root { } pub type pair_first_type<_T1> = _T1; pub type pair_second_type<_T2> = _T2; - pub type pair__PCCP = [u8; 0usize]; #[repr(C)] - #[derive(Debug)] pub struct atomic<_Tp> { - pub _M_i: _Tp, + pub _base: (), + pub _phantom_0: ::std::marker::PhantomData<_Tp>, } - pub mod namespace { - #[allow(unused_imports)] - use self::super::super::super::root; + pub type atomic___base = [u8; 0usize]; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct input_iterator_tag { + pub _address: u8, } - pub mod chrono { - #[allow(unused_imports)] - use self::super::super::super::root; + impl Clone for input_iterator_tag { + fn clone(&self) -> Self { *self } } - } - pub mod __gnu_cxx { - #[allow(unused_imports)] - use self::super::super::root; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct forward_iterator_tag { + pub _address: u8, + } + impl Clone for forward_iterator_tag { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct bidirectional_iterator_tag { + pub _address: u8, + } + impl Clone for bidirectional_iterator_tag { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct random_access_iterator_tag { + pub _address: u8, + } + impl Clone for random_access_iterator_tag { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct __bit_const_reference<_Cp> { + pub __seg_: root::std::__bit_const_reference___storage_pointer<_Cp>, + pub __mask_: root::std::__bit_const_reference___storage_type<_Cp>, + } + pub type __bit_const_reference___storage_type<_Cp> = _Cp; + pub type __bit_const_reference___storage_pointer<_Cp> = _Cp; } /** * MozRefCountType is Mozilla's reference count type. @@ -4334,6 +4614,146 @@ pub mod root { pub mod JS { #[allow(unused_imports)] use self::super::super::root; + /** + * JS::Value is the interface for a single JavaScript Engine value. A few + * general notes on JS::Value: + * + * - JS::Value has setX() and isX() members for X in + * + * { Int32, Double, String, Symbol, Boolean, Undefined, Null, Object, Magic } + * + * JS::Value also contains toX() for each of the non-singleton types. + * + * - Magic is a singleton type whose payload contains either a JSWhyMagic "reason" for + * the magic value or a uint32_t value. By providing JSWhyMagic values when + * creating and checking for magic values, it is possible to assert, at + * runtime, that only magic values with the expected reason flow through a + * particular value. For example, if cx->exception has a magic value, the + * reason must be JS_GENERATOR_CLOSING. + * + * - The JS::Value operations are preferred. The JSVAL_* operations remain for + * compatibility; they may be removed at some point. These operations mostly + * provide similar functionality. But there are a few key differences. One + * is that JS::Value gives null a separate type. + * Also, to help prevent mistakenly boxing a nullable JSObject* as an object, + * Value::setObject takes a JSObject&. (Conversely, Value::toObject returns a + * JSObject&.) A convenience member Value::setObjectOrNull is provided. + * + * - JSVAL_VOID is the same as the singleton value of the Undefined type. + * + * - Note that JS::Value is 8 bytes on 32 and 64-bit architectures. Thus, on + * 32-bit user code should avoid copying jsval/JS::Value as much as possible, + * preferring to pass by const Value&. + */ + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Value { + pub data: root::JS::Value_layout, + } + pub type Value_PayloadType = u64; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Value_layout { + pub asBits: root::__BindgenUnionField<u64>, + pub debugView: root::__BindgenUnionField<root::JS::Value_layout__bindgen_ty_1>, + pub s: root::__BindgenUnionField<root::JS::Value_layout__bindgen_ty_2>, + pub asDouble: root::__BindgenUnionField<f64>, + pub asPtr: root::__BindgenUnionField<*mut ::std::os::raw::c_void>, + pub asWord: root::__BindgenUnionField<usize>, + pub asUIntPtr: root::__BindgenUnionField<usize>, + pub bindgen_union_field: u64, + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Value_layout__bindgen_ty_1 { + pub _bitfield_1: u64, + } + #[test] + fn bindgen_test_layout_Value_layout__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<Value_layout__bindgen_ty_1>() , + 8usize); + assert_eq!(::std::mem::align_of::<Value_layout__bindgen_ty_1>() , + 8usize); + } + impl Clone for Value_layout__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + impl Value_layout__bindgen_ty_1 { + #[inline] + pub fn payload47(&self) -> u64 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & + (140737488355327usize as u64)) + >> 0u32) as u64) + } + } + #[inline] + pub fn set_payload47(&mut self, val: u64) { + self._bitfield_1 &= !(140737488355327usize as u64); + self._bitfield_1 |= + ((val as u64 as u64) << 0u32) & + (140737488355327usize as u64); + } + #[inline] + pub fn tag(&self) -> root::JSValueTag { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & + (18446603336221196288usize as + u64)) >> 47u32) as u32) + } + } + #[inline] + pub fn set_tag(&mut self, val: root::JSValueTag) { + self._bitfield_1 &= !(18446603336221196288usize as u64); + self._bitfield_1 |= + ((val as u32 as u64) << 47u32) & + (18446603336221196288usize as u64); + } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Value_layout__bindgen_ty_2 { + pub payload: root::JS::Value_layout__bindgen_ty_2__bindgen_ty_1, + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Value_layout__bindgen_ty_2__bindgen_ty_1 { + pub i32: root::__BindgenUnionField<i32>, + pub u32: root::__BindgenUnionField<u32>, + pub why: root::__BindgenUnionField<root::JSWhyMagic>, + pub bindgen_union_field: u32, + } + #[test] + fn bindgen_test_layout_Value_layout__bindgen_ty_2__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<Value_layout__bindgen_ty_2__bindgen_ty_1>() + , 4usize); + assert_eq!(::std::mem::align_of::<Value_layout__bindgen_ty_2__bindgen_ty_1>() + , 4usize); + } + impl Clone for Value_layout__bindgen_ty_2__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_Value_layout__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::<Value_layout__bindgen_ty_2>() , + 4usize); + assert_eq!(::std::mem::align_of::<Value_layout__bindgen_ty_2>() , + 4usize); + } + impl Clone for Value_layout__bindgen_ty_2 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_Value_layout() { + assert_eq!(::std::mem::size_of::<Value_layout>() , 8usize); + assert_eq!(::std::mem::align_of::<Value_layout>() , 8usize); + } + impl Clone for Value_layout { + fn clone(&self) -> Self { *self } + } + impl Clone for Value { + fn clone(&self) -> Self { *self } + } #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct DeletePolicy<T> { @@ -4461,6 +4881,11 @@ pub mod root { pub enum TenuredHeap__bindgen_ty_1 { maskBits = 0, } #[test] fn __bindgen_test_layout_template_4() { + assert_eq!(::std::mem::size_of::<[u64; 3usize]>() , 24usize); + assert_eq!(::std::mem::align_of::<[u64; 3usize]>() , 8usize); + } + #[test] + fn __bindgen_test_layout_template_5() { assert_eq!(::std::mem::size_of::<root::mozilla::UniquePtr<*mut ::std::os::raw::c_char, root::JS::FreePolicy>>() , 8usize); @@ -4538,6 +4963,42 @@ pub mod root { impl Clone for JSCompartment { fn clone(&self) -> Self { *self } } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum JSValueTag { + JSVAL_TAG_MAX_DOUBLE = 131056, + JSVAL_TAG_INT32 = 131057, + JSVAL_TAG_UNDEFINED = 131058, + JSVAL_TAG_NULL = 131059, + JSVAL_TAG_BOOLEAN = 131060, + JSVAL_TAG_MAGIC = 131061, + JSVAL_TAG_STRING = 131062, + JSVAL_TAG_SYMBOL = 131063, + JSVAL_TAG_PRIVATE_GCTHING = 131064, + JSVAL_TAG_OBJECT = 131068, + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum JSWhyMagic { + JS_ELEMENTS_HOLE = 0, + JS_NO_ITER_VALUE = 1, + JS_GENERATOR_CLOSING = 2, + JS_NO_CONSTANT = 3, + JS_THIS_POISON = 4, + JS_ARG_POISON = 5, + JS_SERIALIZE_NO_NODE = 6, + JS_LAZY_ARGUMENTS = 7, + JS_OPTIMIZED_ARGUMENTS = 8, + JS_IS_CONSTRUCTING = 9, + JS_BLOCK_NEEDS_CLONE = 10, + JS_HASH_KEY_EMPTY = 11, + JS_ION_ERROR = 12, + JS_ION_BAILOUT = 13, + JS_OPTIMIZED_OUT = 14, + JS_UNINITIALIZED_LEXICAL = 15, + JS_GENERIC_MAGIC = 16, + JS_WHY_MAGIC_COUNT = 17, + } #[repr(C)] #[derive(Debug)] pub struct nsAString_internal { @@ -4866,13 +5327,13 @@ pub mod root { pub _phantom_0: ::std::marker::PhantomData<CharT>, } #[test] - fn __bindgen_test_layout_template_5() { + fn __bindgen_test_layout_template_6() { assert_eq!(::std::mem::size_of::<root::nsCharTraits<u16>>() , 1usize); assert_eq!(::std::mem::align_of::<root::nsCharTraits<u16>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_6() { + fn __bindgen_test_layout_template_7() { assert_eq!(::std::mem::size_of::<root::nsCharTraits<::std::os::raw::c_char>>() , 1usize); assert_eq!(::std::mem::align_of::<root::nsCharTraits<::std::os::raw::c_char>>() @@ -5089,7 +5550,7 @@ pub mod root { pub mRawPtr: *mut root::nsISupports, } #[test] - fn __bindgen_test_layout_template_7() { + fn __bindgen_test_layout_template_8() { assert_eq!(::std::mem::size_of::<root::nsCOMPtr<root::nsISupports>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsCOMPtr<root::nsISupports>>() @@ -5594,7 +6055,7 @@ pub mod root { pub _base_1: root::mozilla::dom::DispatcherTrait, pub mDeprecationWarnedAbout: u64, pub mDocWarningWarnedAbout: u64, - pub mSelectorCache: [u64; 16usize], + pub mSelectorCache: root::nsIDocument_SelectorCache, pub mReferrer: root::nsCString, pub mLastModified: ::nsstring::nsStringRepr, pub mDocumentURI: root::nsCOMPtr<root::nsIURI>, @@ -5756,7 +6217,7 @@ pub mod root { fn clone(&self) -> Self { *self } } #[repr(C)] - #[derive(Debug)] + #[derive(Debug, Copy)] pub struct nsIDocument_SelectorCache { pub _bindgen_opaque_blob: [u64; 16usize], } @@ -5767,6 +6228,9 @@ pub mod root { assert_eq!(::std::mem::align_of::<nsIDocument_SelectorCache>() , 8usize); } + impl Clone for nsIDocument_SelectorCache { + fn clone(&self) -> Self { *self } + } #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum nsIDocument_additionalSheetType { @@ -7024,6 +7488,20 @@ pub mod root { eCompatibility_AlmostStandards = 2, eCompatibility_NavQuirks = 3, } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct gfxSize { + pub _bindgen_opaque_blob: [u64; 2usize], + } + pub type gfxSize_Super = [u64; 2usize]; + #[test] + fn bindgen_test_layout_gfxSize() { + assert_eq!(::std::mem::size_of::<gfxSize>() , 16usize); + assert_eq!(::std::mem::align_of::<gfxSize>() , 8usize); + } + impl Clone for gfxSize { + fn clone(&self) -> Self { *self } + } pub type nscolor = u32; #[repr(C)] #[derive(Debug)] @@ -7053,7 +7531,7 @@ pub mod root { pub mTextZoom: f32, pub mFullZoom: f32, pub mOverrideDPPX: f32, - pub mLastFontInflationScreenSize: [u64; 2usize], + pub mLastFontInflationScreenSize: root::gfxSize, pub mCurAppUnitsPerDevPixel: i32, pub mAutoQualityMinFontSizePixelsPref: i32, pub mTheme: root::nsCOMPtr<root::nsITheme>, @@ -8311,7 +8789,7 @@ pub mod root { root::mozilla::dom::OwningNodeOrString; pub type nsINode_TextOrElementOrDocument = root::mozilla::dom::TextOrElementOrDocument; - pub type nsINode_ErrorResult = [u64; 4usize]; + pub type nsINode_ErrorResult = root::mozilla::ErrorResult; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct nsINode_COMTypeInfo<T, U> { @@ -8522,7 +9000,7 @@ pub mod root { pub mArray: root::nsTArray<root::nsAutoPtr<root::nsMediaQuery>>, pub mStyleSheet: *mut root::mozilla::StyleSheet, } - pub type nsMediaList_ErrorResult = [u64; 4usize]; + pub type nsMediaList_ErrorResult = root::mozilla::ErrorResult; pub type nsMediaList_HasThreadSafeRefCnt = root::mozilla::FalseType; #[repr(C)] #[derive(Debug, Copy)] @@ -8774,7 +9252,7 @@ pub mod root { } pub type nsDOMAttributeMap_Attr = root::mozilla::dom::Attr; pub type nsDOMAttributeMap_Element = root::mozilla::dom::Element; - pub type nsDOMAttributeMap_ErrorResult = [u64; 4usize]; + pub type nsDOMAttributeMap_ErrorResult = root::mozilla::ErrorResult; pub type nsDOMAttributeMap_HasThreadSafeRefCnt = root::mozilla::FalseType; #[repr(C)] #[derive(Debug, Copy)] @@ -9317,63 +9795,63 @@ pub mod root { impl Clone for nsDOMMutationObserver { fn clone(&self) -> Self { *self } } - pub const NODE_HAS_LISTENERMANAGER: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_HAS_LISTENERMANAGER; - pub const NODE_HAS_PROPERTIES: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_HAS_PROPERTIES; - pub const NODE_IS_ANONYMOUS_ROOT: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_IS_ANONYMOUS_ROOT; - pub const NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE; - pub const NODE_IS_NATIVE_ANONYMOUS_ROOT: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_IS_NATIVE_ANONYMOUS_ROOT; - pub const NODE_FORCE_XBL_BINDINGS: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_FORCE_XBL_BINDINGS; - pub const NODE_MAY_BE_IN_BINDING_MNGR: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_MAY_BE_IN_BINDING_MNGR; - pub const NODE_IS_EDITABLE: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_IS_EDITABLE; - pub const NODE_MAY_HAVE_CLASS: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_MAY_HAVE_CLASS; - pub const NODE_IS_IN_SHADOW_TREE: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_IS_IN_SHADOW_TREE; - pub const NODE_HAS_EMPTY_SELECTOR: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_HAS_EMPTY_SELECTOR; - pub const NODE_HAS_SLOW_SELECTOR: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_HAS_SLOW_SELECTOR; - pub const NODE_HAS_EDGE_CHILD_SELECTOR: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_HAS_EDGE_CHILD_SELECTOR; - pub const NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS; - pub const NODE_ALL_SELECTOR_FLAGS: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_ALL_SELECTOR_FLAGS; - pub const NODE_NEEDS_FRAME: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_NEEDS_FRAME; - pub const NODE_DESCENDANTS_NEED_FRAMES: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_DESCENDANTS_NEED_FRAMES; - pub const NODE_HAS_ACCESSKEY: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_HAS_ACCESSKEY; - pub const NODE_HAS_DIRECTION_RTL: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_HAS_DIRECTION_RTL; - pub const NODE_HAS_DIRECTION_LTR: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_HAS_DIRECTION_LTR; - pub const NODE_ALL_DIRECTION_FLAGS: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_ALL_DIRECTION_FLAGS; - pub const NODE_CHROME_ONLY_ACCESS: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_CHROME_ONLY_ACCESS; - pub const NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS; - pub const NODE_SHARED_RESTYLE_BIT_1: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_SHARED_RESTYLE_BIT_1; - pub const NODE_SHARED_RESTYLE_BIT_2: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_SHARED_RESTYLE_BIT_2; - pub const NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_SHARED_RESTYLE_BIT_1; - pub const NODE_TYPE_SPECIFIC_BITS_OFFSET: root::_bindgen_ty_137 = - _bindgen_ty_137::NODE_TYPE_SPECIFIC_BITS_OFFSET; + pub const NODE_HAS_LISTENERMANAGER: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_LISTENERMANAGER; + pub const NODE_HAS_PROPERTIES: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_PROPERTIES; + pub const NODE_IS_ANONYMOUS_ROOT: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_IS_ANONYMOUS_ROOT; + pub const NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE; + pub const NODE_IS_NATIVE_ANONYMOUS_ROOT: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_IS_NATIVE_ANONYMOUS_ROOT; + pub const NODE_FORCE_XBL_BINDINGS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_FORCE_XBL_BINDINGS; + pub const NODE_MAY_BE_IN_BINDING_MNGR: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_MAY_BE_IN_BINDING_MNGR; + pub const NODE_IS_EDITABLE: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_IS_EDITABLE; + pub const NODE_MAY_HAVE_CLASS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_MAY_HAVE_CLASS; + pub const NODE_IS_IN_SHADOW_TREE: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_IS_IN_SHADOW_TREE; + pub const NODE_HAS_EMPTY_SELECTOR: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_EMPTY_SELECTOR; + pub const NODE_HAS_SLOW_SELECTOR: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_SLOW_SELECTOR; + pub const NODE_HAS_EDGE_CHILD_SELECTOR: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_EDGE_CHILD_SELECTOR; + pub const NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS; + pub const NODE_ALL_SELECTOR_FLAGS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_ALL_SELECTOR_FLAGS; + pub const NODE_NEEDS_FRAME: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_NEEDS_FRAME; + pub const NODE_DESCENDANTS_NEED_FRAMES: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_DESCENDANTS_NEED_FRAMES; + pub const NODE_HAS_ACCESSKEY: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_ACCESSKEY; + pub const NODE_HAS_DIRECTION_RTL: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_DIRECTION_RTL; + pub const NODE_HAS_DIRECTION_LTR: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_DIRECTION_LTR; + pub const NODE_ALL_DIRECTION_FLAGS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_ALL_DIRECTION_FLAGS; + pub const NODE_CHROME_ONLY_ACCESS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_CHROME_ONLY_ACCESS; + pub const NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS; + pub const NODE_SHARED_RESTYLE_BIT_1: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_SHARED_RESTYLE_BIT_1; + pub const NODE_SHARED_RESTYLE_BIT_2: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_SHARED_RESTYLE_BIT_2; + pub const NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_SHARED_RESTYLE_BIT_1; + pub const NODE_TYPE_SPECIFIC_BITS_OFFSET: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_TYPE_SPECIFIC_BITS_OFFSET; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] - pub enum _bindgen_ty_137 { + pub enum _bindgen_ty_34 { NODE_HAS_LISTENERMANAGER = 4, NODE_HAS_PROPERTIES = 8, NODE_IS_ANONYMOUS_ROOT = 16, @@ -10192,21 +10670,21 @@ pub mod root { } #[repr(C)] #[derive(Debug, Copy)] - pub struct _bindgen_ty_25 { + pub struct _bindgen_ty_10 { pub mInt: root::__BindgenUnionField<i32>, pub mFloat: root::__BindgenUnionField<f32>, pub mPointer: root::__BindgenUnionField<*mut ::std::os::raw::c_void>, pub bindgen_union_field: u64, } #[test] - fn bindgen_test_layout__bindgen_ty_25() { - assert_eq!(::std::mem::size_of::<_bindgen_ty_25>() , 8usize); - assert_eq!(::std::mem::align_of::<_bindgen_ty_25>() , 8usize); + fn bindgen_test_layout__bindgen_ty_10() { + assert_eq!(::std::mem::size_of::<_bindgen_ty_10>() , 8usize); + assert_eq!(::std::mem::align_of::<_bindgen_ty_10>() , 8usize); } - impl Clone for _bindgen_ty_25 { + impl Clone for _bindgen_ty_10 { fn clone(&self) -> Self { *self } } - pub type nsStyleUnion = root::_bindgen_ty_25; + pub type nsStyleUnion = root::_bindgen_ty_10; /** * Class that hold a single size specification used by the style * system. The size specification consists of two parts -- a number @@ -13211,7 +13689,7 @@ pub mod root { assert_eq!(::std::mem::align_of::<nsCSSValueFloatColor>() , 8usize); } #[test] - fn __bindgen_test_layout_template_8() { + fn __bindgen_test_layout_template_9() { assert_eq!(::std::mem::size_of::<root::mozilla::UniquePtr<root::nsCSSValueList, root::mozilla::DefaultDelete<root::nsCSSValueList>>>() , 8usize); @@ -13220,7 +13698,7 @@ pub mod root { , 8usize); } #[test] - fn __bindgen_test_layout_template_9() { + fn __bindgen_test_layout_template_10() { assert_eq!(::std::mem::size_of::<root::mozilla::UniquePtr<root::nsCSSValuePairList, root::mozilla::DefaultDelete<root::nsCSSValuePairList>>>() , 8usize); @@ -13602,7 +14080,7 @@ pub mod root { assert_eq!(::std::mem::align_of::<CachedBorderImageData>() , 8usize); } #[test] - fn __bindgen_test_layout_template_10() { + fn __bindgen_test_layout_template_11() { assert_eq!(::std::mem::size_of::<root::mozilla::UniquePtr<root::nsStyleSides, root::mozilla::DefaultDelete<root::nsStyleSides>>>() , 8usize); @@ -14847,8 +15325,7 @@ pub mod root { aFeature: *const root::nsMediaFeature, aResult: - *mut root::nsCSSValue) - -> root::nsresult>; + *mut root::nsCSSValue)>; #[repr(C)] #[derive(Debug, Copy)] pub struct nsMediaFeatures { @@ -14897,201 +15374,247 @@ pub mod root { assert_eq!(::std::mem::align_of::<nsMediaQuery>() , 8usize); } #[test] - fn __bindgen_test_layout_template_11() { + fn __bindgen_test_layout_template_12() { assert_eq!(::std::mem::size_of::<root::JS::TenuredHeap<*mut root::JSObject>>() , 8usize); assert_eq!(::std::mem::align_of::<root::JS::TenuredHeap<*mut root::JSObject>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_12() { + fn __bindgen_test_layout_template_13() { assert_eq!(::std::mem::size_of::<root::JS::Heap<*mut root::JSObject>>() , 8usize); assert_eq!(::std::mem::align_of::<root::JS::Heap<*mut root::JSObject>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_13() { + fn __bindgen_test_layout_template_14() { assert_eq!(::std::mem::size_of::<root::nsTArray<root::nsCString>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<root::nsCString>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_14() { + fn __bindgen_test_layout_template_15() { + assert_eq!(::std::mem::size_of::<root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::AssertAndSuppressCleanupPolicy>>() + , 32usize); + assert_eq!(::std::mem::align_of::<root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::AssertAndSuppressCleanupPolicy>>() + , 8usize); + } + #[test] + fn __bindgen_test_layout_template_16() { + assert_eq!(::std::mem::size_of::<root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::JustSuppressCleanupPolicy>>() + , 32usize); + assert_eq!(::std::mem::align_of::<root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::JustSuppressCleanupPolicy>>() + , 8usize); + } + #[test] + fn __bindgen_test_layout_template_17() { + assert_eq!(::std::mem::size_of::<root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::JustAssertCleanupPolicy>>() + , 32usize); + assert_eq!(::std::mem::align_of::<root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::JustAssertCleanupPolicy>>() + , 8usize); + } + #[test] + fn __bindgen_test_layout_template_18() { assert_eq!(::std::mem::size_of::<root::nsCOMPtr<root::nsIPrincipal>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsCOMPtr<root::nsIPrincipal>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_15() { + fn __bindgen_test_layout_template_19() { + assert_eq!(::std::mem::size_of::<[u64; 29usize]>() , 232usize); + assert_eq!(::std::mem::align_of::<[u64; 29usize]>() , 8usize); + } + #[test] + fn __bindgen_test_layout_template_20() { assert_eq!(::std::mem::size_of::<root::RefPtr<root::mozilla::dom::Element>>() , 8usize); assert_eq!(::std::mem::align_of::<root::RefPtr<root::mozilla::dom::Element>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_16() { + fn __bindgen_test_layout_template_21() { assert_eq!(::std::mem::size_of::<root::nsTArray<root::RefPtr<root::mozilla::dom::Element>>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<root::RefPtr<root::mozilla::dom::Element>>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_17() { + fn __bindgen_test_layout_template_22() { assert_eq!(::std::mem::size_of::<root::nsCOMPtr<root::nsIObserver>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsCOMPtr<root::nsIObserver>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_18() { + fn __bindgen_test_layout_template_23() { assert_eq!(::std::mem::size_of::<root::nsCOMPtr<root::nsIWeakReference>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsCOMPtr<root::nsIWeakReference>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_19() { + fn __bindgen_test_layout_template_24() { + assert_eq!(::std::mem::size_of::<u64>() , 8usize); + assert_eq!(::std::mem::align_of::<u64>() , 8usize); + } + #[test] + fn __bindgen_test_layout_template_25() { assert_eq!(::std::mem::size_of::<root::nsTArray<*mut root::nsIContent>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<*mut root::nsIContent>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_20() { + fn __bindgen_test_layout_template_26() { assert_eq!(::std::mem::size_of::<root::nsTArray<::nsstring::nsStringRepr>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<::nsstring::nsStringRepr>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_21() { + fn __bindgen_test_layout_template_27() { + assert_eq!(::std::mem::size_of::<[u64; 6usize]>() , 48usize); + assert_eq!(::std::mem::align_of::<[u64; 6usize]>() , 8usize); + } + #[test] + fn __bindgen_test_layout_template_28() { assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::mozilla::dom::TimeoutManager>>() , 1usize); assert_eq!(::std::mem::align_of::<root::mozilla::DefaultDelete<root::mozilla::dom::TimeoutManager>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_22() { + fn __bindgen_test_layout_template_29() { assert_eq!(::std::mem::size_of::<root::nsCOMPtr<root::nsIRunnable>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsCOMPtr<root::nsIRunnable>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_23() { + fn __bindgen_test_layout_template_30() { assert_eq!(::std::mem::size_of::<root::nsAutoPtr<root::nsMediaQuery>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsAutoPtr<root::nsMediaQuery>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_24() { + fn __bindgen_test_layout_template_31() { assert_eq!(::std::mem::size_of::<root::mozilla::OwningNonNull<root::nsINode>>() , 16usize); assert_eq!(::std::mem::align_of::<root::mozilla::OwningNonNull<root::nsINode>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_25() { + fn __bindgen_test_layout_template_32() { assert_eq!(::std::mem::size_of::<root::nsTArray<f64>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<f64>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_26() { + fn __bindgen_test_layout_template_33() { assert_eq!(::std::mem::size_of::<root::RefPtr<root::mozilla::dom::DOMIntersectionObserverEntry>>() , 8usize); assert_eq!(::std::mem::align_of::<root::RefPtr<root::mozilla::dom::DOMIntersectionObserverEntry>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_27() { + fn __bindgen_test_layout_template_34() { assert_eq!(::std::mem::size_of::<root::nsTArray<root::RefPtr<root::mozilla::dom::DOMIntersectionObserverEntry>>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<root::RefPtr<root::mozilla::dom::DOMIntersectionObserverEntry>>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_28() { + fn __bindgen_test_layout_template_35() { assert_eq!(::std::mem::size_of::<root::nsMainThreadPtrHolder<root::nsIURI>>() , 24usize); assert_eq!(::std::mem::align_of::<root::nsMainThreadPtrHolder<root::nsIURI>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_29() { + fn __bindgen_test_layout_template_36() { assert_eq!(::std::mem::size_of::<root::nsMainThreadPtrHolder<root::nsIPrincipal>>() , 24usize); assert_eq!(::std::mem::align_of::<root::nsMainThreadPtrHolder<root::nsIPrincipal>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_30() { + fn __bindgen_test_layout_template_37() { assert_eq!(::std::mem::size_of::<root::nsPtrHashKey<root::nsIFrame>>() , 16usize); assert_eq!(::std::mem::align_of::<root::nsPtrHashKey<root::nsIFrame>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_31() { + fn __bindgen_test_layout_template_38() { assert_eq!(::std::mem::size_of::<root::nsTArray<root::mozilla::DisplayItemClip_RoundedRect>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<root::mozilla::DisplayItemClip_RoundedRect>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_32() { + fn __bindgen_test_layout_template_39() { assert_eq!(::std::mem::size_of::<root::RefPtr<root::mozilla::dom::DOMRect>>() , 8usize); assert_eq!(::std::mem::align_of::<root::RefPtr<root::mozilla::dom::DOMRect>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_33() { + fn __bindgen_test_layout_template_40() { assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::ProxyBehaviour>>() , 1usize); assert_eq!(::std::mem::align_of::<root::mozilla::DefaultDelete<root::ProxyBehaviour>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_34() { + fn __bindgen_test_layout_template_41() { assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::nsCSSValueList>>() , 1usize); assert_eq!(::std::mem::align_of::<root::mozilla::DefaultDelete<root::nsCSSValueList>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_35() { + fn __bindgen_test_layout_template_42() { assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::nsCSSValuePairList>>() , 1usize); assert_eq!(::std::mem::align_of::<root::mozilla::DefaultDelete<root::nsCSSValuePairList>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_36() { + fn __bindgen_test_layout_template_43() { + assert_eq!(::std::mem::size_of::<u64>() , 8usize); + assert_eq!(::std::mem::align_of::<u64>() , 8usize); + } + #[test] + fn __bindgen_test_layout_template_44() { + assert_eq!(::std::mem::size_of::<[u64; 2usize]>() , 16usize); + assert_eq!(::std::mem::align_of::<[u64; 2usize]>() , 8usize); + } + #[test] + fn __bindgen_test_layout_template_45() { assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::nsStyleSides>>() , 1usize); assert_eq!(::std::mem::align_of::<root::mozilla::DefaultDelete<root::nsStyleSides>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_37() { + fn __bindgen_test_layout_template_46() { assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::CachedBorderImageData>>() , 1usize); assert_eq!(::std::mem::align_of::<root::mozilla::DefaultDelete<root::CachedBorderImageData>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_38() { + fn __bindgen_test_layout_template_47() { assert_eq!(::std::mem::size_of::<root::std::pair<::nsstring::nsStringRepr, ::nsstring::nsStringRepr>>() , 32usize); assert_eq!(::std::mem::align_of::<root::std::pair<::nsstring::nsStringRepr, ::nsstring::nsStringRepr>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_39() { + fn __bindgen_test_layout_template_48() { assert_eq!(::std::mem::size_of::<root::nsTArray<*mut root::mozilla::css::DocumentRule>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<*mut root::mozilla::css::DocumentRule>>() diff --git a/components/style/gecko_bindings/structs_release.rs b/components/style/gecko_bindings/structs_release.rs index 89bef397c47..1c2bc868a04 100644 --- a/components/style/gecko_bindings/structs_release.rs +++ b/components/style/gecko_bindings/structs_release.rs @@ -994,7 +994,6 @@ pub mod root { pub const NS_STYLE_DISPLAY_MODE_BROWSER: ::std::os::raw::c_uint = 0; pub const NS_STYLE_DISPLAY_MODE_MINIMAL_UI: ::std::os::raw::c_uint = 1; pub const NS_STYLE_DISPLAY_MODE_STANDALONE: ::std::os::raw::c_uint = 2; - pub const NS_STYLE_DISPLAY_MODE_FULLSCREEN: ::std::os::raw::c_uint = 3; pub const NS_STYLE_INHERIT_MASK: ::std::os::raw::c_uint = 16777215; pub const NS_STYLE_HAS_TEXT_DECORATION_LINES: ::std::os::raw::c_uint = 16777216; @@ -1454,7 +1453,6 @@ pub mod root { * conceptual! */ #[repr(C)] - #[derive(Debug, Copy, Clone)] pub struct Pair<A, B> { pub _address: u8, pub _phantom_0: ::std::marker::PhantomData<A>, @@ -1626,6 +1624,10 @@ pub mod root { pub mod dom { #[allow(unused_imports)] use self::super::super::super::root; + pub mod binding_detail { + #[allow(unused_imports)] + use self::super::super::super::super::root; + } #[repr(C)] #[derive(Debug, Copy)] pub struct AllOwningUnionBase { @@ -1835,6 +1837,18 @@ pub mod root { eRethrowExceptions = 2, } #[repr(C)] + #[derive(Debug)] + pub struct CallbackObject_JSObjectsDropper { + pub mHolder: root::RefPtr<root::mozilla::dom::CallbackObject>, + } + #[test] + fn bindgen_test_layout_CallbackObject_JSObjectsDropper() { + assert_eq!(::std::mem::size_of::<CallbackObject_JSObjectsDropper>() + , 8usize); + assert_eq!(::std::mem::align_of::<CallbackObject_JSObjectsDropper>() + , 8usize); + } + #[repr(C)] #[derive(Debug, Copy)] pub struct CallbackObject_FastCallbackConstructor { pub _address: u8, @@ -1860,7 +1874,7 @@ pub mod root { pub mAsyncStack: [u64; 4usize], pub mAsyncStackSetter: [u64; 7usize], pub mAc: [u64; 3usize], - pub mErrorResult: *mut [u64; 2usize], + pub mErrorResult: *mut root::mozilla::ErrorResult, pub mExceptionHandling: root::mozilla::dom::CallbackObject_ExceptionHandling, pub mIsMainThread: bool, } @@ -2452,6 +2466,116 @@ pub mod root { } #[repr(C)] #[derive(Debug, Copy)] + pub struct ErrorResult { + pub _bindgen_opaque_blob: [u64; 2usize], + } + pub type ErrorResult_BaseErrorResult = + root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::AssertAndSuppressCleanupPolicy>; + #[test] + fn bindgen_test_layout_ErrorResult() { + assert_eq!(::std::mem::size_of::<ErrorResult>() , 16usize); + assert_eq!(::std::mem::align_of::<ErrorResult>() , 8usize); + } + impl Clone for ErrorResult { + fn clone(&self) -> Self { *self } + } + pub mod binding_danger { + #[allow(unused_imports)] + use self::super::super::super::root; + /** + * Templated implementation class for various ErrorResult-like things. The + * instantiations differ only in terms of their cleanup policies (used in the + * destructor), which they can specify via the template argument. Note that + * this means it's safe to reinterpret_cast between the instantiations unless + * you plan to invoke the destructor through such a cast pointer. + * + * A cleanup policy consists of two booleans: whether to assert that we've been + * reported or suppressed, and whether to then go ahead and suppress the + * exception. + */ + #[repr(C)] + #[derive(Debug)] + pub struct TErrorResult<CleanupPolicy> { + pub mResult: root::nsresult, + pub __bindgen_anon_1: root::mozilla::binding_danger::TErrorResult__bindgen_ty_1<CleanupPolicy>, + pub _phantom_0: ::std::marker::PhantomData<CleanupPolicy>, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct TErrorResult_Message<CleanupPolicy> { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<CleanupPolicy>, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct TErrorResult_DOMExceptionInfo<CleanupPolicy> { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<CleanupPolicy>, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct TErrorResult__bindgen_ty_1<CleanupPolicy> { + pub mMessage: root::__BindgenUnionField<*mut root::mozilla::binding_danger::TErrorResult_Message<CleanupPolicy>>, + pub mJSException: root::__BindgenUnionField<root::JS::Value>, + pub mDOMExceptionInfo: root::__BindgenUnionField<*mut root::mozilla::binding_danger::TErrorResult_DOMExceptionInfo<CleanupPolicy>>, + pub bindgen_union_field: u64, + pub _phantom_0: ::std::marker::PhantomData<CleanupPolicy>, + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct JustAssertCleanupPolicy { + pub _address: u8, + } + pub const JustAssertCleanupPolicy_assertHandled: bool = true; + pub const JustAssertCleanupPolicy_suppress: bool = false; + #[test] + fn bindgen_test_layout_JustAssertCleanupPolicy() { + assert_eq!(::std::mem::size_of::<JustAssertCleanupPolicy>() , + 1usize); + assert_eq!(::std::mem::align_of::<JustAssertCleanupPolicy>() , + 1usize); + } + impl Clone for JustAssertCleanupPolicy { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct AssertAndSuppressCleanupPolicy { + pub _address: u8, + } + pub const AssertAndSuppressCleanupPolicy_assertHandled: bool = + true; + pub const AssertAndSuppressCleanupPolicy_suppress: bool = true; + #[test] + fn bindgen_test_layout_AssertAndSuppressCleanupPolicy() { + assert_eq!(::std::mem::size_of::<AssertAndSuppressCleanupPolicy>() + , 1usize); + assert_eq!(::std::mem::align_of::<AssertAndSuppressCleanupPolicy>() + , 1usize); + } + impl Clone for AssertAndSuppressCleanupPolicy { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct JustSuppressCleanupPolicy { + pub _address: u8, + } + pub const JustSuppressCleanupPolicy_assertHandled: bool = false; + pub const JustSuppressCleanupPolicy_suppress: bool = true; + #[test] + fn bindgen_test_layout_JustSuppressCleanupPolicy() { + assert_eq!(::std::mem::size_of::<JustSuppressCleanupPolicy>() + , 1usize); + assert_eq!(::std::mem::align_of::<JustSuppressCleanupPolicy>() + , 1usize); + } + impl Clone for JustSuppressCleanupPolicy { + fn clone(&self) -> Self { *self } + } + } + #[repr(C)] + #[derive(Debug, Copy)] pub struct ShortcutKeyCandidate { pub _address: u8, } @@ -2681,6 +2805,7 @@ pub mod root { pub mParsingMode: root::mozilla::css::SheetParsingMode, pub mType: root::StyleBackendType, pub mDisabled: bool, + pub mDocumentAssociationMode: root::mozilla::StyleSheet_DocumentAssociationMode, } pub type StyleSheet_HasThreadSafeRefCnt = root::mozilla::FalseType; #[repr(C)] @@ -2698,6 +2823,12 @@ pub mod root { impl Clone for StyleSheet_cycleCollection { fn clone(&self) -> Self { *self } } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleSheet_DocumentAssociationMode { + OwnedByDocument = 0, + NotOwnedByDocument = 1, + } extern "C" { #[link_name = "_ZN7mozilla10StyleSheet21_cycleCollectorGlobalE"] pub static mut StyleSheet__cycleCollectorGlobal: @@ -2705,7 +2836,7 @@ pub mod root { } #[test] fn bindgen_test_layout_StyleSheet() { - assert_eq!(::std::mem::size_of::<StyleSheet>() , 88usize); + assert_eq!(::std::mem::size_of::<StyleSheet>() , 96usize); assert_eq!(::std::mem::align_of::<StyleSheet>() , 8usize); } #[repr(C)] @@ -3132,7 +3263,7 @@ pub mod root { } #[repr(u8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] - pub enum StyleShapeRadius { FarthestSide = 0, ClosestSide = 1, } + pub enum StyleShapeRadius { ClosestSide = 0, FarthestSide = 1, } #[repr(u8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum StyleShapeSourceType { @@ -3417,7 +3548,7 @@ pub mod root { #[derive(Debug)] pub struct PropertyStyleAnimationValuePair { pub mProperty: root::nsCSSPropertyID, - pub mValue: [u64; 2usize], + pub mValue: root::mozilla::StyleAnimationValue, pub mServoValue: root::RefPtr<root::RawServoAnimationValue>, } #[test] @@ -3709,6 +3840,112 @@ pub mod root { root::mozilla::StyleShapeSource<root::mozilla::StyleGeometryBox>; pub type StyleShapeOutside = root::mozilla::StyleShapeSource<root::mozilla::StyleShapeOutsideShapeBox>; + /** + * Utility class to handle animated style values + */ + #[repr(C)] + #[derive(Debug, Copy)] + pub struct StyleAnimationValue { + pub _bindgen_opaque_blob: [u64; 2usize], + } + #[repr(u32)] + /** + * The types and values for the values that we extract and animate. + */ + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleAnimationValue_Unit { + eUnit_Null = 0, + eUnit_Normal = 1, + eUnit_Auto = 2, + eUnit_None = 3, + eUnit_Enumerated = 4, + eUnit_Visibility = 5, + eUnit_Integer = 6, + eUnit_Coord = 7, + eUnit_Percent = 8, + eUnit_Float = 9, + eUnit_Color = 10, + eUnit_CurrentColor = 11, + eUnit_ComplexColor = 12, + eUnit_Calc = 13, + eUnit_ObjectPosition = 14, + eUnit_URL = 15, + eUnit_DiscreteCSSValue = 16, + eUnit_CSSValuePair = 17, + eUnit_CSSValueTriplet = 18, + eUnit_CSSRect = 19, + eUnit_Dasharray = 20, + eUnit_Shadow = 21, + eUnit_Shape = 22, + eUnit_Filter = 23, + eUnit_Transform = 24, + eUnit_BackgroundPositionCoord = 25, + eUnit_CSSValuePairList = 26, + eUnit_UnparsedString = 27, + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct StyleAnimationValue__bindgen_ty_1 { + pub mInt: root::__BindgenUnionField<i32>, + pub mCoord: root::__BindgenUnionField<root::nscoord>, + pub mFloat: root::__BindgenUnionField<f32>, + pub mCSSValue: root::__BindgenUnionField<*mut root::nsCSSValue>, + pub mCSSValuePair: root::__BindgenUnionField<*mut root::nsCSSValuePair>, + pub mCSSValueTriplet: root::__BindgenUnionField<*mut root::nsCSSValueTriplet>, + pub mCSSRect: root::__BindgenUnionField<*mut root::nsCSSRect>, + pub mCSSValueArray: root::__BindgenUnionField<*mut root::nsCSSValue_Array>, + pub mCSSValueList: root::__BindgenUnionField<*mut root::nsCSSValueList>, + pub mCSSValueSharedList: root::__BindgenUnionField<*mut root::nsCSSValueSharedList>, + pub mCSSValuePairList: root::__BindgenUnionField<*mut root::nsCSSValuePairList>, + pub mString: root::__BindgenUnionField<*mut root::nsStringBuffer>, + pub mComplexColor: root::__BindgenUnionField<*mut root::mozilla::css::ComplexColorValue>, + pub bindgen_union_field: u64, + } + #[test] + fn bindgen_test_layout_StyleAnimationValue__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<StyleAnimationValue__bindgen_ty_1>() + , 8usize); + assert_eq!(::std::mem::align_of::<StyleAnimationValue__bindgen_ty_1>() + , 8usize); + } + impl Clone for StyleAnimationValue__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleAnimationValue_IntegerConstructorType { + IntegerConstructor = 0, + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleAnimationValue_CoordConstructorType { + CoordConstructor = 0, + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleAnimationValue_PercentConstructorType { + PercentConstructor = 0, + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleAnimationValue_FloatConstructorType { + FloatConstructor = 0, + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StyleAnimationValue_ColorConstructorType { + ColorConstructor = 0, + } + #[test] + fn bindgen_test_layout_StyleAnimationValue() { + assert_eq!(::std::mem::size_of::<StyleAnimationValue>() , + 16usize); + assert_eq!(::std::mem::align_of::<StyleAnimationValue>() , + 8usize); + } + impl Clone for StyleAnimationValue { + fn clone(&self) -> Self { *self } + } #[test] fn __bindgen_test_layout_template_2() { assert_eq!(::std::mem::size_of::<root::mozilla::StyleShapeSource<root::mozilla::StyleGeometryBox>>() @@ -3747,20 +3984,52 @@ pub mod root { } pub type pair_first_type<_T1> = _T1; pub type pair_second_type<_T2> = _T2; - pub type pair__PCCP = [u8; 0usize]; #[repr(C)] - #[derive(Debug)] pub struct atomic<_Tp> { - pub _M_i: _Tp, + pub _base: (), + pub _phantom_0: ::std::marker::PhantomData<_Tp>, } - pub mod namespace { - #[allow(unused_imports)] - use self::super::super::super::root; + pub type atomic___base = [u8; 0usize]; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct input_iterator_tag { + pub _address: u8, } - } - pub mod __gnu_cxx { - #[allow(unused_imports)] - use self::super::super::root; + impl Clone for input_iterator_tag { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct forward_iterator_tag { + pub _address: u8, + } + impl Clone for forward_iterator_tag { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct bidirectional_iterator_tag { + pub _address: u8, + } + impl Clone for bidirectional_iterator_tag { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct random_access_iterator_tag { + pub _address: u8, + } + impl Clone for random_access_iterator_tag { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct __bit_const_reference<_Cp> { + pub __seg_: root::std::__bit_const_reference___storage_pointer<_Cp>, + pub __mask_: root::std::__bit_const_reference___storage_type<_Cp>, + } + pub type __bit_const_reference___storage_type<_Cp> = _Cp; + pub type __bit_const_reference___storage_pointer<_Cp> = _Cp; } /** * MozRefCountType is Mozilla's reference count type. @@ -4316,6 +4585,146 @@ pub mod root { pub mod JS { #[allow(unused_imports)] use self::super::super::root; + /** + * JS::Value is the interface for a single JavaScript Engine value. A few + * general notes on JS::Value: + * + * - JS::Value has setX() and isX() members for X in + * + * { Int32, Double, String, Symbol, Boolean, Undefined, Null, Object, Magic } + * + * JS::Value also contains toX() for each of the non-singleton types. + * + * - Magic is a singleton type whose payload contains either a JSWhyMagic "reason" for + * the magic value or a uint32_t value. By providing JSWhyMagic values when + * creating and checking for magic values, it is possible to assert, at + * runtime, that only magic values with the expected reason flow through a + * particular value. For example, if cx->exception has a magic value, the + * reason must be JS_GENERATOR_CLOSING. + * + * - The JS::Value operations are preferred. The JSVAL_* operations remain for + * compatibility; they may be removed at some point. These operations mostly + * provide similar functionality. But there are a few key differences. One + * is that JS::Value gives null a separate type. + * Also, to help prevent mistakenly boxing a nullable JSObject* as an object, + * Value::setObject takes a JSObject&. (Conversely, Value::toObject returns a + * JSObject&.) A convenience member Value::setObjectOrNull is provided. + * + * - JSVAL_VOID is the same as the singleton value of the Undefined type. + * + * - Note that JS::Value is 8 bytes on 32 and 64-bit architectures. Thus, on + * 32-bit user code should avoid copying jsval/JS::Value as much as possible, + * preferring to pass by const Value&. + */ + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Value { + pub data: root::JS::Value_layout, + } + pub type Value_PayloadType = u64; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Value_layout { + pub asBits: root::__BindgenUnionField<u64>, + pub debugView: root::__BindgenUnionField<root::JS::Value_layout__bindgen_ty_1>, + pub s: root::__BindgenUnionField<root::JS::Value_layout__bindgen_ty_2>, + pub asDouble: root::__BindgenUnionField<f64>, + pub asPtr: root::__BindgenUnionField<*mut ::std::os::raw::c_void>, + pub asWord: root::__BindgenUnionField<usize>, + pub asUIntPtr: root::__BindgenUnionField<usize>, + pub bindgen_union_field: u64, + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Value_layout__bindgen_ty_1 { + pub _bitfield_1: u64, + } + #[test] + fn bindgen_test_layout_Value_layout__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<Value_layout__bindgen_ty_1>() , + 8usize); + assert_eq!(::std::mem::align_of::<Value_layout__bindgen_ty_1>() , + 8usize); + } + impl Clone for Value_layout__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + impl Value_layout__bindgen_ty_1 { + #[inline] + pub fn payload47(&self) -> u64 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & + (140737488355327usize as u64)) + >> 0u32) as u64) + } + } + #[inline] + pub fn set_payload47(&mut self, val: u64) { + self._bitfield_1 &= !(140737488355327usize as u64); + self._bitfield_1 |= + ((val as u64 as u64) << 0u32) & + (140737488355327usize as u64); + } + #[inline] + pub fn tag(&self) -> root::JSValueTag { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & + (18446603336221196288usize as + u64)) >> 47u32) as u32) + } + } + #[inline] + pub fn set_tag(&mut self, val: root::JSValueTag) { + self._bitfield_1 &= !(18446603336221196288usize as u64); + self._bitfield_1 |= + ((val as u32 as u64) << 47u32) & + (18446603336221196288usize as u64); + } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Value_layout__bindgen_ty_2 { + pub payload: root::JS::Value_layout__bindgen_ty_2__bindgen_ty_1, + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Value_layout__bindgen_ty_2__bindgen_ty_1 { + pub i32: root::__BindgenUnionField<i32>, + pub u32: root::__BindgenUnionField<u32>, + pub why: root::__BindgenUnionField<root::JSWhyMagic>, + pub bindgen_union_field: u32, + } + #[test] + fn bindgen_test_layout_Value_layout__bindgen_ty_2__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<Value_layout__bindgen_ty_2__bindgen_ty_1>() + , 4usize); + assert_eq!(::std::mem::align_of::<Value_layout__bindgen_ty_2__bindgen_ty_1>() + , 4usize); + } + impl Clone for Value_layout__bindgen_ty_2__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_Value_layout__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::<Value_layout__bindgen_ty_2>() , + 4usize); + assert_eq!(::std::mem::align_of::<Value_layout__bindgen_ty_2>() , + 4usize); + } + impl Clone for Value_layout__bindgen_ty_2 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_Value_layout() { + assert_eq!(::std::mem::size_of::<Value_layout>() , 8usize); + assert_eq!(::std::mem::align_of::<Value_layout>() , 8usize); + } + impl Clone for Value_layout { + fn clone(&self) -> Self { *self } + } + impl Clone for Value { + fn clone(&self) -> Self { *self } + } #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct DeletePolicy<T> { @@ -4443,6 +4852,11 @@ pub mod root { pub enum TenuredHeap__bindgen_ty_1 { maskBits = 0, } #[test] fn __bindgen_test_layout_template_4() { + assert_eq!(::std::mem::size_of::<[u64; 3usize]>() , 24usize); + assert_eq!(::std::mem::align_of::<[u64; 3usize]>() , 8usize); + } + #[test] + fn __bindgen_test_layout_template_5() { assert_eq!(::std::mem::size_of::<root::mozilla::UniquePtr<*mut ::std::os::raw::c_char, root::JS::FreePolicy>>() , 8usize); @@ -4520,6 +4934,42 @@ pub mod root { impl Clone for JSCompartment { fn clone(&self) -> Self { *self } } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum JSValueTag { + JSVAL_TAG_MAX_DOUBLE = 131056, + JSVAL_TAG_INT32 = 131057, + JSVAL_TAG_UNDEFINED = 131058, + JSVAL_TAG_NULL = 131059, + JSVAL_TAG_BOOLEAN = 131060, + JSVAL_TAG_MAGIC = 131061, + JSVAL_TAG_STRING = 131062, + JSVAL_TAG_SYMBOL = 131063, + JSVAL_TAG_PRIVATE_GCTHING = 131064, + JSVAL_TAG_OBJECT = 131068, + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum JSWhyMagic { + JS_ELEMENTS_HOLE = 0, + JS_NO_ITER_VALUE = 1, + JS_GENERATOR_CLOSING = 2, + JS_NO_CONSTANT = 3, + JS_THIS_POISON = 4, + JS_ARG_POISON = 5, + JS_SERIALIZE_NO_NODE = 6, + JS_LAZY_ARGUMENTS = 7, + JS_OPTIMIZED_ARGUMENTS = 8, + JS_IS_CONSTRUCTING = 9, + JS_BLOCK_NEEDS_CLONE = 10, + JS_HASH_KEY_EMPTY = 11, + JS_ION_ERROR = 12, + JS_ION_BAILOUT = 13, + JS_OPTIMIZED_OUT = 14, + JS_UNINITIALIZED_LEXICAL = 15, + JS_GENERIC_MAGIC = 16, + JS_WHY_MAGIC_COUNT = 17, + } #[repr(C)] #[derive(Debug)] pub struct nsAString_internal { @@ -4839,13 +5289,13 @@ pub mod root { pub _phantom_0: ::std::marker::PhantomData<CharT>, } #[test] - fn __bindgen_test_layout_template_5() { + fn __bindgen_test_layout_template_6() { assert_eq!(::std::mem::size_of::<root::nsCharTraits<u16>>() , 1usize); assert_eq!(::std::mem::align_of::<root::nsCharTraits<u16>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_6() { + fn __bindgen_test_layout_template_7() { assert_eq!(::std::mem::size_of::<root::nsCharTraits<::std::os::raw::c_char>>() , 1usize); assert_eq!(::std::mem::align_of::<root::nsCharTraits<::std::os::raw::c_char>>() @@ -5059,7 +5509,7 @@ pub mod root { pub mRawPtr: *mut root::nsISupports, } #[test] - fn __bindgen_test_layout_template_7() { + fn __bindgen_test_layout_template_8() { assert_eq!(::std::mem::size_of::<root::nsCOMPtr<root::nsISupports>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsCOMPtr<root::nsISupports>>() @@ -5564,7 +6014,7 @@ pub mod root { pub _base_1: root::mozilla::dom::DispatcherTrait, pub mDeprecationWarnedAbout: u64, pub mDocWarningWarnedAbout: u64, - pub mSelectorCache: [u64; 15usize], + pub mSelectorCache: root::nsIDocument_SelectorCache, pub mReferrer: root::nsCString, pub mLastModified: ::nsstring::nsStringRepr, pub mDocumentURI: root::nsCOMPtr<root::nsIURI>, @@ -5721,7 +6171,7 @@ pub mod root { fn clone(&self) -> Self { *self } } #[repr(C)] - #[derive(Debug)] + #[derive(Debug, Copy)] pub struct nsIDocument_SelectorCache { pub _bindgen_opaque_blob: [u64; 15usize], } @@ -5732,6 +6182,9 @@ pub mod root { assert_eq!(::std::mem::align_of::<nsIDocument_SelectorCache>() , 8usize); } + impl Clone for nsIDocument_SelectorCache { + fn clone(&self) -> Self { *self } + } #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum nsIDocument_additionalSheetType { @@ -6989,6 +7442,20 @@ pub mod root { eCompatibility_AlmostStandards = 2, eCompatibility_NavQuirks = 3, } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct gfxSize { + pub _bindgen_opaque_blob: [u64; 2usize], + } + pub type gfxSize_Super = [u64; 2usize]; + #[test] + fn bindgen_test_layout_gfxSize() { + assert_eq!(::std::mem::size_of::<gfxSize>() , 16usize); + assert_eq!(::std::mem::align_of::<gfxSize>() , 8usize); + } + impl Clone for gfxSize { + fn clone(&self) -> Self { *self } + } pub type nscolor = u32; #[repr(C)] #[derive(Debug)] @@ -7017,7 +7484,7 @@ pub mod root { pub mTextZoom: f32, pub mFullZoom: f32, pub mOverrideDPPX: f32, - pub mLastFontInflationScreenSize: [u64; 2usize], + pub mLastFontInflationScreenSize: root::gfxSize, pub mCurAppUnitsPerDevPixel: i32, pub mAutoQualityMinFontSizePixelsPref: i32, pub mTheme: root::nsCOMPtr<root::nsITheme>, @@ -8253,7 +8720,7 @@ pub mod root { root::mozilla::dom::OwningNodeOrString; pub type nsINode_TextOrElementOrDocument = root::mozilla::dom::TextOrElementOrDocument; - pub type nsINode_ErrorResult = [u64; 2usize]; + pub type nsINode_ErrorResult = root::mozilla::ErrorResult; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct nsINode_COMTypeInfo<T, U> { @@ -8463,7 +8930,7 @@ pub mod root { pub mArray: root::nsTArray<root::nsAutoPtr<root::nsMediaQuery>>, pub mStyleSheet: *mut root::mozilla::StyleSheet, } - pub type nsMediaList_ErrorResult = [u64; 2usize]; + pub type nsMediaList_ErrorResult = root::mozilla::ErrorResult; pub type nsMediaList_HasThreadSafeRefCnt = root::mozilla::FalseType; #[repr(C)] #[derive(Debug, Copy)] @@ -8713,7 +9180,7 @@ pub mod root { } pub type nsDOMAttributeMap_Attr = root::mozilla::dom::Attr; pub type nsDOMAttributeMap_Element = root::mozilla::dom::Element; - pub type nsDOMAttributeMap_ErrorResult = [u64; 2usize]; + pub type nsDOMAttributeMap_ErrorResult = root::mozilla::ErrorResult; pub type nsDOMAttributeMap_HasThreadSafeRefCnt = root::mozilla::FalseType; #[repr(C)] #[derive(Debug, Copy)] @@ -9253,63 +9720,63 @@ pub mod root { impl Clone for nsDOMMutationObserver { fn clone(&self) -> Self { *self } } - pub const NODE_HAS_LISTENERMANAGER: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_HAS_LISTENERMANAGER; - pub const NODE_HAS_PROPERTIES: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_HAS_PROPERTIES; - pub const NODE_IS_ANONYMOUS_ROOT: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_IS_ANONYMOUS_ROOT; - pub const NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE; - pub const NODE_IS_NATIVE_ANONYMOUS_ROOT: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_IS_NATIVE_ANONYMOUS_ROOT; - pub const NODE_FORCE_XBL_BINDINGS: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_FORCE_XBL_BINDINGS; - pub const NODE_MAY_BE_IN_BINDING_MNGR: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_MAY_BE_IN_BINDING_MNGR; - pub const NODE_IS_EDITABLE: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_IS_EDITABLE; - pub const NODE_MAY_HAVE_CLASS: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_MAY_HAVE_CLASS; - pub const NODE_IS_IN_SHADOW_TREE: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_IS_IN_SHADOW_TREE; - pub const NODE_HAS_EMPTY_SELECTOR: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_HAS_EMPTY_SELECTOR; - pub const NODE_HAS_SLOW_SELECTOR: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_HAS_SLOW_SELECTOR; - pub const NODE_HAS_EDGE_CHILD_SELECTOR: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_HAS_EDGE_CHILD_SELECTOR; - pub const NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS; - pub const NODE_ALL_SELECTOR_FLAGS: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_ALL_SELECTOR_FLAGS; - pub const NODE_NEEDS_FRAME: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_NEEDS_FRAME; - pub const NODE_DESCENDANTS_NEED_FRAMES: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_DESCENDANTS_NEED_FRAMES; - pub const NODE_HAS_ACCESSKEY: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_HAS_ACCESSKEY; - pub const NODE_HAS_DIRECTION_RTL: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_HAS_DIRECTION_RTL; - pub const NODE_HAS_DIRECTION_LTR: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_HAS_DIRECTION_LTR; - pub const NODE_ALL_DIRECTION_FLAGS: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_ALL_DIRECTION_FLAGS; - pub const NODE_CHROME_ONLY_ACCESS: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_CHROME_ONLY_ACCESS; - pub const NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS; - pub const NODE_SHARED_RESTYLE_BIT_1: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_SHARED_RESTYLE_BIT_1; - pub const NODE_SHARED_RESTYLE_BIT_2: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_SHARED_RESTYLE_BIT_2; - pub const NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_SHARED_RESTYLE_BIT_1; - pub const NODE_TYPE_SPECIFIC_BITS_OFFSET: root::_bindgen_ty_118 = - _bindgen_ty_118::NODE_TYPE_SPECIFIC_BITS_OFFSET; + pub const NODE_HAS_LISTENERMANAGER: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_LISTENERMANAGER; + pub const NODE_HAS_PROPERTIES: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_PROPERTIES; + pub const NODE_IS_ANONYMOUS_ROOT: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_IS_ANONYMOUS_ROOT; + pub const NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE; + pub const NODE_IS_NATIVE_ANONYMOUS_ROOT: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_IS_NATIVE_ANONYMOUS_ROOT; + pub const NODE_FORCE_XBL_BINDINGS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_FORCE_XBL_BINDINGS; + pub const NODE_MAY_BE_IN_BINDING_MNGR: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_MAY_BE_IN_BINDING_MNGR; + pub const NODE_IS_EDITABLE: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_IS_EDITABLE; + pub const NODE_MAY_HAVE_CLASS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_MAY_HAVE_CLASS; + pub const NODE_IS_IN_SHADOW_TREE: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_IS_IN_SHADOW_TREE; + pub const NODE_HAS_EMPTY_SELECTOR: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_EMPTY_SELECTOR; + pub const NODE_HAS_SLOW_SELECTOR: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_SLOW_SELECTOR; + pub const NODE_HAS_EDGE_CHILD_SELECTOR: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_EDGE_CHILD_SELECTOR; + pub const NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS; + pub const NODE_ALL_SELECTOR_FLAGS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_ALL_SELECTOR_FLAGS; + pub const NODE_NEEDS_FRAME: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_NEEDS_FRAME; + pub const NODE_DESCENDANTS_NEED_FRAMES: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_DESCENDANTS_NEED_FRAMES; + pub const NODE_HAS_ACCESSKEY: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_ACCESSKEY; + pub const NODE_HAS_DIRECTION_RTL: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_DIRECTION_RTL; + pub const NODE_HAS_DIRECTION_LTR: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_HAS_DIRECTION_LTR; + pub const NODE_ALL_DIRECTION_FLAGS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_ALL_DIRECTION_FLAGS; + pub const NODE_CHROME_ONLY_ACCESS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_CHROME_ONLY_ACCESS; + pub const NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS; + pub const NODE_SHARED_RESTYLE_BIT_1: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_SHARED_RESTYLE_BIT_1; + pub const NODE_SHARED_RESTYLE_BIT_2: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_SHARED_RESTYLE_BIT_2; + pub const NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_SHARED_RESTYLE_BIT_1; + pub const NODE_TYPE_SPECIFIC_BITS_OFFSET: root::_bindgen_ty_34 = + _bindgen_ty_34::NODE_TYPE_SPECIFIC_BITS_OFFSET; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] - pub enum _bindgen_ty_118 { + pub enum _bindgen_ty_34 { NODE_HAS_LISTENERMANAGER = 4, NODE_HAS_PROPERTIES = 8, NODE_IS_ANONYMOUS_ROOT = 16, @@ -10127,21 +10594,21 @@ pub mod root { } #[repr(C)] #[derive(Debug, Copy)] - pub struct _bindgen_ty_25 { + pub struct _bindgen_ty_10 { pub mInt: root::__BindgenUnionField<i32>, pub mFloat: root::__BindgenUnionField<f32>, pub mPointer: root::__BindgenUnionField<*mut ::std::os::raw::c_void>, pub bindgen_union_field: u64, } #[test] - fn bindgen_test_layout__bindgen_ty_25() { - assert_eq!(::std::mem::size_of::<_bindgen_ty_25>() , 8usize); - assert_eq!(::std::mem::align_of::<_bindgen_ty_25>() , 8usize); + fn bindgen_test_layout__bindgen_ty_10() { + assert_eq!(::std::mem::size_of::<_bindgen_ty_10>() , 8usize); + assert_eq!(::std::mem::align_of::<_bindgen_ty_10>() , 8usize); } - impl Clone for _bindgen_ty_25 { + impl Clone for _bindgen_ty_10 { fn clone(&self) -> Self { *self } } - pub type nsStyleUnion = root::_bindgen_ty_25; + pub type nsStyleUnion = root::_bindgen_ty_10; /** * Class that hold a single size specification used by the style * system. The size specification consists of two parts -- a number @@ -13137,7 +13604,7 @@ pub mod root { assert_eq!(::std::mem::align_of::<nsCSSValueFloatColor>() , 8usize); } #[test] - fn __bindgen_test_layout_template_8() { + fn __bindgen_test_layout_template_9() { assert_eq!(::std::mem::size_of::<root::mozilla::UniquePtr<root::nsCSSValueList, root::mozilla::DefaultDelete<root::nsCSSValueList>>>() , 8usize); @@ -13146,7 +13613,7 @@ pub mod root { , 8usize); } #[test] - fn __bindgen_test_layout_template_9() { + fn __bindgen_test_layout_template_10() { assert_eq!(::std::mem::size_of::<root::mozilla::UniquePtr<root::nsCSSValuePairList, root::mozilla::DefaultDelete<root::nsCSSValuePairList>>>() , 8usize); @@ -13528,7 +13995,7 @@ pub mod root { assert_eq!(::std::mem::align_of::<CachedBorderImageData>() , 8usize); } #[test] - fn __bindgen_test_layout_template_10() { + fn __bindgen_test_layout_template_11() { assert_eq!(::std::mem::size_of::<root::mozilla::UniquePtr<root::nsStyleSides, root::mozilla::DefaultDelete<root::nsStyleSides>>>() , 8usize); @@ -14773,8 +15240,7 @@ pub mod root { aFeature: *const root::nsMediaFeature, aResult: - *mut root::nsCSSValue) - -> root::nsresult>; + *mut root::nsCSSValue)>; #[repr(C)] #[derive(Debug, Copy)] pub struct nsMediaFeatures { @@ -14823,201 +15289,247 @@ pub mod root { assert_eq!(::std::mem::align_of::<nsMediaQuery>() , 8usize); } #[test] - fn __bindgen_test_layout_template_11() { + fn __bindgen_test_layout_template_12() { assert_eq!(::std::mem::size_of::<root::JS::TenuredHeap<*mut root::JSObject>>() , 8usize); assert_eq!(::std::mem::align_of::<root::JS::TenuredHeap<*mut root::JSObject>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_12() { + fn __bindgen_test_layout_template_13() { assert_eq!(::std::mem::size_of::<root::JS::Heap<*mut root::JSObject>>() , 8usize); assert_eq!(::std::mem::align_of::<root::JS::Heap<*mut root::JSObject>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_13() { + fn __bindgen_test_layout_template_14() { assert_eq!(::std::mem::size_of::<root::nsTArray<root::nsCString>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<root::nsCString>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_14() { + fn __bindgen_test_layout_template_15() { + assert_eq!(::std::mem::size_of::<root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::AssertAndSuppressCleanupPolicy>>() + , 16usize); + assert_eq!(::std::mem::align_of::<root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::AssertAndSuppressCleanupPolicy>>() + , 8usize); + } + #[test] + fn __bindgen_test_layout_template_16() { + assert_eq!(::std::mem::size_of::<root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::JustSuppressCleanupPolicy>>() + , 16usize); + assert_eq!(::std::mem::align_of::<root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::JustSuppressCleanupPolicy>>() + , 8usize); + } + #[test] + fn __bindgen_test_layout_template_17() { + assert_eq!(::std::mem::size_of::<root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::JustAssertCleanupPolicy>>() + , 16usize); + assert_eq!(::std::mem::align_of::<root::mozilla::binding_danger::TErrorResult<root::mozilla::binding_danger::JustAssertCleanupPolicy>>() + , 8usize); + } + #[test] + fn __bindgen_test_layout_template_18() { assert_eq!(::std::mem::size_of::<root::nsCOMPtr<root::nsIPrincipal>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsCOMPtr<root::nsIPrincipal>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_15() { + fn __bindgen_test_layout_template_19() { + assert_eq!(::std::mem::size_of::<[u64; 28usize]>() , 224usize); + assert_eq!(::std::mem::align_of::<[u64; 28usize]>() , 8usize); + } + #[test] + fn __bindgen_test_layout_template_20() { assert_eq!(::std::mem::size_of::<root::RefPtr<root::mozilla::dom::Element>>() , 8usize); assert_eq!(::std::mem::align_of::<root::RefPtr<root::mozilla::dom::Element>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_16() { + fn __bindgen_test_layout_template_21() { assert_eq!(::std::mem::size_of::<root::nsTArray<root::RefPtr<root::mozilla::dom::Element>>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<root::RefPtr<root::mozilla::dom::Element>>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_17() { + fn __bindgen_test_layout_template_22() { assert_eq!(::std::mem::size_of::<root::nsCOMPtr<root::nsIObserver>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsCOMPtr<root::nsIObserver>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_18() { + fn __bindgen_test_layout_template_23() { assert_eq!(::std::mem::size_of::<root::nsCOMPtr<root::nsIWeakReference>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsCOMPtr<root::nsIWeakReference>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_19() { + fn __bindgen_test_layout_template_24() { + assert_eq!(::std::mem::size_of::<u64>() , 8usize); + assert_eq!(::std::mem::align_of::<u64>() , 8usize); + } + #[test] + fn __bindgen_test_layout_template_25() { assert_eq!(::std::mem::size_of::<root::nsTArray<*mut root::nsIContent>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<*mut root::nsIContent>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_20() { + fn __bindgen_test_layout_template_26() { assert_eq!(::std::mem::size_of::<root::nsTArray<::nsstring::nsStringRepr>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<::nsstring::nsStringRepr>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_21() { + fn __bindgen_test_layout_template_27() { + assert_eq!(::std::mem::size_of::<[u64; 5usize]>() , 40usize); + assert_eq!(::std::mem::align_of::<[u64; 5usize]>() , 8usize); + } + #[test] + fn __bindgen_test_layout_template_28() { assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::mozilla::dom::TimeoutManager>>() , 1usize); assert_eq!(::std::mem::align_of::<root::mozilla::DefaultDelete<root::mozilla::dom::TimeoutManager>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_22() { + fn __bindgen_test_layout_template_29() { assert_eq!(::std::mem::size_of::<root::nsCOMPtr<root::nsIRunnable>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsCOMPtr<root::nsIRunnable>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_23() { + fn __bindgen_test_layout_template_30() { assert_eq!(::std::mem::size_of::<root::nsAutoPtr<root::nsMediaQuery>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsAutoPtr<root::nsMediaQuery>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_24() { + fn __bindgen_test_layout_template_31() { assert_eq!(::std::mem::size_of::<root::mozilla::OwningNonNull<root::nsINode>>() , 8usize); assert_eq!(::std::mem::align_of::<root::mozilla::OwningNonNull<root::nsINode>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_25() { + fn __bindgen_test_layout_template_32() { assert_eq!(::std::mem::size_of::<root::nsTArray<f64>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<f64>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_26() { + fn __bindgen_test_layout_template_33() { assert_eq!(::std::mem::size_of::<root::RefPtr<root::mozilla::dom::DOMIntersectionObserverEntry>>() , 8usize); assert_eq!(::std::mem::align_of::<root::RefPtr<root::mozilla::dom::DOMIntersectionObserverEntry>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_27() { + fn __bindgen_test_layout_template_34() { assert_eq!(::std::mem::size_of::<root::nsTArray<root::RefPtr<root::mozilla::dom::DOMIntersectionObserverEntry>>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<root::RefPtr<root::mozilla::dom::DOMIntersectionObserverEntry>>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_28() { + fn __bindgen_test_layout_template_35() { assert_eq!(::std::mem::size_of::<root::nsMainThreadPtrHolder<root::nsIURI>>() , 24usize); assert_eq!(::std::mem::align_of::<root::nsMainThreadPtrHolder<root::nsIURI>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_29() { + fn __bindgen_test_layout_template_36() { assert_eq!(::std::mem::size_of::<root::nsMainThreadPtrHolder<root::nsIPrincipal>>() , 24usize); assert_eq!(::std::mem::align_of::<root::nsMainThreadPtrHolder<root::nsIPrincipal>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_30() { + fn __bindgen_test_layout_template_37() { assert_eq!(::std::mem::size_of::<root::nsPtrHashKey<root::nsIFrame>>() , 16usize); assert_eq!(::std::mem::align_of::<root::nsPtrHashKey<root::nsIFrame>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_31() { + fn __bindgen_test_layout_template_38() { assert_eq!(::std::mem::size_of::<root::nsTArray<root::mozilla::DisplayItemClip_RoundedRect>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<root::mozilla::DisplayItemClip_RoundedRect>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_32() { + fn __bindgen_test_layout_template_39() { assert_eq!(::std::mem::size_of::<root::RefPtr<root::mozilla::dom::DOMRect>>() , 8usize); assert_eq!(::std::mem::align_of::<root::RefPtr<root::mozilla::dom::DOMRect>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_33() { + fn __bindgen_test_layout_template_40() { assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::ProxyBehaviour>>() , 1usize); assert_eq!(::std::mem::align_of::<root::mozilla::DefaultDelete<root::ProxyBehaviour>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_34() { + fn __bindgen_test_layout_template_41() { assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::nsCSSValueList>>() , 1usize); assert_eq!(::std::mem::align_of::<root::mozilla::DefaultDelete<root::nsCSSValueList>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_35() { + fn __bindgen_test_layout_template_42() { assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::nsCSSValuePairList>>() , 1usize); assert_eq!(::std::mem::align_of::<root::mozilla::DefaultDelete<root::nsCSSValuePairList>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_36() { + fn __bindgen_test_layout_template_43() { + assert_eq!(::std::mem::size_of::<u64>() , 8usize); + assert_eq!(::std::mem::align_of::<u64>() , 8usize); + } + #[test] + fn __bindgen_test_layout_template_44() { + assert_eq!(::std::mem::size_of::<[u64; 2usize]>() , 16usize); + assert_eq!(::std::mem::align_of::<[u64; 2usize]>() , 8usize); + } + #[test] + fn __bindgen_test_layout_template_45() { assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::nsStyleSides>>() , 1usize); assert_eq!(::std::mem::align_of::<root::mozilla::DefaultDelete<root::nsStyleSides>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_37() { + fn __bindgen_test_layout_template_46() { assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::CachedBorderImageData>>() , 1usize); assert_eq!(::std::mem::align_of::<root::mozilla::DefaultDelete<root::CachedBorderImageData>>() , 1usize); } #[test] - fn __bindgen_test_layout_template_38() { + fn __bindgen_test_layout_template_47() { assert_eq!(::std::mem::size_of::<root::std::pair<::nsstring::nsStringRepr, ::nsstring::nsStringRepr>>() , 32usize); assert_eq!(::std::mem::align_of::<root::std::pair<::nsstring::nsStringRepr, ::nsstring::nsStringRepr>>() , 8usize); } #[test] - fn __bindgen_test_layout_template_39() { + fn __bindgen_test_layout_template_48() { assert_eq!(::std::mem::size_of::<root::nsTArray<*mut root::mozilla::css::DocumentRule>>() , 8usize); assert_eq!(::std::mem::align_of::<root::nsTArray<*mut root::mozilla::css::DocumentRule>>() diff --git a/components/style/lib.rs b/components/style/lib.rs index 45954458a20..0752b44172a 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -39,12 +39,9 @@ extern crate app_units; extern crate atomic_refcell; -#[allow(unused_extern_crates)] #[macro_use] extern crate bitflags; -#[macro_use] #[no_link] -extern crate cfg_if; -extern crate core; +#[cfg(feature = "gecko")] #[macro_use] #[no_link] extern crate cfg_if; #[macro_use] extern crate cssparser; extern crate encoding; @@ -54,7 +51,6 @@ extern crate fnv; extern crate heapsize; #[cfg(feature = "servo")] #[macro_use] extern crate heapsize_derive; #[cfg(feature = "servo")] #[macro_use] extern crate html5ever_atoms; -#[allow(unused_extern_crates)] #[macro_use] extern crate lazy_static; #[macro_use] @@ -74,8 +70,6 @@ extern crate quickersort; extern crate rayon; extern crate rustc_serialize; extern crate selectors; -#[cfg(feature = "servo")] -extern crate serde; #[cfg(feature = "servo")] #[macro_use] extern crate serde_derive; #[cfg(feature = "servo")] #[macro_use] extern crate servo_atoms; extern crate servo_config; diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index ec3097210ad..5bac0d7dab7 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -19,10 +19,11 @@ values = """inline block inline-block table inline-table table-row-group table-header-group table-footer-group table-row table-column-group table-column table-cell table-caption - list-item flex none + list-item flex inline-flex + none """.split() if product == "gecko": - values += """inline-flex grid inline-grid ruby ruby-base ruby-base-container + values += """grid inline-grid ruby ruby-base ruby-base-container ruby-text ruby-text-container contents flow-root -webkit-box -webkit-inline-box -moz-box -moz-inline-box -moz-grid -moz-inline-grid -moz-grid-group -moz-grid-line -moz-stack -moz-inline-stack -moz-deck diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index ec6873f436a..ca30e123dcc 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1953,8 +1953,10 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>, let is_item = matches!(context.inherited_style.get_box().clone_display(), % if product == "gecko": computed_values::display::T::grid | + computed_values::display::T::inline_grid | % endif - computed_values::display::T::flex); + computed_values::display::T::flex | + computed_values::display::T::inline_flex); let (blockify_root, blockify_item) = match flags.contains(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) { false => (is_root_element, is_item), true => (false, false), diff --git a/components/style/properties/shorthand/font.mako.rs b/components/style/properties/shorthand/font.mako.rs index 7742ab11be5..f058c56a777 100644 --- a/components/style/properties/shorthand/font.mako.rs +++ b/components/style/properties/shorthand/font.mako.rs @@ -4,21 +4,22 @@ <%namespace name="helpers" file="/helpers.mako.rs" /> -<%helpers:shorthand name="font" sub_properties="font-style font-variant font-weight +<%helpers:shorthand name="font" sub_properties="font-style font-variant font-weight font-stretch font-size line-height font-family" spec="https://drafts.csswg.org/css-fonts-3/#propdef-font"> - use properties::longhands::{font_style, font_variant, font_weight, font_size, - line_height, font_family}; + use properties::longhands::{font_style, font_variant, font_weight, font_stretch}; + use properties::longhands::{font_size, line_height, font_family}; pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> { let mut nb_normals = 0; let mut style = None; let mut variant = None; let mut weight = None; + let mut stretch = None; let size; loop { // Special-case 'normal' because it is valid in each of - // font-style, font-weight and font-variant. + // font-style, font-weight, font-variant and font-stretch. // Leaves the values to None, 'normal' is the initial value for each of them. if input.try(|input| input.expect_ident_matching("normal")).is_ok() { nb_normals += 1; @@ -42,6 +43,12 @@ continue } } + if stretch.is_none() { + if let Ok(value) = input.try(|input| font_stretch::parse(context, input)) { + stretch = Some(value); + continue + } + } size = Some(try!(font_size::parse(context, input))); break } @@ -49,7 +56,7 @@ fn count<T>(opt: &Option<T>) -> u8 { if opt.is_some() { 1 } else { 0 } } - if size.is_none() || (count(&style) + count(&weight) + count(&variant) + nb_normals) > 3 { + if size.is_none() || (count(&style) + count(&weight) + count(&variant) + count(&stretch) + nb_normals) > 4 { return Err(()) } let line_height = if input.try(|input| input.expect_delim('/')).is_ok() { @@ -62,6 +69,7 @@ font_style: style, font_variant: variant, font_weight: weight, + font_stretch: stretch, font_size: size, line_height: line_height, font_family: Some(font_family::SpecifiedValue(family)) @@ -86,6 +94,11 @@ try!(write!(dest, " ")); } + if let DeclaredValue::Value(ref stretch) = *self.font_stretch { + try!(stretch.to_css(dest)); + try!(write!(dest, " ")); + } + try!(self.font_size.to_css(dest)); if let DeclaredValue::Value(ref height) = *self.line_height { match *height { diff --git a/components/style_traits/lib.rs b/components/style_traits/lib.rs index 3891f73e2de..857624a5f9c 100644 --- a/components/style_traits/lib.rs +++ b/components/style_traits/lib.rs @@ -20,7 +20,6 @@ extern crate euclid; #[cfg(feature = "servo")] extern crate heapsize; #[cfg(feature = "servo")] #[macro_use] extern crate heapsize_derive; extern crate rustc_serialize; -#[cfg(feature = "servo")] extern crate serde; #[cfg(feature = "servo")] #[macro_use] extern crate serde_derive; /// Opaque type stored in type-unsafe work queues for parallel layout. diff --git a/components/url/lib.rs b/components/url/lib.rs index 4f236a7a225..d9f69497aba 100644 --- a/components/url/lib.rs +++ b/components/url/lib.rs @@ -9,7 +9,6 @@ #![cfg_attr(feature = "servo", feature(plugin))] -#[cfg(feature = "servo")] extern crate serde; #[cfg(feature = "servo")] #[macro_use] extern crate serde_derive; #[cfg(feature = "servo")] extern crate heapsize; #[cfg(feature = "servo")] #[macro_use] extern crate heapsize_derive; diff --git a/components/webvr_traits/lib.rs b/components/webvr_traits/lib.rs index a64da241525..30598105442 100644 --- a/components/webvr_traits/lib.rs +++ b/components/webvr_traits/lib.rs @@ -8,7 +8,6 @@ extern crate ipc_channel; extern crate msg; -extern crate serde; #[macro_use] extern crate serde_derive; pub extern crate rust_webvr as webvr; diff --git a/etc/ci/check_no_panic.sh b/etc/ci/check_no_panic.sh index c25f45fa763..251d61591d0 100755 --- a/etc/ci/check_no_panic.sh +++ b/etc/ci/check_no_panic.sh @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -# Make sure listed files do not use unwrap() or panic!() +# Make sure listed paths do not use unwrap() or panic!() set -o errexit set -o nounset @@ -13,14 +13,21 @@ set -o pipefail # cd into repo root to make sure paths work in any case cd "$(git rev-parse --show-toplevel)" -FILES=("components/compositing/compositor.rs" - "components/constellation/constellation.rs" - "components/constellation/pipeline.rs" - "ports/glutin/lib.rs" - "ports/glutin/window.rs") +# Each path can be either a single file or a directory +PATHS=( + "components/compositing/compositor.rs" + "components/constellation/" + "ports/glutin/lib.rs" + "ports/glutin/window.rs" +) -# make sure the files exist -ls -1 "${FILES[@]}" +# Make sure the paths exist +ls -1 "${PATHS[@]}" -# make sure the files do not contain "unwrap" or "panic!" -! grep --line-number --with-filename "unwrap(\|panic!(" "${FILES[@]}" +# Make sure the files do not contain "unwrap" or "panic!" +! grep \ + --dereference-recursive \ + --line-number \ + --with-filename \ + "unwrap(\|panic!(" \ + "${PATHS[@]}" diff --git a/ports/cef/Cargo.toml b/ports/cef/Cargo.toml index 3ca91e933f8..16d1396e933 100644 --- a/ports/cef/Cargo.toml +++ b/ports/cef/Cargo.toml @@ -35,6 +35,11 @@ servo_geometry = {path = "../../components/geometry"} servo_url = {path = "../../components/url"} style_traits = {path = "../../components/style_traits"} +[dependencies.webrender_traits] +git = "https://github.com/servo/webrender" +default-features = false +features = ["serde_derive", "ipc"] + [target.'cfg(target_os="macos")'.dependencies] objc = "0.2" cocoa = "0.5" diff --git a/ports/cef/browser_host.rs b/ports/cef/browser_host.rs index cf272f3e10b..8d0c2d806f2 100644 --- a/ports/cef/browser_host.rs +++ b/ports/cef/browser_host.rs @@ -8,6 +8,7 @@ use interfaces::{CefBrowser, CefBrowserHost, CefClient, cef_browser_t, cef_brows use types::cef_event_flags_t::{EVENTFLAG_ALT_DOWN, EVENTFLAG_CONTROL_DOWN, EVENTFLAG_SHIFT_DOWN}; use types::cef_key_event_type_t::{KEYEVENT_CHAR, KEYEVENT_KEYDOWN, KEYEVENT_KEYUP, KEYEVENT_RAWKEYDOWN}; use types::{cef_mouse_button_type_t, cef_mouse_event, cef_rect_t, cef_key_event, cef_window_handle_t}; +use webrender_traits::ScrollLocation; use wrappers::CefWrap; use compositing::windowing::{WindowEvent, MouseWindowEvent}; @@ -471,7 +472,7 @@ full_cef_class_impl! { let delta_y: c_int = delta_y; let delta = TypedPoint2D::new(delta_x as f32, delta_y as f32); let origin = TypedPoint2D::new((*event).x as i32, (*event).y as i32); - this.downcast().send_window_event(WindowEvent::Scroll(delta, + this.downcast().send_window_event(WindowEvent::Scroll(ScrollLocation::Delta(delta), origin, TouchEventType::Move)) }} diff --git a/ports/cef/lib.rs b/ports/cef/lib.rs index 94e61baca55..69f3471cdab 100644 --- a/ports/cef/lib.rs +++ b/ports/cef/lib.rs @@ -28,6 +28,7 @@ extern crate style_traits; extern crate net_traits; extern crate msg; +extern crate webrender_traits; extern crate libc; diff --git a/ports/geckolib/Cargo.toml b/ports/geckolib/Cargo.toml index c99a187e39e..48568fc95f0 100644 --- a/ports/geckolib/Cargo.toml +++ b/ports/geckolib/Cargo.toml @@ -23,7 +23,7 @@ libc = "0.2" log = {version = "0.3.5", features = ["release_max_level_info"]} num_cpus = "1.1.0" parking_lot = "0.3" -selectors = "0.15" +selectors = "0.15.1" servo_url = {path = "../../components/url"} style = {path = "../../components/style", features = ["gecko"]} style_traits = {path = "../../components/style_traits"} diff --git a/ports/glutin/Cargo.toml b/ports/glutin/Cargo.toml index 09557e32ed3..c25d0ede382 100644 --- a/ports/glutin/Cargo.toml +++ b/ports/glutin/Cargo.toml @@ -23,6 +23,10 @@ servo_config = {path = "../../components/config"} servo_url = {path = "../../components/url"} style_traits = {path = "../../components/style_traits"} +[dependencies.webrender_traits] +git = "https://github.com/servo/webrender" +default_features = false + [target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies] osmesa-sys = "0.1.2" diff --git a/ports/glutin/lib.rs b/ports/glutin/lib.rs index dd9ebef4087..4e390f7eb8e 100644 --- a/ports/glutin/lib.rs +++ b/ports/glutin/lib.rs @@ -8,7 +8,6 @@ #[macro_use] extern crate bitflags; extern crate compositing; -#[allow(unused_extern_crates)] #[cfg(target_os = "android")] extern crate egl; extern crate euclid; extern crate gleam; @@ -22,6 +21,8 @@ extern crate servo_config; extern crate servo_geometry; extern crate servo_url; extern crate style_traits; +extern crate webrender_traits; + #[cfg(target_os = "windows")] extern crate winapi; #[cfg(target_os = "windows")] extern crate user32; #[cfg(target_os = "windows")] extern crate gdi32; diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index e8565474ca3..66b4b83996b 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -42,6 +42,7 @@ use std::sync::mpsc::{Sender, channel}; use style_traits::cursor::Cursor; #[cfg(target_os = "windows")] use user32; +use webrender_traits::ScrollLocation; #[cfg(target_os = "windows")] use winapi; @@ -425,8 +426,9 @@ impl Window { MouseScrollDelta::LineDelta(dx, dy) => (dx, dy * LINE_HEIGHT), MouseScrollDelta::PixelDelta(dx, dy) => (dx, dy), }; + let scroll_location = ScrollLocation::Delta(TypedPoint2D::new(dx, dy)); let phase = glutin_phase_to_touch_event_type(phase); - self.scroll_window(dx, dy, phase); + self.scroll_window(scroll_location, phase); }, Event::Touch(touch) => { use script_traits::TouchId; @@ -461,16 +463,19 @@ impl Window { } /// Helper function to send a scroll event. - fn scroll_window(&self, mut dx: f32, mut dy: f32, phase: TouchEventType) { + fn scroll_window(&self, scroll_location: ScrollLocation, phase: TouchEventType) { // Scroll events snap to the major axis of movement, with vertical // preferred over horizontal. - if dy.abs() >= dx.abs() { - dx = 0.0; - } else { - dy = 0.0; + if let ScrollLocation::Delta(mut delta) = scroll_location { + if delta.y.abs() >= delta.x.abs() { + delta.x = 0.0; + } else { + delta.y = 0.0; + } } + let mouse_pos = self.mouse_pos.get(); - let event = WindowEvent::Scroll(TypedPoint2D::new(dx as f32, dy as f32), + let event = WindowEvent::Scroll(scroll_location, TypedPoint2D::new(mouse_pos.x as i32, mouse_pos.y as i32), phase); self.event_queue.borrow_mut().push(event); @@ -1034,33 +1039,46 @@ impl WindowMethods for Window { (NONE, None, Key::PageDown) | (NONE, Some(' '), _) => { - self.scroll_window(0.0, + let scroll_location = ScrollLocation::Delta(TypedPoint2D::new(0.0, -self.framebuffer_size() .to_f32() .to_untyped() - .height + 2.0 * LINE_HEIGHT, + .height + 2.0 * LINE_HEIGHT)); + self.scroll_window(scroll_location, TouchEventType::Move); } (NONE, None, Key::PageUp) | (SHIFT, Some(' '), _) => { - self.scroll_window(0.0, + let scroll_location = ScrollLocation::Delta(TypedPoint2D::new(0.0, self.framebuffer_size() .to_f32() .to_untyped() - .height - 2.0 * LINE_HEIGHT, + .height - 2.0 * LINE_HEIGHT)); + self.scroll_window(scroll_location, TouchEventType::Move); } + + (NONE, None, Key::Home) => { + self.scroll_window(ScrollLocation::Start, TouchEventType::Move); + } + + (NONE, None, Key::End) => { + self.scroll_window(ScrollLocation::End, TouchEventType::Move); + } + (NONE, None, Key::Up) => { - self.scroll_window(0.0, 3.0 * LINE_HEIGHT, TouchEventType::Move); + self.scroll_window(ScrollLocation::Delta(TypedPoint2D::new(0.0, 3.0 * LINE_HEIGHT)), + TouchEventType::Move); } (NONE, None, Key::Down) => { - self.scroll_window(0.0, -3.0 * LINE_HEIGHT, TouchEventType::Move); + self.scroll_window(ScrollLocation::Delta(TypedPoint2D::new(0.0, -3.0 * LINE_HEIGHT)), + TouchEventType::Move); } (NONE, None, Key::Left) => { - self.scroll_window(LINE_HEIGHT, 0.0, TouchEventType::Move); + self.scroll_window(ScrollLocation::Delta(TypedPoint2D::new(LINE_HEIGHT, 0.0)), TouchEventType::Move); } (NONE, None, Key::Right) => { - self.scroll_window(-LINE_HEIGHT, 0.0, TouchEventType::Move); + self.scroll_window(ScrollLocation::Delta(TypedPoint2D::new(-LINE_HEIGHT, 0.0)), TouchEventType::Move); } (CMD_OR_CONTROL, Some('r'), _) => { if let Some(true) = PREFS.get("shell.builtin-key-shortcuts.enabled").as_boolean() { diff --git a/ports/servo/Cargo.toml b/ports/servo/Cargo.toml index cfaaa2faf1d..54408d25d74 100644 --- a/ports/servo/Cargo.toml +++ b/ports/servo/Cargo.toml @@ -41,7 +41,6 @@ browserhtml = {git = "https://github.com/browserhtml/browserhtml", branch = "cra glutin_app = {path = "../../ports/glutin"} log = "0.3" libservo = {path = "../../components/servo"} -phf_macros = "0.7.19" [target.'cfg(not(target_os = "android"))'.dependencies] sig = "0.1" diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 185e7420a47..7c8be361801 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -411,16 +411,13 @@ class MachCommands(CommandBase): @Command('test-wpt-failure', description='Run the tests harness that verifies that the test failures are reported correctly', - category='testing') - def test_wpt_failure(self): + category='testing', + parser=create_parser_wpt) + def test_wpt_failure(self, **kwargs): self.ensure_bootstrapped() - return not call([ - "bash", - path.join("tests", "wpt", "run.sh"), - "--no-pause-after-test", - "--include", - "infrastructure/failing-test.html" - ], env=self.build_env()) + kwargs["pause_after_test"] = False + kwargs["include"] = ["infrastructure/failing-test.html"] + return not self._test_wpt(**kwargs) @Command('test-wpt', description='Run the regular web platform test suite', diff --git a/rust-nightly-date b/rust-nightly-date index db017a3d33f..5e1c20c71d9 100644 --- a/rust-nightly-date +++ b/rust-nightly-date @@ -1 +1 @@ -2017-01-12 +2017-01-23 diff --git a/tests/compiletest/plugin/compile-fail/trustedpromise_mustnot_deriveclone.rs b/tests/compiletest/plugin/compile-fail/trustedpromise_mustnot_deriveclone.rs new file mode 100644 index 00000000000..08d684d4e4a --- /dev/null +++ b/tests/compiletest/plugin/compile-fail/trustedpromise_mustnot_deriveclone.rs @@ -0,0 +1,18 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#![feature(plugin)] +#![plugin(plugins)] + +extern crate script; + +use script::test::TrustedPromise; + +fn cloneable<T: Clone>() { +} + +fn main() { + cloneable::<TrustedPromise>(); + //~^ ERROR the trait bound `script::test::TrustedPromise: std::clone::Clone` is not satisfied +} diff --git a/tests/unit/style/Cargo.toml b/tests/unit/style/Cargo.toml index 69e5c3e9991..cfbac8127d1 100644 --- a/tests/unit/style/Cargo.toml +++ b/tests/unit/style/Cargo.toml @@ -22,7 +22,7 @@ owning_ref = "0.2.2" parking_lot = "0.3" rayon = "0.6" rustc-serialize = "0.3" -selectors = "0.15" +selectors = "0.15.1" servo_atoms = {path = "../../../components/atoms"} servo_config = {path = "../../../components/config"} style = {path = "../../../components/style"} diff --git a/tests/unit/style/lib.rs b/tests/unit/style/lib.rs index dd174c19dbf..90276fba75e 100644 --- a/tests/unit/style/lib.rs +++ b/tests/unit/style/lib.rs @@ -9,7 +9,7 @@ extern crate app_units; extern crate cssparser; extern crate euclid; #[macro_use] extern crate html5ever_atoms; -#[macro_use] #[allow(unused_extern_crates)] extern crate matches; +#[macro_use] extern crate matches; extern crate owning_ref; extern crate parking_lot; extern crate rayon; diff --git a/tests/unit/stylo/Cargo.toml b/tests/unit/stylo/Cargo.toml index 81722cc7b5a..b656443cff1 100644 --- a/tests/unit/stylo/Cargo.toml +++ b/tests/unit/stylo/Cargo.toml @@ -22,7 +22,7 @@ libc = "0.2" log = {version = "0.3.5", features = ["release_max_level_info"]} num_cpus = "1.1.0" parking_lot = "0.3" -selectors = "0.15" +selectors = "0.15.1" servo_url = {path = "../../../components/url"} style_traits = {path = "../../../components/style_traits"} geckoservo = {path = "../../../ports/geckolib"} diff --git a/tests/wpt/metadata-css/css-flexbox-1_dev/html/display_inline-flex_exist.htm.ini b/tests/wpt/metadata-css/css-flexbox-1_dev/html/display_inline-flex_exist.htm.ini deleted file mode 100644 index 91449bc2efe..00000000000 --- a/tests/wpt/metadata-css/css-flexbox-1_dev/html/display_inline-flex_exist.htm.ini +++ /dev/null @@ -1,5 +0,0 @@ -[display_inline-flex_exist.htm] - type: testharness - [CSS Flexible Box Test: display_inline-flex] - expected: FAIL - diff --git a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_display-inline.htm.ini b/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_display-inline.htm.ini deleted file mode 100644 index bfb3632381e..00000000000 --- a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_display-inline.htm.ini +++ /dev/null @@ -1,5 +0,0 @@ -[flexbox_computedstyle_display-inline.htm] - type: testharness - [flexbox | computed style | display: inline-flex] - expected: FAIL - diff --git a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_inline.htm.ini b/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_inline.htm.ini deleted file mode 100644 index fdd0f79122b..00000000000 --- a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_inline.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[flexbox_inline.htm] - type: reftest - expected: FAIL diff --git a/tests/wpt/metadata-css/css-flexbox-1_dev/html/ttwf-reftest-flex-inline.htm.ini b/tests/wpt/metadata-css/css-flexbox-1_dev/html/ttwf-reftest-flex-inline.htm.ini deleted file mode 100644 index 4f004f76131..00000000000 --- a/tests/wpt/metadata-css/css-flexbox-1_dev/html/ttwf-reftest-flex-inline.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[ttwf-reftest-flex-inline.htm] - type: reftest - expected: FAIL diff --git a/tests/wpt/metadata/FileAPI/idlharness.html.ini b/tests/wpt/metadata/FileAPI/idlharness.html.ini index 645001eb1c0..f4c97314499 100644 --- a/tests/wpt/metadata/FileAPI/idlharness.html.ini +++ b/tests/wpt/metadata/FileAPI/idlharness.html.ini @@ -3,24 +3,6 @@ [URL interface: operation createFor(Blob)] expected: FAIL - [FileReaderSync interface object length] - expected: FAIL - - [FileReaderSync interface: existence and properties of interface prototype object] - expected: FAIL - - [FileReaderSync interface: existence and properties of interface prototype object's "constructor" property] - expected: FAIL - - [FileReaderSync interface: operation readAsArrayBuffer(Blob)] - expected: FAIL - - [FileReaderSync interface: operation readAsText(Blob,DOMString)] - expected: FAIL - - [FileReaderSync interface: operation readAsDataURL(Blob)] - expected: FAIL - [FileReader interface: operation readAsBinaryString(Blob)] expected: FAIL diff --git a/tests/wpt/metadata/FileAPI/reading-data-section/Determining-Encoding.html.ini b/tests/wpt/metadata/FileAPI/reading-data-section/Determining-Encoding.html.ini index 6ef475882e0..1b62c9bc1e0 100644 --- a/tests/wpt/metadata/FileAPI/reading-data-section/Determining-Encoding.html.ini +++ b/tests/wpt/metadata/FileAPI/reading-data-section/Determining-Encoding.html.ini @@ -2,19 +2,25 @@ type: testharness [Blob Determing Encoding with encoding argument] expected: FAIL + bug: https://github.com/servo/servo/issues/10911 [Blob Determing Encoding with type attribute] expected: FAIL + bug: https://github.com/servo/servo/issues/10911 [Blob Determing Encoding with UTF-8 BOM] expected: FAIL + bug: https://github.com/servo/servo/issues/10911 [Blob Determing Encoding without anything implying charset.] expected: FAIL + bug: https://github.com/servo/servo/issues/10911 [Blob Determing Encoding with UTF-16BE BOM] expected: FAIL + bug: https://github.com/servo/servo/issues/10911 [Blob Determing Encoding with UTF-16LE BOM] expected: FAIL + bug: https://github.com/servo/servo/issues/10911 diff --git a/tests/wpt/metadata/FileAPI/reading-data-section/FileReader-multiple-reads.html.ini b/tests/wpt/metadata/FileAPI/reading-data-section/FileReader-multiple-reads.html.ini deleted file mode 100644 index ccfda894482..00000000000 --- a/tests/wpt/metadata/FileAPI/reading-data-section/FileReader-multiple-reads.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[FileReader-multiple-reads.html] - type: testharness - [test FileReader no InvalidStateError exception in onloadstart event for readAsArrayBuffer] - expected: FAIL - diff --git a/tests/wpt/metadata/FileAPI/reading-data-section/filereader_readAsArrayBuffer.html.ini b/tests/wpt/metadata/FileAPI/reading-data-section/filereader_readAsArrayBuffer.html.ini deleted file mode 100644 index ee637898bde..00000000000 --- a/tests/wpt/metadata/FileAPI/reading-data-section/filereader_readAsArrayBuffer.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[filereader_readAsArrayBuffer.html] - type: testharness - [FileAPI Test: filereader_readAsArrayBuffer] - expected: FAIL - diff --git a/tests/wpt/metadata/FileAPI/reading-data-section/filereader_result.html.ini b/tests/wpt/metadata/FileAPI/reading-data-section/filereader_result.html.ini deleted file mode 100644 index 415751e1ead..00000000000 --- a/tests/wpt/metadata/FileAPI/reading-data-section/filereader_result.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[filereader_result.html] - type: testharness - [readAsArrayBuffer] - expected: FAIL - diff --git a/tests/wpt/metadata/FileAPI/url/url_createobjecturl_blob.html.ini b/tests/wpt/metadata/FileAPI/url/url_createobjecturl_blob.html.ini index 92400cd1d65..b49ae1e4dd4 100644 --- a/tests/wpt/metadata/FileAPI/url/url_createobjecturl_blob.html.ini +++ b/tests/wpt/metadata/FileAPI/url/url_createobjecturl_blob.html.ini @@ -2,4 +2,5 @@ type: testharness [Check if the Blob URI starts with 'blob' using createFor()] expected: FAIL + bug: https://github.com/servo/servo/issues/15112 diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 01441eb3d85..82c13ee87e5 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -45867,6 +45867,12 @@ "url": "/cssom/overflow-serialization.html" } ], + "cssom/stylesheet-same-origin.sub.html": [ + { + "path": "cssom/stylesheet-same-origin.sub.html", + "url": "/cssom/stylesheet-same-origin.sub.html" + } + ], "html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.html": [ { "path": "html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.html", diff --git a/tests/wpt/metadata/dom/events/EventTarget-dispatchEvent.html.ini b/tests/wpt/metadata/dom/events/EventTarget-dispatchEvent.html.ini index 201224d1802..cdf64e987c2 100644 --- a/tests/wpt/metadata/dom/events/EventTarget-dispatchEvent.html.ini +++ b/tests/wpt/metadata/dom/events/EventTarget-dispatchEvent.html.ini @@ -3,9 +3,6 @@ [If the event's initialized flag is not set, an InvalidStateError must be thrown (AnimationEvent).] expected: FAIL - [If the event's initialized flag is not set, an InvalidStateError must be thrown (BeforeUnloadEvent).] - expected: FAIL - [If the event's initialized flag is not set, an InvalidStateError must be thrown (CompositionEvent).] expected: FAIL diff --git a/tests/wpt/metadata/dom/nodes/Document-createEvent.html.ini b/tests/wpt/metadata/dom/nodes/Document-createEvent.html.ini index c8062768eb4..783ad1e01c5 100644 --- a/tests/wpt/metadata/dom/nodes/Document-createEvent.html.ini +++ b/tests/wpt/metadata/dom/nodes/Document-createEvent.html.ini @@ -19,24 +19,6 @@ [createEvent('ANIMATIONEVENT') should be initialized correctly.] expected: FAIL - [BeforeUnloadEvent should be an alias for BeforeUnloadEvent.] - expected: FAIL - - [createEvent('BeforeUnloadEvent') should be initialized correctly.] - expected: FAIL - - [beforeunloadevent should be an alias for BeforeUnloadEvent.] - expected: FAIL - - [createEvent('beforeunloadevent') should be initialized correctly.] - expected: FAIL - - [BEFOREUNLOADEVENT should be an alias for BeforeUnloadEvent.] - expected: FAIL - - [createEvent('BEFOREUNLOADEVENT') should be initialized correctly.] - expected: FAIL - [CompositionEvent should be an alias for CompositionEvent.] expected: FAIL diff --git a/tests/wpt/metadata/subresource-integrity/subresource-integrity.sub.html.ini b/tests/wpt/metadata/subresource-integrity/subresource-integrity.sub.html.ini index 127ce07edb5..ada4d550044 100644 --- a/tests/wpt/metadata/subresource-integrity/subresource-integrity.sub.html.ini +++ b/tests/wpt/metadata/subresource-integrity/subresource-integrity.sub.html.ini @@ -3,25 +3,3 @@ expected: OK [Style: Same-origin with correct sha256 and sha512 hash, rel='alternate stylesheet' enabled] expected: FAIL - - [Style: Same-origin with incorrect hash.] - expected: FAIL - - [Style: Same-origin with sha256 match, sha512 mismatch] - expected: FAIL - - [Style: <crossorigin='anonymous'> with CORS-ineligible resource] - expected: FAIL - - [Style: Cross-origin, not CORS request, with correct hash] - expected: FAIL - - [Style: Cross-origin, not CORS request, with hash mismatch] - expected: FAIL - - [Style: <crossorigin='use-credentials'> with incorrect hash CORS-eligible] - expected: FAIL - - [Style: <crossorigin='anonymous'> with incorrect hash, ACAO: *] - expected: FAIL - diff --git a/tests/wpt/metadata/workers/semantics/interface-objects/002.worker.js.ini b/tests/wpt/metadata/workers/semantics/interface-objects/002.worker.js.ini deleted file mode 100644 index d05ef098814..00000000000 --- a/tests/wpt/metadata/workers/semantics/interface-objects/002.worker.js.ini +++ /dev/null @@ -1,14 +0,0 @@ -[002.worker.html] - type: testharness - [The Location interface object should not be exposed.] - expected: FAIL - - [The PopStateEvent interface object should not be exposed.] - expected: FAIL - - [The HashChangeEvent interface object should not be exposed.] - expected: FAIL - - [The PageTransitionEvent interface object should not be exposed.] - expected: FAIL - diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 98dbd60fcbb..bdff5ad1ed3 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -5220,6 +5220,18 @@ "url": "/_mozilla/css/table_intrinsic_style_specified_width_a.html" } ], + "css/table_margin_a.html": [ + { + "path": "css/table_margin_a.html", + "references": [ + [ + "/_mozilla/css/table_margin_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/table_margin_a.html" + } + ], "css/table_margin_auto_a.html": [ { "path": "css/table_margin_auto_a.html", @@ -6462,6 +6474,42 @@ "url": "/_mozilla/mozilla/iframe/resize_after_load.html" } ], + "mozilla/remove_link_styles.html": [ + { + "path": "mozilla/remove_link_styles.html", + "references": [ + [ + "/_mozilla/mozilla/remove_link_styles_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/remove_link_styles.html" + } + ], + "mozilla/remove_style_styles.html": [ + { + "path": "mozilla/remove_style_styles.html", + "references": [ + [ + "/_mozilla/mozilla/remove_style_styles_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/remove_style_styles.html" + } + ], + "mozilla/reparse_style_elements.html": [ + { + "path": "mozilla/reparse_style_elements.html", + "references": [ + [ + "/_mozilla/mozilla/reparse_style_elements_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/reparse_style_elements.html" + } + ], "mozilla/restyle-out-of-document.html": [ { "path": "mozilla/restyle-out-of-document.html", @@ -8750,6 +8798,18 @@ "url": "/_mozilla/mozilla/node_replaceChild.html" } ], + "mozilla/out-of-order-stylesheet-loads-and-imports.html": [ + { + "path": "mozilla/out-of-order-stylesheet-loads-and-imports.html", + "url": "/_mozilla/mozilla/out-of-order-stylesheet-loads-and-imports.html" + } + ], + "mozilla/out-of-order-stylesheet-loads.html": [ + { + "path": "mozilla/out-of-order-stylesheet-loads.html", + "url": "/_mozilla/mozilla/out-of-order-stylesheet-loads.html" + } + ], "mozilla/parentNode_querySelector.html": [ { "path": "mozilla/parentNode_querySelector.html", @@ -20586,6 +20646,18 @@ "url": "/_mozilla/css/table_intrinsic_style_specified_width_a.html" } ], + "css/table_margin_a.html": [ + { + "path": "css/table_margin_a.html", + "references": [ + [ + "/_mozilla/css/table_margin_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/table_margin_a.html" + } + ], "css/table_margin_auto_a.html": [ { "path": "css/table_margin_auto_a.html", @@ -21840,6 +21912,42 @@ "url": "/_mozilla/mozilla/iframe/resize_after_load.html" } ], + "mozilla/remove_link_styles.html": [ + { + "path": "mozilla/remove_link_styles.html", + "references": [ + [ + "/_mozilla/mozilla/remove_link_styles_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/remove_link_styles.html" + } + ], + "mozilla/remove_style_styles.html": [ + { + "path": "mozilla/remove_style_styles.html", + "references": [ + [ + "/_mozilla/mozilla/remove_style_styles_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/remove_style_styles.html" + } + ], + "mozilla/reparse_style_elements.html": [ + { + "path": "mozilla/reparse_style_elements.html", + "references": [ + [ + "/_mozilla/mozilla/reparse_style_elements_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/reparse_style_elements.html" + } + ], "mozilla/restyle-out-of-document.html": [ { "path": "mozilla/restyle-out-of-document.html", diff --git a/tests/wpt/mozilla/tests/css/table_margin_a.html b/tests/wpt/mozilla/tests/css/table_margin_a.html new file mode 100644 index 00000000000..b95a3a3ef29 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/table_margin_a.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <link rel="match" href="table_margin_ref.html" /> + <style type="text/css"> + table.ombox { + margin: 0 0 0 50%; + background: #f9f9f9; + } + + td, tr, table { + padding: 0; + margin: 0; + } + + .template-documentation { + width: 100%; + background-color: #ecfcf4; + padding: 0; + } + </style> + </head> + <body> + <div class="template-documentation"> + <table class="ombox"> + <tr> + <td> + This is a test. This line is large, large enough so that it will wrap. + Issue #12748, for which this test was created, is about the table margin not behaving correctly. + </td> + </tr> + </table> + </div> + </body> +</html> diff --git a/tests/wpt/mozilla/tests/css/table_margin_ref.html b/tests/wpt/mozilla/tests/css/table_margin_ref.html new file mode 100644 index 00000000000..fa5c4f88d82 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/table_margin_ref.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> +<html> + <head> + <style type="text/css"> + .ombox { + margin-left: 50%; + background: #f9f9f9; + padding: 2px; + } + .template-documentation { + background-color: #ecfcf4; + width: 100%; + } + </style> + </head> + <body> + <div class="template-documentation"> + <div class="ombox"> + This is a test. This line is large, large enough so that it will wrap. + Issue #12748, for which this test was created, is about the table margin not behaving correctly. + </div> + </div> + </body> +</html> diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js b/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js index eca4a7562b6..f91ed7c8bc5 100644 --- a/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js +++ b/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js @@ -7,7 +7,6 @@ importScripts("interfaces.js"); // IMPORTANT: Do not change the list below without review from a DOM peer! test_interfaces([ - "BeforeUnloadEvent", "Blob", "CloseEvent", "CSSStyleDeclaration", @@ -30,21 +29,17 @@ test_interfaces([ "FileReader", "FileReaderSync", "FormData", - "HashChangeEvent", "Headers", "History", "ImageData", - "Location", "MediaError", "MessageEvent", "MimeType", "MimeTypeArray", - "PageTransitionEvent", "Performance", "PerformanceTiming", "Plugin", "PluginArray", - "PopStateEvent", "ProgressEvent", "Request", "Response", diff --git a/tests/wpt/mozilla/tests/mozilla/out-of-order-stylesheet-loads-and-imports.html b/tests/wpt/mozilla/tests/mozilla/out-of-order-stylesheet-loads-and-imports.html new file mode 100644 index 00000000000..d22ae59c689 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/out-of-order-stylesheet-loads-and-imports.html @@ -0,0 +1,18 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Out-of-order stylesheet loads for the same element happen correctly, even with imports (issue #15101)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +async_test(function(t) { + var link = document.createElement("link"); + link.rel = "stylesheet"; + link.href = "resources/imports-background-red.css?pipe=trickle(d3)"; + document.head.appendChild(link); + link.href = "resources/imports-background-green.css"; + t.step_timeout(function() { + assert_equals(getComputedStyle(document.body).getPropertyValue("background-color"), "rgb(0, 128, 0)"); + t.done(); + }, 4000); +}, "out-of-order stylesheet loads for the same element happen correctly, even with imports"); +</script> diff --git a/tests/wpt/mozilla/tests/mozilla/out-of-order-stylesheet-loads.html b/tests/wpt/mozilla/tests/mozilla/out-of-order-stylesheet-loads.html new file mode 100644 index 00000000000..0ed15447bc1 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/out-of-order-stylesheet-loads.html @@ -0,0 +1,18 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Out-of-order stylesheet loads for the same element happen correctly (issue #15101)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +async_test(function(t) { + var link = document.createElement("link"); + link.rel = "stylesheet"; + link.href = "resources/background-red.css?pipe=trickle(d3)"; + document.head.appendChild(link); + link.href = "resources/background-green.css"; + t.step_timeout(function() { + assert_equals(getComputedStyle(document.body).getPropertyValue("background-color"), "rgb(0, 128, 0)"); + t.done(); + }, 4000); +}, "out-of-order stylesheet loads for the same element happen correctly"); +</script> diff --git a/tests/wpt/mozilla/tests/mozilla/remove_link_styles.css b/tests/wpt/mozilla/tests/mozilla/remove_link_styles.css new file mode 100644 index 00000000000..1984cf7df21 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/remove_link_styles.css @@ -0,0 +1,4 @@ +body { + background-color: red; + color: white !important; +} diff --git a/tests/wpt/mozilla/tests/mozilla/remove_link_styles.html b/tests/wpt/mozilla/tests/mozilla/remove_link_styles.html new file mode 100644 index 00000000000..6a1e592d096 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/remove_link_styles.html @@ -0,0 +1,19 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Removing link tag should remove associated styles</title> +<link rel="stylesheet" type="text/css" href="remove_link_styles.css"> +<link rel="match" href="remove_link_styles_ref.html"> +<body> + <style> + body { + color: green; + } + </style> + + This text should be green and the background should not be red. + + <script> + var l = document.querySelector('link[rel="stylesheet"]'); + l.parentNode.removeChild(l); + </script> +</body> diff --git a/tests/wpt/mozilla/tests/mozilla/remove_link_styles_ref.html b/tests/wpt/mozilla/tests/mozilla/remove_link_styles_ref.html new file mode 100644 index 00000000000..e9fd0816b9b --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/remove_link_styles_ref.html @@ -0,0 +1,11 @@ +<!doctype html> +<meta charset="utf-8"> +<body> + <style> + body { + color: green; + } + </style> + + This text should be green and the background should not be red. +</body> diff --git a/tests/wpt/mozilla/tests/mozilla/remove_style_styles.html b/tests/wpt/mozilla/tests/mozilla/remove_style_styles.html new file mode 100644 index 00000000000..f8a94bb7350 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/remove_style_styles.html @@ -0,0 +1,20 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Removing style element should remove all associated styles</title> +<link rel="match" href="remove_style_styles_ref.html"> +<body> + <style> + body { + background-color: red; + } + </style> + + This text should be black and the background should not be red. + + <script> + // Force restyling + window.getComputedStyle(document.body); + var s = document.querySelector('style'); + s.parentNode.removeChild(s); + </script> +</body> diff --git a/tests/wpt/mozilla/tests/mozilla/remove_style_styles_ref.html b/tests/wpt/mozilla/tests/mozilla/remove_style_styles_ref.html new file mode 100644 index 00000000000..d562e127203 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/remove_style_styles_ref.html @@ -0,0 +1,5 @@ +<!doctype html> +<meta charset="utf-8"> +<body> + This text should be black and the background should not be red. +</body> diff --git a/tests/wpt/mozilla/tests/mozilla/reparse_style_elements.html b/tests/wpt/mozilla/tests/mozilla/reparse_style_elements.html new file mode 100644 index 00000000000..e54f5a28d13 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/reparse_style_elements.html @@ -0,0 +1,18 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Style elements should be reparsed on change</title> +<link rel="match" href="reparse_style_elements_ref.html"> +<body> + <style> + body { + background-color: red; + } + </style> + + This text should be green and the background should not be red. + + <script> + var s = document.querySelector('body > style'); + s.textContent = 'body { color: green; }'; + </script> +</body> diff --git a/tests/wpt/mozilla/tests/mozilla/reparse_style_elements_ref.html b/tests/wpt/mozilla/tests/mozilla/reparse_style_elements_ref.html new file mode 100644 index 00000000000..e9fd0816b9b --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/reparse_style_elements_ref.html @@ -0,0 +1,11 @@ +<!doctype html> +<meta charset="utf-8"> +<body> + <style> + body { + color: green; + } + </style> + + This text should be green and the background should not be red. +</body> diff --git a/tests/wpt/mozilla/tests/mozilla/resources/background-green.css b/tests/wpt/mozilla/tests/mozilla/resources/background-green.css new file mode 100644 index 00000000000..9d9d772fb46 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/resources/background-green.css @@ -0,0 +1,3 @@ +body { + background-color: green; +} diff --git a/tests/wpt/mozilla/tests/mozilla/resources/background-red.css b/tests/wpt/mozilla/tests/mozilla/resources/background-red.css new file mode 100644 index 00000000000..aa1634c2550 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/resources/background-red.css @@ -0,0 +1,3 @@ +body { + background-color: red; +} diff --git a/tests/wpt/mozilla/tests/mozilla/resources/imports-background-green.css b/tests/wpt/mozilla/tests/mozilla/resources/imports-background-green.css new file mode 100644 index 00000000000..5d5cb67763d --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/resources/imports-background-green.css @@ -0,0 +1 @@ +@import url("background-green.css"); diff --git a/tests/wpt/mozilla/tests/mozilla/resources/imports-background-red.css b/tests/wpt/mozilla/tests/mozilla/resources/imports-background-red.css new file mode 100644 index 00000000000..c7f68081044 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/resources/imports-background-red.css @@ -0,0 +1 @@ +@import url("background-red.css"); diff --git a/tests/wpt/run.py b/tests/wpt/run.py index b1b158e63ab..77e21fb75ae 100644 --- a/tests/wpt/run.py +++ b/tests/wpt/run.py @@ -31,7 +31,11 @@ def run_tests(paths=None, **kwargs): mozlog.commandline.log_formatters["servo"] = \ (grouping_formatter.GroupingFormatter, "A grouping output formatter") - wptrunner.setup_logging(kwargs, {"servo": sys.stdout}) + + if len(kwargs["test_list"]) == 1: + wptrunner.setup_logging(kwargs, {"mach": sys.stdout}) + else: + wptrunner.setup_logging(kwargs, {"servo": sys.stdout}) success = wptrunner.run_tests(**kwargs) return 0 if success else 1 diff --git a/tests/wpt/web-platform-tests/FileAPI/reading-data-section/FileReader-multiple-reads.html b/tests/wpt/web-platform-tests/FileAPI/reading-data-section/FileReader-multiple-reads.html index 86a29d187b5..ca04f3c1819 100644 --- a/tests/wpt/web-platform-tests/FileAPI/reading-data-section/FileReader-multiple-reads.html +++ b/tests/wpt/web-platform-tests/FileAPI/reading-data-section/FileReader-multiple-reads.html @@ -62,12 +62,12 @@ async_test(function() { var blob_2 = new Blob(['TEST000000002']) var reader = new FileReader(); reader.onloadend = this.step_func_done(function() { - assert_equals(reader.readyState, FileReader.LOADING, - "readyState must be LOADING") + assert_equals(reader.readyState, FileReader.DONE, + "readyState must be DONE") reader.readAsArrayBuffer(blob_2) assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING") }); reader.readAsArrayBuffer(blob_1) assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING") -}, 'test FileReader no InvalidStateError exception in onloadstart event for readAsArrayBuffer'); +}, 'test FileReader no InvalidStateError exception in loadend event handler for readAsArrayBuffer'); </script> diff --git a/tests/wpt/web-platform-tests/cssom/stylesheet-same-origin.css b/tests/wpt/web-platform-tests/cssom/stylesheet-same-origin.css new file mode 100644 index 00000000000..d61a8dd67c9 --- /dev/null +++ b/tests/wpt/web-platform-tests/cssom/stylesheet-same-origin.css @@ -0,0 +1,3 @@ +body { + padding: 10px; +} diff --git a/tests/wpt/web-platform-tests/cssom/stylesheet-same-origin.sub.html b/tests/wpt/web-platform-tests/cssom/stylesheet-same-origin.sub.html new file mode 100644 index 00000000000..b259e4369dd --- /dev/null +++ b/tests/wpt/web-platform-tests/cssom/stylesheet-same-origin.sub.html @@ -0,0 +1,45 @@ +<!doctype html> +<html> +<head> + <meta charset="utf-8"> + <title>CSSOM - CSSStylesheet should support origins</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + + <link id="crossorigin" href="http://www1.{{host}}:{{ports[http][1]}}/stylesheet-same-origin.css" rel="stylesheet"> + <link id="sameorigin" href="stylesheet-same-origin.css" rel="stylesheet"> + + <script> + var crossorigin = document.getElementById("crossorigin").sheet; + var sameorigin = document.getElementById("sameorigin").sheet; + + test(function() { + assert_throws("SecurityError", + function () { + crossorigin.cssRules; + }, + "Cross origin stylesheet.cssRules should throw SecurityError."); + assert_throws("SecurityError", + function () { + crossorigin.insertRule("#test { margin: 10px; }", 1); + }, + "Cross origin stylesheet.insertRule should throw SecurityError."); + + assert_throws("SecurityError", + function () { + crossorigin.deleteRule(0); + }, + "Cross origin stylesheet.deleteRule should throw SecurityError."); + }, "Origin-clean check in cross-origin CSSOM Stylesheets"); + + test(function() { + assert_equals(sameorigin.cssRules.length, 1, "Same origin stylesheet.cssRules should be accessible."); + sameorigin.insertRule("#test { margin: 10px; }", 1); + assert_equals(sameorigin.cssRules.length, 2, "Same origin stylesheet.insertRule should be accessible."); + sameorigin.deleteRule(0); + assert_equals(sameorigin.cssRules.length, 1, "Same origin stylesheet.deleteRule should be accessible."); + }, "Origin-clean check in same-origin CSSOM Stylesheets"); + </script> +</head> +<body> +</html> diff --git a/tests/wpt/web-platform-tests/workers/semantics/interface-objects/002.worker.js b/tests/wpt/web-platform-tests/workers/semantics/interface-objects/002.worker.js index 0f514988bd2..8fc0b6a46f9 100644 --- a/tests/wpt/web-platform-tests/workers/semantics/interface-objects/002.worker.js +++ b/tests/wpt/web-platform-tests/workers/semantics/interface-objects/002.worker.js @@ -16,6 +16,7 @@ var unexpected = [ "DrawingStyle", "CanvasGradient", "CanvasPattern", + "BeforeUnloadEvent", "PopStateEvent", "HashChangeEvent", "PageTransitionEvent", |