Chromium Code Reviews| 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 152a51fcce93175428e06a0f5940dbb22cf42fd0..3630b58078c22a7ad03093b0a96d6030d4d29717 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" | 
| @@ -61,6 +62,7 @@ | 
| #include "ui/base/touch/touch_device_win.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" | 
| @@ -300,6 +302,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(); | 
| 
 
darin (slow to review)
2013/01/30 21:39:12
Wouldn't it be better to provide ui::win::GetDevic
 
kevers
2013/01/30 22:27:01
Removed the #ifdef, as GetDeviceScaleFactor always
 
 | 
| +#else | 
| + results->deviceScaleFactor = 1; | 
| +#endif | 
| +} | 
| + | 
| } // namespace | 
| const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND"; | 
| @@ -464,7 +477,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) { | 
| @@ -597,6 +610,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); | 
| @@ -697,7 +714,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); | 
| } | 
| @@ -2363,6 +2380,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); | 
| @@ -2377,7 +2398,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 | 
| @@ -2722,6 +2745,14 @@ void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message, | 
| return; | 
| } | 
| +#if defined(ENABLE_HIDPI) | 
| 
 
darin (slow to review)
2013/01/30 21:39:12
Why do we need ENABLE_HIDPI?  Why not just have al
 
kevers
2013/01/30 22:27:01
The ScreenToDPIPoint is an identity function when
 
 | 
| + // 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)); | 
| @@ -2974,7 +3005,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; | 
| @@ -3018,4 +3049,10 @@ RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( | 
| return new RenderWidgetHostViewWin(widget); | 
| } | 
| +// static | 
| +void RenderWidgetHostViewPort::GetDefaultScreenInfo( | 
| + WebKit::WebScreenInfo* results) { | 
| + GetScreenInfoForWindow(results, 0); | 
| +} | 
| + | 
| } // namespace content |