| Index: content/browser/renderer_host/render_widget_host_view_win.cc
|
| diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc
|
| index 488d7b421ffaf199478beb433a38333a135f83db..550bbaa03a1bed103d705a2992d928d2e2cce08a 100644
|
| --- a/content/browser/renderer_host/render_widget_host_view_win.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_view_win.cc
|
| @@ -52,6 +52,7 @@
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebInputEventFactory.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/win/WebScreenInfoFactory.h"
|
| #include "ui/base/events/event.h"
|
| #include "ui/base/events/event_utils.h"
|
| #include "ui/base/ime/composition_text.h"
|
| @@ -60,6 +61,7 @@
|
| #include "ui/base/text/text_elider.h"
|
| #include "ui/base/ui_base_switches.h"
|
| #include "ui/base/view_prop.h"
|
| +#include "ui/base/win/dpi.h"
|
| #include "ui/base/win/hwnd_util.h"
|
| #include "ui/base/win/mouse_wheel_util.h"
|
| #include "ui/gfx/canvas.h"
|
| @@ -299,6 +301,17 @@ bool ShouldSendPinchGesture() {
|
| return pinch_allowed;
|
| }
|
|
|
| +void GetScreenInfoForWindow(WebKit::WebScreenInfo* results,
|
| + gfx::NativeViewId id) {
|
| + *results = WebKit::WebScreenInfoFactory::screenInfo(
|
| + gfx::NativeViewFromId(id));
|
| +#if defined(ENABLE_HIDPI)
|
| + results->deviceScaleFactor = ui::win::GetDeviceScaleFactor();
|
| +#else
|
| + results->deviceScaleFactor = 1;
|
| +#endif
|
| +}
|
| +
|
| } // namespace
|
|
|
| const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND";
|
| @@ -463,7 +476,7 @@ void RenderWidgetHostViewWin::WasHidden() {
|
| }
|
|
|
| void RenderWidgetHostViewWin::SetSize(const gfx::Size& size) {
|
| - SetBounds(gfx::Rect(GetViewBounds().origin(), size));
|
| + SetBounds(gfx::Rect(GetPixelBounds().origin(), size));
|
| }
|
|
|
| void RenderWidgetHostViewWin::SetBounds(const gfx::Rect& rect) {
|
| @@ -596,6 +609,10 @@ bool RenderWidgetHostViewWin::IsShowing() {
|
| }
|
|
|
| gfx::Rect RenderWidgetHostViewWin::GetViewBounds() const {
|
| + return ui::win::ScreenToDIPRect(GetPixelBounds());
|
| +}
|
| +
|
| +gfx::Rect RenderWidgetHostViewWin::GetPixelBounds() const {
|
| CRect window_rect;
|
| GetWindowRect(&window_rect);
|
| return gfx::Rect(window_rect);
|
| @@ -696,7 +713,7 @@ void RenderWidgetHostViewWin::Redraw() {
|
|
|
| // Send the invalid rect in screen coordinates.
|
| gfx::Rect invalid_screen_rect(damage_bounds);
|
| - invalid_screen_rect.Offset(GetViewBounds().OffsetFromOrigin());
|
| + invalid_screen_rect.Offset(GetPixelBounds().OffsetFromOrigin());
|
|
|
| PaintPluginWindowsHelper(m_hWnd, invalid_screen_rect);
|
| }
|
| @@ -2362,6 +2379,10 @@ void RenderWidgetHostViewWin::AcceleratedPaint(HDC dc) {
|
| accelerated_surface_->Present(dc);
|
| }
|
|
|
| +void RenderWidgetHostViewWin::GetScreenInfo(WebKit::WebScreenInfo* results) {
|
| + GetScreenInfoForWindow(results, GetNativeViewId());
|
| +}
|
| +
|
| gfx::Rect RenderWidgetHostViewWin::GetBoundsInRootWindow() {
|
| RECT window_rect = {0};
|
| HWND root_window = GetAncestor(m_hWnd, GA_ROOT);
|
| @@ -2376,7 +2397,9 @@ gfx::Rect RenderWidgetHostViewWin::GetBoundsInRootWindow() {
|
| rect.Inset(GetSystemMetrics(SM_CXSIZEFRAME),
|
| GetSystemMetrics(SM_CYSIZEFRAME));
|
| }
|
| - return rect;
|
| +
|
| + // Convert to DIP
|
| + return ui::win::ScreenToDIPRect(rect);
|
| }
|
|
|
| // Creates a HWND within the RenderWidgetHostView that will serve as a host
|
| @@ -2721,6 +2744,14 @@ void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message,
|
| return;
|
| }
|
|
|
| +#if defined(ENABLE_HIDPI)
|
| + // Convert to DIP
|
| + gfx::Point point = ui::win::ScreenToDIPPoint(
|
| + gfx::Point(static_cast<short>(LOWORD(lparam)),
|
| + static_cast<short>(HIWORD(lparam))));
|
| + lparam = (point.y() << 16) + point.x();
|
| +#endif
|
| +
|
| WebMouseEvent event(
|
| WebInputEventFactory::mouseEvent(m_hWnd, message, wparam, lparam));
|
|
|
| @@ -2973,7 +3004,7 @@ LRESULT RenderWidgetHostViewWin::OnQueryCharPosition(
|
| }
|
| ClientToScreen(&target_rect);
|
|
|
| - RECT document_rect = GetViewBounds().ToRECT();
|
| + RECT document_rect = GetPixelBounds().ToRECT();
|
| ClientToScreen(&document_rect);
|
|
|
| position->pt.x = target_rect.left;
|
| @@ -3017,4 +3048,10 @@ RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
|
| return new RenderWidgetHostViewWin(widget);
|
| }
|
|
|
| +// static
|
| +void RenderWidgetHostViewPort::GetDefaultScreenInfo(
|
| + WebKit::WebScreenInfo* results) {
|
| + GetScreenInfoForWindow(results, 0);
|
| +}
|
| +
|
| } // namespace content
|
|
|