Make web-bluetooth optional

This commit is contained in:
Fabrice Desré
2017-12-03 12:02:58 -08:00
parent 08b0114e60
commit 2afbaf365f
3 changed files with 399 additions and 184 deletions

87
Cargo.lock generated
View File

@@ -187,6 +187,20 @@ name = "block"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bluetooth"
version = "0.0.1"
dependencies = [
"bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bluetooth_traits 0.0.1",
"device 0.0.1 (git+https://github.com/servo/devices)",
"ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_config 0.0.1",
"servo_rand 0.0.1",
"tinyfiledialogs 2.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bluetooth_traits"
version = "0.0.1"
@@ -197,6 +211,37 @@ dependencies = [
"servo_config 0.0.1",
]
[[package]]
name = "blurdroid"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "blurmac"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "blurmock"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "blurz"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"dbus 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "brotli"
version = "1.0.8"
@@ -600,6 +645,15 @@ dependencies = [
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "dbus"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"libdbus-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "debug_unreachable"
version = "0.1.1"
@@ -640,6 +694,17 @@ dependencies = [
"deny_public_fields 0.0.1",
]
[[package]]
name = "device"
version = "0.0.1"
source = "git+https://github.com/servo/devices#c3b012b0ac4fbc47d1ebc9bd3fc308f599be4ee4"
dependencies = [
"blurdroid 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"blurmac 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"blurmock 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"blurz 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "devtools"
version = "0.0.1"
@@ -1183,6 +1248,11 @@ dependencies = [
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "hex"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "html5ever"
version = "0.21.0"
@@ -1538,6 +1608,14 @@ name = "libc"
version = "0.2.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libdbus-sys"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"metadeps 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libloading"
version = "0.4.0"
@@ -1552,6 +1630,7 @@ dependencies = [
name = "libservo"
version = "0.0.1"
dependencies = [
"bluetooth 0.0.1",
"bluetooth_traits 0.0.1",
"canvas 0.0.1",
"canvas_traits 0.0.1",
@@ -3713,6 +3792,10 @@ dependencies = [
"checksum bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5cde24d1b2e2216a726368b2363a273739c91f4e3eb4e0dd12d672d396ad989"
"checksum bitreader 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "80b13e2ab064ff3aa0bdbf1eff533f9822dc37899821f5f98c67f263eab51707"
"checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
"checksum blurdroid 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7daba519d29beebfc7d302795af88a16b43f431b9b268586926ac61cc655a68"
"checksum blurmac 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72af3718b3f652fb2026bf9d9dd5f92332cd287884283c343f03fff16cbb0172"
"checksum blurmock 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "68dd72da3a3bb40f3d3bdd366c4cf8e2b1d208c366304f382c80cef8126ca8da"
"checksum blurz 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e46aafc5abff777617a09f64396ed689d76937e440970450972abd615c3d470b"
"checksum brotli 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "951f20a2cc403194b2746d9ac6f796292e3c0344e983c72c7d6bd6cff6c3d102"
"checksum brotli-decompressor 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e80402aa0457c3c03d3996a36af7c1e7efa2ad97ee8ec7c2761b07666bab5566"
"checksum browserhtml 0.1.17 (git+https://github.com/browserhtml/browserhtml?branch=crate)" = "<none>"
@@ -3746,8 +3829,10 @@ dependencies = [
"checksum darling_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1486a8b00b45062c997f767738178b43219133dd0c8c826cb811e60563810821"
"checksum darling_macro 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a86ec160aa0c3dd492dd4a14ec8104ad8f1a9400a820624db857998cc1f80f9"
"checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850"
"checksum dbus 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "796755704353dc297bf81c1461b17244d3d1c6fb018e0fb3f43f3223555118f5"
"checksum debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a032eac705ca39214d169f83e3d3da290af06d8d1d344d1baad2fd002dca4b3"
"checksum deflate 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ebb02aaf4b775afc96684b8402510a338086974e38570a1f65bea8c202eb77a7"
"checksum device 0.0.1 (git+https://github.com/servo/devices)" = "<none>"
"checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90"
"checksum dtoa-short 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe6f727b406462fd57c95fed84d1b0dbfb5f0136fcac005adba9ea0367c05cc8"
"checksum dwmapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07c4c7cc7b396419bc0a4d90371d0cee16cb5053b53647d287c0b728000c41fe"
@@ -3790,6 +3875,7 @@ dependencies = [
"checksum heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c7593b1522161003928c959c20a2ca421c68e940d63d75573316a009e48a6d4"
"checksum heartbeats-simple 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9ad003ce233955e9d95f2c69cde84e68302ba9ba4a673d351c9bff93c738aadc"
"checksum heartbeats-simple-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e1a408c0011427cc0e0049f7861c70377819aedfc006e8c901b1c70fd98fb1a4"
"checksum hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa"
"checksum html5ever 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba3a1fd1857a714d410c191364c5d7bf8a6487c0ab5575146d37dd7eb17ef523"
"checksum httparse 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a6e7a63e511f9edffbab707141fbb8707d1a3098615fb2adbd5769cdfcc9b17d"
"checksum hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)" = "368cb56b2740ebf4230520e2b90ebb0461e69034d85d1945febd9b3971426db2"
@@ -3817,6 +3903,7 @@ dependencies = [
"checksum leak 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bd100e01f1154f2908dfa7d02219aeab25d0b9c7fa955164192e3245255a0c73"
"checksum leaky-cow 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40a8225d44241fd324a8af2806ba635fc7c8a7e9a7de4d5cf3ef54e71f5926fc"
"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2"
"checksum libdbus-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e764c95d2e469b780a35e0a7684857369912d99aa35eeb927f204eb63e6e5b6a"
"checksum libloading 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "be99f814beb3e9503a786a592c909692bb6d4fc5a695f6ed7987223acfbd5194"
"checksum libz-sys 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "87f737ad6cc6fd6eefe3d9dc5412f1573865bded441300904d2f42269e140f16"
"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"

View File

@@ -25,10 +25,11 @@ unstable = [
"profile/unstable",
"script/unstable",
]
web-bluetooth = ["bluetooth"]
[dependencies]
bluetooth_traits = {path = "../bluetooth_traits"}
# bluetooth = {path = "../bluetooth"}
bluetooth = {path = "../bluetooth", optional = true}
canvas = {path = "../canvas"}
canvas_traits = {path = "../canvas_traits"}
compositing = {path = "../compositing"}

View File

@@ -24,6 +24,7 @@ extern crate gleam;
#[macro_use]
extern crate log;
#[cfg(feature = "web-bluetooth")]
pub extern crate bluetooth;
pub extern crate bluetooth_traits;
pub extern crate canvas;
@@ -43,8 +44,8 @@ pub extern crate net_traits;
pub extern crate profile;
pub extern crate profile_traits;
pub extern crate script;
pub extern crate script_traits;
pub extern crate script_layout_interface;
pub extern crate script_traits;
pub extern crate servo_config;
pub extern crate servo_geometry;
pub extern crate servo_url;
@@ -65,14 +66,16 @@ fn webdriver(port: u16, constellation: Sender<ConstellationMsg>) {
}
#[cfg(not(feature = "webdriver"))]
fn webdriver(_port: u16, _constellation: Sender<ConstellationMsg>) { }
fn webdriver(_port: u16, _constellation: Sender<ConstellationMsg>) {}
#[cfg(feature = "web-bluetooth")]
use bluetooth::BluetoothThreadFactory;
use bluetooth_traits::BluetoothRequest;
use canvas::gl_context::GLContextFactory;
use canvas::webgl_thread::WebGLThreads;
use compositing::{IOCompositor, ShutdownState, RenderNotifier};
use compositing::compositor_thread::{self, CompositorProxy, CompositorReceiver, InitialCompositorState};
use compositing::{IOCompositor, RenderNotifier, ShutdownState};
use compositing::compositor_thread::{self, CompositorProxy, CompositorReceiver,
InitialCompositorState};
use compositing::compositor_thread::{EmbedderMsg, EmbedderProxy, EmbedderReceiver};
use compositing::windowing::WindowEvent;
use compositing::windowing::WindowMethods;
@@ -101,9 +104,9 @@ use std::borrow::Cow;
use std::cmp::max;
use std::path::PathBuf;
use std::rc::Rc;
use std::sync::mpsc::{Sender, channel};
use std::sync::mpsc::{channel, Sender};
use webrender::RendererKind;
use webvr::{WebVRThread, WebVRCompositorHandler};
use webvr::{WebVRCompositorHandler, WebVRThread};
pub use gleam::gl;
pub use servo_config as config;
@@ -124,10 +127,13 @@ pub use msg::constellation_msg::TopLevelBrowsingContextId as BrowserId;
pub struct Servo<Window: WindowMethods + 'static> {
compositor: IOCompositor<Window>,
constellation_chan: Sender<ConstellationMsg>,
embedder_receiver: EmbedderReceiver
embedder_receiver: EmbedderReceiver,
}
impl<Window> Servo<Window> where Window: WindowMethods + 'static {
impl<Window> Servo<Window>
where
Window: WindowMethods + 'static,
{
pub fn new(window: Rc<Window>) -> Servo<Window> {
// Global configuration options, parsed from the command line.
let opts = opts::get();
@@ -144,15 +150,13 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
let (embedder_proxy, embedder_receiver) =
create_embedder_channel(window.create_event_loop_waker());
let supports_clipboard = window.supports_clipboard();
let time_profiler_chan = profile_time::Profiler::create(&opts.time_profiling,
opts.time_profiler_trace_path.clone());
let time_profiler_chan = profile_time::Profiler::create(
&opts.time_profiling,
opts.time_profiler_trace_path.clone(),
);
let mem_profiler_chan = profile_mem::Profiler::create(opts.mem_profiler_period);
let debugger_chan = opts.debugger_port.map(|port| {
debugger::start_server(port)
});
let devtools_chan = opts.devtools_port.map(|port| {
devtools::start_server(port)
});
let debugger_chan = opts.debugger_port.map(|port| debugger::start_server(port));
let devtools_chan = opts.devtools_port.map(|port| devtools::start_server(port));
let mut resource_path = resources_dir_path().unwrap();
resource_path.push("shaders");
@@ -165,7 +169,7 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
None => match opts.output_file {
Some(_) => 1.0,
None => scale_factor,
}
},
};
let renderer_kind = if opts::get().should_use_osmesa() {
@@ -187,24 +191,29 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
let render_notifier = Box::new(RenderNotifier::new(compositor_proxy.clone()));
webrender::Renderer::new(window.gl(), render_notifier, webrender::RendererOptions {
device_pixel_ratio: device_pixel_ratio,
resource_override_path: Some(resource_path),
enable_aa: opts.enable_text_antialiasing,
debug_flags: debug_flags,
debug: opts.webrender_debug,
recorder: recorder,
precache_shaders: opts.precache_shaders,
enable_scrollbars: opts.output_file.is_none(),
renderer_kind: renderer_kind,
enable_subpixel_aa: opts.enable_subpixel_text_antialiasing,
..Default::default()
}).expect("Unable to initialize webrender!")
webrender::Renderer::new(
window.gl(),
render_notifier,
webrender::RendererOptions {
device_pixel_ratio: device_pixel_ratio,
resource_override_path: Some(resource_path),
enable_aa: opts.enable_text_antialiasing,
debug_flags: debug_flags,
debug: opts.webrender_debug,
recorder: recorder,
precache_shaders: opts.precache_shaders,
enable_scrollbars: opts.output_file.is_none(),
renderer_kind: renderer_kind,
enable_subpixel_aa: opts.enable_subpixel_text_antialiasing,
..Default::default()
},
).expect("Unable to initialize webrender!")
};
let webrender_api = webrender_api_sender.create_api();
let wr_document_layer = 0; //TODO
let webrender_document = webrender_api.add_document(window.framebuffer_size(), wr_document_layer);
let webrender_document =
webrender_api.add_document(window.framebuffer_size(), wr_document_layer);
// Important that this call is done in a single-threaded fashion, we
// can't defer it after `create_constellation` has started.
@@ -213,19 +222,21 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
// Create the constellation, which maintains the engine
// pipelines, including the script and layout threads, as well
// as the navigation context.
let (constellation_chan, sw_senders) = create_constellation(opts.user_agent.clone(),
opts.config_dir.clone(),
embedder_proxy.clone(),
compositor_proxy.clone(),
time_profiler_chan.clone(),
mem_profiler_chan.clone(),
debugger_chan,
devtools_chan,
supports_clipboard,
&mut webrender,
webrender_document,
webrender_api_sender,
window.gl());
let (constellation_chan, sw_senders) = create_constellation(
opts.user_agent.clone(),
opts.config_dir.clone(),
embedder_proxy.clone(),
compositor_proxy.clone(),
time_profiler_chan.clone(),
mem_profiler_chan.clone(),
debugger_chan,
devtools_chan,
supports_clipboard,
&mut webrender,
webrender_document,
webrender_api_sender,
window.gl(),
);
// Send the constellation's swmanager sender to service worker manager thread
script::init_service_workers(sw_senders);
@@ -238,16 +249,19 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
// The compositor coordinates with the client window to create the final
// rendered page and display it somewhere.
let compositor = IOCompositor::create(window, InitialCompositorState {
sender: compositor_proxy,
receiver: compositor_receiver,
constellation_chan: constellation_chan.clone(),
time_profiler_chan: time_profiler_chan,
mem_profiler_chan: mem_profiler_chan,
webrender,
webrender_document,
webrender_api,
});
let compositor = IOCompositor::create(
window,
InitialCompositorState {
sender: compositor_proxy,
receiver: compositor_receiver,
constellation_chan: constellation_chan.clone(),
time_profiler_chan: time_profiler_chan,
mem_profiler_chan: mem_profiler_chan,
webrender,
webrender_document,
webrender_api,
},
);
Servo {
compositor: compositor,
@@ -258,8 +272,7 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
fn handle_window_event(&mut self, event: WindowEvent) {
match event {
WindowEvent::Idle => {
}
WindowEvent::Idle => {}
WindowEvent::Refresh => {
self.compositor.composite();
@@ -277,7 +290,8 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
}
WindowEvent::MouseWindowEventClass(mouse_window_event) => {
self.compositor.on_mouse_window_event_class(mouse_window_event);
self.compositor
.on_mouse_window_event_class(mouse_window_event);
}
WindowEvent::MouseWindowMoveEventClass(cursor) => {
@@ -285,7 +299,8 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
}
WindowEvent::Touch(event_type, identifier, location) => {
self.compositor.on_touch_event(event_type, identifier, location);
self.compositor
.on_touch_event(event_type, identifier, location);
}
WindowEvent::Scroll(delta, cursor, phase) => {
@@ -305,14 +320,16 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
}
WindowEvent::Navigation(top_level_browsing_context_id, direction) => {
let msg = ConstellationMsg::TraverseHistory(top_level_browsing_context_id, direction);
let msg =
ConstellationMsg::TraverseHistory(top_level_browsing_context_id, direction);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending navigation to constellation failed ({}).", e);
}
}
WindowEvent::TouchpadPressure(cursor, pressure, stage) => {
self.compositor.on_touchpad_pressure_event(cursor, pressure, stage);
self.compositor
.on_touchpad_pressure_event(cursor, pressure, stage);
}
WindowEvent::KeyEvent(ch, key, state, modifiers) => {
@@ -340,21 +357,30 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
WindowEvent::NewBrowser(url, response_chan) => {
let msg = ConstellationMsg::NewBrowser(url, response_chan);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending NewBrowser message to constellation failed ({}).", e);
warn!(
"Sending NewBrowser message to constellation failed ({}).",
e
);
}
}
WindowEvent::SelectBrowser(ctx) => {
let msg = ConstellationMsg::SelectBrowser(ctx);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending SelectBrowser message to constellation failed ({}).", e);
warn!(
"Sending SelectBrowser message to constellation failed ({}).",
e
);
}
}
WindowEvent::CloseBrowser(ctx) => {
let msg = ConstellationMsg::CloseBrowser(ctx);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending CloseBrowser message to constellation failed ({}).", e);
warn!(
"Sending CloseBrowser message to constellation failed ({}).",
e
);
}
}
}
@@ -364,103 +390,171 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
while let Some(msg) = self.embedder_receiver.try_recv_embedder_msg() {
match (msg, self.compositor.shutdown_state) {
(_, ShutdownState::FinishedShuttingDown) => {
error!("embedder shouldn't be handling messages after compositor has shut down");
},
error!(
"embedder shouldn't be handling messages after compositor has shut down"
);
}
(_, ShutdownState::ShuttingDown) => {},
(_, ShutdownState::ShuttingDown) => {}
(EmbedderMsg::Status(top_level_browsing_context, message), ShutdownState::NotShuttingDown) => {
self.compositor.window.status(top_level_browsing_context, message);
},
(
EmbedderMsg::Status(top_level_browsing_context, message),
ShutdownState::NotShuttingDown,
) => {
self.compositor
.window
.status(top_level_browsing_context, message);
}
(EmbedderMsg::ChangePageTitle(top_level_browsing_context, title), ShutdownState::NotShuttingDown) => {
self.compositor.window.set_page_title(top_level_browsing_context, title);
},
(
EmbedderMsg::ChangePageTitle(top_level_browsing_context, title),
ShutdownState::NotShuttingDown,
) => {
self.compositor
.window
.set_page_title(top_level_browsing_context, title);
}
(EmbedderMsg::MoveTo(top_level_browsing_context, point),
ShutdownState::NotShuttingDown) => {
self.compositor.window.set_position(top_level_browsing_context, point);
},
(
EmbedderMsg::MoveTo(top_level_browsing_context, point),
ShutdownState::NotShuttingDown,
) => {
self.compositor
.window
.set_position(top_level_browsing_context, point);
}
(EmbedderMsg::ResizeTo(top_level_browsing_context, size),
ShutdownState::NotShuttingDown) => {
self.compositor.window.set_inner_size(top_level_browsing_context, size);
},
(
EmbedderMsg::ResizeTo(top_level_browsing_context, size),
ShutdownState::NotShuttingDown,
) => {
self.compositor
.window
.set_inner_size(top_level_browsing_context, size);
}
(EmbedderMsg::GetClientWindow(top_level_browsing_context, send),
ShutdownState::NotShuttingDown) => {
let rect = self.compositor.window.client_window(top_level_browsing_context);
(
EmbedderMsg::GetClientWindow(top_level_browsing_context, send),
ShutdownState::NotShuttingDown,
) => {
let rect = self.compositor
.window
.client_window(top_level_browsing_context);
if let Err(e) = send.send(rect) {
warn!("Sending response to get client window failed ({}).", e);
}
},
}
(EmbedderMsg::GetScreenSize(top_level_browsing_context, send),
ShutdownState::NotShuttingDown) => {
let rect = self.compositor.window.screen_size(top_level_browsing_context);
(
EmbedderMsg::GetScreenSize(top_level_browsing_context, send),
ShutdownState::NotShuttingDown,
) => {
let rect = self.compositor
.window
.screen_size(top_level_browsing_context);
if let Err(e) = send.send(rect) {
warn!("Sending response to get screen size failed ({}).", e);
}
},
}
(EmbedderMsg::GetScreenAvailSize(top_level_browsing_context, send),
ShutdownState::NotShuttingDown) => {
let rect = self.compositor.window.screen_avail_size(top_level_browsing_context);
(
EmbedderMsg::GetScreenAvailSize(top_level_browsing_context, send),
ShutdownState::NotShuttingDown,
) => {
let rect = self.compositor
.window
.screen_avail_size(top_level_browsing_context);
if let Err(e) = send.send(rect) {
warn!("Sending response to get screen available size failed ({}).", e);
warn!(
"Sending response to get screen available size failed ({}).",
e
);
}
},
}
(EmbedderMsg::AllowNavigation(top_level_browsing_context,
url,
response_chan),
ShutdownState::NotShuttingDown) => {
self.compositor.window.allow_navigation(top_level_browsing_context, url, response_chan);
},
(
EmbedderMsg::AllowNavigation(top_level_browsing_context, url, response_chan),
ShutdownState::NotShuttingDown,
) => {
self.compositor.window.allow_navigation(
top_level_browsing_context,
url,
response_chan,
);
}
(EmbedderMsg::KeyEvent(top_level_browsing_context,
ch,
key,
state,
modified),
ShutdownState::NotShuttingDown) => {
if state == KeyState::Pressed {
self.compositor.window.handle_key(top_level_browsing_context, ch, key, modified);
}
(
EmbedderMsg::KeyEvent(top_level_browsing_context, ch, key, state, modified),
ShutdownState::NotShuttingDown,
) => if state == KeyState::Pressed {
self.compositor.window.handle_key(
top_level_browsing_context,
ch,
key,
modified,
);
},
(EmbedderMsg::SetCursor(cursor), ShutdownState::NotShuttingDown) => {
self.compositor.window.set_cursor(cursor)
},
}
(EmbedderMsg::NewFavicon(top_level_browsing_context, url), ShutdownState::NotShuttingDown) => {
self.compositor.window.set_favicon(top_level_browsing_context, url);
},
(
EmbedderMsg::NewFavicon(top_level_browsing_context, url),
ShutdownState::NotShuttingDown,
) => {
self.compositor
.window
.set_favicon(top_level_browsing_context, url);
}
(EmbedderMsg::HeadParsed(top_level_browsing_context, ), ShutdownState::NotShuttingDown) => {
self.compositor.window.head_parsed(top_level_browsing_context, );
},
(
EmbedderMsg::HeadParsed(top_level_browsing_context),
ShutdownState::NotShuttingDown,
) => {
self.compositor
.window
.head_parsed(top_level_browsing_context);
}
(EmbedderMsg::HistoryChanged(top_level_browsing_context, entries, current),
ShutdownState::NotShuttingDown) => {
self.compositor.window.history_changed(top_level_browsing_context, entries, current);
},
(
EmbedderMsg::HistoryChanged(top_level_browsing_context, entries, current),
ShutdownState::NotShuttingDown,
) => {
self.compositor.window.history_changed(
top_level_browsing_context,
entries,
current,
);
}
(EmbedderMsg::SetFullscreenState(top_level_browsing_context, state),
ShutdownState::NotShuttingDown) => {
self.compositor.window.set_fullscreen_state(top_level_browsing_context, state);
},
(
EmbedderMsg::SetFullscreenState(top_level_browsing_context, state),
ShutdownState::NotShuttingDown,
) => {
self.compositor
.window
.set_fullscreen_state(top_level_browsing_context, state);
}
(EmbedderMsg::LoadStart(top_level_browsing_context), ShutdownState::NotShuttingDown) => {
self.compositor.window.load_start(top_level_browsing_context);
},
(
EmbedderMsg::LoadStart(top_level_browsing_context),
ShutdownState::NotShuttingDown,
) => {
self.compositor
.window
.load_start(top_level_browsing_context);
}
(EmbedderMsg::LoadComplete(top_level_browsing_context), ShutdownState::NotShuttingDown) => {
(
EmbedderMsg::LoadComplete(top_level_browsing_context),
ShutdownState::NotShuttingDown,
) => {
// Inform the embedder that the load has finished.
//
// TODO(pcwalton): Specify which frame's load completed.
self.compositor.window.load_end(top_level_browsing_context);
},
}
}
}
}
@@ -503,53 +597,70 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
}
}
fn create_embedder_channel(event_loop_waker: Box<compositor_thread::EventLoopWaker>)
-> (EmbedderProxy, EmbedderReceiver) {
fn create_embedder_channel(
event_loop_waker: Box<compositor_thread::EventLoopWaker>,
) -> (EmbedderProxy, EmbedderReceiver) {
let (sender, receiver) = channel();
(EmbedderProxy {
sender: sender,
event_loop_waker: event_loop_waker,
},
EmbedderReceiver {
receiver: receiver
})
(
EmbedderProxy {
sender: sender,
event_loop_waker: event_loop_waker,
},
EmbedderReceiver { receiver: receiver },
)
}
fn create_compositor_channel(event_loop_waker: Box<compositor_thread::EventLoopWaker>)
-> (CompositorProxy, CompositorReceiver) {
fn create_compositor_channel(
event_loop_waker: Box<compositor_thread::EventLoopWaker>,
) -> (CompositorProxy, CompositorReceiver) {
let (sender, receiver) = channel();
(CompositorProxy {
sender: sender,
event_loop_waker: event_loop_waker,
},
CompositorReceiver {
receiver: receiver
})
(
CompositorProxy {
sender: sender,
event_loop_waker: event_loop_waker,
},
CompositorReceiver { receiver: receiver },
)
}
fn create_constellation(user_agent: Cow<'static, str>,
config_dir: Option<PathBuf>,
embedder_proxy: EmbedderProxy,
compositor_proxy: CompositorProxy,
time_profiler_chan: time::ProfilerChan,
mem_profiler_chan: mem::ProfilerChan,
debugger_chan: Option<debugger::Sender>,
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
supports_clipboard: bool,
webrender: &mut webrender::Renderer,
webrender_document: webrender_api::DocumentId,
webrender_api_sender: webrender_api::RenderApiSender,
window_gl: Rc<gl::Gl>)
-> (Sender<ConstellationMsg>, SWManagerSenders) {
let bluetooth_thread: IpcSender<BluetoothRequest> = BluetoothThreadFactory::new();
fn create_constellation(
user_agent: Cow<'static, str>,
config_dir: Option<PathBuf>,
embedder_proxy: EmbedderProxy,
compositor_proxy: CompositorProxy,
time_profiler_chan: time::ProfilerChan,
mem_profiler_chan: mem::ProfilerChan,
debugger_chan: Option<debugger::Sender>,
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
supports_clipboard: bool,
webrender: &mut webrender::Renderer,
webrender_document: webrender_api::DocumentId,
webrender_api_sender: webrender_api::RenderApiSender,
window_gl: Rc<gl::Gl>,
) -> (Sender<ConstellationMsg>, SWManagerSenders) {
let bluetooth_thread: IpcSender<BluetoothRequest>;
let (public_resource_threads, private_resource_threads) =
new_resource_threads(user_agent,
devtools_chan.clone(),
time_profiler_chan.clone(),
config_dir);
let font_cache_thread = FontCacheThread::new(public_resource_threads.sender(),
webrender_api_sender.create_api());
#[cfg(feature = "web-bluetooth")]
{
bluetooth_thread = BluetoothThreadFactory::new();
}
#[cfg(not(feature = "web-bluetooth"))]
{
let (sender, _receiver) = ipc::channel().unwrap();
bluetooth_thread = sender;
}
let (public_resource_threads, private_resource_threads) = new_resource_threads(
user_agent,
devtools_chan.clone(),
time_profiler_chan.clone(),
config_dir,
);
let font_cache_thread = FontCacheThread::new(
public_resource_threads.sender(),
webrender_api_sender.create_api(),
);
let resource_sender = public_resource_threads.sender();
@@ -558,7 +669,11 @@ fn create_constellation(user_agent: Cow<'static, str>,
let (mut handler, sender) = WebVRCompositorHandler::new();
let (webvr_thread, constellation_sender) = WebVRThread::spawn(sender);
handler.set_webvr_thread_sender(webvr_thread.clone());
(Some(webvr_thread), Some(constellation_sender), Some(handler))
(
Some(webvr_thread),
Some(constellation_sender),
Some(handler),
)
} else {
(None, None, None)
};
@@ -571,10 +686,12 @@ fn create_constellation(user_agent: Cow<'static, str>,
};
// Initialize WebGL Thread entry point.
let (webgl_threads, image_handler, output_handler) = WebGLThreads::new(gl_factory,
window_gl,
webrender_api_sender.clone(),
webvr_compositor.map(|c| c as Box<_>));
let (webgl_threads, image_handler, output_handler) = WebGLThreads::new(
gl_factory,
window_gl,
webrender_api_sender.clone(),
webvr_compositor.map(|c| c as Box<_>),
);
// Set webrender external image handler for WebGL textures
webrender.set_external_image_handler(image_handler);
@@ -600,20 +717,23 @@ fn create_constellation(user_agent: Cow<'static, str>,
webgl_threads,
webvr_chan,
};
let (constellation_chan, from_swmanager_sender) =
Constellation::<script_layout_interface::message::Msg,
layout_thread::LayoutThread,
script::script_thread::ScriptThread>::start(initial_state);
let (constellation_chan, from_swmanager_sender) = Constellation::<
script_layout_interface::message::Msg,
layout_thread::LayoutThread,
script::script_thread::ScriptThread,
>::start(initial_state);
if let Some(webvr_constellation_sender) = webvr_constellation_sender {
// Set constellation channel used by WebVR thread to broadcast events
webvr_constellation_sender.send(constellation_chan.clone()).unwrap();
webvr_constellation_sender
.send(constellation_chan.clone())
.unwrap();
}
// channels to communicate with Service Worker Manager
let sw_senders = SWManagerSenders {
swmanager_sender: from_swmanager_sender,
resource_sender: resource_sender
resource_sender: resource_sender,
};
(constellation_chan, sw_senders)
@@ -623,7 +743,11 @@ fn create_constellation(user_agent: Cow<'static, str>,
// This should probably be in the log crate.
struct BothLogger<Log1, Log2>(Log1, Log2);
impl<Log1, Log2> Log for BothLogger<Log1, Log2> where Log1: Log, Log2: Log {
impl<Log1, Log2> Log for BothLogger<Log1, Log2>
where
Log1: Log,
Log2: Log,
{
fn enabled(&self, metadata: &LogMetadata) -> bool {
self.0.enabled(metadata) || self.1.enabled(metadata)
}
@@ -651,7 +775,9 @@ pub fn run_content_process(token: String) {
ipc::channel::<UnprivilegedPipelineContent>().unwrap();
let connection_bootstrap: IpcSender<IpcSender<UnprivilegedPipelineContent>> =
IpcSender::connect(token).unwrap();
connection_bootstrap.send(unprivileged_content_sender).unwrap();
connection_bootstrap
.send(unprivileged_content_sender)
.unwrap();
let unprivileged_content = unprivileged_content_receiver.recv().unwrap();
opts::set_defaults(unprivileged_content.opts());
@@ -660,7 +786,7 @@ pub fn run_content_process(token: String) {
// Enter the sandbox if necessary.
if opts::get().sandbox {
create_sandbox();
create_sandbox();
}
// send the required channels to the service worker manager
@@ -675,7 +801,8 @@ pub fn run_content_process(token: String) {
#[cfg(all(not(target_os = "windows"), not(target_os = "ios")))]
fn create_sandbox() {
ChildSandbox::new(content_process_sandbox_profile()).activate()
ChildSandbox::new(content_process_sandbox_profile())
.activate()
.expect("Failed to activate sandbox!");
}