/* * Copyright (C) 1999 Lars Knoll ([email protected]) * (C) 1999 Antti Koivisto ([email protected]) * (C) 2001 Dirk Mueller ([email protected]) * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2006 Alexey Proskuryakov ([email protected]) * (C) 2007, 2008 Nikolas Zimmermann <[email protected]> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_DOM_EVENTS_EVENT_TARGET_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_DOM_EVENTS_EVENT_TARGET_H_ #include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/dom/events/event_dispatch_result.h" #include "third_party/blink/renderer/core/dom/events/event_listener_map.h" #include "third_party/blink/renderer/core/event_type_names.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/text/atomic_string.h" namespace blink { class AddEventListenerOptionsResolved; class DOMWindow; class Event; class ExceptionState; class ExecutionContext; class LocalDOMWindow; class MessagePort; class Node; class Observable; class ObservableEventListenerOptions; class ScriptState; class ServiceWorker; class V8EventListener; class V8UnionAddEventListenerOptionsOrBoolean; class V8UnionBooleanOrEventListenerOptions; // Macros to define an attribute event listener. // |lower_name| - Lower-cased event type name. e.g. |focus| // |symbol_name| - C++ symbol name in event_type_names namespace. e.g. |kFocus| // FIXME: These macros should be split into separate DEFINE and DECLARE // macros to avoid causing so many header includes. #define DEFINE_ATTRIBUTE_EVENT_LISTENER(lower_name, symbol_name) … #define DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(lower_name, symbol_name) … #define DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(lower_name, symbol_name) … class CORE_EXPORT EventTargetData final : public GarbageCollected<EventTargetData> { … }; // All DOM event targets extend EventTarget. The spec is defined here: // https://dom.spec.whatwg.org/#interface-eventtarget // EventTarget objects allow us to add and remove an event // listeners of a specific event type. Each EventTarget object also represents // the target to which an event is dispatched when something has occurred. // All nodes are EventTargets, some other event targets include: XMLHttpRequest, // AudioNode and AudioContext. // To make your class an EventTarget, follow these steps: // - Make your IDL interface inherit from EventTarget. // - In your class declaration, EventTarget must come first in the base class // list. If your class is non-final, your class must be the first base class // for any derived classes as well. // - If you added an onfoo attribute, use DEFINE_ATTRIBUTE_EVENT_LISTENER(foo) // in your class declaration. Add "attribute EventHandler onfoo;" to the IDL // file. // - Override EventTarget::interfaceName() and getExecutionContext(). The former // will typically return EventTargetNames::YourClassName. The latter will // return ExecutionContextLifecycleObserver::executionContext (if you are an // ExecutionContextLifecycleObserver) // or the document you're in. class CORE_EXPORT EventTarget : public ScriptWrappable { … }; DISABLE_CFI_PERF inline bool EventTarget::HasEventListeners() const { … } DISABLE_CFI_PERF inline bool EventTarget::HasEventListeners( const AtomicString& event_type) const { … } DISABLE_CFI_PERF inline bool EventTarget::HasAnyEventListeners( const Vector<AtomicString>& event_types) const { … } inline bool EventTarget::HasCapturingEventListeners( const AtomicString& event_type) { … } inline bool EventTarget::HasJSBasedEventListeners( const AtomicString& event_type) const { … } } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_DOM_EVENTS_EVENT_TARGET_H_