Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * This file is part of libdom.
  3.  * Licensed under the MIT License,
  4.  *                http://www.opensource.org/licenses/mit-license.php
  5.  * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
  6.  */
  7.  
  8. #ifndef dom_internal_events_event_h_
  9. #define dom_internal_events_event_h_
  10.  
  11. #include <inttypes.h>
  12.  
  13. #include <dom/core/document.h>
  14. #include <dom/events/event_target.h>
  15. #include <dom/events/event.h>
  16.  
  17. #include "utils/list.h"
  18.  
  19. /* The private virtual table */
  20. struct dom_event_private_vtable {
  21.         void (*destroy)(dom_event *evt);
  22. };
  23.  
  24. /**
  25.  * The Event Object
  26.  */
  27. struct dom_event {
  28.         dom_string *type;       /**< The type of the event */
  29.         dom_event_target *target;       /**< The event target */
  30.         dom_event_target *current;      /**< The current event target */
  31.         dom_event_flow_phase phase;             /**< The event phase */
  32.         bool bubble;    /**< Whether this event is a bubbling event */
  33.         bool cancelable;        /**< Whether this event is cancelable */
  34.         unsigned int timestamp;
  35.                         /**< The timestamp this event is created */
  36.  
  37.         dom_string *namespace;  /**< The namespace of this event */
  38.  
  39.         dom_document *doc;
  40.                         /**< The document which created this event */
  41.  
  42.         bool stop;              /**< Whether stopPropagation is called */
  43.         bool stop_now;  /**< Whether stopImmediatePropagation is called */
  44.         bool prevent_default;
  45.                         /**< Whether the default action is prevented */
  46.  
  47.         bool custom;    /**< Whether this is a custom event */
  48.  
  49.         uint32_t refcnt;        /**< The reference count of this object */
  50.  
  51.         struct dom_event_private_vtable *vtable;
  52.                         /**< The private virtual function table of Event */
  53.         bool in_dispatch;       /**< Whether this event is in dispatch */
  54. };
  55.  
  56. /* Constructor */
  57. dom_exception _dom_event_create(dom_document *doc, dom_event **evt);
  58.  
  59. /* Destructor */
  60. void _dom_event_destroy(dom_event *evt);
  61.  
  62. /* Initialise function */
  63. dom_exception _dom_event_initialise(dom_document *doc, dom_event *evt);
  64.  
  65. /* Finalise function */
  66. void _dom_event_finalise(dom_event *evt);
  67.  
  68.  
  69. static inline void dom_event_destroy(dom_event *evt)
  70. {
  71.         evt->vtable->destroy(evt);
  72. }
  73. #define dom_event_destroy(e) dom_event_destroy((dom_event *) (e))
  74.  
  75. #endif
  76.  
  77.