mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Merge the fragment handling into handle_navigate.
This is handled in the 'navigate' algorithm in the specification.
This commit is contained in:
parent
0bfde427e6
commit
f62e7be168
2 changed files with 14 additions and 27 deletions
|
@ -887,15 +887,8 @@ impl<'a> WindowHelpers for &'a Window {
|
||||||
|
|
||||||
/// Commence a new URL load which will either replace this window or scroll to a fragment.
|
/// Commence a new URL load which will either replace this window or scroll to a fragment.
|
||||||
fn load_url(self, url: Url) {
|
fn load_url(self, url: Url) {
|
||||||
match url.fragment {
|
|
||||||
Some(fragment) => {
|
|
||||||
self.script_chan.send(ScriptMsg::TriggerFragment(self.id, fragment)).unwrap();
|
|
||||||
},
|
|
||||||
None => {
|
|
||||||
self.script_chan.send(ScriptMsg::Navigate(self.id, LoadData::new(url))).unwrap();
|
self.script_chan.send(ScriptMsg::Navigate(self.id, LoadData::new(url))).unwrap();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_fire_timer(self, timer_id: TimerId) {
|
fn handle_fire_timer(self, timer_id: TimerId) {
|
||||||
self.timers.fire_timer(timer_id, self);
|
self.timers.fire_timer(timer_id, self);
|
||||||
|
|
|
@ -182,9 +182,6 @@ pub trait MainThreadRunnable {
|
||||||
/// Messages used to control script event loops, such as ScriptTask and
|
/// Messages used to control script event loops, such as ScriptTask and
|
||||||
/// DedicatedWorkerGlobalScope.
|
/// DedicatedWorkerGlobalScope.
|
||||||
pub enum ScriptMsg {
|
pub enum ScriptMsg {
|
||||||
/// Acts on a fragment URL load on the specified pipeline (only dispatched
|
|
||||||
/// to ScriptTask).
|
|
||||||
TriggerFragment(PipelineId, String),
|
|
||||||
/// Begins a content-initiated load on the specified pipeline (only
|
/// Begins a content-initiated load on the specified pipeline (only
|
||||||
/// dispatched to ScriptTask).
|
/// dispatched to ScriptTask).
|
||||||
Navigate(PipelineId, LoadData),
|
Navigate(PipelineId, LoadData),
|
||||||
|
@ -862,8 +859,6 @@ impl ScriptTask {
|
||||||
match msg {
|
match msg {
|
||||||
ScriptMsg::Navigate(id, load_data) =>
|
ScriptMsg::Navigate(id, load_data) =>
|
||||||
self.handle_navigate(id, None, load_data),
|
self.handle_navigate(id, None, load_data),
|
||||||
ScriptMsg::TriggerFragment(id, fragment) =>
|
|
||||||
self.trigger_fragment(id, fragment),
|
|
||||||
ScriptMsg::FireTimer(TimerSource::FromWindow(id), timer_id) =>
|
ScriptMsg::FireTimer(TimerSource::FromWindow(id), timer_id) =>
|
||||||
self.handle_fire_timer_msg(id, timer_id),
|
self.handle_fire_timer_msg(id, timer_id),
|
||||||
ScriptMsg::FireTimer(TimerSource::FromWorker, _) =>
|
ScriptMsg::FireTimer(TimerSource::FromWorker, _) =>
|
||||||
|
@ -1680,6 +1675,19 @@ impl ScriptTask {
|
||||||
/// The entry point for content to notify that a new load has been requested
|
/// The entry point for content to notify that a new load has been requested
|
||||||
/// for the given pipeline (specifically the "navigate" algorithm).
|
/// for the given pipeline (specifically the "navigate" algorithm).
|
||||||
fn handle_navigate(&self, pipeline_id: PipelineId, subpage_id: Option<SubpageId>, load_data: LoadData) {
|
fn handle_navigate(&self, pipeline_id: PipelineId, subpage_id: Option<SubpageId>, load_data: LoadData) {
|
||||||
|
// Step 8.
|
||||||
|
if let Some(fragment) = load_data.url.fragment {
|
||||||
|
let page = get_page(&self.root_page(), pipeline_id);
|
||||||
|
let document = page.document();
|
||||||
|
match document.r().find_fragment_node(fragment) {
|
||||||
|
Some(ref node) => {
|
||||||
|
self.scroll_fragment_point(pipeline_id, node.r());
|
||||||
|
}
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
match subpage_id {
|
match subpage_id {
|
||||||
Some(subpage_id) => {
|
Some(subpage_id) => {
|
||||||
let borrowed_page = self.root_page();
|
let borrowed_page = self.root_page();
|
||||||
|
@ -1698,20 +1706,6 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The entry point for content to notify that a fragment url has been requested
|
|
||||||
/// for the given pipeline.
|
|
||||||
fn trigger_fragment(&self, pipeline_id: PipelineId, fragment: String) {
|
|
||||||
let page = get_page(&self.root_page(), pipeline_id);
|
|
||||||
let document = page.document();
|
|
||||||
match document.r().find_fragment_node(fragment) {
|
|
||||||
Some(ref node) => {
|
|
||||||
self.scroll_fragment_point(pipeline_id, node.r());
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fn handle_resize_event(&self, pipeline_id: PipelineId, new_size: WindowSizeData) {
|
fn handle_resize_event(&self, pipeline_id: PipelineId, new_size: WindowSizeData) {
|
||||||
let page = get_page(&self.root_page(), pipeline_id);
|
let page = get_page(&self.root_page(), pipeline_id);
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue