diff options
author | Steve Melia <steve.j.melia@gmail.com> | 2016-06-11 06:25:13 +0100 |
---|---|---|
committer | Steve Melia <steve.j.melia@gmail.com> | 2016-08-03 13:23:10 +0100 |
commit | 04f536957728948b59fc3269f45cf469f7771c63 (patch) | |
tree | 36d99033ebc40b384c681368556c6cef78bb1623 /components/script/script_thread.rs | |
parent | 7807895d5839ddd8e042b7e741961a75b70c37d8 (diff) | |
download | servo-04f536957728948b59fc3269f45cf469f7771c63.tar.gz servo-04f536957728948b59fc3269f45cf469f7771c63.zip |
Issue 7720: Add target selector and update when scrolling to fragment
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index e3d2766c84c..c7e7dde4ad3 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1198,6 +1198,22 @@ impl ScriptThread { // https://html.spec.whatwg.org/multipage/#the-end step 7 let handler = box DocumentProgressHandler::new(Trusted::new(doc)); self.dom_manipulation_task_source.queue(handler, GlobalRef::Window(doc.window())).unwrap(); + + if let Some(fragment) = doc.url().fragment() { + self.check_and_scroll_fragment(fragment, pipeline, doc); + } + } + + fn check_and_scroll_fragment(&self, fragment: &str, pipeline_id: PipelineId, doc: &Document) { + match doc.find_fragment_node(fragment) { + Some(ref node) => { + doc.set_target_element(Some(node.r())); + self.scroll_fragment_point(pipeline_id, node.r()); + } + None => { + doc.set_target_element(None); + } + } } fn collect_reports(&self, reports_chan: ReportsChan) { @@ -1996,7 +2012,7 @@ impl ScriptThread { /// 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, pipeline_id: PipelineId, subpage_id: Option<SubpageId>, load_data: LoadData) { - // Step 8. + // Step 7. { let nurl = &load_data.url; if let Some(fragment) = nurl.fragment() { @@ -2007,12 +2023,7 @@ impl ScriptThread { let url = document.url(); if &url[..Position::AfterQuery] == &nurl[..Position::AfterQuery] && load_data.method == Method::Get { - match document.find_fragment_node(fragment) { - Some(ref node) => { - self.scroll_fragment_point(pipeline_id, node.r()); - } - None => {} - } + self.check_and_scroll_fragment(fragment, pipeline_id, document.r()); return; } } |