mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
Auto merge of #15795 - paulrouget:follow-link, r=asajeffrey
Let the embedder decide if servo should follow a link or not We want to give a chance to the embedder to handle a link itself. Is it a problem that this will add a round trip to the main thread every time `load_url` is called? --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #15655 <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because I'm not sure how to test that <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15795) <!-- Reviewable:end -->
This commit is contained in:
commit
808ffffd1e
6 changed files with 27 additions and 0 deletions
|
@ -544,6 +544,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
self.window.load_end(back, forward, root);
|
self.window.load_end(back, forward, root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(Msg::DelayedCompositionTimeout(timestamp), ShutdownState::NotShuttingDown) => {
|
(Msg::DelayedCompositionTimeout(timestamp), ShutdownState::NotShuttingDown) => {
|
||||||
if let CompositionRequest::DelayedComposite(this_timestamp) =
|
if let CompositionRequest::DelayedComposite(this_timestamp) =
|
||||||
self.composition_request {
|
self.composition_request {
|
||||||
|
|
|
@ -86,6 +86,8 @@ pub enum Msg {
|
||||||
LoadStart(bool, bool),
|
LoadStart(bool, bool),
|
||||||
/// The load of a page has completed: (can go back, can go forward, is root frame).
|
/// The load of a page has completed: (can go back, can go forward, is root frame).
|
||||||
LoadComplete(bool, bool, bool),
|
LoadComplete(bool, bool, bool),
|
||||||
|
/// Wether or not to follow a link
|
||||||
|
AllowNavigation(ServoUrl, IpcSender<bool>),
|
||||||
/// We hit the delayed composition timeout. (See `delayed_composition.rs`.)
|
/// We hit the delayed composition timeout. (See `delayed_composition.rs`.)
|
||||||
DelayedCompositionTimeout(u64),
|
DelayedCompositionTimeout(u64),
|
||||||
/// Composite.
|
/// Composite.
|
||||||
|
@ -144,6 +146,7 @@ impl Debug for Msg {
|
||||||
Msg::ChangePageUrl(..) => write!(f, "ChangePageUrl"),
|
Msg::ChangePageUrl(..) => write!(f, "ChangePageUrl"),
|
||||||
Msg::SetFrameTree(..) => write!(f, "SetFrameTree"),
|
Msg::SetFrameTree(..) => write!(f, "SetFrameTree"),
|
||||||
Msg::LoadComplete(..) => write!(f, "LoadComplete"),
|
Msg::LoadComplete(..) => write!(f, "LoadComplete"),
|
||||||
|
Msg::AllowNavigation(..) => write!(f, "AllowNavigation"),
|
||||||
Msg::LoadStart(..) => write!(f, "LoadStart"),
|
Msg::LoadStart(..) => write!(f, "LoadStart"),
|
||||||
Msg::DelayedCompositionTimeout(..) => write!(f, "DelayedCompositionTimeout"),
|
Msg::DelayedCompositionTimeout(..) => write!(f, "DelayedCompositionTimeout"),
|
||||||
Msg::Recomposite(..) => write!(f, "Recomposite"),
|
Msg::Recomposite(..) => write!(f, "Recomposite"),
|
||||||
|
|
|
@ -137,6 +137,8 @@ pub trait WindowMethods {
|
||||||
fn load_end(&self, back: bool, forward: bool, root: bool);
|
fn load_end(&self, back: bool, forward: bool, root: bool);
|
||||||
/// Called when the browser encounters an error while loading a URL
|
/// Called when the browser encounters an error while loading a URL
|
||||||
fn load_error(&self, code: NetError, url: String);
|
fn load_error(&self, code: NetError, url: String);
|
||||||
|
/// Wether or not to follow a link
|
||||||
|
fn allow_navigation(&self, url: ServoUrl) -> bool;
|
||||||
/// Called when the <head> tag has finished parsing
|
/// Called when the <head> tag has finished parsing
|
||||||
fn head_parsed(&self);
|
fn head_parsed(&self);
|
||||||
|
|
||||||
|
|
|
@ -1575,6 +1575,13 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_url(&mut self, source_id: PipelineId, load_data: LoadData, replace: bool) -> Option<PipelineId> {
|
fn load_url(&mut self, source_id: PipelineId, load_data: LoadData, replace: bool) -> Option<PipelineId> {
|
||||||
|
// Allow the embedder to handle the url itself
|
||||||
|
let (chan, port) = ipc::channel().expect("Failed to create IPC channel!");
|
||||||
|
self.compositor_proxy.send(ToCompositorMsg::AllowNavigation(load_data.url.clone(), chan));
|
||||||
|
if let Ok(false) = port.recv() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
debug!("Loading {} in pipeline {}.", load_data.url, source_id);
|
debug!("Loading {} in pipeline {}.", load_data.url, source_id);
|
||||||
// If this load targets an iframe, its framing element may exist
|
// If this load targets an iframe, its framing element may exist
|
||||||
// in a separate script thread than the framed document that initiated
|
// in a separate script thread than the framed document that initiated
|
||||||
|
|
|
@ -484,6 +484,10 @@ impl WindowMethods for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn allow_navigation(&self, _: ServoUrl) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
fn supports_clipboard(&self) -> bool {
|
fn supports_clipboard(&self) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
|
@ -1107,6 +1107,10 @@ impl WindowMethods for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn allow_navigation(&self, _: ServoUrl) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
fn supports_clipboard(&self) -> bool {
|
fn supports_clipboard(&self) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue