mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #23368 - gterzian:clean_up_navigation, r=asajeffrey
Clean-up navigation <!-- Please describe your changes on the following line: --> 1. Navigation as a result of following a hyperlink should be done in a task: https://html.spec.whatwg.org/multipage/links.html#following-hyperlinks:dom-manipulation-task-source 2. The javascript url navigation should also be done in a task: https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigating-across-documents:dom-manipulation-task-source 3. In `window.load_url`, it seems there is no need to send a message to the script-thread(the entirety of `load_url` should instead be done in a task when appropriate), so we can just do that last part "sync" by calling a method on the script, which will send a message to the constellation(for the parallel navigation steps), or queue task(for the JS navigation), as appropriate. 4. Separate the "normal" navigation flow from the handling of "navigate an iframe" message from constellation, since doing everything in one method as was previously done with `handle_navigate`, is confusing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- 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/23368) <!-- Reviewable:end -->
This commit is contained in:
commit
2dfbbd0ca2
14 changed files with 402 additions and 220 deletions
|
@ -63,7 +63,8 @@ use webrender_api::{DocumentId, ExternalScrollId, ImageKey, RenderApiSender};
|
|||
use webvr_traits::{WebVREvent, WebVRMsg};
|
||||
|
||||
pub use crate::script_msg::{
|
||||
DOMMessage, SWManagerMsg, SWManagerSenders, ScopeThings, ServiceWorkerMsg,
|
||||
DOMMessage, HistoryEntryReplacement, SWManagerMsg, SWManagerSenders, ScopeThings,
|
||||
ServiceWorkerMsg,
|
||||
};
|
||||
pub use crate::script_msg::{
|
||||
EventResult, IFrameSize, IFrameSizeMsg, LayoutMsg, LogEntry, ScriptMsg,
|
||||
|
@ -118,10 +119,24 @@ pub enum LayoutControlMsg {
|
|||
PaintMetric(Epoch, u64),
|
||||
}
|
||||
|
||||
/// The origin where a given load was initiated.
|
||||
/// Useful for origin checks, for example before evaluation a JS URL.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub enum LoadOrigin {
|
||||
/// A load originating in the constellation.
|
||||
Constellation,
|
||||
/// A load originating in webdriver.
|
||||
WebDriver,
|
||||
/// A load originating in script.
|
||||
Script(ImmutableOrigin),
|
||||
}
|
||||
|
||||
/// can be passed to `LoadUrl` to load a page with GET/POST
|
||||
/// parameters or headers
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct LoadData {
|
||||
/// The origin where the load started.
|
||||
pub load_origin: LoadOrigin,
|
||||
/// The URL.
|
||||
pub url: ServoUrl,
|
||||
/// The creator pipeline id if this is an about:blank load.
|
||||
|
@ -161,12 +176,14 @@ pub enum JsEvalResult {
|
|||
impl LoadData {
|
||||
/// Create a new `LoadData` object.
|
||||
pub fn new(
|
||||
load_origin: LoadOrigin,
|
||||
url: ServoUrl,
|
||||
creator_pipeline_id: Option<PipelineId>,
|
||||
referrer: Option<Referrer>,
|
||||
referrer_policy: Option<ReferrerPolicy>,
|
||||
) -> LoadData {
|
||||
LoadData {
|
||||
load_origin,
|
||||
url: url,
|
||||
creator_pipeline_id: creator_pipeline_id,
|
||||
method: Method::GET,
|
||||
|
@ -290,7 +307,12 @@ pub enum ConstellationControlMsg {
|
|||
NotifyVisibilityChange(PipelineId, BrowsingContextId, bool),
|
||||
/// Notifies script thread that a url should be loaded in this iframe.
|
||||
/// PipelineId is for the parent, BrowsingContextId is for the nested browsing context
|
||||
Navigate(PipelineId, BrowsingContextId, LoadData, bool),
|
||||
NavigateIframe(
|
||||
PipelineId,
|
||||
BrowsingContextId,
|
||||
LoadData,
|
||||
HistoryEntryReplacement,
|
||||
),
|
||||
/// Post a message to a given window.
|
||||
PostMessage {
|
||||
/// The target of the message.
|
||||
|
@ -377,7 +399,7 @@ impl fmt::Debug for ConstellationControlMsg {
|
|||
SetDocumentActivity(..) => "SetDocumentActivity",
|
||||
ChangeFrameVisibilityStatus(..) => "ChangeFrameVisibilityStatus",
|
||||
NotifyVisibilityChange(..) => "NotifyVisibilityChange",
|
||||
Navigate(..) => "Navigate",
|
||||
NavigateIframe(..) => "NavigateIframe",
|
||||
PostMessage { .. } => "PostMessage",
|
||||
UpdatePipelineId(..) => "UpdatePipelineId",
|
||||
UpdateHistoryState(..) => "UpdateHistoryState",
|
||||
|
@ -673,6 +695,8 @@ pub enum IFrameSandboxState {
|
|||
/// Specifies the information required to load an auxiliary browsing context.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct AuxiliaryBrowsingContextLoadInfo {
|
||||
/// Load data containing the url to load
|
||||
pub load_data: LoadData,
|
||||
/// The pipeline opener browsing context.
|
||||
pub opener_pipeline_id: PipelineId,
|
||||
/// The new top-level ID for the auxiliary.
|
||||
|
@ -698,7 +722,7 @@ pub struct IFrameLoadInfo {
|
|||
pub is_private: bool,
|
||||
/// Wether this load should replace the current entry (reload). If true, the current
|
||||
/// entry will be replaced instead of a new entry being added.
|
||||
pub replace: bool,
|
||||
pub replace: HistoryEntryReplacement,
|
||||
}
|
||||
|
||||
/// Specifies the information required to load a URL in an iframe.
|
||||
|
@ -707,7 +731,7 @@ pub struct IFrameLoadInfoWithData {
|
|||
/// The information required to load an iframe.
|
||||
pub info: IFrameLoadInfo,
|
||||
/// Load data containing the url to load
|
||||
pub load_data: Option<LoadData>,
|
||||
pub load_data: LoadData,
|
||||
/// The old pipeline ID for this iframe, if a page was previously loaded.
|
||||
pub old_pipeline_id: Option<PipelineId>,
|
||||
/// Sandbox type of this iframe
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue