mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-17 20:50:42 +01:00
windows: Fix Views test failures (fixes issue #3365)
This commit is contained in:
parent
44748db484
commit
8c9bbb1a73
@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=6a8166eca76513b59a4f6355f4f765dc1d77e4ee$
|
||||
// $hash=a75487288913e4646f67ee8aded4bc9ef328bb79$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_
|
||||
@ -49,9 +49,10 @@ extern "C" {
|
||||
struct _cef_view_t;
|
||||
|
||||
///
|
||||
// Implement this structure to handle view events. The functions of this
|
||||
// structure will be called on the browser process UI thread unless otherwise
|
||||
// indicated.
|
||||
// Implement this structure to handle view events. All size and position values
|
||||
// are in density independent pixels (DIP) unless otherwise indicated. The
|
||||
// functions of this structure will be called on the browser process UI thread
|
||||
// unless otherwise indicated.
|
||||
///
|
||||
typedef struct _cef_view_delegate_t {
|
||||
///
|
||||
|
@ -43,8 +43,10 @@
|
||||
class CefView;
|
||||
|
||||
///
|
||||
// Implement this interface to handle view events. The methods of this class
|
||||
// will be called on the browser process UI thread unless otherwise indicated.
|
||||
// Implement this interface to handle view events. All size and position values
|
||||
// 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)--*/
|
||||
class CefViewDelegate : public virtual CefBaseRefCounted {
|
||||
|
@ -552,12 +552,8 @@ void CefWindowImpl::SendMouseMove(int screen_x, int screen_y) {
|
||||
CEF_REQUIRE_VALID_RETURN_VOID();
|
||||
InitializeUITesting();
|
||||
|
||||
// Converts to pixel coordinates internally on Windows.
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#include "tests/shared/browser/geometry_util.h"
|
||||
#include "tests/shared/browser/util_win.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
@ -28,18 +30,30 @@ const int TestWindowDelegate::kWSize = 400;
|
||||
// static
|
||||
void TestWindowDelegate::RunTest(CefRefPtr<CefWaitableEvent> event,
|
||||
std::unique_ptr<Config> config) {
|
||||
CefSize window_size{config->window_size, config->window_size};
|
||||
|
||||
#if defined(OS_WIN)
|
||||
RECT rect = {0, 0, config->window_size, config->window_size};
|
||||
if (!config->frameless) {
|
||||
// The size value is for the client area. Calculate the whole window size
|
||||
// based on the default frame window style.
|
||||
// Expand the client area size to full window size based on the default
|
||||
// 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,
|
||||
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);
|
||||
#else
|
||||
CefSize window_size = CefSize(config->window_size, config->window_size);
|
||||
#endif
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
CefWindow::CreateTopLevelWindow(
|
||||
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));
|
||||
}
|
||||
|
||||
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) {
|
||||
value.x = DeviceToLogical(value.x, 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.
|
||||
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(CefTouchEvent& value, float device_scale_factor);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user