#include "third_party/blink/renderer/platform/widget/input/widget_input_handler_impl.h"
#include <utility>
#include "base/check.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/task/current_thread.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/self_owned_associated_receiver.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/input/web_coalesced_input_event.h"
#include "third_party/blink/public/common/input/web_keyboard_event.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.h"
#include "third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.h"
#include "third_party/blink/renderer/platform/widget/widget_base.h"
namespace blink {
namespace {
void RunClosureIfNotSwappedOut(base::WeakPtr<WidgetBase> widget,
base::OnceClosure closure) { … }
}
WidgetInputHandlerImpl::WidgetInputHandlerImpl(
scoped_refptr<WidgetInputHandlerManager> manager,
scoped_refptr<MainThreadEventQueue> input_event_queue,
base::WeakPtr<WidgetBase> widget,
base::WeakPtr<mojom::blink::FrameWidgetInputHandler>
frame_widget_input_handler)
: … { … }
WidgetInputHandlerImpl::~WidgetInputHandlerImpl() = default;
void WidgetInputHandlerImpl::SetReceiver(
mojo::PendingReceiver<mojom::blink::WidgetInputHandler>
interface_receiver) { … }
void WidgetInputHandlerImpl::SetFocus(mojom::blink::FocusState focus_state) { … }
void WidgetInputHandlerImpl::MouseCaptureLost() { … }
void WidgetInputHandlerImpl::SetEditCommandsForNextKeyEvent(
Vector<mojom::blink::EditCommandPtr> commands) { … }
void WidgetInputHandlerImpl::CursorVisibilityChanged(bool visible) { … }
static void ImeSetCompositionOnMainThread(
base::WeakPtr<WidgetBase> widget,
scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner,
const String& text,
const Vector<ui::ImeTextSpan>& ime_text_spans,
const gfx::Range& range,
int32_t start,
int32_t end,
WidgetInputHandlerImpl::ImeSetCompositionCallback callback) { … }
void WidgetInputHandlerImpl::ImeSetComposition(
const String& text,
const Vector<ui::ImeTextSpan>& ime_text_spans,
const gfx::Range& range,
int32_t start,
int32_t end,
WidgetInputHandlerImpl::ImeSetCompositionCallback callback) { … }
static void ImeCommitTextOnMainThread(
base::WeakPtr<WidgetBase> widget,
scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner,
const String& text,
const Vector<ui::ImeTextSpan>& ime_text_spans,
const gfx::Range& range,
int32_t relative_cursor_position,
WidgetInputHandlerImpl::ImeCommitTextCallback callback) { … }
void WidgetInputHandlerImpl::ImeCommitText(
const String& text,
const Vector<ui::ImeTextSpan>& ime_text_spans,
const gfx::Range& range,
int32_t relative_cursor_position,
ImeCommitTextCallback callback) { … }
void WidgetInputHandlerImpl::ImeFinishComposingText(bool keep_selection) { … }
void WidgetInputHandlerImpl::RequestTextInputStateUpdate() { … }
void WidgetInputHandlerImpl::RequestCompositionUpdates(bool immediate_request,
bool monitor_request) { … }
void WidgetInputHandlerImpl::DispatchEvent(
std::unique_ptr<WebCoalescedInputEvent> event,
DispatchEventCallback callback) { … }
void WidgetInputHandlerImpl::DispatchNonBlockingEvent(
std::unique_ptr<WebCoalescedInputEvent> event) { … }
void WidgetInputHandlerImpl::WaitForInputProcessed(
WaitForInputProcessedCallback callback) { … }
void WidgetInputHandlerImpl::InputWasProcessed() { … }
#if BUILDFLAG(IS_ANDROID)
void WidgetInputHandlerImpl::AttachSynchronousCompositor(
mojo::PendingRemote<mojom::blink::SynchronousCompositorControlHost>
control_host,
mojo::PendingAssociatedRemote<mojom::blink::SynchronousCompositorHost> host,
mojo::PendingAssociatedReceiver<mojom::blink::SynchronousCompositor>
compositor_receiver) {
input_handler_manager_->AttachSynchronousCompositor(
std::move(control_host), std::move(host), std::move(compositor_receiver));
}
#endif
void WidgetInputHandlerImpl::GetFrameWidgetInputHandler(
mojo::PendingAssociatedReceiver<mojom::blink::FrameWidgetInputHandler>
frame_receiver) { … }
void WidgetInputHandlerImpl::UpdateBrowserControlsState(
cc::BrowserControlsState constraints,
cc::BrowserControlsState current,
bool animate,
const std::optional<cc::BrowserControlsOffsetTagsInfo>& offset_tags_info) { … }
void WidgetInputHandlerImpl::RunOnMainThread(base::OnceClosure closure) { … }
void WidgetInputHandlerImpl::Release() { … }
}