]>
git.saurik.com Git - iphone-api.git/blob - WebCore/EventTarget.h
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
7 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <wtf/Forward.h>
40 class DOMApplicationCache
;
43 class EventTargetNode
;
45 class ScriptExecutionContext
;
46 class SVGElementInstance
;
50 class XMLHttpRequestUpload
;
52 typedef int ExceptionCode
;
56 virtual MessagePort
* toMessagePort();
57 virtual EventTargetNode
* toNode();
58 virtual XMLHttpRequest
* toXMLHttpRequest();
59 virtual XMLHttpRequestUpload
* toXMLHttpRequestUpload();
60 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
61 virtual DOMApplicationCache
* toDOMApplicationCache();
64 virtual SVGElementInstance
* toSVGElementInstance();
67 virtual Worker
* toWorker();
68 virtual WorkerContext
* toWorkerContext();
71 virtual ScriptExecutionContext
* scriptExecutionContext() const = 0;
73 virtual void addEventListener(const AtomicString
& eventType
, PassRefPtr
<EventListener
>, bool useCapture
) = 0;
74 virtual void removeEventListener(const AtomicString
& eventType
, EventListener
*, bool useCapture
) = 0;
75 virtual bool dispatchEvent(PassRefPtr
<Event
>, ExceptionCode
&) = 0;
77 void ref() { refEventTarget(); }
78 void deref() { derefEventTarget(); }
80 // Handlers to do/undo actions on the target node before an event is dispatched to it and after the event
81 // has been dispatched. The data pointer is handed back by the preDispatch and passed to postDispatch.
82 virtual void* preDispatchEventHandler(Event
*) { return 0; }
83 virtual void postDispatchEventHandler(Event
*, void* /*dataFromPreDispatch*/) { }
86 virtual ~EventTarget();
89 virtual void refEventTarget() = 0;
90 virtual void derefEventTarget() = 0;
93 void forbidEventDispatch();
94 void allowEventDispatch();
97 bool eventDispatchForbidden();
99 inline void forbidEventDispatch() { }
100 inline void allowEventDispatch() { }