windows: Fix Views test failures (fixes issue #3365)
This commit is contained in:
parent
a9043f2e80
commit
654f570b6e
|
@ -33,7 +33,7 @@
|
||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=6a8166eca76513b59a4f6355f4f765dc1d77e4ee$
|
// $hash=a75487288913e4646f67ee8aded4bc9ef328bb79$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_
|
||||||
|
@ -49,9 +49,10 @@ extern "C" {
|
||||||
struct _cef_view_t;
|
struct _cef_view_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle view events. The functions of this
|
// Implement this structure to handle view events. All size and position values
|
||||||
// structure will be called on the browser process UI thread unless otherwise
|
// are in density independent pixels (DIP) unless otherwise indicated. The
|
||||||
// indicated.
|
// functions of this structure will be called on the browser process UI thread
|
||||||
|
// unless otherwise indicated.
|
||||||
///
|
///
|
||||||
typedef struct _cef_view_delegate_t {
|
typedef struct _cef_view_delegate_t {
|
||||||
///
|
///
|
||||||
|
|
|
@ -43,8 +43,10 @@
|
||||||
class CefView;
|
class CefView;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this interface to handle view events. The methods of this class
|
// Implement this interface to handle view events. All size and position values
|
||||||
// will be called on the browser process UI thread unless otherwise indicated.
|
// are in density independent pixels (DIP) unless otherwise indicated. The
|
||||||
|
// methods of this class will be called on the browser process UI thread unless
|
||||||
|
// otherwise indicated.
|
||||||
///
|
///
|
||||||
/*--cef(source=client)--*/
|
/*--cef(source=client)--*/
|
||||||
class CefViewDelegate : public virtual CefBaseRefCounted {
|
class CefViewDelegate : public virtual CefBaseRefCounted {
|
||||||
|
|
|
@ -552,12 +552,8 @@ void CefWindowImpl::SendMouseMove(int screen_x, int screen_y) {
|
||||||
CEF_REQUIRE_VALID_RETURN_VOID();
|
CEF_REQUIRE_VALID_RETURN_VOID();
|
||||||
InitializeUITesting();
|
InitializeUITesting();
|
||||||
|
|
||||||
|
// Converts to pixel coordinates internally on Windows.
|
||||||
gfx::Point point(screen_x, screen_y);
|
gfx::Point point(screen_x, screen_y);
|
||||||
#if BUILDFLAG(IS_WIN)
|
|
||||||
// Windows expects pixel coordinates.
|
|
||||||
point = display::win::ScreenWin::DIPToScreenPoint(point);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ui_controls::SendMouseMove(point.x(), point.y());
|
ui_controls::SendMouseMove(point.x(), point.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include "tests/shared/browser/geometry_util.h"
|
||||||
|
#include "tests/shared/browser/util_win.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -28,18 +30,30 @@ const int TestWindowDelegate::kWSize = 400;
|
||||||
// static
|
// static
|
||||||
void TestWindowDelegate::RunTest(CefRefPtr<CefWaitableEvent> event,
|
void TestWindowDelegate::RunTest(CefRefPtr<CefWaitableEvent> event,
|
||||||
std::unique_ptr<Config> config) {
|
std::unique_ptr<Config> config) {
|
||||||
|
CefSize window_size{config->window_size, config->window_size};
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
RECT rect = {0, 0, config->window_size, config->window_size};
|
|
||||||
if (!config->frameless) {
|
if (!config->frameless) {
|
||||||
// The size value is for the client area. Calculate the whole window size
|
// Expand the client area size to full window size based on the default
|
||||||
// based on the default frame window style.
|
// frame window style. AdjustWindowRect expects pixel coordinates, so
|
||||||
|
// perform the necessary conversions.
|
||||||
|
auto scale_factor = client::GetDeviceScaleFactor();
|
||||||
|
auto scaled_size =
|
||||||
|
client::LogicalToDevice(config->window_size, scale_factor);
|
||||||
|
|
||||||
|
// Convert from DIP to pixel coords.
|
||||||
|
RECT rect = {0, 0, scaled_size, scaled_size};
|
||||||
|
|
||||||
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
|
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
|
||||||
false /* has_menu */);
|
false /* has_menu */);
|
||||||
|
|
||||||
|
// Convert from pixel to DIP coords.
|
||||||
|
auto scaled_rect = client::DeviceToLogical(
|
||||||
|
{rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top},
|
||||||
|
scale_factor);
|
||||||
|
window_size = {scaled_rect.width, scaled_rect.height};
|
||||||
}
|
}
|
||||||
CefSize window_size = CefSize(rect.right - rect.left, rect.bottom - rect.top);
|
#endif // defined(OS_WIN)
|
||||||
#else
|
|
||||||
CefSize window_size = CefSize(config->window_size, config->window_size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CefWindow::CreateTopLevelWindow(
|
CefWindow::CreateTopLevelWindow(
|
||||||
new TestWindowDelegate(event, std::move(config), window_size));
|
new TestWindowDelegate(event, std::move(config), window_size));
|
||||||
|
|
|
@ -25,6 +25,13 @@ int DeviceToLogical(int value, float device_scale_factor) {
|
||||||
return static_cast<int>(std::floor(scaled_val));
|
return static_cast<int>(std::floor(scaled_val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefRect DeviceToLogical(const CefRect& value, float device_scale_factor) {
|
||||||
|
return CefRect(DeviceToLogical(value.x, device_scale_factor),
|
||||||
|
DeviceToLogical(value.y, device_scale_factor),
|
||||||
|
DeviceToLogical(value.width, device_scale_factor),
|
||||||
|
DeviceToLogical(value.height, device_scale_factor));
|
||||||
|
}
|
||||||
|
|
||||||
void DeviceToLogical(CefMouseEvent& value, float device_scale_factor) {
|
void DeviceToLogical(CefMouseEvent& value, float device_scale_factor) {
|
||||||
value.x = DeviceToLogical(value.x, device_scale_factor);
|
value.x = DeviceToLogical(value.x, device_scale_factor);
|
||||||
value.y = DeviceToLogical(value.y, device_scale_factor);
|
value.y = DeviceToLogical(value.y, device_scale_factor);
|
||||||
|
|
|
@ -16,6 +16,7 @@ CefRect LogicalToDevice(const CefRect& value, float device_scale_factor);
|
||||||
|
|
||||||
// Convert |value| from device coordinates to logical coordinates.
|
// Convert |value| from device coordinates to logical coordinates.
|
||||||
int DeviceToLogical(int value, float device_scale_factor);
|
int DeviceToLogical(int value, float device_scale_factor);
|
||||||
|
CefRect DeviceToLogical(const CefRect& value, float device_scale_factor);
|
||||||
void DeviceToLogical(CefMouseEvent& value, float device_scale_factor);
|
void DeviceToLogical(CefMouseEvent& value, float device_scale_factor);
|
||||||
void DeviceToLogical(CefTouchEvent& value, float device_scale_factor);
|
void DeviceToLogical(CefTouchEvent& value, float device_scale_factor);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue