From 2523a012c07585ca1ce96dcd34e518a74a3f65b7 Mon Sep 17 00:00:00 2001 From: Paul Rouget Date: Sun, 16 Jul 2017 23:58:48 -0700 Subject: [PATCH] servo: Merge #17684 - allow_navigation: use channel to send response (from paulrouget:fix_allow_navigation); r=paulrouget From the embedder perspective, this makes things easier in term of synchronicity. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ Source-Repo: https://github.com/servo/servo Source-Revision: 495faf3201141980acbf16c186252fa96d1cc3ea --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : c2b9931907dc844793413bdef7e052e0f23bc906 --- servo/Cargo.lock | 1 + servo/components/compositing/compositor.rs | 5 +---- servo/components/compositing/windowing.rs | 3 ++- servo/ports/cef/window.rs | 7 +++++-- servo/ports/glutin/Cargo.toml | 1 + servo/ports/glutin/lib.rs | 1 + servo/ports/glutin/window.rs | 7 +++++-- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/servo/Cargo.lock b/servo/Cargo.lock index 48a6e4354562..8f70f7e6aa85 100644 --- a/servo/Cargo.lock +++ b/servo/Cargo.lock @@ -1141,6 +1141,7 @@ dependencies = [ "euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libservo 0.0.1", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "net_traits 0.0.1", diff --git a/servo/components/compositing/compositor.rs b/servo/components/compositing/compositor.rs index 707ccf830164..93431755a4d8 100644 --- a/servo/components/compositing/compositor.rs +++ b/servo/components/compositing/compositor.rs @@ -509,10 +509,7 @@ impl IOCompositor { } (Msg::AllowNavigation(url, response_chan), ShutdownState::NotShuttingDown) => { - let allow = self.window.allow_navigation(url); - if let Err(e) = response_chan.send(allow) { - warn!("Failed to send allow_navigation result ({}).", e); - } + self.window.allow_navigation(url, response_chan); } (Msg::Recomposite(reason), ShutdownState::NotShuttingDown) => { diff --git a/servo/components/compositing/windowing.rs b/servo/components/compositing/windowing.rs index 8e728d220846..8604b41de465 100644 --- a/servo/components/compositing/windowing.rs +++ b/servo/components/compositing/windowing.rs @@ -8,6 +8,7 @@ use compositor_thread::EventLoopWaker; use euclid::{Point2D, Size2D}; use euclid::{TypedPoint2D, TypedRect, ScaleFactor, TypedSize2D}; use gleam::gl; +use ipc_channel::ipc::IpcSender; use msg::constellation_msg::{Key, KeyModifiers, KeyState, TraversalDirection}; use net_traits::net_error_list::NetError; use script_traits::{DevicePixel, LoadData, MouseButton, TouchEventType, TouchId, TouchpadPressurePhase}; @@ -131,7 +132,7 @@ pub trait WindowMethods { /// Called when the browser encounters an error while loading a URL fn load_error(&self, code: NetError, url: String); /// Wether or not to follow a link - fn allow_navigation(&self, url: ServoUrl) -> bool; + fn allow_navigation(&self, url: ServoUrl, IpcSender); /// Called when the tag has finished parsing fn head_parsed(&self); /// Called when the history state has changed. diff --git a/servo/ports/cef/window.rs b/servo/ports/cef/window.rs index 4f4837e0a41e..f38a7c11a740 100644 --- a/servo/ports/cef/window.rs +++ b/servo/ports/cef/window.rs @@ -24,6 +24,7 @@ use gleam::gl; use msg::constellation_msg::{Key, KeyModifiers}; use net_traits::net_error_list::NetError; use script_traits::{DevicePixel, LoadData}; +use servo::ipc_channel::ipc::IpcSender; use servo_geometry::DeviceIndependentPixel; use std::cell::RefCell; use std::ffi::CString; @@ -489,8 +490,10 @@ impl WindowMethods for Window { } } - fn allow_navigation(&self, _: ServoUrl) -> bool { - true + fn allow_navigation(&self, _: ServoUrl, response_chan: IpcSender) { + if let Err(e) = response_chan.send(true) { + warn!("Failed to send allow_navigation() response: {}", e); + }; } fn supports_clipboard(&self) -> bool { diff --git a/servo/ports/glutin/Cargo.toml b/servo/ports/glutin/Cargo.toml index 7a4e746915f2..b53ea7db4a0c 100644 --- a/servo/ports/glutin/Cargo.toml +++ b/servo/ports/glutin/Cargo.toml @@ -13,6 +13,7 @@ bitflags = "0.7" compositing = {path = "../../components/compositing"} euclid = "0.15" gleam = "0.4" +libservo = {path = "../../components/servo"} log = "0.3.5" msg = {path = "../../components/msg"} net_traits = {path = "../../components/net_traits"} diff --git a/servo/ports/glutin/lib.rs b/servo/ports/glutin/lib.rs index 025572e65a11..0426d2ba4d60 100644 --- a/servo/ports/glutin/lib.rs +++ b/servo/ports/glutin/lib.rs @@ -17,6 +17,7 @@ extern crate msg; extern crate net_traits; #[cfg(any(target_os = "linux", target_os = "macos"))] extern crate osmesa_sys; extern crate script_traits; +extern crate servo; extern crate servo_config; extern crate servo_geometry; extern crate servo_url; diff --git a/servo/ports/glutin/window.rs b/servo/ports/glutin/window.rs index 6488a48164f9..b35b7d5f3c04 100644 --- a/servo/ports/glutin/window.rs +++ b/servo/ports/glutin/window.rs @@ -25,6 +25,7 @@ use net_traits::net_error_list::NetError; #[cfg(any(target_os = "linux", target_os = "macos"))] use osmesa_sys; use script_traits::{DevicePixel, LoadData, TouchEventType, TouchpadPressurePhase}; +use servo::ipc_channel::ipc::IpcSender; use servo_config::opts; use servo_config::prefs::PREFS; use servo_config::resource_files; @@ -1300,8 +1301,10 @@ impl WindowMethods for Window { } } - fn allow_navigation(&self, _: ServoUrl) -> bool { - true + fn allow_navigation(&self, _: ServoUrl, response_chan: IpcSender) { + if let Err(e) = response_chan.send(true) { + warn!("Failed to send allow_navigation() response: {}", e); + }; } fn supports_clipboard(&self) -> bool {