chromium/content/browser/renderer_host/render_widget_host_view_event_handler.cc

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

#include "content/browser/renderer_host/render_widget_host_view_event_handler.h"

#include "base/command_line.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/numerics/safe_conversions.h"
#include "build/build_config.h"
#include "components/input/render_widget_host_input_event_router.h"
#include "components/viz/common/features.h"
#include "content/browser/renderer_host/input/touch_selection_controller_client_aura.h"
#include "content/browser/renderer_host/overscroll_controller.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_view_host_delegate_view.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/renderer_host/text_input_manager.h"
#include "content/common/content_switches_internal.h"
#include "content/common/features.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/scoped_keyboard_hook.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
#include "ui/events/blink/blink_event_util.h"
#include "ui/events/blink/web_input_event.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/gfx/delegated_ink_point.h"
#include "ui/touch_selection/touch_selection_controller.h"

#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif

namespace {

// In mouse lock mode, we need to prevent the (invisible) cursor from hitting
// the border of the view, in order to get valid movement information. However,
// forcing the cursor back to the center of the view after each mouse move
// doesn't work well. It reduces the frequency of useful mouse move messages
// significantly. Therefore, we move the cursor to the center of the view only
// if it approaches the border. |kMouseLockBorderPercentage| specifies the width
// of the border area, in percentage of the corresponding dimension.
const int kMouseLockBorderPercentage =;

#if BUILDFLAG(IS_WIN)
// A callback function for EnumThreadWindows to enumerate and dismiss
// any owned popup windows.
BOOL CALLBACK DismissOwnedPopups(HWND window, LPARAM arg) {
  const HWND toplevel_hwnd = reinterpret_cast<HWND>(arg);

  if (::IsWindowVisible(window)) {
    const HWND owner = ::GetWindow(window, GW_OWNER);
    if (toplevel_hwnd == owner) {
      ::PostMessageW(window, WM_CANCELMODE, 0, 0);
    }
  }

  return TRUE;
}
#endif  // BUILDFLAG(IS_WIN)

bool IsFractionalScaleFactor(float scale_factor) {}

// We don't mark these as handled so that they're sent back to the
// DefWindowProc so it can generate WM_APPCOMMAND as necessary.
bool ShouldGenerateAppCommand(const ui::MouseEvent* event) {}

// Reset unchanged touch points to StateStationary for touchmove and
// touchcancel.
void MarkUnchangedTouchPointsAsStationary(blink::WebTouchEvent* event,
                                          int changed_touch_id) {}

bool NeedsInputGrab(content::RenderWidgetHostViewBase* view) {}

}  // namespace

namespace content {

RenderWidgetHostViewEventHandler::Delegate::Delegate() = default;

RenderWidgetHostViewEventHandler::Delegate::~Delegate() {}

RenderWidgetHostViewEventHandler::RenderWidgetHostViewEventHandler(
    RenderWidgetHostImpl* host,
    RenderWidgetHostViewBase* host_view,
    Delegate* delegate)
    :{}

RenderWidgetHostViewEventHandler::~RenderWidgetHostViewEventHandler() {}

void RenderWidgetHostViewEventHandler::SetPopupChild(
    RenderWidgetHostViewBase* popup_child_host_view,
    ui::EventHandler* popup_child_event_handler) {}

blink::mojom::PointerLockResult RenderWidgetHostViewEventHandler::LockPointer(
    bool request_unadjusted_movement) {}

blink::mojom::PointerLockResult
RenderWidgetHostViewEventHandler::ChangePointerLock(
    bool request_unadjusted_movement) {}

void RenderWidgetHostViewEventHandler::UnlockPointer() {}

bool RenderWidgetHostViewEventHandler::LockKeyboard(
    std::optional<base::flat_set<ui::DomCode>> codes) {}

void RenderWidgetHostViewEventHandler::UnlockKeyboard() {}

bool RenderWidgetHostViewEventHandler::IsKeyboardLocked() const {}

void RenderWidgetHostViewEventHandler::OnKeyEvent(ui::KeyEvent* event) {}

void RenderWidgetHostViewEventHandler::HandleMouseWheelEvent(
    ui::MouseEvent* event) {}

void RenderWidgetHostViewEventHandler::OnMouseEvent(ui::MouseEvent* event) {}

void RenderWidgetHostViewEventHandler::OnScrollEvent(ui::ScrollEvent* event) {}

void RenderWidgetHostViewEventHandler::OnTouchEvent(ui::TouchEvent* event) {}

void RenderWidgetHostViewEventHandler::OnGestureEvent(ui::GestureEvent* event) {}

void RenderWidgetHostViewEventHandler::GestureEventAck(
    const blink::WebGestureEvent& event,
    blink::mojom::InputEventResultState ack_result) {}

bool RenderWidgetHostViewEventHandler::CanRendererHandleEvent(
    const ui::MouseEvent* event,
    bool mouse_locked,
    bool selection_popup) const {}

void RenderWidgetHostViewEventHandler::FinishImeCompositionSession() {}

void RenderWidgetHostViewEventHandler::ForwardMouseEventToParent(
    ui::MouseEvent* event) {}

void RenderWidgetHostViewEventHandler::HandleGestureForTouchSelection(
    ui::GestureEvent* event) {}

void RenderWidgetHostViewEventHandler::HandleSwipeToMoveCursorGestureAck(
    const blink::WebGestureEvent& event) {}

void RenderWidgetHostViewEventHandler::HandleMouseEventWhileLocked(
    ui::MouseEvent* event) {}

void RenderWidgetHostViewEventHandler::ModifyEventMovementAndCoords(
    const ui::MouseEvent& ui_mouse_event,
    blink::WebMouseEvent* event) {}

void RenderWidgetHostViewEventHandler::MoveCursorToCenter(
    ui::MouseEvent* event) {}

bool RenderWidgetHostViewEventHandler::MatchesSynthesizedMovePosition(
    const blink::WebMouseEvent& event) {}

void RenderWidgetHostViewEventHandler::SetKeyboardFocus() {}

bool RenderWidgetHostViewEventHandler::ShouldMoveToCenter(
    gfx::PointF mouse_screen_position) {}

bool RenderWidgetHostViewEventHandler::ShouldRouteEvents() const {}

void RenderWidgetHostViewEventHandler::ProcessMouseEvent(
    const blink::WebMouseEvent& event,
    const ui::LatencyInfo& latency) {}

void RenderWidgetHostViewEventHandler::ProcessMouseWheelEvent(
    const blink::WebMouseWheelEvent& event,
    const ui::LatencyInfo& latency) {}

void RenderWidgetHostViewEventHandler::ProcessTouchEvent(
    const blink::WebTouchEvent& event,
    const ui::LatencyInfo& latency) {}

bool RenderWidgetHostViewEventHandler::IsKeyLocked(const ui::KeyEvent& event) {}

}  // namespace content