| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/browser/accessibility/browser_accessibility_manager.h" | 8 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 9 #include "content/browser/gpu/gpu_data_manager_impl.h" | 9 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 10 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" | 10 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" |
| 11 #include "content/browser/renderer_host/render_process_host_impl.h" | 11 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 12 #include "content/browser/renderer_host/render_widget_host_impl.h" | 12 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 13 #include "content/common/content_switches_internal.h" | 13 #include "content/common/content_switches_internal.h" |
| 14 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 14 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 15 #include "ui/gfx/display.h" | 15 #include "ui/gfx/display.h" |
| 16 #include "ui/gfx/dpi.h" |
| 16 #include "ui/gfx/screen.h" | 17 #include "ui/gfx/screen.h" |
| 17 #include "ui/gfx/size_conversions.h" | 18 #include "ui/gfx/size_conversions.h" |
| 18 #include "ui/gfx/size_f.h" | 19 #include "ui/gfx/size_f.h" |
| 19 | 20 |
| 20 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 21 #include "base/command_line.h" | 22 #include "base/command_line.h" |
| 22 #include "base/message_loop/message_loop.h" | 23 #include "base/message_loop/message_loop.h" |
| 23 #include "base/win/wrapped_window_proc.h" | 24 #include "base/win/wrapped_window_proc.h" |
| 24 #include "content/browser/plugin_process_host.h" | 25 #include "content/browser/plugin_process_host.h" |
| 25 #include "content/browser/plugin_service_impl.h" | 26 #include "content/browser/plugin_service_impl.h" |
| 26 #include "content/common/plugin_constants_win.h" | 27 #include "content/common/plugin_constants_win.h" |
| 27 #include "content/common/webplugin_geometry.h" | 28 #include "content/common/webplugin_geometry.h" |
| 28 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/browser/child_process_data.h" | 30 #include "content/public/browser/child_process_data.h" |
| 30 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
| 31 #include "ui/gfx/gdi_util.h" | 32 #include "ui/gfx/gdi_util.h" |
| 32 #include "ui/gfx/win/dpi.h" | |
| 33 #include "ui/gfx/win/hwnd_util.h" | 33 #include "ui/gfx/win/hwnd_util.h" |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 namespace content { | 36 namespace content { |
| 37 | 37 |
| 38 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
| 39 | 39 |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| 42 // |window| is the plugin HWND, created and destroyed in the plugin process. | 42 // |window| is the plugin HWND, created and destroyed in the plugin process. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 base::Bind(&NotifyPluginProcessHostHelper, window, new_parent, | 142 base::Bind(&NotifyPluginProcessHostHelper, window, new_parent, |
| 143 kMaxTries)); | 143 kMaxTries)); |
| 144 return new_parent; | 144 return new_parent; |
| 145 } | 145 } |
| 146 | 146 |
| 147 BOOL CALLBACK PaintEnumChildProc(HWND hwnd, LPARAM lparam) { | 147 BOOL CALLBACK PaintEnumChildProc(HWND hwnd, LPARAM lparam) { |
| 148 if (!PluginServiceImpl::GetInstance()->IsPluginWindow(hwnd)) | 148 if (!PluginServiceImpl::GetInstance()->IsPluginWindow(hwnd)) |
| 149 return TRUE; | 149 return TRUE; |
| 150 | 150 |
| 151 gfx::Rect* rect = reinterpret_cast<gfx::Rect*>(lparam); | 151 gfx::Rect* rect = reinterpret_cast<gfx::Rect*>(lparam); |
| 152 gfx::Rect rect_in_pixels = gfx::win::DIPToScreenRect(*rect); | 152 gfx::Rect rect_in_pixels = gfx::DIPToScreenRect(*rect); |
| 153 static UINT msg = RegisterWindowMessage(kPaintMessageName); | 153 static UINT msg = RegisterWindowMessage(kPaintMessageName); |
| 154 WPARAM wparam = MAKEWPARAM(rect_in_pixels.x(), rect_in_pixels.y()); | 154 WPARAM wparam = MAKEWPARAM(rect_in_pixels.x(), rect_in_pixels.y()); |
| 155 lparam = MAKELPARAM(rect_in_pixels.width(), rect_in_pixels.height()); | 155 lparam = MAKELPARAM(rect_in_pixels.width(), rect_in_pixels.height()); |
| 156 | 156 |
| 157 // SendMessage gets the message across much quicker than PostMessage, since it | 157 // SendMessage gets the message across much quicker than PostMessage, since it |
| 158 // doesn't get queued. When the plugin thread calls PeekMessage or other | 158 // doesn't get queued. When the plugin thread calls PeekMessage or other |
| 159 // Win32 APIs, sent messages are dispatched automatically. | 159 // Win32 APIs, sent messages are dispatched automatically. |
| 160 SendNotifyMessage(hwnd, msg, wparam, lparam); | 160 SendNotifyMessage(hwnd, msg, wparam, lparam); |
| 161 | 161 |
| 162 return TRUE; | 162 return TRUE; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // if Windows tries to paint it synchronously inside EndDeferWindowsPos | 256 // if Windows tries to paint it synchronously inside EndDeferWindowsPos |
| 257 // then it won't have the data and it will flash white. So instead we | 257 // then it won't have the data and it will flash white. So instead we |
| 258 // manually redraw the plugin. | 258 // manually redraw the plugin. |
| 259 // Why not do this for native Windows? Not sure if there are any | 259 // Why not do this for native Windows? Not sure if there are any |
| 260 // performance issues with this. | 260 // performance issues with this. |
| 261 flags |= SWP_NOREDRAW; | 261 flags |= SWP_NOREDRAW; |
| 262 } | 262 } |
| 263 #endif | 263 #endif |
| 264 | 264 |
| 265 if (move.rects_valid) { | 265 if (move.rects_valid) { |
| 266 gfx::Rect clip_rect_in_pixel = gfx::win::DIPToScreenRect(move.clip_rect); | 266 gfx::Rect clip_rect_in_pixel = gfx::DIPToScreenRect(move.clip_rect); |
| 267 HRGN hrgn = ::CreateRectRgn(clip_rect_in_pixel.x(), | 267 HRGN hrgn = ::CreateRectRgn(clip_rect_in_pixel.x(), |
| 268 clip_rect_in_pixel.y(), | 268 clip_rect_in_pixel.y(), |
| 269 clip_rect_in_pixel.right(), | 269 clip_rect_in_pixel.right(), |
| 270 clip_rect_in_pixel.bottom()); | 270 clip_rect_in_pixel.bottom()); |
| 271 gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects); | 271 gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects); |
| 272 | 272 |
| 273 // Note: System will own the hrgn after we call SetWindowRgn, | 273 // Note: System will own the hrgn after we call SetWindowRgn, |
| 274 // so we don't need to call DeleteObject(hrgn) | 274 // so we don't need to call DeleteObject(hrgn) |
| 275 ::SetWindowRgn(window, hrgn, | 275 ::SetWindowRgn(window, hrgn, |
| 276 !move.clip_rect.IsEmpty() && (flags & SWP_NOREDRAW) == 0); | 276 !move.clip_rect.IsEmpty() && (flags & SWP_NOREDRAW) == 0); |
| 277 | 277 |
| 278 #if defined(USE_AURA) | 278 #if defined(USE_AURA) |
| 279 // When using the software compositor, if the clipping rectangle is empty | 279 // When using the software compositor, if the clipping rectangle is empty |
| 280 // then DeferWindowPos won't redraw the newly uncovered area under the | 280 // then DeferWindowPos won't redraw the newly uncovered area under the |
| 281 // plugin. | 281 // plugin. |
| 282 if (clip_rect_in_pixel.IsEmpty() && | 282 if (clip_rect_in_pixel.IsEmpty() && |
| 283 !GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { | 283 !GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { |
| 284 RECT r; | 284 RECT r; |
| 285 GetClientRect(window, &r); | 285 GetClientRect(window, &r); |
| 286 MapWindowPoints(window, parent, reinterpret_cast<POINT*>(&r), 2); | 286 MapWindowPoints(window, parent, reinterpret_cast<POINT*>(&r), 2); |
| 287 invalidate_rects.push_back(r); | 287 invalidate_rects.push_back(r); |
| 288 } | 288 } |
| 289 #endif | 289 #endif |
| 290 } else { | 290 } else { |
| 291 flags |= SWP_NOMOVE; | 291 flags |= SWP_NOMOVE; |
| 292 flags |= SWP_NOSIZE; | 292 flags |= SWP_NOSIZE; |
| 293 } | 293 } |
| 294 | 294 |
| 295 gfx::Rect window_rect_in_pixel = | 295 gfx::Rect window_rect_in_pixel = gfx::DIPToScreenRect(move.window_rect); |
| 296 gfx::win::DIPToScreenRect(move.window_rect); | |
| 297 defer_window_pos_info = ::DeferWindowPos(defer_window_pos_info, | 296 defer_window_pos_info = ::DeferWindowPos(defer_window_pos_info, |
| 298 window, NULL, | 297 window, NULL, |
| 299 window_rect_in_pixel.x(), | 298 window_rect_in_pixel.x(), |
| 300 window_rect_in_pixel.y(), | 299 window_rect_in_pixel.y(), |
| 301 window_rect_in_pixel.width(), | 300 window_rect_in_pixel.width(), |
| 302 window_rect_in_pixel.height(), | 301 window_rect_in_pixel.height(), |
| 303 flags); | 302 flags); |
| 304 | 303 |
| 305 if (!defer_window_pos_info) { | 304 if (!defer_window_pos_info) { |
| 306 DCHECK(false) << "DeferWindowPos failed, so all plugin moves ignored."; | 305 DCHECK(false) << "DeferWindowPos failed, so all plugin moves ignored."; |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 ? blink::WebScreenOrientationPortraitPrimary | 680 ? blink::WebScreenOrientationPortraitPrimary |
| 682 : blink::WebScreenOrientationPortraitSecondary; | 681 : blink::WebScreenOrientationPortraitSecondary; |
| 683 } | 682 } |
| 684 | 683 |
| 685 return primary_landscape_angle == angle | 684 return primary_landscape_angle == angle |
| 686 ? blink::WebScreenOrientationLandscapePrimary | 685 ? blink::WebScreenOrientationLandscapePrimary |
| 687 : blink::WebScreenOrientationLandscapeSecondary; | 686 : blink::WebScreenOrientationLandscapeSecondary; |
| 688 } | 687 } |
| 689 | 688 |
| 690 } // namespace content | 689 } // namespace content |
| OLD | NEW |