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..dba7e822eec4f245c57d391413543f28e78c8745 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) { |
+ |
pkotwicz
2013/01/23 19:39:23
Pass in NativeViewId here instead of HWND
Nit: Ge
kevers
2013/01/23 21:37:00
Done.
|
+ *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 { |
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); |
pkotwicz
2013/01/23 19:39:23
This should be GetNativeViewId() instead of 0.
kevers
2013/01/23 21:37:00
Done.
|
+} |
+ |
+// static |
+void RenderWidgetHostViewPort::GetDefaultScreenInfo( |
+ WebKit::WebScreenInfo* results) { |
+ GetScreenInfoForWindow(results, NULL); |
pkotwicz
2013/01/23 19:39:23
This should probably be 0 instead of NULL.
kevers
2013/01/23 21:37:00
Done.
|
+} |
+ |
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)), |
+ 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; |