Gitweb links:
...log
http://git.netsurf-browser.org/libdom.git/shortlog/a39a24f6f85bc26ff3fe5a071440573cee4230f5
...commit
http://git.netsurf-browser.org/libdom.git/commit/a39a24f6f85bc26ff3fe5a071440573cee4230f5
...tree
http://git.netsurf-browser.org/libdom.git/tree/a39a24f6f85bc26ff3fe5a071440573cee4230f5
The branch, master has been updated
via a39a24f6f85bc26ff3fe5a071440573cee4230f5 (commit)
via 7e52c7a7927f0b01e0a4588c78c29df884c1e900 (commit)
via 898cae149dd5016e087c5ba4252a980dd8f51a9f (commit)
via 0c2b0013ee9929feded230cc9aa0c825a436349f (commit)
from b57b8a47109d8de7a773a32e52c1263b3617149c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libdom.git/commit/?id=a39a24f6f85bc26ff3fe5a071440573cee4230f5
commit a39a24f6f85bc26ff3fe5a071440573cee4230f5
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
keyboard events: Update to latest DOM spec.
diff --git a/include/dom/events/keyboard_event.h
b/include/dom/events/keyboard_event.h
index 236a3f4..03cab4b 100644
--- a/include/dom/events/keyboard_event.h
+++ b/include/dom/events/keyboard_event.h
@@ -27,14 +27,20 @@ dom_exception _dom_keyboard_event_create(dom_keyboard_event
**evt);
#define dom_keyboard_event_create(n) \
_dom_keyboard_event_create((dom_keyboard_event **) (n))
-dom_exception _dom_keyboard_event_get_key_identifier(dom_keyboard_event *evt,
- dom_string **ident);
-#define dom_keyboard_event_get_key_identifier(e, i) \
- _dom_keyboard_event_get_key_identifier( \
+dom_exception _dom_keyboard_event_get_key(dom_keyboard_event *evt,
+ dom_string **key);
+#define dom_keyboard_event_get_key(e, i) \
+ _dom_keyboard_event_get_key( \
(dom_keyboard_event *) (e), (dom_string **) (i))
-dom_exception _dom_keyboard_event_get_key_location(dom_keyboard_event *evt,
- dom_key_location *loc);
+dom_exception _dom_keyboard_event_get_code(dom_keyboard_event *evt,
+ dom_string **code);
+#define dom_keyboard_event_get_code(e, i) \
+ _dom_keyboard_event_get_code( \
+ (dom_keyboard_event *) (e), (dom_string **) (i))
+
+dom_exception _dom_keyboard_event_get_location(dom_keyboard_event *evt,
+ dom_key_location *location);
#define dom_keyboard_event_get_key_location(e, l) \
_dom_keyboard_event_get_key_location( \
(dom_keyboard_event *) (e), (dom_key_location *) (l))
@@ -69,25 +75,32 @@ dom_exception
_dom_keyboard_event_get_modifier_state(dom_keyboard_event *evt,
dom_exception _dom_keyboard_event_init(dom_keyboard_event *evt,
dom_string *type, bool bubble, bool cancelable,
- struct dom_abstract_view *view, dom_string *key_ident,
- dom_key_location key_loc, dom_string *modifier_list);
-#define dom_keyboard_event_init(e, t, b, c, v, ki, kl, m) \
+ struct dom_abstract_view *view, dom_string *key,
+ dom_string *code, dom_key_location location,
+ bool ctrl_key, bool shift_key, bool alt_key, bool meta_key,
+ bool repeat, bool is_composing);
+#define dom_keyboard_event_init(e, t, b, c, v, kk, kc, kl, ck, sk, ak, mk, r,
ic) \
_dom_keyboard_event_init((dom_keyboard_event *) (e), \
(dom_string *) (t), (bool) (b), (bool) (c), \
- (struct dom_abstract_view *) (v), (dom_string *) (ki), \
- (dom_key_location) (kl), (dom_string *) (m))
+ (struct dom_abstract_view *) (v), (dom_string *) (kk), \
+ (dom_string *) (kc), (dom_key_location) (kl), \
+ (bool) (ck), (bool) (sk), (bool) (ak), (bool) (mk), \
+ (bool) (r), (bool) (ic))
dom_exception _dom_keyboard_event_init_ns(dom_keyboard_event *evt,
dom_string *namespace, dom_string *type,
bool bubble, bool cancelable, struct dom_abstract_view *view,
- dom_string *key_ident, dom_key_location key_loc,
- dom_string *modifier_list);
+ dom_string *key, dom_string *code, dom_key_location location,
+ bool ctrl_key, bool shift_key, bool alt_key, bool meta_key,
+ bool repeat, bool is_composing);
#define dom_keyboard_event_init_ns(e, n, t, b, c, v, ki, kl, m) \
_dom_keyboard_event_init_ns((dom_keyboard_event *) (e), \
(dom_string *) (n), (dom_string *) (t), \
- (bool) (b), (bool) (c), (struct dom_abstract_view *) (v), \
- (dom_string *) (ki), (dom_key_location) (kl), \
- (dom_string *) (m))
+ (bool) (b), (bool) (c), \
+ (struct dom_abstract_view *) (v), (dom_string *) (kk), \
+ (dom_string *) (kc), (dom_key_location) (kl), \
+ (bool) (ck), (bool) (sk), (bool) (ak), (bool) (mk), \
+ (bool) (r), (bool) (ic))
#endif
diff --git a/src/events/keyboard_event.c b/src/events/keyboard_event.c
index 2d9a26e..d349355 100644
--- a/src/events/keyboard_event.c
+++ b/src/events/keyboard_event.c
@@ -42,12 +42,28 @@ void _dom_keyboard_event_destroy(struct dom_keyboard_event
*evt)
/* Initialise function */
dom_exception _dom_keyboard_event_initialise(struct dom_keyboard_event *evt)
{
+ dom_exception err;
+ dom_string *empty_string;
+
+ err = dom_string_create((const uint8_t *)"", 0, &empty_string);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
+
+ evt->key = empty_string;
+ evt->code = dom_string_ref(empty_string);
+
return _dom_ui_event_initialise(&evt->base);
}
/* Finalise function */
void _dom_keyboard_event_finalise(struct dom_keyboard_event *evt)
{
+ if (evt->key != NULL)
+ dom_string_unref(evt->key);
+ if (evt->code != NULL)
+ dom_string_unref(evt->code);
+
_dom_ui_event_finalise(&evt->base);
}
@@ -61,17 +77,31 @@ void _virtual_dom_keyboard_event_destroy(struct dom_event
*evt)
/* The public API */
/**
- * Get the key identifier
+ * Get the key
*
* \param evt The Event object
- * \param ident The returned key identifier
+ * \param key The returned key
* \return DOM_NO_ERR.
*/
-dom_exception _dom_keyboard_event_get_key_identifier(dom_keyboard_event *evt,
- dom_string **ident)
+dom_exception _dom_keyboard_event_get_key(dom_keyboard_event *evt,
+ dom_string **key)
{
- *ident = evt->key_ident;
- dom_string_ref(*ident);
+ *key = dom_string_ref(evt->key);
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Get the code
+ *
+ * \param evt The Event object
+ * \param code The returned code
+ * \return DOM_NO_ERR.
+ */
+dom_exception _dom_keyboard_event_get_code(dom_keyboard_event *evt,
+ dom_string **code)
+{
+ *code = dom_string_ref(evt->code);
return DOM_NO_ERR;
}
@@ -80,13 +110,13 @@ dom_exception
_dom_keyboard_event_get_key_identifier(dom_keyboard_event *evt,
* Get the key location
*
* \param evt The Event object
- * \param loc The returned key location
+ * \param location The returned key location
* \return DOM_NO_ERR.
*/
-dom_exception _dom_keyboard_event_get_key_location(dom_keyboard_event *evt,
- dom_key_location *loc)
+dom_exception _dom_keyboard_event_get_location(dom_keyboard_event *evt,
+ dom_key_location *location)
{
- *loc = evt->key_loc;
+ *location = evt->location;
return DOM_NO_ERR;
}
@@ -120,7 +150,7 @@ dom_exception
_dom_keyboard_event_get_shift_key(dom_keyboard_event *evt,
return DOM_NO_ERR;
}
-
+
/**
* Get the alt key state
*
@@ -204,70 +234,147 @@ dom_exception
_dom_keyboard_event_get_modifier_state(dom_keyboard_event *evt,
}
/**
- * Initialise the keyboard event
+ * Helper to initialise the keyboard event
*
- * \param evt The Event object
- * \param type The event's type
- * \param bubble Whether this is a bubbling event
- * \param cancelable Whether this is a cancelable event
- * \param view The AbstractView associated with this event
- * \param key_indent The key identifier of pressed key
- * \param key_loc The key location of the preesed key
- * \param modifier_list A string of modifier key identifiers, separated with
- * space
- * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ * \param evt The Event object
+ * \param view The AbstractView associated with this event
+ * \param key The key identifier of pressed key
+ * \param code The code identifier of pressed key
+ * \param location The key location of the preesed key
+ * \param ctrl_key Whether the ctrl_key is pressed
+ * \param shift_key Whether the shift_key is pressed
+ * \param alt_key Whether the alt_key is pressed
+ * \param meta_key Whether the ctrl_key is pressed
+ * \param repeat Whether this is a repeat press from a held key
+ * \param is_composing Whether the input is being composed
*/
-dom_exception _dom_keyboard_event_init(dom_keyboard_event *evt,
- dom_string *type, bool bubble, bool cancelable,
- struct dom_abstract_view *view, dom_string *key_ident,
- dom_key_location key_loc, dom_string *modifier_list)
+static void _dom_keyboard_event_init_helper(
+ dom_keyboard_event *evt,
+ dom_string *key,
+ dom_string *code,
+ dom_key_location location,
+ bool ctrl_key,
+ bool shift_key,
+ bool alt_key,
+ bool meta_key,
+ bool repeat,
+ bool is_composing)
{
- dom_exception err;
+ if (key != NULL) {
+ dom_string_unref(evt->key);
+ evt->key = dom_string_ref(key);
+ }
+ if (code != NULL) {
+ dom_string_unref(evt->code);
+ evt->code = dom_string_ref(code);
+ }
- evt->key_ident = key_ident;
- dom_string_ref(evt->key_ident);
- evt->key_loc = key_loc;
+ evt->location = location;
- err = _dom_parse_modifier_list(modifier_list, &evt->modifier_state);
- if (err != DOM_NO_ERR)
- return err;
+ if (ctrl_key) {
+ evt->modifier_state |= DOM_MOD_CTRL;
+ }
+ if (shift_key) {
+ evt->modifier_state |= DOM_MOD_CTRL;
+ }
+ if (alt_key) {
+ evt->modifier_state |= DOM_MOD_SHIFT;
+ }
+ if (meta_key) {
+ evt->modifier_state |= DOM_MOD_META;
+ }
- return _dom_ui_event_init(&evt->base, type, bubble, cancelable,
- view, 0);
+ evt->repeat = repeat;
+ evt->is_composing = is_composing;
}
+
+
/**
* Initialise the keyboard event with namespace
*
- * \param evt The Event object
- * \param namespace The namespace of this event
- * \param type The event's type
- * \param bubble Whether this is a bubbling event
- * \param cancelable Whether this is a cancelable event
- * \param view The AbstractView associated with this event
- * \param key_indent The key identifier of pressed key
- * \param key_loc The key location of the preesed key
- * \param modifier_list A string of modifier key identifiers, separated with
- * space
+ * \param evt The Event object
+ * \param type The event's type
+ * \param bubble Whether this is a bubbling event
+ * \param cancelable Whether this is a cancelable event
+ * \param view The AbstractView associated with this event
+ * \param key The key identifier of pressed key
+ * \param code The code identifier of pressed key
+ * \param location The key location of the preesed key
+ * \param ctrl_key Whether the ctrl_key is pressed
+ * \param shift_key Whether the shift_key is pressed
+ * \param alt_key Whether the alt_key is pressed
+ * \param meta_key Whether the ctrl_key is pressed
+ * \param repeat Whether this is a repeat press from a held key
+ * \param is_composing Whether the input is being composed
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
-dom_exception _dom_keyboard_event_init_ns(dom_keyboard_event *evt,
- dom_string *namespace, dom_string *type,
- bool bubble, bool cancelable, struct dom_abstract_view *view,
- dom_string *key_ident, dom_key_location key_loc,
- dom_string *modifier_list)
+dom_exception _dom_keyboard_event_init(
+ dom_keyboard_event *evt,
+ dom_string *type,
+ bool bubble,
+ bool cancelable,
+ struct dom_abstract_view *view,
+ dom_string *key,
+ dom_string *code,
+ dom_key_location location,
+ bool ctrl_key,
+ bool shift_key,
+ bool alt_key,
+ bool meta_key,
+ bool repeat,
+ bool is_composing)
{
- dom_exception err;
+ _dom_keyboard_event_init_helper(evt, key, code, location,
+ ctrl_key, shift_key, alt_key, meta_key,
+ repeat, is_composing);
- evt->key_ident = key_ident;
- dom_string_ref(evt->key_ident);
- evt->key_loc = key_loc;
+ return _dom_ui_event_init(&evt->base, type, bubble, cancelable,
+ view, 0);
+}
- err = _dom_parse_modifier_list(modifier_list, &evt->modifier_state);
- if (err != DOM_NO_ERR)
- return err;
+/**
+ * Initialise the keyboard event with namespace
+ *
+ * \param evt The Event object
+ * \param namespace The namespace of this event
+ * \param type The event's type
+ * \param bubble Whether this is a bubbling event
+ * \param cancelable Whether this is a cancelable event
+ * \param view The AbstractView associated with this event
+ * \param key The key identifier of pressed key
+ * \param code The code identifier of pressed key
+ * \param location The key location of the preesed key
+ * \param ctrl_key Whether the ctrl_key is pressed
+ * \param shift_key Whether the shift_key is pressed
+ * \param alt_key Whether the alt_key is pressed
+ * \param meta_key Whether the ctrl_key is pressed
+ * \param repeat Whether this is a repeat press from a held key
+ * \param is_composing Whether the input is being composed
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_keyboard_event_init_ns(
+ dom_keyboard_event *evt,
+ dom_string *namespace,
+ dom_string *type,
+ bool bubble,
+ bool cancelable,
+ struct dom_abstract_view *view,
+ dom_string *key,
+ dom_string *code,
+ dom_key_location location,
+ bool ctrl_key,
+ bool shift_key,
+ bool alt_key,
+ bool meta_key,
+ bool repeat,
+ bool is_composing)
+{
+ _dom_keyboard_event_init_helper(evt, key, code, location,
+ ctrl_key, shift_key, alt_key, meta_key,
+ repeat, is_composing);
- return _dom_ui_event_init_ns(&evt->base, namespace, type, bubble,
+ return _dom_ui_event_init_ns(&evt->base, namespace, type, bubble,
cancelable, view, 0);
}
diff --git a/src/events/keyboard_event.h b/src/events/keyboard_event.h
index 60cbca3..81b702f 100644
--- a/src/events/keyboard_event.h
+++ b/src/events/keyboard_event.h
@@ -18,17 +18,14 @@
struct dom_keyboard_event {
struct dom_ui_event base; /**< The base class */
- dom_string *key_ident; /**< The identifier of the key in this
- * event, please refer:
- *
http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set
- * for detail
- */
-
- dom_key_location key_loc; /**< Indicate the location of the key on
- * the keyboard
- */
+ dom_string *key;
+ dom_string *code;
+ dom_key_location location;
uint32_t modifier_state; /**< The modifier keys state */
+
+ bool repeat;
+ bool is_composing;
};
/* Destructor */
commitdiff
http://git.netsurf-browser.org/libdom.git/commit/?id=7e52c7a7927f0b01e0a4588c78c29df884c1e900
commit 7e52c7a7927f0b01e0a4588c78c29df884c1e900
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
ui events: constructor: initialise the detail attribute.
diff --git a/src/events/ui_event.c b/src/events/ui_event.c
index 4fac3b6..34ec84d 100644
--- a/src/events/ui_event.c
+++ b/src/events/ui_event.c
@@ -18,7 +18,7 @@ static struct dom_event_private_vtable _event_vtable = {
/* Constructor */
dom_exception _dom_ui_event_create(struct dom_ui_event **evt)
{
- *evt = malloc(sizeof(dom_ui_event));
+ *evt = calloc(1, sizeof(dom_ui_event));
if (*evt == NULL)
return DOM_NO_MEM_ERR;
@@ -38,7 +38,6 @@ void _dom_ui_event_destroy(struct dom_ui_event *evt)
/* Initialise function */
dom_exception _dom_ui_event_initialise(struct dom_ui_event *evt)
{
- evt->view = NULL;
return _dom_event_initialise(&evt->base);
}
commitdiff
http://git.netsurf-browser.org/libdom.git/commit/?id=898cae149dd5016e087c5ba4252a980dd8f51a9f
commit 898cae149dd5016e087c5ba4252a980dd8f51a9f
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
keyboard events: constructor: initialise the key location.
diff --git a/src/events/keyboard_event.c b/src/events/keyboard_event.c
index fb29c18..2d9a26e 100644
--- a/src/events/keyboard_event.c
+++ b/src/events/keyboard_event.c
@@ -22,7 +22,7 @@ static struct dom_event_private_vtable _event_vtable = {
/* Constructor */
dom_exception _dom_keyboard_event_create(struct dom_keyboard_event **evt)
{
- *evt = malloc(sizeof(dom_keyboard_event));
+ *evt = calloc(1, sizeof(dom_keyboard_event));
if (*evt == NULL)
return DOM_NO_MEM_ERR;
@@ -42,9 +42,6 @@ void _dom_keyboard_event_destroy(struct dom_keyboard_event
*evt)
/* Initialise function */
dom_exception _dom_keyboard_event_initialise(struct dom_keyboard_event *evt)
{
- evt->key_ident = NULL;
- evt->modifier_state = 0;
-
return _dom_ui_event_initialise(&evt->base);
}
commitdiff
http://git.netsurf-browser.org/libdom.git/commit/?id=0c2b0013ee9929feded230cc9aa0c825a436349f
commit 0c2b0013ee9929feded230cc9aa0c825a436349f
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
keyboard events: Expose the creation function.
diff --git a/include/dom/events/keyboard_event.h
b/include/dom/events/keyboard_event.h
index 132049e..236a3f4 100644
--- a/include/dom/events/keyboard_event.h
+++ b/include/dom/events/keyboard_event.h
@@ -23,6 +23,10 @@ typedef enum {
DOM_KEY_LOCATION_NUMPAD = 3
} dom_key_location;
+dom_exception _dom_keyboard_event_create(dom_keyboard_event **evt);
+#define dom_keyboard_event_create(n) \
+ _dom_keyboard_event_create((dom_keyboard_event **) (n))
+
dom_exception _dom_keyboard_event_get_key_identifier(dom_keyboard_event *evt,
dom_string **ident);
#define dom_keyboard_event_get_key_identifier(e, i) \
diff --git a/src/events/keyboard_event.h b/src/events/keyboard_event.h
index d640bbb..60cbca3 100644
--- a/src/events/keyboard_event.h
+++ b/src/events/keyboard_event.h
@@ -31,9 +31,6 @@ struct dom_keyboard_event {
uint32_t modifier_state; /**< The modifier keys state */
};
-/* Constructor */
-dom_exception _dom_keyboard_event_create(struct dom_keyboard_event **evt);
-
/* Destructor */
void _dom_keyboard_event_destroy(struct dom_keyboard_event *evt);
-----------------------------------------------------------------------
Summary of changes:
include/dom/events/keyboard_event.h | 49 +++++---
src/events/keyboard_event.c | 226 +++++++++++++++++++++++++----------
src/events/keyboard_event.h | 18 +--
src/events/ui_event.c | 3 +-
4 files changed, 205 insertions(+), 91 deletions(-)
diff --git a/include/dom/events/keyboard_event.h
b/include/dom/events/keyboard_event.h
index 132049e..03cab4b 100644
--- a/include/dom/events/keyboard_event.h
+++ b/include/dom/events/keyboard_event.h
@@ -23,14 +23,24 @@ typedef enum {
DOM_KEY_LOCATION_NUMPAD = 3
} dom_key_location;
-dom_exception _dom_keyboard_event_get_key_identifier(dom_keyboard_event *evt,
- dom_string **ident);
-#define dom_keyboard_event_get_key_identifier(e, i) \
- _dom_keyboard_event_get_key_identifier( \
+dom_exception _dom_keyboard_event_create(dom_keyboard_event **evt);
+#define dom_keyboard_event_create(n) \
+ _dom_keyboard_event_create((dom_keyboard_event **) (n))
+
+dom_exception _dom_keyboard_event_get_key(dom_keyboard_event *evt,
+ dom_string **key);
+#define dom_keyboard_event_get_key(e, i) \
+ _dom_keyboard_event_get_key( \
(dom_keyboard_event *) (e), (dom_string **) (i))
-dom_exception _dom_keyboard_event_get_key_location(dom_keyboard_event *evt,
- dom_key_location *loc);
+dom_exception _dom_keyboard_event_get_code(dom_keyboard_event *evt,
+ dom_string **code);
+#define dom_keyboard_event_get_code(e, i) \
+ _dom_keyboard_event_get_code( \
+ (dom_keyboard_event *) (e), (dom_string **) (i))
+
+dom_exception _dom_keyboard_event_get_location(dom_keyboard_event *evt,
+ dom_key_location *location);
#define dom_keyboard_event_get_key_location(e, l) \
_dom_keyboard_event_get_key_location( \
(dom_keyboard_event *) (e), (dom_key_location *) (l))
@@ -65,25 +75,32 @@ dom_exception
_dom_keyboard_event_get_modifier_state(dom_keyboard_event *evt,
dom_exception _dom_keyboard_event_init(dom_keyboard_event *evt,
dom_string *type, bool bubble, bool cancelable,
- struct dom_abstract_view *view, dom_string *key_ident,
- dom_key_location key_loc, dom_string *modifier_list);
-#define dom_keyboard_event_init(e, t, b, c, v, ki, kl, m) \
+ struct dom_abstract_view *view, dom_string *key,
+ dom_string *code, dom_key_location location,
+ bool ctrl_key, bool shift_key, bool alt_key, bool meta_key,
+ bool repeat, bool is_composing);
+#define dom_keyboard_event_init(e, t, b, c, v, kk, kc, kl, ck, sk, ak, mk, r,
ic) \
_dom_keyboard_event_init((dom_keyboard_event *) (e), \
(dom_string *) (t), (bool) (b), (bool) (c), \
- (struct dom_abstract_view *) (v), (dom_string *) (ki), \
- (dom_key_location) (kl), (dom_string *) (m))
+ (struct dom_abstract_view *) (v), (dom_string *) (kk), \
+ (dom_string *) (kc), (dom_key_location) (kl), \
+ (bool) (ck), (bool) (sk), (bool) (ak), (bool) (mk), \
+ (bool) (r), (bool) (ic))
dom_exception _dom_keyboard_event_init_ns(dom_keyboard_event *evt,
dom_string *namespace, dom_string *type,
bool bubble, bool cancelable, struct dom_abstract_view *view,
- dom_string *key_ident, dom_key_location key_loc,
- dom_string *modifier_list);
+ dom_string *key, dom_string *code, dom_key_location location,
+ bool ctrl_key, bool shift_key, bool alt_key, bool meta_key,
+ bool repeat, bool is_composing);
#define dom_keyboard_event_init_ns(e, n, t, b, c, v, ki, kl, m) \
_dom_keyboard_event_init_ns((dom_keyboard_event *) (e), \
(dom_string *) (n), (dom_string *) (t), \
- (bool) (b), (bool) (c), (struct dom_abstract_view *) (v), \
- (dom_string *) (ki), (dom_key_location) (kl), \
- (dom_string *) (m))
+ (bool) (b), (bool) (c), \
+ (struct dom_abstract_view *) (v), (dom_string *) (kk), \
+ (dom_string *) (kc), (dom_key_location) (kl), \
+ (bool) (ck), (bool) (sk), (bool) (ak), (bool) (mk), \
+ (bool) (r), (bool) (ic))
#endif
diff --git a/src/events/keyboard_event.c b/src/events/keyboard_event.c
index fb29c18..d349355 100644
--- a/src/events/keyboard_event.c
+++ b/src/events/keyboard_event.c
@@ -22,7 +22,7 @@ static struct dom_event_private_vtable _event_vtable = {
/* Constructor */
dom_exception _dom_keyboard_event_create(struct dom_keyboard_event **evt)
{
- *evt = malloc(sizeof(dom_keyboard_event));
+ *evt = calloc(1, sizeof(dom_keyboard_event));
if (*evt == NULL)
return DOM_NO_MEM_ERR;
@@ -42,8 +42,16 @@ void _dom_keyboard_event_destroy(struct dom_keyboard_event
*evt)
/* Initialise function */
dom_exception _dom_keyboard_event_initialise(struct dom_keyboard_event *evt)
{
- evt->key_ident = NULL;
- evt->modifier_state = 0;
+ dom_exception err;
+ dom_string *empty_string;
+
+ err = dom_string_create((const uint8_t *)"", 0, &empty_string);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
+
+ evt->key = empty_string;
+ evt->code = dom_string_ref(empty_string);
return _dom_ui_event_initialise(&evt->base);
}
@@ -51,6 +59,11 @@ dom_exception _dom_keyboard_event_initialise(struct
dom_keyboard_event *evt)
/* Finalise function */
void _dom_keyboard_event_finalise(struct dom_keyboard_event *evt)
{
+ if (evt->key != NULL)
+ dom_string_unref(evt->key);
+ if (evt->code != NULL)
+ dom_string_unref(evt->code);
+
_dom_ui_event_finalise(&evt->base);
}
@@ -64,17 +77,31 @@ void _virtual_dom_keyboard_event_destroy(struct dom_event
*evt)
/* The public API */
/**
- * Get the key identifier
+ * Get the key
*
* \param evt The Event object
- * \param ident The returned key identifier
+ * \param key The returned key
+ * \return DOM_NO_ERR.
+ */
+dom_exception _dom_keyboard_event_get_key(dom_keyboard_event *evt,
+ dom_string **key)
+{
+ *key = dom_string_ref(evt->key);
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Get the code
+ *
+ * \param evt The Event object
+ * \param code The returned code
* \return DOM_NO_ERR.
*/
-dom_exception _dom_keyboard_event_get_key_identifier(dom_keyboard_event *evt,
- dom_string **ident)
+dom_exception _dom_keyboard_event_get_code(dom_keyboard_event *evt,
+ dom_string **code)
{
- *ident = evt->key_ident;
- dom_string_ref(*ident);
+ *code = dom_string_ref(evt->code);
return DOM_NO_ERR;
}
@@ -83,13 +110,13 @@ dom_exception
_dom_keyboard_event_get_key_identifier(dom_keyboard_event *evt,
* Get the key location
*
* \param evt The Event object
- * \param loc The returned key location
+ * \param location The returned key location
* \return DOM_NO_ERR.
*/
-dom_exception _dom_keyboard_event_get_key_location(dom_keyboard_event *evt,
- dom_key_location *loc)
+dom_exception _dom_keyboard_event_get_location(dom_keyboard_event *evt,
+ dom_key_location *location)
{
- *loc = evt->key_loc;
+ *location = evt->location;
return DOM_NO_ERR;
}
@@ -123,7 +150,7 @@ dom_exception
_dom_keyboard_event_get_shift_key(dom_keyboard_event *evt,
return DOM_NO_ERR;
}
-
+
/**
* Get the alt key state
*
@@ -207,70 +234,147 @@ dom_exception
_dom_keyboard_event_get_modifier_state(dom_keyboard_event *evt,
}
/**
- * Initialise the keyboard event
+ * Helper to initialise the keyboard event
*
- * \param evt The Event object
- * \param type The event's type
- * \param bubble Whether this is a bubbling event
- * \param cancelable Whether this is a cancelable event
- * \param view The AbstractView associated with this event
- * \param key_indent The key identifier of pressed key
- * \param key_loc The key location of the preesed key
- * \param modifier_list A string of modifier key identifiers, separated with
- * space
- * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ * \param evt The Event object
+ * \param view The AbstractView associated with this event
+ * \param key The key identifier of pressed key
+ * \param code The code identifier of pressed key
+ * \param location The key location of the preesed key
+ * \param ctrl_key Whether the ctrl_key is pressed
+ * \param shift_key Whether the shift_key is pressed
+ * \param alt_key Whether the alt_key is pressed
+ * \param meta_key Whether the ctrl_key is pressed
+ * \param repeat Whether this is a repeat press from a held key
+ * \param is_composing Whether the input is being composed
*/
-dom_exception _dom_keyboard_event_init(dom_keyboard_event *evt,
- dom_string *type, bool bubble, bool cancelable,
- struct dom_abstract_view *view, dom_string *key_ident,
- dom_key_location key_loc, dom_string *modifier_list)
+static void _dom_keyboard_event_init_helper(
+ dom_keyboard_event *evt,
+ dom_string *key,
+ dom_string *code,
+ dom_key_location location,
+ bool ctrl_key,
+ bool shift_key,
+ bool alt_key,
+ bool meta_key,
+ bool repeat,
+ bool is_composing)
{
- dom_exception err;
+ if (key != NULL) {
+ dom_string_unref(evt->key);
+ evt->key = dom_string_ref(key);
+ }
+ if (code != NULL) {
+ dom_string_unref(evt->code);
+ evt->code = dom_string_ref(code);
+ }
- evt->key_ident = key_ident;
- dom_string_ref(evt->key_ident);
- evt->key_loc = key_loc;
+ evt->location = location;
- err = _dom_parse_modifier_list(modifier_list, &evt->modifier_state);
- if (err != DOM_NO_ERR)
- return err;
+ if (ctrl_key) {
+ evt->modifier_state |= DOM_MOD_CTRL;
+ }
+ if (shift_key) {
+ evt->modifier_state |= DOM_MOD_CTRL;
+ }
+ if (alt_key) {
+ evt->modifier_state |= DOM_MOD_SHIFT;
+ }
+ if (meta_key) {
+ evt->modifier_state |= DOM_MOD_META;
+ }
- return _dom_ui_event_init(&evt->base, type, bubble, cancelable,
- view, 0);
+ evt->repeat = repeat;
+ evt->is_composing = is_composing;
}
+
+
/**
* Initialise the keyboard event with namespace
*
- * \param evt The Event object
- * \param namespace The namespace of this event
- * \param type The event's type
- * \param bubble Whether this is a bubbling event
- * \param cancelable Whether this is a cancelable event
- * \param view The AbstractView associated with this event
- * \param key_indent The key identifier of pressed key
- * \param key_loc The key location of the preesed key
- * \param modifier_list A string of modifier key identifiers, separated with
- * space
+ * \param evt The Event object
+ * \param type The event's type
+ * \param bubble Whether this is a bubbling event
+ * \param cancelable Whether this is a cancelable event
+ * \param view The AbstractView associated with this event
+ * \param key The key identifier of pressed key
+ * \param code The code identifier of pressed key
+ * \param location The key location of the preesed key
+ * \param ctrl_key Whether the ctrl_key is pressed
+ * \param shift_key Whether the shift_key is pressed
+ * \param alt_key Whether the alt_key is pressed
+ * \param meta_key Whether the ctrl_key is pressed
+ * \param repeat Whether this is a repeat press from a held key
+ * \param is_composing Whether the input is being composed
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
-dom_exception _dom_keyboard_event_init_ns(dom_keyboard_event *evt,
- dom_string *namespace, dom_string *type,
- bool bubble, bool cancelable, struct dom_abstract_view *view,
- dom_string *key_ident, dom_key_location key_loc,
- dom_string *modifier_list)
+dom_exception _dom_keyboard_event_init(
+ dom_keyboard_event *evt,
+ dom_string *type,
+ bool bubble,
+ bool cancelable,
+ struct dom_abstract_view *view,
+ dom_string *key,
+ dom_string *code,
+ dom_key_location location,
+ bool ctrl_key,
+ bool shift_key,
+ bool alt_key,
+ bool meta_key,
+ bool repeat,
+ bool is_composing)
{
- dom_exception err;
+ _dom_keyboard_event_init_helper(evt, key, code, location,
+ ctrl_key, shift_key, alt_key, meta_key,
+ repeat, is_composing);
- evt->key_ident = key_ident;
- dom_string_ref(evt->key_ident);
- evt->key_loc = key_loc;
+ return _dom_ui_event_init(&evt->base, type, bubble, cancelable,
+ view, 0);
+}
- err = _dom_parse_modifier_list(modifier_list, &evt->modifier_state);
- if (err != DOM_NO_ERR)
- return err;
+/**
+ * Initialise the keyboard event with namespace
+ *
+ * \param evt The Event object
+ * \param namespace The namespace of this event
+ * \param type The event's type
+ * \param bubble Whether this is a bubbling event
+ * \param cancelable Whether this is a cancelable event
+ * \param view The AbstractView associated with this event
+ * \param key The key identifier of pressed key
+ * \param code The code identifier of pressed key
+ * \param location The key location of the preesed key
+ * \param ctrl_key Whether the ctrl_key is pressed
+ * \param shift_key Whether the shift_key is pressed
+ * \param alt_key Whether the alt_key is pressed
+ * \param meta_key Whether the ctrl_key is pressed
+ * \param repeat Whether this is a repeat press from a held key
+ * \param is_composing Whether the input is being composed
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_keyboard_event_init_ns(
+ dom_keyboard_event *evt,
+ dom_string *namespace,
+ dom_string *type,
+ bool bubble,
+ bool cancelable,
+ struct dom_abstract_view *view,
+ dom_string *key,
+ dom_string *code,
+ dom_key_location location,
+ bool ctrl_key,
+ bool shift_key,
+ bool alt_key,
+ bool meta_key,
+ bool repeat,
+ bool is_composing)
+{
+ _dom_keyboard_event_init_helper(evt, key, code, location,
+ ctrl_key, shift_key, alt_key, meta_key,
+ repeat, is_composing);
- return _dom_ui_event_init_ns(&evt->base, namespace, type, bubble,
+ return _dom_ui_event_init_ns(&evt->base, namespace, type, bubble,
cancelable, view, 0);
}
diff --git a/src/events/keyboard_event.h b/src/events/keyboard_event.h
index d640bbb..81b702f 100644
--- a/src/events/keyboard_event.h
+++ b/src/events/keyboard_event.h
@@ -18,21 +18,15 @@
struct dom_keyboard_event {
struct dom_ui_event base; /**< The base class */
- dom_string *key_ident; /**< The identifier of the key in this
- * event, please refer:
- *
http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set
- * for detail
- */
-
- dom_key_location key_loc; /**< Indicate the location of the key on
- * the keyboard
- */
+ dom_string *key;
+ dom_string *code;
+ dom_key_location location;
uint32_t modifier_state; /**< The modifier keys state */
-};
-/* Constructor */
-dom_exception _dom_keyboard_event_create(struct dom_keyboard_event **evt);
+ bool repeat;
+ bool is_composing;
+};
/* Destructor */
void _dom_keyboard_event_destroy(struct dom_keyboard_event *evt);
diff --git a/src/events/ui_event.c b/src/events/ui_event.c
index 4fac3b6..34ec84d 100644
--- a/src/events/ui_event.c
+++ b/src/events/ui_event.c
@@ -18,7 +18,7 @@ static struct dom_event_private_vtable _event_vtable = {
/* Constructor */
dom_exception _dom_ui_event_create(struct dom_ui_event **evt)
{
- *evt = malloc(sizeof(dom_ui_event));
+ *evt = calloc(1, sizeof(dom_ui_event));
if (*evt == NULL)
return DOM_NO_MEM_ERR;
@@ -38,7 +38,6 @@ void _dom_ui_event_destroy(struct dom_ui_event *evt)
/* Initialise function */
dom_exception _dom_ui_event_initialise(struct dom_ui_event *evt)
{
- evt->view = NULL;
return _dom_event_initialise(&evt->base);
}
--
Document Object Model library
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org