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 PopStateEvent only in Window

  • Loading branch information
nox committed Jan 21, 2017
commit 1f8106a1dc84ade7c6be3c5da6faeb19b1462797
@@ -2624,7 +2624,7 @@ impl DocumentMethods for Document {
"pagetransitionevent" =>
Ok(Root::upcast(PageTransitionEvent::new_uninitialized(&self.window))),
"popstateevent" =>
Ok(Root::upcast(PopStateEvent::new_uninitialized(self.window.upcast()))),
Ok(Root::upcast(PopStateEvent::new_uninitialized(&self.window))),
"progressevent" =>
Ok(Root::upcast(ProgressEvent::new_uninitialized(self.window.upcast()))),
"storageevent" => {
@@ -11,7 +11,7 @@ use dom::bindings::js::{MutHeapJSVal, Root};
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::str::DOMString;
use dom::event::Event;
use dom::globalscope::GlobalScope;
use dom::window::Window;
use js::jsapi::{HandleValue, JSContext};
use js::jsval::JSVal;
use servo_atoms::Atom;
@@ -32,19 +32,19 @@ impl PopStateEvent {
}
}

pub fn new_uninitialized(global: &GlobalScope) -> Root<PopStateEvent> {
pub fn new_uninitialized(window: &Window) -> Root<PopStateEvent> {
reflect_dom_object(box PopStateEvent::new_inherited(),
global,
window,
PopStateEventBinding::Wrap)
}

pub fn new(global: &GlobalScope,
pub fn new(window: &Window,
type_: Atom,
bubbles: bool,
cancelable: bool,
state: HandleValue)
-> Root<PopStateEvent> {
let ev = PopStateEvent::new_uninitialized(global);
let ev = PopStateEvent::new_uninitialized(window);
ev.state.set(state.get());
{
let event = ev.upcast::<Event>();
@@ -54,11 +54,11 @@ impl PopStateEvent {
}

#[allow(unsafe_code)]
pub fn Constructor(global: &GlobalScope,
pub fn Constructor(window: &Window,
type_: DOMString,
init: &PopStateEventBinding::PopStateEventInit)
-> Fallible<Root<PopStateEvent>> {
Ok(PopStateEvent::new(global,
Ok(PopStateEvent::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/#the-popstateevent-interface
[Constructor(DOMString type, optional PopStateEventInit eventInitDict), Exposed=(Window,Worker)]
[Constructor(DOMString type, optional PopStateEventInit eventInitDict),
Exposed=Window]
interface PopStateEvent : Event {
readonly attribute any state;
};
@@ -3,6 +3,3 @@
[The Location interface object should not be exposed.]
expected: FAIL

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

@@ -41,7 +41,6 @@ test_interfaces([
"PerformanceTiming",
"Plugin",
"PluginArray",
"PopStateEvent",
"ProgressEvent",
"Request",
"Response",
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.