aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py14
-rw-r--r--components/script/dom/bindings/codegen/parser/WebIDL.py3
-rw-r--r--components/script/dom/event.rs2
-rw-r--r--components/script/dom/keyboardevent.rs43
-rw-r--r--components/script/dom/mouseevent.rs18
-rw-r--r--components/script/dom/webidls/KeyboardEvent.webidl36
-rw-r--r--components/script/dom/webidls/MouseEvent.webidl6
-rw-r--r--components/script/dom/webidls/SharedMouseAndKeyboardEventInit.webidl23
-rw-r--r--components/script/lib.rs1
9 files changed, 122 insertions, 24 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 9ca15459ba1..aaac17a9002 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -4280,7 +4280,7 @@ class CGDictionary(CGThing):
d = self.dictionary
if d.parent:
inheritance = " pub parent: %s::%s<'a, 'b>,\n" % (self.makeModuleName(d.parent),
- self.makeClassName(d.parent))
+ self.makeClassName(d.parent))
else:
inheritance = ""
memberDecls = [" pub %s: %s," %
@@ -4347,12 +4347,7 @@ class CGDictionary(CGThing):
@staticmethod
def makeModuleName(dictionary):
- name = dictionary.identifier.name
- if name.endswith('Init'):
- return toBindingNamespace(name.replace('Init', ''))
- #XXXjdm This breaks on the test webidl files, sigh.
- #raise TypeError("No idea how to find this dictionary's definition: " + name)
- return "/* uh oh */ %s" % name
+ return dictionary.module()
def getMemberType(self, memberInfo):
member, (_, _, declType, _) = memberInfo
@@ -4535,7 +4530,7 @@ class CGBindingRoot(CGThing):
'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}',
'dom::bindings::utils::{FindEnumStringIndex, GetArrayIndexFromId}',
'dom::bindings::utils::{GetPropertyOnPrototype, GetProtoOrIfaceArray}',
- 'dom::bindings::utils::{HasPropertyOnPrototype, IntVal}',
+ 'dom::bindings::utils::{HasPropertyOnPrototype, IntVal, UintVal}',
'dom::bindings::utils::{Reflectable}',
'dom::bindings::utils::{squirrel_away_unique}',
'dom::bindings::utils::{ThrowingConstructor, unwrap, unwrap_jsmanaged}',
@@ -5430,7 +5425,8 @@ class GlobalGenRoots():
def Bindings(config):
descriptors = (set(d.name + "Binding" for d in config.getDescriptors(register=True)) |
- set(d.unroll().module() for d in config.callbacks))
+ set(d.unroll().module() for d in config.callbacks) |
+ set(d.module() for d in config.getDictionaries()))
curr = CGList([CGGeneric("pub mod %s;\n" % name) for name in sorted(descriptors)])
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
return curr
diff --git a/components/script/dom/bindings/codegen/parser/WebIDL.py b/components/script/dom/bindings/codegen/parser/WebIDL.py
index 32f80e82c56..370ac7df7c0 100644
--- a/components/script/dom/bindings/codegen/parser/WebIDL.py
+++ b/components/script/dom/bindings/codegen/parser/WebIDL.py
@@ -1422,6 +1422,9 @@ class IDLDictionary(IDLObjectWithScope):
self.identifier.name,
[member.location] + locations)
+ def module(self):
+ return self.location.filename().split('/')[-1].split('.webidl')[0] + 'Binding'
+
def addExtendedAttributes(self, attrs):
assert len(attrs) == 0
diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs
index d6dc2cfe00f..bbeb2cb7df2 100644
--- a/components/script/dom/event.rs
+++ b/components/script/dom/event.rs
@@ -29,7 +29,7 @@ pub enum EventPhase {
pub enum EventTypeId {
CustomEventTypeId,
HTMLEventTypeId,
- KeyEventTypeId,
+ KeyboardEventTypeId,
MessageEventTypeId,
MouseEventTypeId,
ProgressEventTypeId,
diff --git a/components/script/dom/keyboardevent.rs b/components/script/dom/keyboardevent.rs
new file mode 100644
index 00000000000..de9c8992d9d
--- /dev/null
+++ b/components/script/dom/keyboardevent.rs
@@ -0,0 +1,43 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+use dom::bindings::codegen::Bindings::KeyboardEventBinding;
+use dom::bindings::codegen::Bindings::KeyboardEventBinding::KeyboardEventMethods;
+use dom::bindings::codegen::InheritTypes::KeyboardEventDerived;
+use dom::bindings::error::Fallible;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::{JSRef, Temporary};
+use dom::bindings::utils::{Reflectable, Reflector/*, reflect_dom_object*/};
+use dom::event::{Event, KeyboardEventTypeId};
+use dom::uievent::UIEvent;
+use servo_util::str::DOMString;
+
+#[jstraceable]
+#[must_root]
+pub struct KeyboardEvent {
+ uievent: UIEvent,
+}
+
+impl KeyboardEventDerived for Event {
+ fn is_keyboardevent(&self) -> bool {
+ *self.type_id() == KeyboardEventTypeId
+ }
+}
+
+impl KeyboardEvent {
+ pub fn Constructor(_global: &GlobalRef,
+ _type_: DOMString,
+ _init: &KeyboardEventBinding::KeyboardEventInit) -> Fallible<Temporary<KeyboardEvent>> {
+ fail!()
+ }
+}
+
+impl<'a> KeyboardEventMethods for JSRef<'a, KeyboardEvent> {
+}
+
+impl Reflectable for KeyboardEvent {
+ fn reflector<'a>(&'a self) -> &'a Reflector {
+ self.uievent.reflector()
+ }
+}
diff --git a/components/script/dom/mouseevent.rs b/components/script/dom/mouseevent.rs
index a4d3a0a9e09..c65a53217b7 100644
--- a/components/script/dom/mouseevent.rs
+++ b/components/script/dom/mouseevent.rs
@@ -21,7 +21,7 @@ use std::default::Default;
#[dom_struct]
pub struct MouseEvent {
- mouseevent: UIEvent,
+ uievent: UIEvent,
screen_x: Cell<i32>,
screen_y: Cell<i32>,
client_x: Cell<i32>,
@@ -43,7 +43,7 @@ impl MouseEventDerived for Event {
impl MouseEvent {
fn new_inherited() -> MouseEvent {
MouseEvent {
- mouseevent: UIEvent::new_inherited(MouseEventTypeId),
+ uievent: UIEvent::new_inherited(MouseEventTypeId),
screen_x: Cell::new(0),
screen_y: Cell::new(0),
client_x: Cell::new(0),
@@ -91,13 +91,13 @@ impl MouseEvent {
type_: DOMString,
init: &MouseEventBinding::MouseEventInit) -> Fallible<Temporary<MouseEvent>> {
let event = MouseEvent::new(global.as_window(), type_,
- init.parent.parent.bubbles,
- init.parent.parent.cancelable,
- init.parent.view.root_ref(),
- init.parent.detail,
+ init.parent.parent.parent.bubbles,
+ init.parent.parent.parent.cancelable,
+ init.parent.parent.view.root_ref(),
+ init.parent.parent.detail,
init.screenX, init.screenY,
- init.clientX, init.clientY, init.ctrlKey,
- init.altKey, init.shiftKey, init.metaKey,
+ init.clientX, init.clientY, init.parent.ctrlKey,
+ init.parent.altKey, init.parent.shiftKey, init.parent.metaKey,
init.button, init.relatedTarget.root_ref());
Ok(event)
}
@@ -178,6 +178,6 @@ impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> {
impl Reflectable for MouseEvent {
fn reflector<'a>(&'a self) -> &'a Reflector {
- self.mouseevent.reflector()
+ self.uievent.reflector()
}
}
diff --git a/components/script/dom/webidls/KeyboardEvent.webidl b/components/script/dom/webidls/KeyboardEvent.webidl
new file mode 100644
index 00000000000..589e39393b5
--- /dev/null
+++ b/components/script/dom/webidls/KeyboardEvent.webidl
@@ -0,0 +1,36 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#interface-KeyboardEvent
+ *
+ */
+
+[Constructor(DOMString typeArg, optional KeyboardEventInit keyboardEventInitDict)]
+interface KeyboardEvent : UIEvent {
+ // KeyLocationCode
+ const unsigned long DOM_KEY_LOCATION_STANDARD = 0x00;
+ const unsigned long DOM_KEY_LOCATION_LEFT = 0x01;
+ const unsigned long DOM_KEY_LOCATION_RIGHT = 0x02;
+ const unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03;
+ //readonly attribute DOMString key;
+ //readonly attribute DOMString code;
+ //readonly attribute unsigned long location;
+ //readonly attribute boolean ctrlKey;
+ //readonly attribute boolean shiftKey;
+ //readonly attribute boolean altKey;
+ //readonly attribute boolean metaKey;
+ //readonly attribute boolean repeat;
+ //readonly attribute boolean isComposing;
+ //boolean getModifierState (DOMString keyArg);
+};
+
+dictionary KeyboardEventInit : SharedKeyboardAndMouseEventInit {
+ DOMString key = "";
+ DOMString code = "";
+ unsigned long location = 0;
+ boolean repeat = false;
+ boolean isComposing = false;
+};
diff --git a/components/script/dom/webidls/MouseEvent.webidl b/components/script/dom/webidls/MouseEvent.webidl
index cdef58228c1..a46a44938ca 100644
--- a/components/script/dom/webidls/MouseEvent.webidl
+++ b/components/script/dom/webidls/MouseEvent.webidl
@@ -22,15 +22,11 @@ interface MouseEvent : UIEvent {
};
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#idl-def-MouseEventInit
-dictionary MouseEventInit : UIEventInit {
+dictionary MouseEventInit : SharedKeyboardAndMouseEventInit {
long screenX = 0;
long screenY = 0;
long clientX = 0;
long clientY = 0;
- boolean ctrlKey = false;
- boolean shiftKey = false;
- boolean altKey = false;
- boolean metaKey = false;
short button = 0;
//unsigned short buttons = 0;
EventTarget? relatedTarget = null;
diff --git a/components/script/dom/webidls/SharedMouseAndKeyboardEventInit.webidl b/components/script/dom/webidls/SharedMouseAndKeyboardEventInit.webidl
new file mode 100644
index 00000000000..eb852604ed1
--- /dev/null
+++ b/components/script/dom/webidls/SharedMouseAndKeyboardEventInit.webidl
@@ -0,0 +1,23 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#idl-def-SharedKeyboardAndMouseEventInit
+dictionary SharedKeyboardAndMouseEventInit : UIEventInit {
+ boolean ctrlKey = false;
+ boolean shiftKey = false;
+ boolean altKey = false;
+ boolean metaKey = false;
+ boolean keyModifierStateAltGraph = false;
+ boolean keyModifierStateCapsLock = false;
+ boolean keyModifierStateFn = false;
+ boolean keyModifierStateFnLock = false;
+ boolean keyModifierStateHyper = false;
+ boolean keyModifierStateNumLock = false;
+ boolean keyModifierStateOS = false;
+ boolean keyModifierStateScrollLock = false;
+ boolean keyModifierStateSuper = false;
+ boolean keyModifierStateSymbol = false;
+ boolean keyModifierStateSymbolLock = false;
+};
diff --git a/components/script/lib.rs b/components/script/lib.rs
index 1d64397e20e..959c245b63f 100644
--- a/components/script/lib.rs
+++ b/components/script/lib.rs
@@ -178,6 +178,7 @@ pub mod dom {
pub mod htmlulistelement;
pub mod htmlvideoelement;
pub mod htmlunknownelement;
+ pub mod keyboardevent;
pub mod location;
pub mod messageevent;
pub mod mouseevent;