Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various events-related improvements #15133

Merged
merged 10 commits into from Jan 21, 2017

Expose HashChangeEvent only in Window

  • Loading branch information
nox committed Jan 21, 2017
commit 2221203359ce83de1876285e4425b30c02214ed9
@@ -2614,7 +2614,7 @@ impl DocumentMethods for Document {
"focusevent" =>
Ok(Root::upcast(FocusEvent::new_uninitialized(&self.window))),
"hashchangeevent" =>
Ok(Root::upcast(HashChangeEvent::new_uninitialized(&self.window.upcast()))),
Ok(Root::upcast(HashChangeEvent::new_uninitialized(&self.window))),
"keyboardevent" =>
Ok(Root::upcast(KeyboardEvent::new_uninitialized(&self.window))),
"messageevent" =>
@@ -11,7 +11,7 @@ use dom::bindings::js::Root;
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::str::{DOMString, USVString};
use dom::event::Event;
use dom::globalscope::GlobalScope;
use dom::window::Window;
use servo_atoms::Atom;

// https://html.spec.whatwg.org/multipage/#hashchangeevent
@@ -31,21 +31,21 @@ impl HashChangeEvent {
}
}

pub fn new_uninitialized(global: &GlobalScope) -> Root<HashChangeEvent> {
pub fn new_uninitialized(window: &Window) -> Root<HashChangeEvent> {
reflect_dom_object(box HashChangeEvent::new_inherited(String::new(), String::new()),
global,
window,
HashChangeEventBinding::Wrap)
}

pub fn new(global: &GlobalScope,
pub fn new(window: &Window,
type_: Atom,
bubbles: bool,
cancelable: bool,
old_url: String,
new_url: String)
-> Root<HashChangeEvent> {
let ev = reflect_dom_object(box HashChangeEvent::new_inherited(old_url, new_url),
global,
window,
HashChangeEventBinding::Wrap);
{
let event = ev.upcast::<Event>();
@@ -54,11 +54,11 @@ impl HashChangeEvent {
ev
}

pub fn Constructor(global: &GlobalScope,
pub fn Constructor(window: &Window,
type_: DOMString,
init: &HashChangeEventBinding::HashChangeEventInit)
-> Fallible<Root<HashChangeEvent>> {
Ok(HashChangeEvent::new(global,
Ok(HashChangeEvent::new(window,
Atom::from(type_),
init.parent.bubbles,
init.parent.cancelable,
@@ -3,7 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// https://html.spec.whatwg.org/multipage/#hashchangeevent
[Constructor(DOMString type, optional HashChangeEventInit eventInitDict), Exposed=(Window,Worker)]
[Constructor(DOMString type, optional HashChangeEventInit eventInitDict),
Exposed=Window]
interface HashChangeEvent : Event {
readonly attribute USVString oldURL;
readonly attribute USVString newURL;
@@ -6,9 +6,6 @@
[The PopStateEvent interface object should not be exposed.]
expected: FAIL

[The HashChangeEvent interface object should not be exposed.]
expected: FAIL

[The PageTransitionEvent interface object should not be exposed.]
expected: FAIL

@@ -29,7 +29,6 @@ test_interfaces([
"FileReader",
"FileReaderSync",
"FormData",
"HashChangeEvent",
"Headers",
"History",
"ImageData",
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.