Compare commits

...

11 Commits

Author SHA1 Message Date
Fabrice Desré
d181be5482 Merge branch 'master' into gonk 2018-02-06 15:59:07 -08:00
Fabrice Desré
312da45327 Merge branch 'master' into gonk 2018-01-31 19:39:37 -08:00
Fabrice Desré
03ec258b42 Merge branch 'master' into gonk 2018-01-24 05:08:01 -08:00
Fabrice Desré
3a89ff2449 merge master 2018-01-14 22:38:42 -08:00
Fabrice Desré
2c1a527375 Merge branch 'master' into gonk 2018-01-10 21:12:56 -08:00
Fabrice Desré
4e18912cc3 Merge branch 'master' into gonk 2018-01-09 13:05:59 -08:00
Fabrice Desré
c15b8be0c7 Gonk config support 2018-01-09 08:51:25 -08:00
Fabrice Desré
7cae256c84 Merge branch 'master' into gonk 2018-01-06 23:26:53 -08:00
Fabrice Desré
ba40ca8447 merge master 2017-12-10 20:18:31 -08:00
Fabrice Desré
2afbaf365f Make web-bluetooth optional 2017-12-03 12:02:58 -08:00
Fabrice Desré
08b0114e60 wip 2017-11-30 11:35:14 -08:00
8 changed files with 383 additions and 222 deletions

30
Cargo.lock generated
View File

@@ -232,11 +232,11 @@ dependencies = [
[[package]]
name = "blurz"
version = "0.2.2"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"dbus 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"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]]
@@ -611,11 +611,11 @@ dependencies = [
[[package]]
name = "dbus"
version = "0.5.3"
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)",
"metadeps 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libdbus-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -666,7 +666,7 @@ 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.2 (registry+https://github.com/rust-lang/crates.io-index)",
"blurz 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1109,6 +1109,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.22.0"
@@ -1462,6 +1467,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"
@@ -2724,7 +2737,6 @@ dependencies = [
name = "servo_config"
version = "0.0.1"
dependencies = [
"android_injected_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3564,7 +3576,7 @@ 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.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4aee01fb76ada3e5e7ca642ea6664ebf7308a810739ca2aca44909a1191ac254"
"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>"
@@ -3606,6 +3618,7 @@ dependencies = [
"checksum harfbuzz-sys 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "52aa65c5649a0a2f1b27ab30093b3cc84681e17ddb552267e21948c5a6fa6b05"
"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.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e579ac8647178ab915d400d7d22938bda5cd351c6c62e1c294d56884ccfc75fe"
"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"
@@ -3634,6 +3647,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

@@ -5,6 +5,9 @@ authors = ["The Servo Project Developers"]
license = "MPL-2.0"
publish = false
[features]
gonk = []
[lib]
name = "servo_config"
path = "lib.rs"
@@ -29,5 +32,5 @@ env_logger = "0.4"
[target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))'.dependencies]
xdg = "2.0"
[target.'cfg(target_os = "android")'.dependencies]
android_injected_glue = "0.2"
# [target.'cfg(all(target_os = "android", not(feature = "gonk")))'.dependencies]
# android_injected_glue = "0.2"

View File

@@ -6,11 +6,11 @@
//! For linux based platforms, it uses the XDG base directory spec but provides
//! similar abstractions for non-linux platforms.
#[cfg(target_os = "android")]
#[cfg(all(target_os = "android", not(feature = "gonk")))]
use android_injected_glue;
#[cfg(any(target_os = "macos", target_os = "windows"))]
use std::env;
#[cfg(target_os = "android")]
#[cfg(all(target_os = "android", not(feature = "gonk")))]
use std::ffi::CStr;
use std::path::PathBuf;
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
@@ -23,12 +23,11 @@ pub fn default_config_dir() -> Option<PathBuf> {
Some(config_dir)
}
#[cfg(target_os = "android")]
#[cfg(all(target_os = "android", not(feature = "gonk")))]
#[allow(unsafe_code)]
pub fn default_config_dir() -> Option<PathBuf> {
let dir = unsafe {
CStr::from_ptr((*android_injected_glue::get_app().activity).externalDataPath)
};
let dir =
unsafe { CStr::from_ptr((*android_injected_glue::get_app().activity).externalDataPath) };
Some(PathBuf::from(dir.to_str().unwrap()))
}
@@ -39,12 +38,11 @@ pub fn default_data_dir() -> Option<PathBuf> {
Some(data_dir)
}
#[cfg(target_os = "android")]
#[cfg(all(target_os = "android", not(feature = "gonk")))]
#[allow(unsafe_code)]
pub fn default_data_dir() -> Option<PathBuf> {
let dir = unsafe {
CStr::from_ptr((*android_injected_glue::get_app().activity).internalDataPath)
};
let dir =
unsafe { CStr::from_ptr((*android_injected_glue::get_app().activity).internalDataPath) };
Some(PathBuf::from(dir.to_str().unwrap()))
}
@@ -55,14 +53,13 @@ pub fn default_cache_dir() -> Option<PathBuf> {
Some(cache_dir)
}
#[cfg(target_os = "android")]
#[cfg(all(target_os = "android", not(feature = "gonk")))]
#[allow(unsafe_code)]
pub fn default_cache_dir() -> Option<PathBuf> {
// TODO: Use JNI to call context.getCacheDir().
// There is no equivalent function in NDK/NativeActivity.
let dir = unsafe {
CStr::from_ptr((*android_injected_glue::get_app().activity).externalDataPath)
};
let dir =
unsafe { CStr::from_ptr((*android_injected_glue::get_app().activity).externalDataPath) };
Some(PathBuf::from(dir.to_str().unwrap()))
}
@@ -89,3 +86,18 @@ pub fn default_config_dir() -> Option<PathBuf> {
config_dir.push("Servo");
Some(config_dir)
}
#[cfg(feature = "gonk")]
pub fn default_config_dir() -> Option<PathBuf> {
Some("/data/local/servo".into())
}
#[cfg(feature = "gonk")]
pub fn default_data_dir() -> Option<PathBuf> {
Some("/data/local/servo".into())
}
#[cfg(feature = "gonk")]
pub fn default_cache_dir() -> Option<PathBuf> {
Some("/data/local/servo".into())
}

View File

@@ -4,15 +4,18 @@
#![deny(unsafe_code)]
#[cfg(target_os = "android")]
#[cfg(all(target_os = "android", not(feature = "gonk")))]
extern crate android_injected_glue;
extern crate euclid;
extern crate getopts;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate log;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
extern crate num_cpus;
extern crate rustc_serialize;
#[macro_use] extern crate serde;
#[macro_use]
extern crate serde;
extern crate servo_geometry;
extern crate servo_url;
extern crate url;
@@ -20,7 +23,8 @@ extern crate url;
extern crate xdg;
pub mod basedir;
#[allow(unsafe_code)] pub mod opts;
#[allow(unsafe_code)]
pub mod opts;
pub mod prefs;
pub mod resource_files;

View File

@@ -2,11 +2,11 @@
* 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(target_os = "android")]
#[cfg(all(target_os = "android", not(feature = "gonk")))]
use android_injected_glue;
#[cfg(not(target_os = "android"))]
#[cfg(any(not(target_os = "android"), feature = "gonk"))]
use std::env;
#[cfg(target_os = "android")]
#[cfg(all(target_os = "android", not(feature = "gonk")))]
use std::ffi::CStr;
use std::fs::File;
use std::io::{self, Read};
@@ -24,7 +24,7 @@ pub fn set_resources_path(path: Option<String>) {
*dir = path;
}
#[cfg(target_os = "android")]
#[cfg(all(target_os = "android", not(feature = "gonk")))]
#[allow(unsafe_code)]
pub fn resources_dir_path() -> io::Result<PathBuf> {
let mut dir = CMD_RESOURCE_DIR.lock().unwrap();
@@ -33,15 +33,14 @@ pub fn resources_dir_path() -> io::Result<PathBuf> {
return Ok(PathBuf::from(path));
}
let data_path = unsafe {
CStr::from_ptr((*android_injected_glue::get_app().activity).externalDataPath)
};
let data_path =
unsafe { CStr::from_ptr((*android_injected_glue::get_app().activity).externalDataPath) };
let path = PathBuf::from(data_path.to_str().unwrap());
*dir = Some(path.to_str().unwrap().to_owned());
Ok(path)
}
#[cfg(not(target_os = "android"))]
#[cfg(any(not(target_os = "android"), feature = "gonk"))]
pub fn resources_dir_path() -> io::Result<PathBuf> {
let mut dir = CMD_RESOURCE_DIR.lock().unwrap();

View File

@@ -25,10 +25,12 @@ unstable = [
"profile/unstable",
"script/unstable",
]
web-bluetooth = ["bluetooth"]
gonk = [ "servo_config/gonk" ]
[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!");
}

View File

@@ -19,7 +19,7 @@ euclid = "0.16"
ipc-channel = "0.9"
log = "0.3"
msg = {path = "../msg"}
rust-webvr = {version = "0.9", features = ["openvr"]}
rust-webvr = {version = "0.9", features = ["mock"]}
script_traits = {path = "../script_traits"}
servo_config = {path = "../config"}
webvr_traits = {path = "../webvr_traits" }