chromium/ui/events/event.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/events/event.h"

#include <cmath>
#include <cstring>
#include <memory>
#include <string>
#include <utility>

#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "base/types/cxx23_to_underlying.h"
#include "build/build_config.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/dom_key.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion.h"
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/transform.h"
#include "ui/gfx/geometry/transform_util.h"

#if BUILDFLAG(IS_OZONE)
#include "ui/base/ui_base_features.h"                               // nogncheck
#include "ui/events/ozone/events_ozone.h"                           // nogncheck
#include "ui/events/ozone/layout/keyboard_layout_engine.h"          // nogncheck
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"  // nogncheck
#endif

#if BUILDFLAG(IS_WIN)
#include "ui/events/keycodes/platform_key_map_win.h"
#endif

namespace ui {
namespace {

constexpr int kChangedButtonFlagMask =;

std::string MomentumPhaseToString(EventMomentumPhase phase) {}

std::string ScrollEventPhaseToString(ScrollEventPhase phase) {}

#if BUILDFLAG(IS_OZONE)
uint32_t ScanCodeFromNative(const PlatformEvent& native_event) {}
#endif  // BUILDFLAG(IS_OZONE)

bool IsNearZero(const float num) {}

bool IsRepeatedClickTimes(const base::TimeTicks& time_stamp1,
                          const base::TimeTicks& time_stamp2) {}

}  // namespace

////////////////////////////////////////////////////////////////////////////////
// Event

Event::~Event() = default;

void Event::SetNativeEvent(const PlatformEvent& event) {}

const char* Event::GetName() const {}

void Event::SetProperties(const Properties& properties) {}

CancelModeEvent* Event::AsCancelModeEvent() {}

const CancelModeEvent* Event::AsCancelModeEvent() const {}

GestureEvent* Event::AsGestureEvent() {}

const GestureEvent* Event::AsGestureEvent() const {}

KeyEvent* Event::AsKeyEvent() {}

const KeyEvent* Event::AsKeyEvent() const {}

LocatedEvent* Event::AsLocatedEvent() {}

const LocatedEvent* Event::AsLocatedEvent() const {}

MouseEvent* Event::AsMouseEvent() {}

const MouseEvent* Event::AsMouseEvent() const {}

MouseWheelEvent* Event::AsMouseWheelEvent() {}

const MouseWheelEvent* Event::AsMouseWheelEvent() const {}

ScrollEvent* Event::AsScrollEvent() {}

const ScrollEvent* Event::AsScrollEvent() const {}

TouchEvent* Event::AsTouchEvent() {}

const TouchEvent* Event::AsTouchEvent() const {}

bool Event::HasNativeEvent() const {}

void Event::StopPropagation() {}

void Event::SetHandled() {}

void Event::SetSkipped() {}

void Event::SetFlags(int flags) {}

std::string Event::ToString() const {}

Event::Event(EventType type, base::TimeTicks time_stamp, int flags)
    :{}

Event::Event(const PlatformEvent& native_event, EventType type, int flags)
    :{}

Event::Event(const Event& copy)
    :{}

Event& Event::operator=(const Event& rhs) {}

void Event::SetType(EventType type) {}

////////////////////////////////////////////////////////////////////////////////
// CancelModeEvent

CancelModeEvent::CancelModeEvent()
    :{}

CancelModeEvent::~CancelModeEvent() = default;

std::unique_ptr<Event> CancelModeEvent::Clone() const {}

////////////////////////////////////////////////////////////////////////////////
// LocatedEvent

LocatedEvent::~LocatedEvent() = default;

LocatedEvent::LocatedEvent(const PlatformEvent& native_event)
    :{}

LocatedEvent::LocatedEvent(EventType type,
                           const gfx::PointF& location,
                           const gfx::PointF& root_location,
                           base::TimeTicks time_stamp,
                           int flags)
    :{}

LocatedEvent::LocatedEvent(const LocatedEvent& copy) = default;

void LocatedEvent::UpdateForRootTransform(
    const gfx::Transform& reversed_root_transform,
    const gfx::Transform& reversed_local_transform) {}

std::string LocatedEvent::ToString() const {}

////////////////////////////////////////////////////////////////////////////////
// MouseEvent

MouseEvent::MouseEvent(const PlatformEvent& native_event)
    :{}

MouseEvent::MouseEvent(EventType type,
                       const gfx::PointF& location,
                       const gfx::PointF& root_location,
                       base::TimeTicks time_stamp,
                       int flags,
                       int changed_button_flags,
                       const PointerDetails& pointer_details)
    :{}

MouseEvent::MouseEvent(EventType type,
                       const gfx::Point& location,
                       const gfx::Point& root_location,
                       base::TimeTicks time_stamp,
                       int flags,
                       int changed_button_flags,
                       const PointerDetails& pointer_details)
    :{}

MouseEvent::MouseEvent(const MouseEvent& other) = default;

MouseEvent::~MouseEvent() = default;

void MouseEvent::InitializeNative() {}

// static
bool MouseEvent::IsRepeatedClickEvent(const MouseEvent& event1,
                                      const MouseEvent& event2) {}

// static
int MouseEvent::GetRepeatCount(const MouseEvent& event) {}

void MouseEvent::ResetLastClickForTest() {}

// static
MouseEvent* MouseEvent::last_click_event_ =;

int MouseEvent::GetClickCount() const {}

void MouseEvent::SetClickCount(int click_count) {}

std::string MouseEvent::ToString() const {}

std::unique_ptr<Event> MouseEvent::Clone() const {}

////////////////////////////////////////////////////////////////////////////////
// MouseWheelEvent

MouseWheelEvent::MouseWheelEvent(const PlatformEvent& native_event)
    :{}

MouseWheelEvent::MouseWheelEvent(const ScrollEvent& scroll_event)
    :{}

MouseWheelEvent::MouseWheelEvent(const MouseEvent& mouse_event,
                                 int x_offset,
                                 int y_offset)
    :{}

MouseWheelEvent::MouseWheelEvent(const MouseWheelEvent& mouse_wheel_event)
    :{}

MouseWheelEvent::MouseWheelEvent(const gfx::Vector2d& offset,
                                 const gfx::PointF& location,
                                 const gfx::PointF& root_location,
                                 base::TimeTicks time_stamp,
                                 int flags,
                                 int changed_button_flags,
                                 const std::optional<gfx::Vector2d> tick_120ths)
    :{}

MouseWheelEvent::MouseWheelEvent(const gfx::Vector2d& offset,
                                 const gfx::Point& location,
                                 const gfx::Point& root_location,
                                 base::TimeTicks time_stamp,
                                 int flags,
                                 int changed_button_flags)
    :{}

MouseWheelEvent::~MouseWheelEvent() = default;

std::unique_ptr<Event> MouseWheelEvent::Clone() const {}

#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_LINUX)
// This value matches Windows, Fuchsia WHEEL_DELTA, and (roughly) Firefox on
// Linux.
// static
const int MouseWheelEvent::kWheelDelta =;
#else
// This is a legacy value that matches GTK+ wheel scroll amount.  Although being
// inherited from Linux, it is no longer used on Linux itself, but is still used
// on some other platforms.
// See https://crbug.com/1270089 for the detailed reasoning.
// static
const int MouseWheelEvent::kWheelDelta = 53;
#endif

////////////////////////////////////////////////////////////////////////////////
// TouchEvent

TouchEvent::TouchEvent(const PlatformEvent& native_event)
    :{}

TouchEvent::TouchEvent(EventType type,
                       const gfx::PointF& location,
                       const gfx::PointF& root_location,
                       base::TimeTicks time_stamp,
                       const PointerDetails& pointer_details,
                       int flags)
    :{}

TouchEvent::TouchEvent(EventType type,
                       const gfx::Point& location,
                       base::TimeTicks time_stamp,
                       const PointerDetails& pointer_details,
                       int flags)
    :{}

TouchEvent::TouchEvent(const TouchEvent& copy)
    :{}

TouchEvent::~TouchEvent() = default;

void TouchEvent::UpdateForRootTransform(
    const gfx::Transform& inverted_root_transform,
    const gfx::Transform& inverted_local_transform) {}

void TouchEvent::DisableSynchronousHandling() {}

void TouchEvent::ForceProcessGesture() {}

void TouchEvent::SetPointerDetailsForTest(
    const PointerDetails& pointer_details) {}

float TouchEvent::ComputeRotationAngle() const {}

std::unique_ptr<Event> TouchEvent::Clone() const {}

////////////////////////////////////////////////////////////////////////////////
// KeyEvent

// static
KeyEvent* KeyEvent::last_key_event_ =;
#if BUILDFLAG(IS_OZONE)
KeyEvent* KeyEvent::last_ibus_key_event_ =;
#endif

KeyEvent::KeyEvent(const PlatformEvent& native_event)
    :{}

KeyEvent::KeyEvent(const PlatformEvent& native_event, int event_flags)
    :{}

KeyEvent::KeyEvent(EventType type,
                   KeyboardCode key_code,
                   int flags,
                   base::TimeTicks time_stamp)
    :{}

KeyEvent::KeyEvent(EventType type,
                   KeyboardCode key_code,
                   DomCode code,
                   int flags)
    :{}

KeyEvent::KeyEvent(EventType type,
                   KeyboardCode key_code,
                   DomCode code,
                   int flags,
                   DomKey key,
                   base::TimeTicks time_stamp,
                   bool is_char)
    :{}

KeyEvent::KeyEvent(EventType type,
                   KeyboardCode key_code,
                   DomCode code,
                   int flags,
                   base::TimeTicks time_stamp)
    :{}

KeyEvent::KeyEvent(const KeyEvent& rhs)
    :{}

KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) {}

KeyEvent::~KeyEvent() = default;

// static
// For compatibility, this is enabled by default.
bool KeyEvent::synthesize_key_repeat_enabled_ =;

// static
bool KeyEvent::IsSynthesizeKeyRepeatEnabled() {}

// static
void KeyEvent::SetSynthesizeKeyRepeatEnabled(bool enabled) {}

KeyEvent KeyEvent::FromCharacter(char16_t character,
                                 KeyboardCode key_code,
                                 DomCode code,
                                 int flags,
                                 base::TimeTicks time_stamp) {}

void KeyEvent::InitializeNative() {}

void KeyEvent::ApplyLayout() const {}

bool KeyEvent::IsRepeated(KeyEvent** last_key_event) {}

KeyEvent** KeyEvent::GetLastKeyEvent() {}

DomKey KeyEvent::GetDomKey() const {}

void KeyEvent::OnFlagsUpdated() {}

char16_t KeyEvent::GetCharacter() const {}

char16_t KeyEvent::GetText() const {}

char16_t KeyEvent::GetUnmodifiedText() const {}

bool KeyEvent::IsUnicodeKeyCode() const {}

void KeyEvent::NormalizeFlags() {}

std::string KeyEvent::ToString() const {}

std::unique_ptr<Event> KeyEvent::Clone() const {}

KeyboardCode KeyEvent::GetLocatedWindowsKeyboardCode() const {}

uint16_t KeyEvent::GetConflatedWindowsKeyCode() const {}

std::string KeyEvent::GetCodeString() const {}

////////////////////////////////////////////////////////////////////////////////
// ScrollEvent

ScrollEvent::ScrollEvent(const PlatformEvent& native_event)
    :{}

ScrollEvent::ScrollEvent(EventType type,
                         const gfx::PointF& location,
                         const gfx::PointF& root_location,
                         base::TimeTicks time_stamp,
                         int flags,
                         float x_offset,
                         float y_offset,
                         float x_offset_ordinal,
                         float y_offset_ordinal,
                         int finger_count,
                         EventMomentumPhase momentum_phase,
                         ScrollEventPhase scroll_event_phase)
    :{}

ScrollEvent::ScrollEvent(EventType type,
                         const gfx::Point& location,
                         base::TimeTicks time_stamp,
                         int flags,
                         float x_offset,
                         float y_offset,
                         float x_offset_ordinal,
                         float y_offset_ordinal,
                         int finger_count,
                         EventMomentumPhase momentum_phase,
                         ScrollEventPhase scroll_event_phase)
    :{}

ScrollEvent::ScrollEvent(const ScrollEvent& other) = default;

ScrollEvent::~ScrollEvent() = default;

void ScrollEvent::Scale(const float factor) {}

std::string ScrollEvent::ToString() const {}

std::unique_ptr<Event> ScrollEvent::Clone() const {}

////////////////////////////////////////////////////////////////////////////////
// GestureEvent

GestureEvent::GestureEvent(float x,
                           float y,
                           int flags,
                           base::TimeTicks time_stamp,
                           const GestureEventDetails& details,
                           uint32_t unique_touch_event_id)
    :{}

GestureEvent::GestureEvent(const GestureEvent& other) = default;

GestureEvent::~GestureEvent() = default;

std::string GestureEvent::ToString() const {}

std::unique_ptr<Event> GestureEvent::Clone() const {}

}  // namespace ui