mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Replace HistoryEntryReplacement with NavigationHistoryBehavior from the navigation API (#34681)
Signed-off-by: Shane Handley <shanehandley@fastmail.com>
This commit is contained in:
parent
3cbc8c2442
commit
3a4e5d4245
11 changed files with 127 additions and 108 deletions
|
@ -15,7 +15,7 @@ use js::rust::HandleObject;
|
|||
use mime::{self, Mime};
|
||||
use net_traits::http_percent_encode;
|
||||
use net_traits::request::Referrer;
|
||||
use script_traits::{HistoryEntryReplacement, LoadData, LoadOrigin};
|
||||
use script_traits::{LoadData, LoadOrigin, NavigationHistoryBehavior};
|
||||
use servo_atoms::Atom;
|
||||
use servo_rand::random;
|
||||
use style::attr::AttrValue;
|
||||
|
@ -1030,7 +1030,7 @@ impl HTMLFormElement {
|
|||
window
|
||||
.root()
|
||||
.load_url(
|
||||
HistoryEntryReplacement::Disabled,
|
||||
NavigationHistoryBehavior::Push,
|
||||
false,
|
||||
load_data,
|
||||
CanGc::note(),
|
||||
|
|
|
@ -13,8 +13,8 @@ use net_traits::ReferrerPolicy;
|
|||
use profile_traits::ipc as ProfiledIpc;
|
||||
use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
|
||||
use script_traits::{
|
||||
HistoryEntryReplacement, IFrameLoadInfo, IFrameLoadInfoWithData, JsEvalResult, LoadData,
|
||||
LoadOrigin, NewLayoutInfo, ScriptMsg, UpdatePipelineIdReason, WindowSizeData,
|
||||
IFrameLoadInfo, IFrameLoadInfoWithData, JsEvalResult, LoadData, LoadOrigin,
|
||||
NavigationHistoryBehavior, NewLayoutInfo, ScriptMsg, UpdatePipelineIdReason, WindowSizeData,
|
||||
};
|
||||
use servo_atoms::Atom;
|
||||
use servo_url::ServoUrl;
|
||||
|
@ -117,17 +117,22 @@ impl HTMLIFrameElement {
|
|||
pub fn navigate_or_reload_child_browsing_context(
|
||||
&self,
|
||||
load_data: LoadData,
|
||||
replace: HistoryEntryReplacement,
|
||||
history_handling: NavigationHistoryBehavior,
|
||||
can_gc: CanGc,
|
||||
) {
|
||||
self.start_new_pipeline(load_data, PipelineType::Navigation, replace, can_gc);
|
||||
self.start_new_pipeline(
|
||||
load_data,
|
||||
PipelineType::Navigation,
|
||||
history_handling,
|
||||
can_gc,
|
||||
);
|
||||
}
|
||||
|
||||
fn start_new_pipeline(
|
||||
&self,
|
||||
mut load_data: LoadData,
|
||||
pipeline_type: PipelineType,
|
||||
replace: HistoryEntryReplacement,
|
||||
history_handling: NavigationHistoryBehavior,
|
||||
can_gc: CanGc,
|
||||
) {
|
||||
let sandboxed = if self.is_sandboxed() {
|
||||
|
@ -191,7 +196,7 @@ impl HTMLIFrameElement {
|
|||
new_pipeline_id,
|
||||
is_private: false, // FIXME
|
||||
inherited_secure_context: load_data.inherited_secure_context,
|
||||
replace,
|
||||
history_handling,
|
||||
};
|
||||
|
||||
let window_size = WindowSizeData {
|
||||
|
@ -269,7 +274,7 @@ impl HTMLIFrameElement {
|
|||
load_data.srcdoc = String::from(element.get_string_attribute(&local_name!("srcdoc")));
|
||||
self.navigate_or_reload_child_browsing_context(
|
||||
load_data,
|
||||
HistoryEntryReplacement::Disabled,
|
||||
NavigationHistoryBehavior::Push,
|
||||
can_gc,
|
||||
);
|
||||
return;
|
||||
|
@ -361,12 +366,14 @@ impl HTMLIFrameElement {
|
|||
// see https://html.spec.whatwg.org/multipage/#the-iframe-element:about:blank-3
|
||||
let is_about_blank =
|
||||
pipeline_id.is_some() && pipeline_id == self.about_blank_pipeline_id.get();
|
||||
let replace = if is_about_blank {
|
||||
HistoryEntryReplacement::Enabled
|
||||
|
||||
let history_handling = if is_about_blank {
|
||||
NavigationHistoryBehavior::Replace
|
||||
} else {
|
||||
HistoryEntryReplacement::Disabled
|
||||
NavigationHistoryBehavior::Push
|
||||
};
|
||||
self.navigate_or_reload_child_browsing_context(load_data, replace, can_gc);
|
||||
|
||||
self.navigate_or_reload_child_browsing_context(load_data, history_handling, can_gc);
|
||||
}
|
||||
|
||||
fn create_nested_browsing_context(&self, can_gc: CanGc) {
|
||||
|
@ -407,7 +414,7 @@ impl HTMLIFrameElement {
|
|||
self.start_new_pipeline(
|
||||
load_data,
|
||||
PipelineType::InitialAboutBlank,
|
||||
HistoryEntryReplacement::Disabled,
|
||||
NavigationHistoryBehavior::Push,
|
||||
can_gc,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use dom_struct::dom_struct;
|
|||
use html5ever::{LocalName, Prefix};
|
||||
use js::rust::HandleObject;
|
||||
use regex::bytes::Regex;
|
||||
use script_traits::HistoryEntryReplacement;
|
||||
use script_traits::NavigationHistoryBehavior;
|
||||
use servo_url::ServoUrl;
|
||||
use style::str::HTML_SPACE_CHARACTERS;
|
||||
|
||||
|
@ -49,7 +49,7 @@ impl RefreshRedirectDue {
|
|||
pub fn invoke(self, can_gc: CanGc) {
|
||||
self.window.Location().navigate(
|
||||
self.url.clone(),
|
||||
HistoryEntryReplacement::Enabled,
|
||||
NavigationHistoryBehavior::Replace,
|
||||
NavigationType::DeclarativeRefresh,
|
||||
can_gc,
|
||||
);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use dom_struct::dom_struct;
|
||||
use net_traits::request::Referrer;
|
||||
use script_traits::{HistoryEntryReplacement, LoadData, LoadOrigin};
|
||||
use script_traits::{LoadData, LoadOrigin, NavigationHistoryBehavior};
|
||||
use servo_url::{MutableOrigin, ServoUrl};
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
||||
|
@ -69,7 +69,7 @@ impl Location {
|
|||
pub fn navigate(
|
||||
&self,
|
||||
url: ServoUrl,
|
||||
replacement_flag: HistoryEntryReplacement,
|
||||
history_handling: NavigationHistoryBehavior,
|
||||
navigation_type: NavigationType,
|
||||
can_gc: CanGc,
|
||||
) {
|
||||
|
@ -131,7 +131,7 @@ impl Location {
|
|||
None, // Top navigation doesn't inherit secure context
|
||||
);
|
||||
self.window
|
||||
.load_url(replacement_flag, reload_triggered, load_data, can_gc);
|
||||
.load_url(history_handling, reload_triggered, load_data, can_gc);
|
||||
}
|
||||
|
||||
/// Get if this `Location`'s [relevant `Document`][1] is non-null.
|
||||
|
@ -233,7 +233,7 @@ impl Location {
|
|||
// Step 6: Location-object navigate to copyURL.
|
||||
self.navigate(
|
||||
copy_url,
|
||||
HistoryEntryReplacement::Disabled,
|
||||
NavigationHistoryBehavior::Push,
|
||||
NavigationType::Normal,
|
||||
can_gc,
|
||||
);
|
||||
|
@ -254,7 +254,7 @@ impl Location {
|
|||
let url = self.window.get_url();
|
||||
self.navigate(
|
||||
url,
|
||||
HistoryEntryReplacement::Enabled,
|
||||
NavigationHistoryBehavior::Replace,
|
||||
NavigationType::ReloadByConstellation,
|
||||
can_gc,
|
||||
);
|
||||
|
@ -290,7 +290,7 @@ impl LocationMethods<crate::DomTypeHolder> for Location {
|
|||
let url = self.get_url_if_same_origin()?;
|
||||
self.navigate(
|
||||
url,
|
||||
HistoryEntryReplacement::Enabled,
|
||||
NavigationHistoryBehavior::Replace,
|
||||
NavigationType::ReloadByScript,
|
||||
can_gc,
|
||||
);
|
||||
|
@ -312,7 +312,7 @@ impl LocationMethods<crate::DomTypeHolder> for Location {
|
|||
// the replacement flag set.
|
||||
self.navigate(
|
||||
url,
|
||||
HistoryEntryReplacement::Enabled,
|
||||
NavigationHistoryBehavior::Replace,
|
||||
NavigationType::Normal,
|
||||
can_gc,
|
||||
);
|
||||
|
@ -424,7 +424,7 @@ impl LocationMethods<crate::DomTypeHolder> for Location {
|
|||
// Step 3: Location-object navigate to the resulting URL record.
|
||||
self.navigate(
|
||||
url,
|
||||
HistoryEntryReplacement::Disabled,
|
||||
NavigationHistoryBehavior::Push,
|
||||
NavigationType::Normal,
|
||||
can_gc,
|
||||
);
|
||||
|
|
|
@ -56,7 +56,7 @@ use script_layout_interface::{
|
|||
};
|
||||
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
|
||||
use script_traits::{
|
||||
ConstellationControlMsg, DocumentState, HistoryEntryReplacement, IFrameSizeMsg, LoadData,
|
||||
ConstellationControlMsg, DocumentState, IFrameSizeMsg, LoadData, NavigationHistoryBehavior,
|
||||
ScriptMsg, ScriptToConstellationChan, ScrollState, StructuredSerializedData, Theme,
|
||||
TimerSchedulerMsg, WindowSizeData, WindowSizeType,
|
||||
};
|
||||
|
@ -2387,7 +2387,7 @@ impl Window {
|
|||
/// <https://html.spec.whatwg.org/multipage/#navigating-across-documents>
|
||||
pub fn load_url(
|
||||
&self,
|
||||
replace: HistoryEntryReplacement,
|
||||
history_handling: NavigationHistoryBehavior,
|
||||
force_reload: bool,
|
||||
load_data: LoadData,
|
||||
can_gc: CanGc,
|
||||
|
@ -2403,7 +2403,7 @@ impl Window {
|
|||
if let Some(fragment) = load_data.url.fragment() {
|
||||
self.send_to_constellation(ScriptMsg::NavigatedToFragment(
|
||||
load_data.url.clone(),
|
||||
replace,
|
||||
history_handling,
|
||||
));
|
||||
doc.check_and_scroll_fragment(fragment, can_gc);
|
||||
let this = Trusted::new(self);
|
||||
|
@ -2462,7 +2462,7 @@ impl Window {
|
|||
window_proxy.browsing_context_id(),
|
||||
pipeline_id,
|
||||
load_data,
|
||||
replace,
|
||||
history_handling,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ use js::JSCLASS_IS_GLOBAL;
|
|||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
use net_traits::request::Referrer;
|
||||
use script_traits::{
|
||||
AuxiliaryBrowsingContextLoadInfo, HistoryEntryReplacement, LoadData, LoadOrigin, NewLayoutInfo,
|
||||
ScriptMsg,
|
||||
AuxiliaryBrowsingContextLoadInfo, LoadData, LoadOrigin, NavigationHistoryBehavior,
|
||||
NewLayoutInfo, ScriptMsg,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use servo_url::{ImmutableOrigin, ServoUrl};
|
||||
|
@ -526,12 +526,13 @@ impl WindowProxy {
|
|||
referrer_policy,
|
||||
Some(secure),
|
||||
);
|
||||
let replacement_flag = if new {
|
||||
HistoryEntryReplacement::Enabled
|
||||
let history_handling = if new {
|
||||
NavigationHistoryBehavior::Replace
|
||||
} else {
|
||||
HistoryEntryReplacement::Disabled
|
||||
NavigationHistoryBehavior::Push
|
||||
};
|
||||
target_window.load_url(replacement_flag, false, load_data, can_gc);
|
||||
|
||||
target_window.load_url(history_handling, false, load_data, can_gc);
|
||||
}
|
||||
if noopener {
|
||||
// Step 15 (Dis-owning has been done in create_auxiliary_browsing_context).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue