Move OnCursorChange from CefRenderHandler to CefDisplayHandler

The cursor change can now be handled by the client with both windowed and
off-screen rendering.

Returning true from OnCursorChange will disable the default cursor change
behavior. This is functionally equivalent to the
CefBrowserHost::SetMouseCursorChangeDisabled method, so that method has been
removed.
This commit is contained in:
Marshall Greenblatt
2020-10-28 12:30:54 -04:00
parent 4e6c558bf2
commit 023d218104
38 changed files with 282 additions and 354 deletions

View File

@ -556,6 +556,8 @@ static_library("libcef_static") {
"libcef/browser/menu_runner.h",
"libcef/browser/native/browser_platform_delegate_native.cc",
"libcef/browser/native/browser_platform_delegate_native.h",
"libcef/browser/native/cursor_util.h",
"libcef/browser/native/cursor_util.cc",
"libcef/browser/navigate_params.cc",
"libcef/browser/navigate_params.h",
"libcef/browser/navigation_entry_impl.cc",
@ -938,6 +940,7 @@ static_library("libcef_static") {
"libcef/browser/alloy/alloy_browser_main_win.cc",
"libcef/browser/native/browser_platform_delegate_native_win.cc",
"libcef/browser/native/browser_platform_delegate_native_win.h",
"libcef/browser/native/cursor_util_win.cc",
"libcef/browser/native/file_dialog_runner_win.cc",
"libcef/browser/native/file_dialog_runner_win.h",
"libcef/browser/native/javascript_dialog_runner_win.cc",
@ -951,7 +954,6 @@ static_library("libcef_static") {
"libcef/browser/native/native_menu_win.h",
"libcef/browser/osr/browser_platform_delegate_osr_win.cc",
"libcef/browser/osr/browser_platform_delegate_osr_win.h",
"libcef/browser/osr/render_widget_host_view_osr_win.cc",
# Part of //chrome/utility.
"//chrome/utility/printing_handler.cc",
@ -982,11 +984,11 @@ static_library("libcef_static") {
sources += includes_linux + [
"libcef/browser/native/browser_platform_delegate_native_linux.cc",
"libcef/browser/native/browser_platform_delegate_native_linux.h",
"libcef/browser/native/cursor_util_linux.cc",
"libcef/browser/native/menu_runner_linux.cc",
"libcef/browser/native/menu_runner_linux.h",
"libcef/browser/osr/browser_platform_delegate_osr_linux.cc",
"libcef/browser/osr/browser_platform_delegate_osr_linux.h",
"libcef/browser/osr/render_widget_host_view_osr_linux.cc",
"libcef/browser/printing/print_dialog_linux.cc",
"libcef/browser/printing/print_dialog_linux.h",
]

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=6cb00a0fa3631a46903abb3a783f315895511db2$
// $hash=965eb2e55afec0a4618a7acd9478b9c1215be29d$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
@ -562,19 +562,6 @@ typedef struct _cef_browser_host_t {
struct _cef_navigation_entry_visitor_t* visitor,
int current_only);
///
// Set whether mouse cursor change is disabled.
///
void(CEF_CALLBACK* set_mouse_cursor_change_disabled)(
struct _cef_browser_host_t* self,
int disabled);
///
// Returns true (1) if mouse cursor change is disabled.
///
int(CEF_CALLBACK* is_mouse_cursor_change_disabled)(
struct _cef_browser_host_t* self);
///
// If a misspelled word is currently selected in an editable node calling this
// function will replace it with the specified |word|.

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=951c936c8070dbf9bd246cc766b81cdfe06a3d81$
// $hash=eada7e92085d96497f4e69f3e8a7e8aa6746b175$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
@ -141,6 +141,19 @@ typedef struct _cef_display_handler_t {
struct _cef_display_handler_t* self,
struct _cef_browser_t* browser,
double progress);
///
// Called when the browser's cursor has changed. If |type| is CT_CUSTOM then
// |custom_cursor_info| will be populated with the custom cursor information.
// Return true (1) if the cursor change was handled or false (0) for default
// handling.
///
int(CEF_CALLBACK* on_cursor_change)(
struct _cef_display_handler_t* self,
struct _cef_browser_t* browser,
cef_cursor_handle_t cursor,
cef_cursor_type_t type,
const struct _cef_cursor_info_t* custom_cursor_info);
} cef_display_handler_t;
#ifdef __cplusplus

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=e642fc1fe3b97a90c0eae7f0fc0a5cfd385e3e17$
// $hash=f9806cd79f33b6a762fff25edd4189ae42bc8fd2$
//
#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_
@ -159,17 +159,6 @@ typedef struct _cef_render_handler_t {
cef_rect_t const* dirtyRects,
void* shared_handle);
///
// Called when the browser's cursor has changed. If |type| is CT_CUSTOM then
// |custom_cursor_info| will be populated with the custom cursor information.
///
void(CEF_CALLBACK* on_cursor_change)(
struct _cef_render_handler_t* self,
struct _cef_browser_t* browser,
cef_cursor_handle_t cursor,
cef_cursor_type_t type,
const struct _cef_cursor_info_t* custom_cursor_info);
///
// Called when the user starts dragging content in the web view. Contextual
// information about the dragged content is supplied by |drag_data|. (|x|,

View File

@ -42,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "22df40aa24a8bd920a2d18500c94dcc1b2c9508f"
#define CEF_API_HASH_UNIVERSAL "7f349b7262bfe13bda037370004f56a6081e543b"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "7698e6c4e3bc0f749609a0172a24d34cddbe8a1f"
#define CEF_API_HASH_PLATFORM "8a5523fec15255e2fb1de64deaa15dc3554b91e5"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "5189bd75f9d076d7f136bf140b6cc5990ad452ec"
#define CEF_API_HASH_PLATFORM "f572c8f7d3aee3cd3b85bd398b0ba43eb7fe79a0"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "96412a3d498054d352e5f9dcf5ad8ff90917c361"
#define CEF_API_HASH_PLATFORM "abf4cc6ff102e5cd019aaf51f13eb30f9bfeae45"
#endif
#ifdef __cplusplus

View File

@ -592,18 +592,6 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
CefRefPtr<CefNavigationEntryVisitor> visitor,
bool current_only) = 0;
///
// Set whether mouse cursor change is disabled.
///
/*--cef()--*/
virtual void SetMouseCursorChangeDisabled(bool disabled) = 0;
///
// Returns true if mouse cursor change is disabled.
///
/*--cef()--*/
virtual bool IsMouseCursorChangeDisabled() = 0;
///
// If a misspelled word is currently selected in an editable node calling
// this method will replace it with the specified |word|.

View File

@ -135,6 +135,19 @@ class CefDisplayHandler : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual void OnLoadingProgressChange(CefRefPtr<CefBrowser> browser,
double progress) {}
///
// Called when the browser's cursor has changed. If |type| is CT_CUSTOM then
// |custom_cursor_info| will be populated with the custom cursor information.
// Return true if the cursor change was handled or false for default handling.
///
/*--cef()--*/
virtual bool OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) {
return false;
}
};
#endif // CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_

View File

@ -52,7 +52,6 @@
/*--cef(source=client)--*/
class CefRenderHandler : public virtual CefBaseRefCounted {
public:
typedef cef_cursor_type_t CursorType;
typedef cef_drag_operations_mask_t DragOperation;
typedef cef_drag_operations_mask_t DragOperationsMask;
typedef cef_paint_element_type_t PaintElementType;
@ -162,16 +161,6 @@ class CefRenderHandler : public virtual CefBaseRefCounted {
const RectList& dirtyRects,
void* shared_handle) {}
///
// Called when the browser's cursor has changed. If |type| is CT_CUSTOM then
// |custom_cursor_info| will be populated with the custom cursor information.
///
/*--cef()--*/
virtual void OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CursorType type,
const CefCursorInfo& custom_cursor_info) {}
///
// Called when the user starts dragging content in the web view. Contextual
// information about the dragged content is supplied by |drag_data|.

View File

@ -17,6 +17,7 @@
#include "libcef/browser/context.h"
#include "libcef/browser/devtools/devtools_manager.h"
#include "libcef/browser/media_capture_devices_dispatcher.h"
#include "libcef/browser/native/cursor_util.h"
#include "libcef/browser/osr/osr_util.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/thread_util.h"
@ -102,10 +103,11 @@ class CefWidgetHostInterceptor
// WidgetHostInterceptorForTesting method:
void SetCursor(const ui::Cursor& cursor) override {
if (browser_->IsMouseCursorChangeDisabled()) {
if (cursor_util::OnCursorChange(browser_, cursor)) {
// Don't change the cursor.
return;
}
GetForwardingInterface()->SetCursor(cursor);
}
@ -643,18 +645,6 @@ bool AlloyBrowserHostImpl::IsBackgroundHost() {
return is_background_host_;
}
void AlloyBrowserHostImpl::SetMouseCursorChangeDisabled(bool disabled) {
base::AutoLock lock_scope(state_lock_);
if (mouse_cursor_change_disabled_ == disabled)
return;
mouse_cursor_change_disabled_ = disabled;
}
bool AlloyBrowserHostImpl::IsMouseCursorChangeDisabled() {
base::AutoLock lock_scope(state_lock_);
return mouse_cursor_change_disabled_;
}
bool AlloyBrowserHostImpl::IsWindowRenderingDisabled() {
return IsWindowless();
}

View File

@ -119,8 +119,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
CefRefPtr<CefDictionaryValue> params) override;
CefRefPtr<CefRegistration> AddDevToolsMessageObserver(
CefRefPtr<CefDevToolsMessageObserver> observer) override;
void SetMouseCursorChangeDisabled(bool disabled) override;
bool IsMouseCursorChangeDisabled() override;
bool IsWindowRenderingDisabled() override;
void WasResized() override;
void WasHidden(bool hidden) override;
@ -388,9 +386,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
// on the UI thread.
bool window_destroyed_ = false;
// True if mouse cursor change is disabled.
bool mouse_cursor_change_disabled_ = false;
// Used for creating and managing file dialogs.
std::unique_ptr<CefFileDialogManager> file_dialog_manager_;

View File

@ -265,15 +265,6 @@ CefRefPtr<CefRegistration> ChromeBrowserHostImpl::AddDevToolsMessageObserver(
return nullptr;
}
void ChromeBrowserHostImpl::SetMouseCursorChangeDisabled(bool disabled) {
NOTIMPLEMENTED();
}
bool ChromeBrowserHostImpl::IsMouseCursorChangeDisabled() {
NOTIMPLEMENTED();
return false;
}
bool ChromeBrowserHostImpl::IsWindowRenderingDisabled() {
return false;
}

View File

@ -97,8 +97,6 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
CefRefPtr<CefDictionaryValue> params) override;
CefRefPtr<CefRegistration> AddDevToolsMessageObserver(
CefRefPtr<CefDevToolsMessageObserver> observer) override;
void SetMouseCursorChangeDisabled(bool disabled) override;
bool IsMouseCursorChangeDisabled() override;
bool IsWindowRenderingDisabled() override;
void WasResized() override;
void WasHidden(bool hidden) override;

View File

@ -0,0 +1,63 @@
// Copyright 2020 The Chromium Embedded Framework Authors. Portions copyright
// 2012 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#include "libcef/browser/native/cursor_util.h"
#include "libcef/browser/browser_host_base.h"
#include "content/common/cursors/webcursor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom.h"
namespace cursor_util {
bool OnCursorChange(CefBrowserHostBase* browser, const ui::Cursor& ui_cursor) {
auto client = browser->GetClient();
if (!client)
return false;
auto handler = client->GetDisplayHandler();
if (!handler)
return false;
const cef_cursor_type_t cursor_type =
static_cast<cef_cursor_type_t>(ui_cursor.type());
CefCursorInfo custom_cursor_info;
if (ui_cursor.type() == ui::mojom::CursorType::kCustom) {
custom_cursor_info.hotspot.x = ui_cursor.custom_hotspot().x();
custom_cursor_info.hotspot.y = ui_cursor.custom_hotspot().y();
custom_cursor_info.image_scale_factor = ui_cursor.image_scale_factor();
custom_cursor_info.buffer = ui_cursor.custom_bitmap().getPixels();
custom_cursor_info.size.width = ui_cursor.custom_bitmap().width();
custom_cursor_info.size.height = ui_cursor.custom_bitmap().height();
}
bool handled = false;
#if defined(USE_AURA)
content::WebCursor web_cursor(ui_cursor);
CefCursorHandle platform_cursor;
if (ui_cursor.type() == ui::mojom::CursorType::kCustom) {
// |web_cursor| owns the resulting |platform_cursor|.
platform_cursor =
cursor_util::ToCursorHandle(web_cursor.GetPlatformCursor(ui_cursor));
} else {
platform_cursor = cursor_util::GetPlatformCursor(ui_cursor.type());
}
handled = handler->OnCursorChange(browser, platform_cursor, cursor_type,
custom_cursor_info);
#elif defined(OS_MAC)
// |web_cursor| owns the resulting |native_cursor|.
content::WebCursor web_cursor(ui_cursor);
CefCursorHandle native_cursor = web_cursor.GetNativeCursor();
handled = handler->OnCursorChange(browser, native_cursor, cursor_type,
custom_cursor_info);
#else
NOTIMPLEMENTED();
#endif
return handled;
}
} // namespace cursor_util

View File

@ -0,0 +1,27 @@
// Copyright 2020 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.
#ifndef CEF_LIBCEF_BROWSER_NATIVE_CURSOR_UTIL_H_
#define CEF_LIBCEF_BROWSER_NATIVE_CURSOR_UTIL_H_
#include "include/internal/cef_types.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
class CefBrowserHostBase;
namespace cursor_util {
#if defined(USE_AURA)
cef_cursor_handle_t GetPlatformCursor(ui::mojom::CursorType type);
cef_cursor_handle_t ToCursorHandle(ui::PlatformCursor cursor);
#endif // defined(USE_AURA)
// Returns true if the client handled the cursor change.
bool OnCursorChange(CefBrowserHostBase* browser, const ui::Cursor& ui_cursor);
} // namespace cursor_util
#endif // CEF_LIBCEF_BROWSER_NATIVE_CURSOR_UTIL_H_

View File

@ -1,9 +1,8 @@
// Copyright (c) 2014 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2020 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.
#include "libcef/browser/osr/render_widget_host_view_osr.h"
#include "libcef/browser/native/cursor_util.h"
#include "ui/base/cursor/cursor_factory.h"
@ -11,8 +10,9 @@
#include "ui/base/x/x11_cursor.h"
#endif
CefCursorHandle CefRenderWidgetHostViewOSR::GetPlatformCursor(
ui::mojom::CursorType type) {
namespace cursor_util {
cef_cursor_handle_t GetPlatformCursor(ui::mojom::CursorType type) {
auto cursor = ui::CursorFactory::GetInstance()->GetDefaultCursor(type);
if (cursor) {
return ToCursorHandle(*cursor);
@ -20,13 +20,14 @@ CefCursorHandle CefRenderWidgetHostViewOSR::GetPlatformCursor(
return 0;
}
CefCursorHandle CefRenderWidgetHostViewOSR::ToCursorHandle(
ui::PlatformCursor cursor) {
cef_cursor_handle_t ToCursorHandle(ui::PlatformCursor cursor) {
#if defined(USE_X11)
// See https://crbug.com/1029142 for background.
return static_cast<CefCursorHandle>(
return static_cast<cef_cursor_handle_t>(
static_cast<ui::X11Cursor*>(cursor)->xcursor());
#else
return cursor;
#endif
}
} // namespace cursor_util

View File

@ -1,42 +1,21 @@
// Copyright (c) 2014 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Copyright 2020 The Chromium Embedded Framework Authors. Portions copyright
// 2012 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#include "libcef/browser/osr/render_widget_host_view_osr.h"
#include "libcef/browser/native/cursor_util.h"
#include <windows.h>
#include "libcef/common/app_manager.h"
#include "ui/base/cursor/mojom/cursor_type.mojom.h"
#include "ui/resources/grit/ui_unscaled_resources.h"
namespace cursor_util {
namespace {
class CefCompositorHostWin : public gfx::WindowImpl {
public:
CefCompositorHostWin() {
// Create a hidden 1x1 borderless window.
set_window_style(WS_POPUP | WS_SYSMENU);
Init(NULL, gfx::Rect(0, 0, 1, 1));
}
~CefCompositorHostWin() override { DestroyWindow(hwnd()); }
private:
CR_BEGIN_MSG_MAP_EX(CefCompositorHostWin)
CR_MSG_WM_PAINT(OnPaint)
CR_END_MSG_MAP()
CR_MSG_MAP_CLASS_DECLARATIONS(CefCompositorHostWin)
void OnPaint(HDC dc) { ValidateRect(hwnd(), NULL); }
DISALLOW_COPY_AND_ASSIGN(CefCompositorHostWin);
};
// From content/common/cursors/webcursor_win.cc.
LPCWSTR ToCursorID(ui::mojom::CursorType type) {
switch (type) {
case ui::mojom::CursorType::kPointer:
@ -152,8 +131,7 @@ bool IsSystemCursorID(LPCWSTR cursor_id) {
} // namespace
CefCursorHandle CefRenderWidgetHostViewOSR::GetPlatformCursor(
ui::mojom::CursorType type) {
cef_cursor_handle_t GetPlatformCursor(ui::mojom::CursorType type) {
// Using a dark 1x1 bit bmp kNone cursor may still cause DWM to do composition
// work unnecessarily. Better to totally remove it from the screen.
// crbug.com/1069698
@ -173,7 +151,8 @@ CefCursorHandle CefRenderWidgetHostViewOSR::GetPlatformCursor(
return LoadCursor(module_handle, cursor_id);
}
CefCursorHandle CefRenderWidgetHostViewOSR::ToCursorHandle(
ui::PlatformCursor cursor) {
cef_cursor_handle_t ToCursorHandle(ui::PlatformCursor cursor) {
return cursor;
}
} // namespace cursor_util

View File

@ -604,54 +604,7 @@ void CefRenderWidgetHostViewOSR::InitAsFullscreen(
}
void CefRenderWidgetHostViewOSR::UpdateCursor(
const content::WebCursor& cursor) {
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::UpdateCursor");
if (!browser_impl_.get())
return;
CefRefPtr<CefRenderHandler> handler =
browser_impl_->GetClient()->GetRenderHandler();
CHECK(handler);
const auto& ui_cursor = cursor.cursor();
const cef_cursor_type_t cursor_type =
static_cast<cef_cursor_type_t>(ui_cursor.type());
CefCursorInfo custom_cursor_info;
if (ui_cursor.type() == ui::mojom::CursorType::kCustom) {
custom_cursor_info.hotspot.x = ui_cursor.custom_hotspot().x();
custom_cursor_info.hotspot.y = ui_cursor.custom_hotspot().y();
custom_cursor_info.image_scale_factor = ui_cursor.image_scale_factor();
custom_cursor_info.buffer = ui_cursor.custom_bitmap().getPixels();
custom_cursor_info.size.width = ui_cursor.custom_bitmap().width();
custom_cursor_info.size.height = ui_cursor.custom_bitmap().height();
}
#if defined(USE_AURA)
content::WebCursor web_cursor(ui_cursor);
CefCursorHandle platform_cursor;
if (ui_cursor.type() == ui::mojom::CursorType::kCustom) {
// |web_cursor| owns the resulting |platform_cursor|.
platform_cursor = ToCursorHandle(web_cursor.GetPlatformCursor(ui_cursor));
} else {
platform_cursor = GetPlatformCursor(ui_cursor.type());
}
handler->OnCursorChange(browser_impl_.get(), platform_cursor, cursor_type,
custom_cursor_info);
#elif defined(OS_MAC)
// |web_cursor| owns the resulting |native_cursor|.
content::WebCursor web_cursor(cursor);
CefCursorHandle native_cursor = web_cursor.GetNativeCursor();
handler->OnCursorChange(browser_impl_.get(), native_cursor, cursor_type,
custom_cursor_info);
#else
// TODO(port): Implement this method to work on other platforms as part of
// off-screen rendering support.
NOTREACHED();
#endif
}
const content::WebCursor& cursor) {}
content::CursorManager* CefRenderWidgetHostViewOSR::GetCursorManager() {
return cursor_manager_.get();

View File

@ -328,11 +328,6 @@ class CefRenderWidgetHostViewOSR
// opaqueness changes.
void UpdateBackgroundColorFromRenderer(SkColor color);
#if defined(USE_AURA)
CefCursorHandle GetPlatformCursor(ui::mojom::CursorType type);
CefCursorHandle ToCursorHandle(ui::PlatformCursor cursor);
#endif
// The background color of the web content.
SkColor background_color_;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=516b55b7ea53e2de2b096e85ba0eb83f2a2693f3$
// $hash=fa230168d79d0644b518d042bf3f9370e6eccf8c$
//
#include "libcef_dll/cpptoc/browser_host_cpptoc.h"
@ -621,39 +621,6 @@ browser_host_get_navigation_entries(struct _cef_browser_host_t* self,
current_only ? true : false);
}
void CEF_CALLBACK
browser_host_set_mouse_cursor_change_disabled(struct _cef_browser_host_t* self,
int disabled) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Execute
CefBrowserHostCppToC::Get(self)->SetMouseCursorChangeDisabled(
disabled ? true : false);
}
int CEF_CALLBACK
browser_host_is_mouse_cursor_change_disabled(struct _cef_browser_host_t* self) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefBrowserHostCppToC::Get(self)->IsMouseCursorChangeDisabled();
// Return type: bool
return _retval;
}
void CEF_CALLBACK
browser_host_replace_misspelling(struct _cef_browser_host_t* self,
const cef_string_t* word) {
@ -1367,10 +1334,6 @@ CefBrowserHostCppToC::CefBrowserHostCppToC() {
GetStruct()->add_dev_tools_message_observer =
browser_host_add_dev_tools_message_observer;
GetStruct()->get_navigation_entries = browser_host_get_navigation_entries;
GetStruct()->set_mouse_cursor_change_disabled =
browser_host_set_mouse_cursor_change_disabled;
GetStruct()->is_mouse_cursor_change_disabled =
browser_host_is_mouse_cursor_change_disabled;
GetStruct()->replace_misspelling = browser_host_replace_misspelling;
GetStruct()->add_word_to_dictionary = browser_host_add_word_to_dictionary;
GetStruct()->is_window_rendering_disabled =

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=1e329026cfad131337e794e5501367604f62fdb6$
// $hash=a6a81143ea8792ba5643643389f4dc2a8815174a$
//
#include "libcef_dll/cpptoc/display_handler_cpptoc.h"
@ -252,6 +252,41 @@ display_handler_on_loading_progress_change(struct _cef_display_handler_t* self,
CefBrowserCToCpp::Wrap(browser), progress);
}
int CEF_CALLBACK display_handler_on_cursor_change(
struct _cef_display_handler_t* self,
cef_browser_t* browser,
cef_cursor_handle_t cursor,
cef_cursor_type_t type,
const struct _cef_cursor_info_t* custom_cursor_info) {
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: custom_cursor_info; type: struct_byref_const
DCHECK(custom_cursor_info);
if (!custom_cursor_info)
return 0;
// Translate param: custom_cursor_info; type: struct_byref_const
CefCursorInfo custom_cursor_infoObj;
if (custom_cursor_info)
custom_cursor_infoObj.Set(*custom_cursor_info, false);
// Execute
bool _retval = CefDisplayHandlerCppToC::Get(self)->OnCursorChange(
CefBrowserCToCpp::Wrap(browser), cursor, type, custom_cursor_infoObj);
// Return type: bool
return _retval;
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
@ -268,6 +303,7 @@ CefDisplayHandlerCppToC::CefDisplayHandlerCppToC() {
GetStruct()->on_auto_resize = display_handler_on_auto_resize;
GetStruct()->on_loading_progress_change =
display_handler_on_loading_progress_change;
GetStruct()->on_cursor_change = display_handler_on_cursor_change;
}
// 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=2e22f210ff06337ac41e71a00b9dc6edce08e6d8$
// $hash=22da80871c4a9dfc9989f577456b7e3d987e805d$
//
#include "libcef_dll/cpptoc/render_handler_cpptoc.h"
@ -324,38 +324,6 @@ render_handler_on_accelerated_paint(struct _cef_render_handler_t* self,
CefBrowserCToCpp::Wrap(browser), type, dirtyRectsList, shared_handle);
}
void CEF_CALLBACK render_handler_on_cursor_change(
struct _cef_render_handler_t* self,
cef_browser_t* browser,
cef_cursor_handle_t cursor,
cef_cursor_type_t type,
const struct _cef_cursor_info_t* custom_cursor_info) {
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: custom_cursor_info; type: struct_byref_const
DCHECK(custom_cursor_info);
if (!custom_cursor_info)
return;
// Translate param: custom_cursor_info; type: struct_byref_const
CefCursorInfo custom_cursor_infoObj;
if (custom_cursor_info)
custom_cursor_infoObj.Set(*custom_cursor_info, false);
// Execute
CefRenderHandlerCppToC::Get(self)->OnCursorChange(
CefBrowserCToCpp::Wrap(browser), cursor, type, custom_cursor_infoObj);
}
int CEF_CALLBACK
render_handler_start_dragging(struct _cef_render_handler_t* self,
cef_browser_t* browser,
@ -536,7 +504,6 @@ 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()->on_cursor_change = render_handler_on_cursor_change;
GetStruct()->start_dragging = render_handler_start_dragging;
GetStruct()->update_drag_cursor = render_handler_update_drag_cursor;
GetStruct()->on_scroll_offset_changed =

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=a362e11e85ce68488bbb0f5232b01f53cffeec1d$
// $hash=9751b66edccb575f54c07bf14da39516f52b7402$
//
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
@ -567,37 +567,6 @@ void CefBrowserHostCToCpp::GetNavigationEntries(
_struct, CefNavigationEntryVisitorCppToC::Wrap(visitor), current_only);
}
NO_SANITIZE("cfi-icall")
void CefBrowserHostCToCpp::SetMouseCursorChangeDisabled(bool disabled) {
shutdown_checker::AssertNotShutdown();
cef_browser_host_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, set_mouse_cursor_change_disabled))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
_struct->set_mouse_cursor_change_disabled(_struct, disabled);
}
NO_SANITIZE("cfi-icall")
bool CefBrowserHostCToCpp::IsMouseCursorChangeDisabled() {
shutdown_checker::AssertNotShutdown();
cef_browser_host_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, is_mouse_cursor_change_disabled))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = _struct->is_mouse_cursor_change_disabled(_struct);
// Return type: bool
return _retval ? true : false;
}
NO_SANITIZE("cfi-icall")
void CefBrowserHostCToCpp::ReplaceMisspelling(const CefString& word) {
shutdown_checker::AssertNotShutdown();

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=c9abd1293472afbac964aac4cd7dd4cac9dd8e58$
// $hash=07e94d03d7ceb97115adedb4cc641318cd77975b$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_
@ -84,8 +84,6 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted<CefBrowserHostCToCpp,
CefRefPtr<CefDevToolsMessageObserver> observer) OVERRIDE;
void GetNavigationEntries(CefRefPtr<CefNavigationEntryVisitor> visitor,
bool current_only) OVERRIDE;
void SetMouseCursorChangeDisabled(bool disabled) OVERRIDE;
bool IsMouseCursorChangeDisabled() OVERRIDE;
void ReplaceMisspelling(const CefString& word) OVERRIDE;
void AddWordToDictionary(const CefString& word) OVERRIDE;
bool IsWindowRenderingDisabled() OVERRIDE;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=11c971f10c02ae341f62e70dca05528f78c8d1a2$
// $hash=16db2529b69497fdccf21d56531906127e473044$
//
#include "libcef_dll/ctocpp/display_handler_ctocpp.h"
@ -249,6 +249,34 @@ void CefDisplayHandlerCToCpp::OnLoadingProgressChange(
progress);
}
NO_SANITIZE("cfi-icall")
bool CefDisplayHandlerCToCpp::OnCursorChange(
CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) {
shutdown_checker::AssertNotShutdown();
cef_display_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_cursor_change))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return false;
// Execute
int _retval =
_struct->on_cursor_change(_struct, CefBrowserCppToC::Wrap(browser),
cursor, type, &custom_cursor_info);
// Return type: bool
return _retval ? true : false;
}
// CONSTRUCTOR - Do not edit by hand.
CefDisplayHandlerCToCpp::CefDisplayHandlerCToCpp() {}

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=2a5e7a2afb4d183e4688ef7aec8d12d2bc1d5212$
// $hash=4874f1f7e3c35cb0b079b65c03aed01f9cc30e47$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_DISPLAY_HANDLER_CTOCPP_H_
@ -57,6 +57,10 @@ class CefDisplayHandlerCToCpp
const CefSize& new_size) override;
void OnLoadingProgressChange(CefRefPtr<CefBrowser> browser,
double progress) override;
bool OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) override;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_DISPLAY_HANDLER_CTOCPP_H_

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=f592f3806c9f87ee6c691b9f072cee4d6bb4650e$
// $hash=b9bf8bf4ccc5ef6a43f86ef697617fc6fe8470a5$
//
#include "libcef_dll/ctocpp/render_handler_ctocpp.h"
@ -265,30 +265,6 @@ void CefRenderHandlerCToCpp::OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
delete[] dirtyRectsList;
}
NO_SANITIZE("cfi-icall")
void CefRenderHandlerCToCpp::OnCursorChange(
CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CursorType type,
const CefCursorInfo& custom_cursor_info) {
shutdown_checker::AssertNotShutdown();
cef_render_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_cursor_change))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return;
// Execute
_struct->on_cursor_change(_struct, CefBrowserCppToC::Wrap(browser), cursor,
type, &custom_cursor_info);
}
NO_SANITIZE("cfi-icall")
bool CefRenderHandlerCToCpp::StartDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=ed8882abe62f08d4746a646307ef74d4987780c4$
// $hash=be7b5b4b7b8782c7bd3a4c52ed75bc3c9c044265$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_RENDER_HANDLER_CTOCPP_H_
@ -57,10 +57,6 @@ class CefRenderHandlerCToCpp
PaintElementType type,
const RectList& dirtyRects,
void* shared_handle) override;
void OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CursorType type,
const CefCursorInfo& custom_cursor_info) override;
bool StartDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,
DragOperationsMask allowed_ops,

View File

@ -1285,7 +1285,7 @@ void BrowserWindowOsrGtk::OnPaint(CefRefPtr<CefBrowser> browser,
void BrowserWindowOsrGtk::OnCursorChange(
CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CefRenderHandler::CursorType type,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) {
CEF_REQUIRE_UI_THREAD();

View File

@ -76,7 +76,7 @@ class BrowserWindowOsrGtk : public BrowserWindow,
int height) OVERRIDE;
void OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CefRenderHandler::CursorType type,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) OVERRIDE;
bool StartDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,

View File

@ -73,7 +73,7 @@ class BrowserWindowOsrMac : public BrowserWindow,
int height) OVERRIDE;
void OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CefRenderHandler::CursorType type,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) OVERRIDE;
bool StartDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,

View File

@ -1323,7 +1323,7 @@ class BrowserWindowOsrMacImpl {
int height);
void OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CefRenderHandler::CursorType type,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info);
bool StartDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,
@ -1655,7 +1655,7 @@ void BrowserWindowOsrMacImpl::OnPaint(
void BrowserWindowOsrMacImpl::OnCursorChange(
CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CefRenderHandler::CursorType type,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) {
CEF_REQUIRE_UI_THREAD();
REQUIRE_MAIN_THREAD();
@ -1877,7 +1877,7 @@ void BrowserWindowOsrMac::OnPaint(CefRefPtr<CefBrowser> browser,
void BrowserWindowOsrMac::OnCursorChange(
CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CefRenderHandler::CursorType type,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) {
impl_->OnCursorChange(browser, cursor, type, custom_cursor_info);
}

View File

@ -333,7 +333,7 @@ void ClientHandler::OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
model->AddSeparator();
model->AddItem(CLIENT_ID_CURSOR_CHANGE_DISABLED, "Cursor change disabled");
if (browser->GetHost()->IsMouseCursorChangeDisabled())
if (mouse_cursor_change_disabled_)
model->SetChecked(CLIENT_ID_CURSOR_CHANGE_DISABLED, true);
model->AddSeparator();
@ -370,8 +370,7 @@ bool ClientHandler::OnContextMenuCommand(CefRefPtr<CefBrowser> browser,
ShowSSLInformation(browser);
return true;
case CLIENT_ID_CURSOR_CHANGE_DISABLED:
browser->GetHost()->SetMouseCursorChangeDisabled(
!browser->GetHost()->IsMouseCursorChangeDisabled());
mouse_cursor_change_disabled_ = !mouse_cursor_change_disabled_;
return true;
case CLIENT_ID_OFFLINE:
offline_ = !offline_;
@ -469,6 +468,16 @@ bool ClientHandler::OnAutoResize(CefRefPtr<CefBrowser> browser,
return true;
}
bool ClientHandler::OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) {
CEF_REQUIRE_UI_THREAD();
// Return true to disable default handling of cursor changes.
return mouse_cursor_change_disabled_;
}
void ClientHandler::OnBeforeDownload(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
@ -595,10 +604,6 @@ void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
message_router_->AddHandler(*(it), false);
}
// Disable mouse cursor change if requested via the command-line flag.
if (mouse_cursor_change_disabled_)
browser->GetHost()->SetMouseCursorChangeDisabled(true);
// Set offline mode if requested via the command-line flag.
if (offline_)
SetOfflineState(browser, true);

View File

@ -152,6 +152,10 @@ class ClientHandler : public CefClient,
int line) OVERRIDE;
bool OnAutoResize(CefRefPtr<CefBrowser> browser,
const CefSize& new_size) OVERRIDE;
bool OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) OVERRIDE;
// CefDownloadHandler methods
void OnBeforeDownload(CefRefPtr<CefBrowser> browser,

View File

@ -118,16 +118,6 @@ void ClientHandlerOsr::OnAcceleratedPaint(
osr_delegate_->OnAcceleratedPaint(browser, type, dirtyRects, share_handle);
}
void ClientHandlerOsr::OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CursorType type,
const CefCursorInfo& custom_cursor_info) {
CEF_REQUIRE_UI_THREAD();
if (!osr_delegate_)
return;
osr_delegate_->OnCursorChange(browser, cursor, type, custom_cursor_info);
}
bool ClientHandlerOsr::StartDragging(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,
@ -167,6 +157,21 @@ void ClientHandlerOsr::OnAccessibilityTreeChange(CefRefPtr<CefValue> value) {
osr_delegate_->UpdateAccessibilityTree(value);
}
bool ClientHandlerOsr::OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) {
CEF_REQUIRE_UI_THREAD();
if (ClientHandler::OnCursorChange(browser, cursor, type,
custom_cursor_info)) {
return true;
}
if (osr_delegate_) {
osr_delegate_->OnCursorChange(browser, cursor, type, custom_cursor_info);
}
return true;
}
void ClientHandlerOsr::OnAccessibilityLocationChange(
CefRefPtr<CefValue> value) {
CEF_REQUIRE_UI_THREAD();

View File

@ -49,10 +49,6 @@ class ClientHandlerOsr : public ClientHandler,
CefRenderHandler::PaintElementType type,
const CefRenderHandler::RectList& dirtyRects,
void* share_handle) {}
virtual void OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CefRenderHandler::CursorType type,
const CefCursorInfo& custom_cursor_info) = 0;
virtual bool StartDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,
CefRenderHandler::DragOperationsMask allowed_ops,
@ -66,8 +62,13 @@ class ClientHandlerOsr : public ClientHandler,
const CefRange& selection_range,
const CefRenderHandler::RectList& character_bounds) = 0;
virtual void UpdateAccessibilityTree(CefRefPtr<CefValue> value) = 0;
// These methods match the CefDisplayHandler interface.
virtual void OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) = 0;
virtual void UpdateAccessibilityTree(CefRefPtr<CefValue> value) = 0;
virtual void UpdateAccessibilityLocation(CefRefPtr<CefValue> value) = 0;
protected:
@ -114,10 +115,6 @@ class ClientHandlerOsr : public ClientHandler,
CefRenderHandler::PaintElementType type,
const CefRenderHandler::RectList& dirtyRects,
void* share_handle) OVERRIDE;
void OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CursorType type,
const CefCursorInfo& custom_cursor_info) OVERRIDE;
bool StartDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,
CefRenderHandler::DragOperationsMask allowed_ops,
@ -130,6 +127,12 @@ class ClientHandlerOsr : public ClientHandler,
const CefRange& selection_range,
const CefRenderHandler::RectList& character_bounds) OVERRIDE;
// CefDisplayHandler methods.
bool OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) OVERRIDE;
// CefAccessibilityHandler methods.
void OnAccessibilityTreeChange(CefRefPtr<CefValue> value) OVERRIDE;
void OnAccessibilityLocationChange(CefRefPtr<CefValue> value) OVERRIDE;

View File

@ -1027,7 +1027,7 @@ void OsrWindowWin::OnAcceleratedPaint(
void OsrWindowWin::OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CefRenderHandler::CursorType type,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) {
CEF_REQUIRE_UI_THREAD();

View File

@ -133,7 +133,7 @@ class OsrWindowWin
void* share_handle) OVERRIDE;
void OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CefRenderHandler::CursorType type,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) OVERRIDE;
bool StartDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,

View File

@ -1149,15 +1149,16 @@ class OSRTestHandler : public RoutingTestHandler,
}
}
void OnCursorChange(CefRefPtr<CefBrowser> browser,
bool OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
CursorType type,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) override {
if (test_type_ == OSR_TEST_CURSOR && started()) {
EXPECT_EQ(CT_HAND, type);
EXPECT_EQ(nullptr, custom_cursor_info.buffer);
DestroySucceededTestSoon();
}
return true;
}
void OnImeCompositionRangeChanged(