#include "third_party/blink/renderer/core/dom/events/event_target.h"
#include <memory>
#include "base/format_macros.h"
#include "base/time/time.h"
#include "third_party/blink/renderer/bindings/core/v8/js_based_event_listener.h"
#include "third_party/blink/renderer/bindings/core/v8/js_event_listener.h"
#include "third_party/blink/renderer/bindings/core/v8/to_v8_traits.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_observable_event_listener_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_addeventlisteneroptions_boolean.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_boolean_eventlisteneroptions.h"
#include "third_party/blink/renderer/core/dom/abort_signal.h"
#include "third_party/blink/renderer/core/dom/abort_signal_registry.h"
#include "third_party/blink/renderer/core/dom/events/add_event_listener_options_resolved.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/events/event_dispatch_forbidden_scope.h"
#include "third_party/blink/renderer/core/dom/events/event_target_impl.h"
#include "third_party/blink/renderer/core/dom/events/native_event_listener.h"
#include "third_party/blink/renderer/core/dom/observable.h"
#include "third_party/blink/renderer/core/dom/subscriber.h"
#include "third_party/blink/renderer/core/editing/editor.h"
#include "third_party/blink/renderer/core/events/event_util.h"
#include "third_party/blink/renderer/core/events/pointer_event.h"
#include "third_party/blink/renderer/core/frame/deprecation/deprecation.h"
#include "third_party/blink/renderer/core/frame/frame_console.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/performance_monitor.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/pointer_type_names.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/source_location.h"
#include "third_party/blink/renderer/platform/bindings/v8_dom_activity_logger.h"
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/threading.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
namespace {
enum PassiveForcedListenerResultType { … };
Event::PassiveMode EventPassiveMode(
const RegisteredEventListener& event_listener) { … }
bool IsTouchScrollBlockingEvent(const AtomicString& event_type) { … }
bool IsWheelScrollBlockingEvent(const AtomicString& event_type) { … }
bool IsScrollBlockingEvent(const AtomicString& event_type) { … }
bool IsInstrumentedForAsyncStack(const AtomicString& event_type) { … }
base::TimeDelta BlockedEventsWarningThreshold(ExecutionContext* context,
const Event& event) { … }
void ReportBlockedEvent(EventTarget& target,
const Event& event,
RegisteredEventListener* registered_listener,
base::TimeDelta delayed) { … }
bool CheckTypeThenUseCount(const Event& event,
const AtomicString& event_type_to_count,
const WebFeature feature,
Document& document) { … }
void CountFiringEventListeners(const Event& event,
const LocalDOMWindow* executing_window) { … }
class ObservableEventListener final : public NativeEventListener { … };
ObservableEventListener::ObservableEventListener(
Subscriber* subscriber,
ScriptState* script_state,
const AtomicString& event_type,
EventTarget* event_target,
const ObservableEventListenerOptions* options)
: … { … }
void ObservableEventListener::Invoke(ExecutionContext* execution_context,
Event* event) { … }
void ObservableEventListener::Trace(Visitor* visitor) const { … }
class ObservableSubscribeDelegate final : public Observable::SubscribeDelegate { … };
ObservableSubscribeDelegate::ObservableSubscribeDelegate(
EventTarget* event_target,
const AtomicString& event_type,
const ObservableEventListenerOptions* options)
: … { … }
void ObservableSubscribeDelegate::OnSubscribe(Subscriber* subscriber,
ScriptState* script_state) { … }
void ObservableSubscribeDelegate::Trace(Visitor* visitor) const { … }
}
EventTargetData::EventTargetData() = default;
EventTargetData::~EventTargetData() = default;
void EventTargetData::Trace(Visitor* visitor) const { … }
EventTarget::EventTarget() = default;
EventTarget::~EventTarget() = default;
Node* EventTarget::ToNode() { … }
const DOMWindow* EventTarget::ToDOMWindow() const { … }
const LocalDOMWindow* EventTarget::ToLocalDOMWindow() const { … }
LocalDOMWindow* EventTarget::ToLocalDOMWindow() { … }
MessagePort* EventTarget::ToMessagePort() { … }
ServiceWorker* EventTarget::ToServiceWorker() { … }
void EventTarget::ResetEventQueueStatus(const AtomicString& event_type) { … }
EventTarget* EventTarget::Create(ScriptState* script_state) { … }
inline LocalDOMWindow* EventTarget::ExecutingWindow() { … }
bool EventTarget::IsTopLevelNode() { … }
void EventTarget::SetDefaultAddEventListenerOptions(
const AtomicString& event_type,
EventListener* event_listener,
AddEventListenerOptionsResolved* options) { … }
Observable* EventTarget::when(const AtomicString& event_type,
const ObservableEventListenerOptions* options) { … }
bool EventTarget::addEventListener(const AtomicString& event_type,
V8EventListener* listener) { … }
bool EventTarget::addEventListener(
const AtomicString& event_type,
V8EventListener* listener,
const V8UnionAddEventListenerOptionsOrBoolean* bool_or_options) { … }
bool EventTarget::addEventListener(const AtomicString& event_type,
EventListener* listener,
bool use_capture) { … }
bool EventTarget::addEventListener(const AtomicString& event_type,
EventListener* listener,
AddEventListenerOptionsResolved* options) { … }
bool EventTarget::AddEventListenerInternal(
const AtomicString& event_type,
EventListener* listener,
const AddEventListenerOptionsResolved* options) { … }
void EventTarget::AddedEventListener(
const AtomicString& event_type,
RegisteredEventListener& registered_listener) { … }
bool EventTarget::removeEventListener(const AtomicString& event_type,
V8EventListener* listener) { … }
bool EventTarget::removeEventListener(
const AtomicString& event_type,
V8EventListener* listener,
const V8UnionBooleanOrEventListenerOptions* bool_or_options) { … }
bool EventTarget::removeEventListener(const AtomicString& event_type,
const EventListener* listener,
bool use_capture) { … }
bool EventTarget::removeEventListener(const AtomicString& event_type,
const EventListener* listener,
EventListenerOptions* options) { … }
bool EventTarget::RemoveEventListenerInternal(
const AtomicString& event_type,
const EventListener* listener,
const EventListenerOptions* options) { … }
void EventTarget::RemovedEventListener(
const AtomicString& event_type,
const RegisteredEventListener& registered_listener) { … }
RegisteredEventListener* EventTarget::GetAttributeRegisteredEventListener(
const AtomicString& event_type) { … }
bool EventTarget::SetAttributeEventListener(const AtomicString& event_type,
EventListener* listener) { … }
EventListener* EventTarget::GetAttributeEventListener(
const AtomicString& event_type) { … }
bool EventTarget::dispatchEventForBindings(Event* event,
ExceptionState& exception_state) { … }
DispatchEventResult EventTarget::DispatchEvent(Event& event) { … }
DispatchEventResult EventTarget::DispatchEventInternal(Event& event) { … }
EventTargetData* EventTarget::GetEventTargetData() { … }
EventTargetData& EventTarget::EnsureEventTargetData() { … }
static const AtomicString& LegacyType(const Event& event) { … }
void EventTarget::CountLegacyEvents(
const AtomicString& legacy_type_name,
EventListenerVector* listeners_vector,
EventListenerVector* legacy_listeners_vector) { … }
DispatchEventResult EventTarget::FireEventListeners(Event& event) { … }
bool EventTarget::FireEventListeners(Event& event,
EventTargetData* d,
EventListenerVector entry) { … }
DispatchEventResult EventTarget::GetDispatchEventResult(const Event& event) { … }
EventListenerVector* EventTarget::GetEventListeners(
const AtomicString& event_type) { … }
int EventTarget::NumberOfEventListeners(const AtomicString& event_type) const { … }
Vector<AtomicString> EventTarget::EventTypes() { … }
void EventTarget::RemoveAllEventListeners() { … }
void EventTarget::EnqueueEvent(Event& event, TaskType task_type) { … }
void EventTarget::DispatchEnqueuedEvent(Event* event,
ExecutionContext* context) { … }
void EventTarget::Trace(Visitor* visitor) const { … }
}