Index: mojo/services/native_viewport/native_viewport_win.cc |
diff --git a/mojo/services/native_viewport/native_viewport_win.cc b/mojo/services/native_viewport/native_viewport_win.cc |
index 86e7ce9a53e7c0186e8be2a2ac437613d1f8154b..84bfdc37f7cf1fccc56aa429baf484309cbe59cb 100644 |
--- a/mojo/services/native_viewport/native_viewport_win.cc |
+++ b/mojo/services/native_viewport/native_viewport_win.cc |
@@ -20,7 +20,14 @@ gfx::Rect GetWindowBoundsForClientBounds(DWORD style, DWORD ex_style, |
wr.right = bounds.x() + bounds.width(); |
wr.bottom = bounds.y() + bounds.height(); |
AdjustWindowRectEx(&wr, style, FALSE, ex_style); |
- return gfx::Rect(wr.left, wr.top, wr.right - wr.left, wr.bottom - wr.top); |
+ |
+ // Make sure to keep the window onscreen, as AdjustWindowRectEx() may have |
+ // moved part of it offscreen. |
+ gfx::Rect window_bounds(wr.left, wr.top, |
+ wr.right - wr.left, wr.bottom - wr.top); |
+ window_bounds.set_x(std::max(0, window_bounds.x())); |
+ window_bounds.set_y(std::max(0, window_bounds.y())); |
+ return window_bounds; |
} |
} |