mirror of
https://github.com/servo/servo.git
synced 2025-06-17 04:44:28 +00:00
auto merge of #4866 : KiChjang/servo/trigger-fragment-string, r=jdm
Fixes #4863
This commit is contained in:
commit
29d24a5049
2 changed files with 12 additions and 9 deletions
|
@ -385,10 +385,13 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
||||||
let url = UrlParser::new().base_url(&base_url).parse(href.as_slice());
|
let url = UrlParser::new().base_url(&base_url).parse(href.as_slice());
|
||||||
// FIXME: handle URL parse errors more gracefully.
|
// FIXME: handle URL parse errors more gracefully.
|
||||||
let url = url.unwrap();
|
let url = url.unwrap();
|
||||||
if href.as_slice().starts_with("#") {
|
match url.fragment {
|
||||||
self.script_chan.send(ScriptMsg::TriggerFragment(self.page.id, url));
|
Some(fragment) => {
|
||||||
} else {
|
self.script_chan.send(ScriptMsg::TriggerFragment(self.page.id, fragment));
|
||||||
self.script_chan.send(ScriptMsg::TriggerLoad(self.page.id, LoadData::new(url)));
|
},
|
||||||
|
None => {
|
||||||
|
self.script_chan.send(ScriptMsg::TriggerLoad(self.page.id, LoadData::new(url)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ pub trait Runnable {
|
||||||
pub enum ScriptMsg {
|
pub enum ScriptMsg {
|
||||||
/// Acts on a fragment URL load on the specified pipeline (only dispatched
|
/// Acts on a fragment URL load on the specified pipeline (only dispatched
|
||||||
/// to ScriptTask).
|
/// to ScriptTask).
|
||||||
TriggerFragment(PipelineId, Url),
|
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).
|
||||||
TriggerLoad(PipelineId, LoadData),
|
TriggerLoad(PipelineId, LoadData),
|
||||||
|
@ -610,8 +610,8 @@ impl ScriptTask {
|
||||||
match msg {
|
match msg {
|
||||||
ScriptMsg::TriggerLoad(id, load_data) =>
|
ScriptMsg::TriggerLoad(id, load_data) =>
|
||||||
self.trigger_load(id, load_data),
|
self.trigger_load(id, load_data),
|
||||||
ScriptMsg::TriggerFragment(id, url) =>
|
ScriptMsg::TriggerFragment(id, fragment) =>
|
||||||
self.trigger_fragment(id, url),
|
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, _) =>
|
||||||
|
@ -1113,9 +1113,9 @@ impl ScriptTask {
|
||||||
|
|
||||||
/// The entry point for content to notify that a fragment url has been requested
|
/// The entry point for content to notify that a fragment url has been requested
|
||||||
/// for the given pipeline.
|
/// for the given pipeline.
|
||||||
fn trigger_fragment(&self, pipeline_id: PipelineId, url: Url) {
|
fn trigger_fragment(&self, pipeline_id: PipelineId, fragment: String) {
|
||||||
let page = get_page(&*self.page.borrow(), pipeline_id);
|
let page = get_page(&*self.page.borrow(), pipeline_id);
|
||||||
match page.find_fragment_node(url.fragment.unwrap()).root() {
|
match page.find_fragment_node(fragment).root() {
|
||||||
Some(node) => {
|
Some(node) => {
|
||||||
self.scroll_fragment_point(pipeline_id, node.r());
|
self.scroll_fragment_point(pipeline_id, node.r());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue