aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/window.rs
diff options
context:
space:
mode:
authorConnor Brewster <connor.brewster@eagles.oc.edu>2018-06-12 22:12:17 +0200
committerConnor Brewster <connor.brewster@eagles.oc.edu>2018-07-21 12:38:51 -0600
commit61442cce4b93ef6b88b4ce59bad2358e8ce8bf4e (patch)
treee5a99859dc9708a4299a3238091cd414838762d5 /components/script/dom/window.rs
parentc1cc2aaf9cd82ec1be317dbdea057f617d0c4541 (diff)
downloadservo-61442cce4b93ef6b88b4ce59bad2358e8ce8bf4e.tar.gz
servo-61442cce4b93ef6b88b4ce59bad2358e8ce8bf4e.zip
Track hash changes in session history
Notify history changed on pushState and scroll to frag
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r--components/script/dom/window.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index ea3a92e0f37..a26570edb1c 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -33,7 +33,10 @@ use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSSt
use dom::customelementregistry::CustomElementRegistry;
use dom::document::{AnimationFrameCallback, Document};
use dom::element::Element;
+use dom::event::Event;
+use dom::eventtarget::EventTarget;
use dom::globalscope::GlobalScope;
+use dom::hashchangeevent::HashChangeEvent;
use dom::history::History;
use dom::location::Location;
use dom::mediaquerylist::{MediaQueryList, WeakMediaQueryListVec};
@@ -1582,13 +1585,33 @@ impl Window {
referrer_policy: Option<ReferrerPolicy>) {
let doc = self.Document();
let referrer_policy = referrer_policy.or(doc.get_referrer_policy());
-
// https://html.spec.whatwg.org/multipage/#navigating-across-documents
if !force_reload && url.as_url()[..Position::AfterQuery] ==
doc.url().as_url()[..Position::AfterQuery] {
// Step 6
if let Some(fragment) = url.fragment() {
+ self.send_to_constellation(ScriptMsg::NavigatedToFragment(url.clone(), replace));
doc.check_and_scroll_fragment(fragment);
+ let this = Trusted::new(self);
+ let old_url = doc.url().into_string();
+ let new_url = url.clone().into_string();
+ let task = task!(hashchange_event: move || {
+ let this = this.root();
+ let event = HashChangeEvent::new(
+ &this,
+ atom!("hashchange"),
+ false,
+ false,
+ old_url,
+ new_url);
+ event.upcast::<Event>().fire(this.upcast::<EventTarget>());
+ });
+ // FIXME(nox): Why are errors silenced here?
+ let _ = self.script_chan.send(CommonScriptMsg::Task(
+ ScriptThreadEventCategory::DomEvent,
+ Box::new(self.task_canceller(TaskSourceName::DOMManipulation).wrap_task(task)),
+ self.pipeline_id()
+ ));
doc.set_url(url.clone());
return
}