chromium/third_party/blink/renderer/core/dom/events/event_target.cc

/*
 * 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 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.
 *
 */

#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) {}

// UseCounts the event if it has the specified type. Returns true iff the event
// type matches.
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) {}

// See documentation for `ObservableSubscribeDelegate` below.
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 {}

// This is the synthetic subscribe callback that we construct `Observable`s with
// that are created by `EventTarget#when()`. `OnSubscribe()` adds a brand new
// `ObservableEventListener` as a new event listener for events named
// `event_type_`. When events are received, they are propagated directly to
// `Subscriber`.
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 {}

}  // namespace

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) {}

// An instance of EventTargetImpl is returned because EventTarget
// is an abstract class, and making it non-abstract is unfavorable
// because it will increase the size of EventTarget and all of its
// subclasses with code that are mostly unnecessary for them,
// resulting in a performance decrease.
// We also don't use ImplementedAs=EventTargetImpl in event_target.idl
// because it will result in some complications with classes that are
// currently derived from EventTarget.
// Spec: https://dom.spec.whatwg.org/#dom-eventtarget-eventtarget
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) {}

// Fire event listeners, creates a copy of EventListenerVector on being called.
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 {}

}  // namespace blink