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 ae301349d8fb9de35a15a052b7c0ae0ee4162bf1..dd7630d3b533dc982ed4240bd2dba4c92c448d58 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_win.cc |
| +++ b/content/browser/renderer_host/render_widget_host_view_win.cc |
| @@ -50,6 +50,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" |
| @@ -57,6 +58,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" |
| @@ -296,6 +298,16 @@ bool ShouldSendPinchGesture() { |
| return pinch_allowed; |
| } |
| +void GetScreenInfoForWindow(WebKit::WebScreenInfo* results, HWND window) { |
| + |
| + *results = WebKit::WebScreenInfoFactory::screenInfo(window); |
| +#if defined(ENABLE_HIDPI) |
| + results->deviceScaleFactor = gfx::Display::GetForcedDeviceScaleFactor(); |
| +#else |
| + results->deviceScaleFactor = 1; |
| +#endif |
| +} |
| + |
| } // namespace |
| const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND"; |
| @@ -460,7 +472,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) { |
| @@ -593,6 +605,10 @@ bool RenderWidgetHostViewWin::IsShowing() { |
| } |
| gfx::Rect RenderWidgetHostViewWin::GetViewBounds() const { |
| + return ui::win::ScreenToDIPRect(getPixelBounds()); |
| +} |
| + |
| +gfx::Rect RenderWidgetHostViewWin::getPixelBounds() const { |
|
pkotwicz
2013/01/23 18:13:12
Nit:GetPixelBounds()
kevers
2013/01/23 20:02:19
Done.
|
| CRect window_rect; |
| GetWindowRect(&window_rect); |
| return gfx::Rect(window_rect); |
| @@ -690,7 +706,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); |
| } |
| @@ -811,6 +827,16 @@ void RenderWidgetHostViewWin::CopyFromCompositingSurface( |
| callback); |
| } |
| +void RenderWidgetHostViewWin::GetScreenInfo(WebKit::WebScreenInfo* results) { |
| + GetScreenInfoForWindow(results, 0); |
| +} |
| + |
| +// static |
| +void RenderWidgetHostViewPort::GetDefaultScreenInfo( |
| + WebKit::WebScreenInfo* results) { |
| + GetScreenInfoForWindow(results, NULL); |
| +} |
| + |
| void RenderWidgetHostViewWin::SetBackground(const SkBitmap& background) { |
| RenderWidgetHostViewBase::SetBackground(background); |
| render_widget_host_->SetBackground(background); |
| @@ -2367,7 +2393,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 |
| @@ -2712,6 +2740,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)), |
|
pkotwicz
2013/01/23 18:13:12
Nit: alignment, 4 spaces
kevers
2013/01/23 20:02:19
Done.
|
| + static_cast<short>(HIWORD(lparam)))); |
| + lparam = (point.y() << 16) + point.x(); |
| +#endif |
| + |
| WebMouseEvent event( |
| WebInputEventFactory::mouseEvent(m_hWnd, message, wparam, lparam)); |
| @@ -2964,7 +3000,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; |