#ifndef EventTargetNode_h
#define EventTargetNode_h
#include "EventTarget.h"
#include "Node.h"
namespace WebCore {
template <typename T> class DeprecatedValueList;
class EventTargetNode : public Node, public EventTarget {
public:
EventTargetNode(Document*);
virtual ~EventTargetNode();
virtual bool isEventTargetNode() const { return true; }
virtual EventTargetNode* toNode() { return this; }
virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&, bool tempEvent = false);
void removeAllEventListeners();
void setHTMLEventListener(const AtomicString& eventType, PassRefPtr<EventListener>);
void removeHTMLEventListener(const AtomicString& eventType);
bool dispatchHTMLEvent(const AtomicString& eventType, bool canBubble, bool cancelable);
EventListener* getHTMLEventListener(const AtomicString& eventType);
bool dispatchGenericEvent(PassRefPtr<Event>, ExceptionCode&, bool tempEvent = false);
bool dispatchSubtreeModifiedEvent(bool childrenChanged = true);
void dispatchWindowEvent(const AtomicString& eventType, bool canBubble, bool cancelable);
bool dispatchUIEvent(const AtomicString& eventType, int detail = 0, PassRefPtr<Event> underlyingEvent = 0);
bool dispatchKeyEvent(const PlatformKeyboardEvent&);
void dispatchWheelEvent(PlatformWheelEvent&);
bool dispatchMouseEvent(const PlatformMouseEvent&, const AtomicString& eventType,
int clickCount = 0, Node* relatedTarget = 0);
bool dispatchMouseEvent(const AtomicString& eventType, int button, int clickCount,
int pageX, int pageY, int screenX, int screenY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
bool isSimulated = false, Node* relatedTarget = 0, PassRefPtr<Event> underlyingEvent = 0);
void dispatchSimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<Event> underlyingEvent = 0);
void dispatchSimulatedClick(PassRefPtr<Event> underlyingEvent, bool sendMouseEvents = false, bool showPressedLook = true);
virtual void handleLocalEvents(Event*, bool useCapture);
virtual void dispatchFocusEvent();
virtual void dispatchBlurEvent();
virtual void insertedIntoDocument();
virtual void removedFromDocument();
virtual void* preDispatchEventHandler(Event*) { return 0; }
virtual void postDispatchEventHandler(Event*, void* dataFromPreDispatch) { }
virtual void defaultEventHandler(Event*);
virtual bool disabled() const;
#ifndef NDEBUG
virtual void dump(TextStream*, DeprecatedString indent = "") const;
#endif
using Node::ref;
using Node::deref;
private:
friend class SVGElement;
bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&, bool tempEvent, EventTarget* target);
protected:
typedef DeprecatedValueList<RefPtr<RegisteredEventListener> > RegisteredEventListenerList;
RegisteredEventListenerList* m_regdListeners;
private:
virtual void refEventTarget() { ref(); }
virtual void derefEventTarget() { deref(); }
};
inline EventTargetNode* EventTargetNodeCast(Node* n)
{
ASSERT(n->isEventTargetNode());
return static_cast<EventTargetNode*>(n);
}
inline const EventTargetNode* EventTargetNodeCast(const Node* n)
{
ASSERT(n->isEventTargetNode());
return static_cast<const EventTargetNode*>(n);
}
#ifndef NDEBUG
void forbidEventDispatch();
void allowEventDispatch();
bool eventDispatchForbidden();
#else
inline void forbidEventDispatch() { }
inline void allowEventDispatch() { }
#endif // NDEBUG
}
#endif // EventTargetNode_h