mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Replace current session entry for reloads
This commit is contained in:
parent
0b0495cff4
commit
e9b2f1b916
10 changed files with 89 additions and 57 deletions
|
@ -588,5 +588,5 @@ fn follow_hyperlink(subject: &Element, hyperlink_suffix: Option<String>) {
|
|||
|
||||
debug!("following hyperlink to {}", url);
|
||||
let window = document.window();
|
||||
window.load_url(url);
|
||||
window.load_url(url, false);
|
||||
}
|
||||
|
|
|
@ -902,7 +902,7 @@ impl Runnable for PlannedNavigation {
|
|||
fn handler(self: Box<PlannedNavigation>) {
|
||||
if self.generation_id == self.form.root().generation_id.get() {
|
||||
let script_chan = self.script_chan.clone();
|
||||
script_chan.send(MainThreadScriptMsg::Navigate(self.pipeline_id, self.load_data)).unwrap();
|
||||
script_chan.send(MainThreadScriptMsg::Navigate(self.pipeline_id, self.load_data, false)).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ impl HTMLIFrameElement {
|
|||
(old_pipeline_id, new_pipeline_id)
|
||||
}
|
||||
|
||||
pub fn navigate_or_reload_child_browsing_context(&self, load_data: Option<LoadData>) {
|
||||
pub fn navigate_or_reload_child_browsing_context(&self, load_data: Option<LoadData>, replace: bool) {
|
||||
let sandboxed = if self.is_sandboxed() {
|
||||
IFrameSandboxed
|
||||
} else {
|
||||
|
@ -134,6 +134,7 @@ impl HTMLIFrameElement {
|
|||
sandbox: sandboxed,
|
||||
is_private: private_iframe,
|
||||
frame_type: frame_type,
|
||||
replace: replace,
|
||||
};
|
||||
window.constellation_chan()
|
||||
.send(ConstellationMsg::ScriptLoadedURLInIFrame(load_info))
|
||||
|
@ -150,7 +151,7 @@ impl HTMLIFrameElement {
|
|||
|
||||
let document = document_from_node(self);
|
||||
self.navigate_or_reload_child_browsing_context(
|
||||
Some(LoadData::new(url, document.get_referrer_policy(), Some(document.url().clone()))));
|
||||
Some(LoadData::new(url, document.get_referrer_policy(), Some(document.url().clone()))), false);
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -491,7 +492,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
|||
fn Reload(&self, _hard_reload: bool) -> ErrorResult {
|
||||
if self.Mozbrowser() {
|
||||
if self.upcast::<Node>().is_in_doc() {
|
||||
self.navigate_or_reload_child_browsing_context(None);
|
||||
self.navigate_or_reload_child_browsing_context(None, true);
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
|
|
|
@ -40,7 +40,7 @@ impl Location {
|
|||
setter: fn(&mut Url, USVString)) {
|
||||
let mut url = self.window.get_url();
|
||||
setter(&mut url, value);
|
||||
self.window.load_url(url);
|
||||
self.window.load_url(url, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,13 +51,13 @@ impl LocationMethods for Location {
|
|||
// _entry settings object_.
|
||||
let base_url = self.window.get_url();
|
||||
if let Ok(url) = base_url.join(&url.0) {
|
||||
self.window.load_url(url);
|
||||
self.window.load_url(url, false);
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-reload
|
||||
fn Reload(&self) {
|
||||
self.window.load_url(self.get_url());
|
||||
self.window.load_url(self.get_url(), true);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-hash
|
||||
|
@ -106,7 +106,7 @@ impl LocationMethods for Location {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-location-href
|
||||
fn SetHref(&self, value: USVString) {
|
||||
if let Ok(url) = self.window.get_url().join(&value.0) {
|
||||
self.window.load_url(url);
|
||||
self.window.load_url(url, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1410,11 +1410,12 @@ impl Window {
|
|||
}
|
||||
|
||||
/// Commence a new URL load which will either replace this window or scroll to a fragment.
|
||||
pub fn load_url(&self, url: Url) {
|
||||
pub fn load_url(&self, url: Url, replace: bool) {
|
||||
let doc = self.Document();
|
||||
self.main_thread_script_chan().send(
|
||||
MainThreadScriptMsg::Navigate(self.id,
|
||||
LoadData::new(url, doc.get_referrer_policy(), Some(doc.url().clone())))).unwrap();
|
||||
LoadData::new(url, doc.get_referrer_policy(), Some(doc.url().clone())),
|
||||
replace)).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_fire_timer(&self, timer_id: TimerEventId) {
|
||||
|
|
|
@ -228,8 +228,9 @@ pub enum MainThreadScriptMsg {
|
|||
/// should be closed (only dispatched to ScriptThread).
|
||||
ExitWindow(PipelineId),
|
||||
/// Begins a content-initiated load on the specified pipeline (only
|
||||
/// dispatched to ScriptThread).
|
||||
Navigate(PipelineId, LoadData),
|
||||
/// dispatched to ScriptThread). Allows for a replace bool to be passed. If true,
|
||||
/// the current entry will be replaced instead of a new entry being added.
|
||||
Navigate(PipelineId, LoadData, bool),
|
||||
/// Tasks that originate from the DOM manipulation task source
|
||||
DOMManipulation(DOMManipulationTask),
|
||||
/// Tasks that originate from the user interaction task source
|
||||
|
@ -877,8 +878,8 @@ impl ScriptThread {
|
|||
|
||||
fn handle_msg_from_constellation(&self, msg: ConstellationControlMsg) {
|
||||
match msg {
|
||||
ConstellationControlMsg::Navigate(parent_pipeline_id, pipeline_id, load_data) =>
|
||||
self.handle_navigate(parent_pipeline_id, Some(pipeline_id), load_data),
|
||||
ConstellationControlMsg::Navigate(parent_pipeline_id, pipeline_id, load_data, replace) =>
|
||||
self.handle_navigate(parent_pipeline_id, Some(pipeline_id), load_data, replace),
|
||||
ConstellationControlMsg::SendEvent(id, event) =>
|
||||
self.handle_event(id, event),
|
||||
ConstellationControlMsg::ResizeInactive(id, new_size) =>
|
||||
|
@ -933,8 +934,8 @@ impl ScriptThread {
|
|||
|
||||
fn handle_msg_from_script(&self, msg: MainThreadScriptMsg) {
|
||||
match msg {
|
||||
MainThreadScriptMsg::Navigate(parent_pipeline_id, load_data) =>
|
||||
self.handle_navigate(parent_pipeline_id, None, load_data),
|
||||
MainThreadScriptMsg::Navigate(parent_pipeline_id, load_data, replace) =>
|
||||
self.handle_navigate(parent_pipeline_id, None, load_data, replace),
|
||||
MainThreadScriptMsg::ExitWindow(id) =>
|
||||
self.handle_exit_window_msg(id),
|
||||
MainThreadScriptMsg::DocumentLoadsComplete(id) =>
|
||||
|
@ -2000,7 +2001,10 @@ impl ScriptThread {
|
|||
/// https://html.spec.whatwg.org/multipage/#navigating-across-documents
|
||||
/// The entry point for content to notify that a new load has been requested
|
||||
/// for the given pipeline (specifically the "navigate" algorithm).
|
||||
fn handle_navigate(&self, parent_pipeline_id: PipelineId, pipeline_id: Option<PipelineId>, load_data: LoadData) {
|
||||
fn handle_navigate(&self, parent_pipeline_id: PipelineId,
|
||||
pipeline_id: Option<PipelineId>,
|
||||
load_data: LoadData,
|
||||
replace: bool) {
|
||||
// Step 7.
|
||||
{
|
||||
let nurl = &load_data.url;
|
||||
|
@ -2026,12 +2030,12 @@ impl ScriptThread {
|
|||
doc.find_iframe(pipeline_id)
|
||||
});
|
||||
if let Some(iframe) = iframe.r() {
|
||||
iframe.navigate_or_reload_child_browsing_context(Some(load_data));
|
||||
iframe.navigate_or_reload_child_browsing_context(Some(load_data), replace);
|
||||
}
|
||||
}
|
||||
None => {
|
||||
self.constellation_chan
|
||||
.send(ConstellationMsg::LoadUrl(parent_pipeline_id, load_data))
|
||||
.send(ConstellationMsg::LoadUrl(parent_pipeline_id, load_data, replace))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue