Update to Chromium version 111.0.5563.0 (#1097615)

This commit is contained in:
Marshall Greenblatt
2023-01-30 12:43:54 -05:00
parent 4c41f14360
commit dc2231cdfb
179 changed files with 986 additions and 930 deletions

View File

@@ -4,72 +4,12 @@
#include "libcef/browser/native/cursor_util.h"
#include "libcef/browser/browser_host_base.h"
#include "include/cef_client.h"
#include "content/common/cursors/webcursor.h"
#include "content/public/browser/render_widget_host_view.h"
#include "ui/base/cursor/cursor_factory.h"
#include "ui/base/cursor/mojom/cursor_type.mojom.h"
#if defined(USE_AURA)
#include "ui/display/display_util.h"
#include "ui/wm/core/cursor_loader.h"
#endif
namespace cursor_util {
namespace {
#if defined(USE_AURA)
display::ScreenInfo GetScreenInfo(CefRefPtr<CefBrowser> browser) {
display::ScreenInfo screen_info;
bool screen_info_set = false;
if (auto web_contents =
static_cast<CefBrowserHostBase*>(browser.get())->GetWebContents()) {
if (auto view = web_contents->GetRenderWidgetHostView()) {
const auto screen_infos = view->GetScreenInfos();
if (!screen_infos.screen_infos.empty()) {
screen_info = screen_infos.current();
screen_info_set = true;
}
}
}
if (!screen_info_set) {
display::DisplayUtil::GetDefaultScreenInfo(&screen_info);
}
return screen_info;
}
display::Display::Rotation OrientationAngleToRotation(
uint16_t orientation_angle) {
// The Display rotation and the ScreenInfo orientation are not the same
// angle. The former is the physical display rotation while the later is the
// rotation required by the content to be shown properly on the screen, in
// other words, relative to the physical display.
if (orientation_angle == 0) {
return display::Display::ROTATE_0;
}
if (orientation_angle == 90) {
return display::Display::ROTATE_270;
}
if (orientation_angle == 180) {
return display::Display::ROTATE_180;
}
if (orientation_angle == 270) {
return display::Display::ROTATE_90;
}
NOTREACHED();
return display::Display::ROTATE_0;
}
#endif // defined(USE_AURA)
} // namespace
bool OnCursorChange(CefRefPtr<CefBrowser> browser,
const ui::Cursor& ui_cursor) {
auto client = browser->GetHost()->GetClient();
@@ -93,47 +33,10 @@ bool OnCursorChange(CefRefPtr<CefBrowser> browser,
custom_cursor_info.size.height = ui_cursor.custom_bitmap().height();
}
bool handled = false;
#if defined(USE_AURA)
wm::CursorLoader cursor_loader;
scoped_refptr<ui::PlatformCursor> platform_cursor;
CefCursorHandle native_cursor = kNullCursorHandle;
ui::Cursor loaded_cursor = ui_cursor;
if (ui_cursor.type() == ui::mojom::CursorType::kCustom) {
platform_cursor = ui::CursorFactory::GetInstance()->CreateImageCursor(
ui::mojom::CursorType::kCustom, ui_cursor.custom_bitmap(),
ui_cursor.custom_hotspot());
} else {
const auto& screen_info = GetScreenInfo(browser);
cursor_loader.SetDisplayData(
OrientationAngleToRotation(screen_info.orientation_angle),
screen_info.device_scale_factor);
// Attempts to load the cursor via the platform or from pak resources.
cursor_loader.SetPlatformCursor(&loaded_cursor);
platform_cursor = loaded_cursor.platform();
}
if (platform_cursor) {
native_cursor = cursor_util::ToCursorHandle(platform_cursor);
}
handled = handler->OnCursorChange(browser, native_cursor, cursor_type,
custom_cursor_info);
#elif BUILDFLAG(IS_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;
auto scoped_cursor_handle(ScopedCursorHandle::Create(browser, ui_cursor));
return handler->OnCursorChange(browser,
scoped_cursor_handle->GetCursorHandle(),
cursor_type, custom_cursor_info);
}
} // namespace cursor_util

View File

@@ -7,6 +7,8 @@
#include "include/cef_browser.h"
#include <memory>
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
@@ -16,9 +18,17 @@
namespace cursor_util {
#if defined(USE_AURA)
cef_cursor_handle_t ToCursorHandle(scoped_refptr<ui::PlatformCursor> cursor);
#endif // defined(USE_AURA)
// Scoped ownership of a native cursor handle.
class ScopedCursorHandle {
public:
virtual ~ScopedCursorHandle() = default;
static std::unique_ptr<ScopedCursorHandle> Create(
CefRefPtr<CefBrowser> browser,
const ui::Cursor& ui_cursor);
virtual cef_cursor_handle_t GetCursorHandle() = 0;
};
// Returns true if the client handled the cursor change.
bool OnCursorChange(CefRefPtr<CefBrowser> browser, const ui::Cursor& ui_cursor);

View File

@@ -0,0 +1,153 @@
// Copyright 2023 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 "content/public/browser/render_widget_host_view.h"
#include "ui/base/cursor/cursor_factory.h"
#include "ui/base/cursor/mojom/cursor_type.mojom.h"
#include "ui/display/display_util.h"
#include "ui/wm/core/cursor_loader.h"
#if BUILDFLAG(IS_LINUX)
#include "ui/ozone/buildflags.h"
#if BUILDFLAG(OZONE_PLATFORM_X11)
#include "ui/base/x/x11_cursor.h"
#elif BUILDFLAG(IS_OZONE)
#include "ui/ozone/common/bitmap_cursor.h"
#endif
#endif // BUILDFLAG(IS_LINUX)
#if BUILDFLAG(IS_WIN)
#include "ui/base/win/win_cursor.h"
#endif
namespace cursor_util {
namespace {
display::ScreenInfo GetScreenInfo(CefRefPtr<CefBrowser> browser) {
display::ScreenInfo screen_info;
bool screen_info_set = false;
if (auto web_contents =
static_cast<CefBrowserHostBase*>(browser.get())->GetWebContents()) {
if (auto view = web_contents->GetRenderWidgetHostView()) {
const auto screen_infos = view->GetScreenInfos();
if (!screen_infos.screen_infos.empty()) {
screen_info = screen_infos.current();
screen_info_set = true;
}
}
}
if (!screen_info_set) {
display::DisplayUtil::GetDefaultScreenInfo(&screen_info);
}
return screen_info;
}
display::Display::Rotation OrientationAngleToRotation(
uint16_t orientation_angle) {
// The Display rotation and the ScreenInfo orientation are not the same
// angle. The former is the physical display rotation while the later is the
// rotation required by the content to be shown properly on the screen, in
// other words, relative to the physical display.
if (orientation_angle == 0) {
return display::Display::ROTATE_0;
}
if (orientation_angle == 90) {
return display::Display::ROTATE_270;
}
if (orientation_angle == 180) {
return display::Display::ROTATE_180;
}
if (orientation_angle == 270) {
return display::Display::ROTATE_90;
}
NOTREACHED();
return display::Display::ROTATE_0;
}
scoped_refptr<ui::PlatformCursor> ToPlatformCursor(
CefRefPtr<CefBrowser> browser,
const ui::Cursor& ui_cursor) {
wm::CursorLoader cursor_loader;
scoped_refptr<ui::PlatformCursor> platform_cursor;
ui::Cursor loaded_cursor = ui_cursor;
if (ui_cursor.type() == ui::mojom::CursorType::kCustom) {
platform_cursor = ui::CursorFactory::GetInstance()->CreateImageCursor(
ui::mojom::CursorType::kCustom, ui_cursor.custom_bitmap(),
ui_cursor.custom_hotspot());
} else {
const auto& screen_info = GetScreenInfo(browser);
cursor_loader.SetDisplayData(
OrientationAngleToRotation(screen_info.orientation_angle),
screen_info.device_scale_factor);
// Attempts to load the cursor via the platform or from pak resources.
cursor_loader.SetPlatformCursor(&loaded_cursor);
platform_cursor = loaded_cursor.platform();
}
return platform_cursor;
}
#if BUILDFLAG(IS_WIN)
using CursorType = ui::WinCursor;
inline cef_cursor_handle_t GetCursorHandleImpl(CursorType* cursor) {
return cursor->hcursor();
}
#elif BUILDFLAG(OZONE_PLATFORM_X11)
// See https://crbug.com/1029142 for background.
using CursorType = ui::X11Cursor;
inline cef_cursor_handle_t GetCursorHandleImpl(CursorType* cursor) {
return static_cast<cef_cursor_handle_t>(cursor->xcursor());
}
#elif BUILDFLAG(IS_OZONE)
using CursorType = ui::BitmapCursor;
inline cef_cursor_handle_t GetCursorHandleImpl(CursorType* cursor) {
return static_cast<cef_cursor_handle_t>(cursor->platform_data());
}
#else
#error Unsupported platform
#endif
class ScopedCursorHandleImpl : public ScopedCursorHandle {
public:
explicit ScopedCursorHandleImpl(
scoped_refptr<ui::PlatformCursor> platform_cursor) {
if (platform_cursor) {
cursor_ = CursorType::FromPlatformCursor(platform_cursor);
}
}
cef_cursor_handle_t GetCursorHandle() override {
if (cursor_) {
return GetCursorHandleImpl(cursor_.get());
}
return kNullCursorHandle;
}
private:
scoped_refptr<CursorType> cursor_;
};
} // namespace
// static
std::unique_ptr<ScopedCursorHandle> ScopedCursorHandle::Create(
CefRefPtr<CefBrowser> browser,
const ui::Cursor& ui_cursor) {
return std::make_unique<ScopedCursorHandleImpl>(
ToPlatformCursor(browser, ui_cursor));
}
} // namespace cursor_util

View File

@@ -1,30 +0,0 @@
// 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/native/cursor_util.h"
#include "ui/ozone/buildflags.h"
#if BUILDFLAG(OZONE_PLATFORM_X11)
#include "ui/base/x/x11_cursor.h"
#elif BUILDFLAG(IS_OZONE)
#include "ui/ozone/common/bitmap_cursor.h"
#endif
namespace cursor_util {
cef_cursor_handle_t ToCursorHandle(scoped_refptr<ui::PlatformCursor> cursor) {
#if BUILDFLAG(OZONE_PLATFORM_X11)
// See https://crbug.com/1029142 for background.
return static_cast<cef_cursor_handle_t>(
ui::X11Cursor::FromPlatformCursor(cursor)->xcursor());
#elif BUILDFLAG(IS_OZONE)
return static_cast<cef_cursor_handle_t>(
ui::BitmapCursor::FromPlatformCursor(cursor)->platform_data());
#else
return 0;
#endif
}
} // namespace cursor_util

View File

@@ -0,0 +1,38 @@
// Copyright 2023 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/native/cursor_util.h"
#import "base/mac/scoped_nsobject.h"
#import "ui/base/cocoa/cursor_utils.h"
namespace cursor_util {
namespace {
class ScopedCursorHandleImpl : public ScopedCursorHandle {
public:
explicit ScopedCursorHandleImpl(NSCursor* native_cursor) {
if (native_cursor) {
cursor_.reset([native_cursor retain]);
}
}
cef_cursor_handle_t GetCursorHandle() override { return cursor_.get(); }
private:
base::scoped_nsobject<NSCursor> cursor_;
};
} // namespace
// static
std::unique_ptr<ScopedCursorHandle> ScopedCursorHandle::Create(
CefRefPtr<CefBrowser> /*browser*/,
const ui::Cursor& ui_cursor) {
return std::make_unique<ScopedCursorHandleImpl>(
ui::GetNativeCursor(ui_cursor));
}
} // namespace cursor_util

View File

@@ -1,15 +0,0 @@
// 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 "ui/base/win/win_cursor.h"
namespace cursor_util {
cef_cursor_handle_t ToCursorHandle(scoped_refptr<ui::PlatformCursor> cursor) {
return ui::WinCursor::FromPlatformCursor(cursor)->hcursor();
}
} // namespace cursor_util

View File

@@ -9,7 +9,7 @@
#include "libcef/browser/javascript_dialog_runner.h"
#include "base/callback.h"
#include "base/functional/callback.h"
#include "base/mac/scoped_nsobject.h"
#include "base/memory/weak_ptr.h"

View File

@@ -7,7 +7,7 @@
#import <Cocoa/Cocoa.h>
#include "base/bind.h"
#include "base/functional/bind.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "components/url_formatter/elide_url.h"