auto merge of #4866 : KiChjang/servo/trigger-fragment-string, r=jdm

Fixes #4863
This commit is contained in:
bors-servo 2015-02-12 10:18:45 -07:00
commit 29d24a5049
2 changed files with 12 additions and 9 deletions

View file

@ -385,12 +385,15 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
let url = UrlParser::new().base_url(&base_url).parse(href.as_slice());
// FIXME: handle URL parse errors more gracefully.
let url = url.unwrap();
if href.as_slice().starts_with("#") {
self.script_chan.send(ScriptMsg::TriggerFragment(self.page.id, url));
} else {
match url.fragment {
Some(fragment) => {
self.script_chan.send(ScriptMsg::TriggerFragment(self.page.id, fragment));
},
None => {
self.script_chan.send(ScriptMsg::TriggerLoad(self.page.id, LoadData::new(url)));
}
}
}
fn handle_fire_timer(self, timer_id: TimerId) {
self.timers.fire_timer(timer_id, self);

View file

@ -109,7 +109,7 @@ pub trait Runnable {
pub enum ScriptMsg {
/// Acts on a fragment URL load on the specified pipeline (only dispatched
/// to ScriptTask).
TriggerFragment(PipelineId, Url),
TriggerFragment(PipelineId, String),
/// Begins a content-initiated load on the specified pipeline (only
/// dispatched to ScriptTask).
TriggerLoad(PipelineId, LoadData),
@ -610,8 +610,8 @@ impl ScriptTask {
match msg {
ScriptMsg::TriggerLoad(id, load_data) =>
self.trigger_load(id, load_data),
ScriptMsg::TriggerFragment(id, url) =>
self.trigger_fragment(id, url),
ScriptMsg::TriggerFragment(id, fragment) =>
self.trigger_fragment(id, fragment),
ScriptMsg::FireTimer(TimerSource::FromWindow(id), timer_id) =>
self.handle_fire_timer_msg(id, timer_id),
ScriptMsg::FireTimer(TimerSource::FromWorker, _) =>
@ -1113,9 +1113,9 @@ 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, url: Url) {
fn trigger_fragment(&self, pipeline_id: PipelineId, fragment: String) {
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) => {
self.scroll_fragment_point(pipeline_id, node.r());
}