alloy: Add touch handle and quick menu support for OSR (fixes issue #3268)

The client is responsible for rendering both as no default implementation
is currently available for OSR.
This commit is contained in:
JohnKarel
2022-05-27 12:03:31 +03:00
committed by Marshall Greenblatt
parent 771e5c7c0c
commit d9b764860a
41 changed files with 2166 additions and 52 deletions

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=a689271e9c27cfd0d6f6fadb8bb624898f165934$
// $hash=1531579b642c3009765e7ef273887c423e552b36$
//
#include "libcef_dll/cpptoc/context_menu_handler_cpptoc.h"
@@ -18,6 +18,7 @@
#include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/ctocpp/menu_model_ctocpp.h"
#include "libcef_dll/ctocpp/run_context_menu_callback_ctocpp.h"
#include "libcef_dll/ctocpp/run_quick_menu_callback_ctocpp.h"
#include "libcef_dll/shutdown_checker.h"
namespace {
@@ -167,6 +168,112 @@ void CEF_CALLBACK context_menu_handler_on_context_menu_dismissed(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame));
}
int CEF_CALLBACK context_menu_handler_run_quick_menu(
struct _cef_context_menu_handler_t* self,
cef_browser_t* browser,
struct _cef_frame_t* frame,
const cef_point_t* location,
const cef_size_t* size,
cef_quick_menu_edit_state_flags_t edit_state_flags,
cef_run_quick_menu_callback_t* callback) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: frame; type: refptr_diff
DCHECK(frame);
if (!frame)
return 0;
// Verify param: location; type: simple_byref_const
DCHECK(location);
if (!location)
return 0;
// Verify param: size; type: simple_byref_const
DCHECK(size);
if (!size)
return 0;
// Verify param: callback; type: refptr_diff
DCHECK(callback);
if (!callback)
return 0;
// Translate param: location; type: simple_byref_const
CefPoint locationVal = location ? *location : CefPoint();
// Translate param: size; type: simple_byref_const
CefSize sizeVal = size ? *size : CefSize();
// Execute
bool _retval = CefContextMenuHandlerCppToC::Get(self)->RunQuickMenu(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), locationVal,
sizeVal, edit_state_flags, CefRunQuickMenuCallbackCToCpp::Wrap(callback));
// Return type: bool
return _retval;
}
int CEF_CALLBACK context_menu_handler_on_quick_menu_command(
struct _cef_context_menu_handler_t* self,
cef_browser_t* browser,
struct _cef_frame_t* frame,
int command_id,
cef_event_flags_t event_flags) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: frame; type: refptr_diff
DCHECK(frame);
if (!frame)
return 0;
// Execute
bool _retval = CefContextMenuHandlerCppToC::Get(self)->OnQuickMenuCommand(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), command_id,
event_flags);
// Return type: bool
return _retval;
}
void CEF_CALLBACK context_menu_handler_on_quick_menu_dismissed(
struct _cef_context_menu_handler_t* self,
cef_browser_t* browser,
struct _cef_frame_t* frame) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: frame; type: refptr_diff
DCHECK(frame);
if (!frame)
return;
// Execute
CefContextMenuHandlerCppToC::Get(self)->OnQuickMenuDismissed(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame));
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
@@ -179,6 +286,11 @@ CefContextMenuHandlerCppToC::CefContextMenuHandlerCppToC() {
context_menu_handler_on_context_menu_command;
GetStruct()->on_context_menu_dismissed =
context_menu_handler_on_context_menu_dismissed;
GetStruct()->run_quick_menu = context_menu_handler_run_quick_menu;
GetStruct()->on_quick_menu_command =
context_menu_handler_on_quick_menu_command;
GetStruct()->on_quick_menu_dismissed =
context_menu_handler_on_quick_menu_dismissed;
}
// DESTRUCTOR - Do not edit by hand.

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=17fc7e8f42e6c518405f2aba5e849c98bf8122ce$
// $hash=6671ca3d639065c49adfc8ceac4c58833344d558$
//
#include "libcef_dll/cpptoc/render_handler_cpptoc.h"
@@ -329,6 +329,73 @@ render_handler_on_accelerated_paint(struct _cef_render_handler_t* self,
CefBrowserCToCpp::Wrap(browser), type, dirtyRectsList, shared_handle);
}
void CEF_CALLBACK
render_handler_get_touch_handle_size(struct _cef_render_handler_t* self,
cef_browser_t* browser,
cef_horizontal_alignment_t orientation,
cef_size_t* size) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: size; type: simple_byref
DCHECK(size);
if (!size)
return;
// Translate param: size; type: simple_byref
CefSize sizeVal = size ? *size : CefSize();
// Execute
CefRenderHandlerCppToC::Get(self)->GetTouchHandleSize(
CefBrowserCToCpp::Wrap(browser), orientation, sizeVal);
// Restore param: size; type: simple_byref
if (size)
*size = sizeVal;
}
void CEF_CALLBACK render_handler_on_touch_handle_state_changed(
struct _cef_render_handler_t* self,
cef_browser_t* browser,
const struct _cef_touch_handle_state_t* state) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: state; type: struct_byref_const
DCHECK(state);
if (!state)
return;
if (!template_util::has_valid_size(state)) {
NOTREACHED() << "invalid state->[base.]size";
return;
}
// Translate param: state; type: struct_byref_const
CefTouchHandleState stateObj;
if (state)
stateObj.Set(*state, false);
// Execute
CefRenderHandlerCppToC::Get(self)->OnTouchHandleStateChanged(
CefBrowserCToCpp::Wrap(browser), stateObj);
}
int CEF_CALLBACK
render_handler_start_dragging(struct _cef_render_handler_t* self,
cef_browser_t* browser,
@@ -509,6 +576,9 @@ CefRenderHandlerCppToC::CefRenderHandlerCppToC() {
GetStruct()->on_popup_size = render_handler_on_popup_size;
GetStruct()->on_paint = render_handler_on_paint;
GetStruct()->on_accelerated_paint = render_handler_on_accelerated_paint;
GetStruct()->get_touch_handle_size = render_handler_get_touch_handle_size;
GetStruct()->on_touch_handle_state_changed =
render_handler_on_touch_handle_state_changed;
GetStruct()->start_dragging = render_handler_start_dragging;
GetStruct()->update_drag_cursor = render_handler_update_drag_cursor;
GetStruct()->on_scroll_offset_changed =

View File

@@ -0,0 +1,83 @@
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=51e850e2768a6ec8ec7d764830d27138334d82ac$
//
#include "libcef_dll/cpptoc/run_quick_menu_callback_cpptoc.h"
#include "libcef_dll/shutdown_checker.h"
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK
run_quick_menu_callback_cont(struct _cef_run_quick_menu_callback_t* self,
int command_id,
cef_event_flags_t event_flags) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Execute
CefRunQuickMenuCallbackCppToC::Get(self)->Continue(command_id, event_flags);
}
void CEF_CALLBACK
run_quick_menu_callback_cancel(struct _cef_run_quick_menu_callback_t* self) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Execute
CefRunQuickMenuCallbackCppToC::Get(self)->Cancel();
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefRunQuickMenuCallbackCppToC::CefRunQuickMenuCallbackCppToC() {
GetStruct()->cont = run_quick_menu_callback_cont;
GetStruct()->cancel = run_quick_menu_callback_cancel;
}
// DESTRUCTOR - Do not edit by hand.
CefRunQuickMenuCallbackCppToC::~CefRunQuickMenuCallbackCppToC() {
shutdown_checker::AssertNotShutdown();
}
template <>
CefRefPtr<CefRunQuickMenuCallback> CefCppToCRefCounted<
CefRunQuickMenuCallbackCppToC,
CefRunQuickMenuCallback,
cef_run_quick_menu_callback_t>::UnwrapDerived(CefWrapperType type,
cef_run_quick_menu_callback_t*
s) {
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType
CefCppToCRefCounted<CefRunQuickMenuCallbackCppToC,
CefRunQuickMenuCallback,
cef_run_quick_menu_callback_t>::kWrapperType =
WT_RUN_QUICK_MENU_CALLBACK;

View File

@@ -0,0 +1,38 @@
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=b641fe8119fa5ab3e3a635105ca25985dec40bd0$
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_RUN_QUICK_MENU_CALLBACK_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_RUN_QUICK_MENU_CALLBACK_CPPTOC_H_
#pragma once
#if !defined(BUILDING_CEF_SHARED)
#error This file can be included DLL-side only
#endif
#include "include/capi/cef_context_menu_handler_capi.h"
#include "include/cef_context_menu_handler.h"
#include "libcef_dll/cpptoc/cpptoc_ref_counted.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefRunQuickMenuCallbackCppToC
: public CefCppToCRefCounted<CefRunQuickMenuCallbackCppToC,
CefRunQuickMenuCallback,
cef_run_quick_menu_callback_t> {
public:
CefRunQuickMenuCallbackCppToC();
virtual ~CefRunQuickMenuCallbackCppToC();
};
#endif // CEF_LIBCEF_DLL_CPPTOC_RUN_QUICK_MENU_CALLBACK_CPPTOC_H_