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_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 text_input_flags_(0), | 441 text_input_flags_(0), |
442 can_compose_inline_(true), | 442 can_compose_inline_(true), |
443 has_composition_text_(false), | 443 has_composition_text_(false), |
444 accept_return_character_(false), | 444 accept_return_character_(false), |
445 last_swapped_software_frame_scale_factor_(1.f), | 445 last_swapped_software_frame_scale_factor_(1.f), |
446 paint_canvas_(NULL), | 446 paint_canvas_(NULL), |
447 synthetic_move_sent_(false), | 447 synthetic_move_sent_(false), |
448 cursor_visibility_state_in_renderer_(UNKNOWN), | 448 cursor_visibility_state_in_renderer_(UNKNOWN), |
449 #if defined(OS_WIN) | 449 #if defined(OS_WIN) |
450 legacy_render_widget_host_HWND_(NULL), | 450 legacy_render_widget_host_HWND_(NULL), |
| 451 legacy_window_destroyed_(false), |
451 #endif | 452 #endif |
452 has_snapped_to_boundary_(false), | 453 has_snapped_to_boundary_(false), |
453 touch_editing_client_(NULL), | 454 touch_editing_client_(NULL), |
454 is_guest_view_hack_(is_guest_view_hack), | 455 is_guest_view_hack_(is_guest_view_hack), |
455 weak_ptr_factory_(this) { | 456 weak_ptr_factory_(this) { |
456 if (!is_guest_view_hack_) | 457 if (!is_guest_view_hack_) |
457 host_->SetView(this); | 458 host_->SetView(this); |
458 | 459 |
459 window_observer_.reset(new WindowObserver(this)); | 460 window_observer_.reset(new WindowObserver(this)); |
460 aura::client::SetTooltipText(window_, &tooltip_); | 461 aura::client::SetTooltipText(window_, &tooltip_); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 if (root) { | 595 if (root) { |
595 aura::client::CursorClient* cursor_client = | 596 aura::client::CursorClient* cursor_client = |
596 aura::client::GetCursorClient(root); | 597 aura::client::GetCursorClient(root); |
597 if (cursor_client) | 598 if (cursor_client) |
598 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 599 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
599 } | 600 } |
600 | 601 |
601 delegated_frame_host_->WasShown(browser_latency_info); | 602 delegated_frame_host_->WasShown(browser_latency_info); |
602 | 603 |
603 #if defined(OS_WIN) | 604 #if defined(OS_WIN) |
| 605 if (legacy_render_widget_host_HWND_) { |
| 606 // Reparent the legacy Chrome_RenderWidgetHostHWND window to the parent |
| 607 // window before reparenting any plugins. This ensures that the plugin |
| 608 // windows stay on top of the child Zorder in the parent and receive |
| 609 // mouse events, etc. |
| 610 legacy_render_widget_host_HWND_->UpdateParent( |
| 611 GetNativeView()->GetHost()->GetAcceleratedWidget()); |
| 612 legacy_render_widget_host_HWND_->SetBounds( |
| 613 window_->GetBoundsInRootWindow()); |
| 614 } |
604 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 615 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
605 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); | 616 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); |
606 #endif | 617 #endif |
607 } | 618 } |
608 | 619 |
609 void RenderWidgetHostViewAura::WasHidden() { | 620 void RenderWidgetHostViewAura::WasHidden() { |
610 if (!host_ || host_->is_hidden()) | 621 if (!host_ || host_->is_hidden()) |
611 return; | 622 return; |
612 host_->WasHidden(); | 623 host_->WasHidden(); |
613 delegated_frame_host_->WasHidden(); | 624 delegated_frame_host_->WasHidden(); |
614 | 625 |
615 #if defined(OS_WIN) | 626 #if defined(OS_WIN) |
616 constrained_rects_.clear(); | 627 constrained_rects_.clear(); |
617 aura::WindowTreeHost* host = window_->GetHost(); | 628 aura::WindowTreeHost* host = window_->GetHost(); |
618 if (host) { | 629 if (host) { |
619 HWND parent = host->GetAcceleratedWidget(); | 630 HWND parent = host->GetAcceleratedWidget(); |
620 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 631 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
621 EnumChildWindows(parent, HideWindowsCallback, lparam); | 632 EnumChildWindows(parent, HideWindowsCallback, lparam); |
| 633 // We reparent the legacy Chrome_RenderWidgetHostHWND window to the global |
| 634 // hidden window on the same lines as Windowed plugin windows. |
| 635 if (legacy_render_widget_host_HWND_) |
| 636 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow()); |
622 } | 637 } |
623 #endif | 638 #endif |
624 } | 639 } |
625 | 640 |
626 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { | 641 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { |
627 // For a SetSize operation, we don't care what coordinate system the origin | 642 // For a SetSize operation, we don't care what coordinate system the origin |
628 // of the window is in, it's only important to make sure that the origin | 643 // of the window is in, it's only important to make sure that the origin |
629 // remains constant after the operation. | 644 // remains constant after the operation. |
630 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size)); | 645 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size)); |
631 } | 646 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 return window_->HasFocus(); | 790 return window_->HasFocus(); |
776 } | 791 } |
777 | 792 |
778 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { | 793 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { |
779 return delegated_frame_host_->CanCopyToBitmap(); | 794 return delegated_frame_host_->CanCopyToBitmap(); |
780 } | 795 } |
781 | 796 |
782 void RenderWidgetHostViewAura::Show() { | 797 void RenderWidgetHostViewAura::Show() { |
783 window_->Show(); | 798 window_->Show(); |
784 WasShown(); | 799 WasShown(); |
| 800 #if defined(OS_WIN) |
| 801 if (legacy_render_widget_host_HWND_) |
| 802 legacy_render_widget_host_HWND_->Show(); |
| 803 #endif |
785 } | 804 } |
786 | 805 |
787 void RenderWidgetHostViewAura::Hide() { | 806 void RenderWidgetHostViewAura::Hide() { |
788 window_->Hide(); | 807 window_->Hide(); |
789 WasHidden(); | 808 WasHidden(); |
| 809 #if defined(OS_WIN) |
| 810 if (legacy_render_widget_host_HWND_) |
| 811 legacy_render_widget_host_HWND_->Hide(); |
| 812 #endif |
790 } | 813 } |
791 | 814 |
792 bool RenderWidgetHostViewAura::IsShowing() { | 815 bool RenderWidgetHostViewAura::IsShowing() { |
793 return window_->IsVisible(); | 816 return window_->IsVisible(); |
794 } | 817 } |
795 | 818 |
796 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { | 819 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { |
797 return window_->GetBoundsInScreen(); | 820 return window_->GetBoundsInScreen(); |
798 } | 821 } |
799 | 822 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); | 1054 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); |
1032 } | 1055 } |
1033 | 1056 |
1034 void RenderWidgetHostViewAura::UpdateMouseLockRegion() { | 1057 void RenderWidgetHostViewAura::UpdateMouseLockRegion() { |
1035 // Clip the cursor if chrome is running on regular desktop. | 1058 // Clip the cursor if chrome is running on regular desktop. |
1036 if (gfx::Screen::GetScreenFor(window_) == gfx::Screen::GetNativeScreen()) { | 1059 if (gfx::Screen::GetScreenFor(window_) == gfx::Screen::GetNativeScreen()) { |
1037 RECT window_rect = window_->GetBoundsInScreen().ToRECT(); | 1060 RECT window_rect = window_->GetBoundsInScreen().ToRECT(); |
1038 ::ClipCursor(&window_rect); | 1061 ::ClipCursor(&window_rect); |
1039 } | 1062 } |
1040 } | 1063 } |
1041 #endif // defined(OS_WIN) | 1064 |
| 1065 void RenderWidgetHostViewAura::OnLegacyWindowDestroyed() { |
| 1066 legacy_render_widget_host_HWND_ = NULL; |
| 1067 legacy_window_destroyed_ = true; |
| 1068 } |
| 1069 #endif |
1042 | 1070 |
1043 void RenderWidgetHostViewAura::OnSwapCompositorFrame( | 1071 void RenderWidgetHostViewAura::OnSwapCompositorFrame( |
1044 uint32 output_surface_id, | 1072 uint32 output_surface_id, |
1045 scoped_ptr<cc::CompositorFrame> frame) { | 1073 scoped_ptr<cc::CompositorFrame> frame) { |
1046 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); | 1074 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); |
1047 | 1075 |
1048 last_scroll_offset_ = frame->metadata.root_scroll_offset; | 1076 last_scroll_offset_ = frame->metadata.root_scroll_offset; |
1049 if (frame->delegated_frame_data) { | 1077 if (frame->delegated_frame_data) { |
1050 delegated_frame_host_->SwapDelegatedFrame( | 1078 delegated_frame_host_->SwapDelegatedFrame( |
1051 output_surface_id, | 1079 output_surface_id, |
(...skipping 11 matching lines...) Expand all Loading... |
1063 return; | 1091 return; |
1064 } | 1092 } |
1065 } | 1093 } |
1066 | 1094 |
1067 void RenderWidgetHostViewAura::DidStopFlinging() { | 1095 void RenderWidgetHostViewAura::DidStopFlinging() { |
1068 if (touch_editing_client_) | 1096 if (touch_editing_client_) |
1069 touch_editing_client_->DidStopFlinging(); | 1097 touch_editing_client_->DidStopFlinging(); |
1070 } | 1098 } |
1071 | 1099 |
1072 #if defined(OS_WIN) | 1100 #if defined(OS_WIN) |
1073 void RenderWidgetHostViewAura::SetLegacyRenderWidgetHostHWND( | |
1074 LegacyRenderWidgetHostHWND* legacy_hwnd) { | |
1075 legacy_render_widget_host_HWND_ = legacy_hwnd; | |
1076 } | |
1077 | |
1078 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( | 1101 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( |
1079 gfx::NativeViewAccessible accessible_parent) { | 1102 gfx::NativeViewAccessible accessible_parent) { |
1080 } | 1103 } |
1081 | 1104 |
1082 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() | 1105 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() |
1083 const { | 1106 const { |
1084 if (legacy_render_widget_host_HWND_) { | 1107 if (legacy_render_widget_host_HWND_) { |
1085 HWND hwnd = legacy_render_widget_host_HWND_->hwnd(); | 1108 return reinterpret_cast<gfx::NativeViewId>( |
1086 if (::IsWindow(hwnd)) | 1109 legacy_render_widget_host_HWND_->hwnd()); |
1087 return reinterpret_cast<gfx::NativeViewId>(hwnd); | |
1088 } | 1110 } |
1089 return NULL; | 1111 return NULL; |
1090 } | 1112 } |
1091 #endif | 1113 #endif |
1092 | 1114 |
1093 bool RenderWidgetHostViewAura::HasAcceleratedSurface( | 1115 bool RenderWidgetHostViewAura::HasAcceleratedSurface( |
1094 const gfx::Size& desired_size) { | 1116 const gfx::Size& desired_size) { |
1095 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't | 1117 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't |
1096 // matter what is returned here as GetBackingStore is the only caller of this | 1118 // matter what is returned here as GetBackingStore is the only caller of this |
1097 // method. TODO(jbates) implement this if other Aura code needs it. | 1119 // method. TODO(jbates) implement this if other Aura code needs it. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 #else | 1242 #else |
1221 manager = BrowserAccessibilityManager::Create( | 1243 manager = BrowserAccessibilityManager::Create( |
1222 BrowserAccessibilityManager::GetEmptyDocument(), delegate); | 1244 BrowserAccessibilityManager::GetEmptyDocument(), delegate); |
1223 #endif | 1245 #endif |
1224 return manager; | 1246 return manager; |
1225 } | 1247 } |
1226 | 1248 |
1227 gfx::AcceleratedWidget | 1249 gfx::AcceleratedWidget |
1228 RenderWidgetHostViewAura::AccessibilityGetAcceleratedWidget() { | 1250 RenderWidgetHostViewAura::AccessibilityGetAcceleratedWidget() { |
1229 #if defined(OS_WIN) | 1251 #if defined(OS_WIN) |
1230 if (legacy_render_widget_host_HWND_) { | 1252 if (legacy_render_widget_host_HWND_) |
1231 HWND hwnd = legacy_render_widget_host_HWND_->hwnd(); | 1253 return legacy_render_widget_host_HWND_->hwnd(); |
1232 if (::IsWindow(hwnd)) | |
1233 return hwnd; | |
1234 } | |
1235 #endif | 1254 #endif |
1236 return gfx::kNullAcceleratedWidget; | 1255 return gfx::kNullAcceleratedWidget; |
1237 } | 1256 } |
1238 | 1257 |
1239 gfx::NativeViewAccessible | 1258 gfx::NativeViewAccessible |
1240 RenderWidgetHostViewAura::AccessibilityGetNativeViewAccessible() { | 1259 RenderWidgetHostViewAura::AccessibilityGetNativeViewAccessible() { |
1241 #if defined(OS_WIN) | 1260 #if defined(OS_WIN) |
1242 if (legacy_render_widget_host_HWND_) | 1261 if (legacy_render_widget_host_HWND_) |
1243 return legacy_render_widget_host_HWND_->window_accessible(); | 1262 return legacy_render_widget_host_HWND_->window_accessible(); |
1244 #endif | 1263 #endif |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 HWND parent = NULL; | 1775 HWND parent = NULL; |
1757 // If the tab was hidden and it's closed, host_->is_hidden would have been | 1776 // If the tab was hidden and it's closed, host_->is_hidden would have been |
1758 // reset to false in RenderWidgetHostImpl::RendererExited. | 1777 // reset to false in RenderWidgetHostImpl::RendererExited. |
1759 if (!window_->GetRootWindow() || host_->is_hidden()) { | 1778 if (!window_->GetRootWindow() || host_->is_hidden()) { |
1760 parent = ui::GetHiddenWindow(); | 1779 parent = ui::GetHiddenWindow(); |
1761 } else { | 1780 } else { |
1762 parent = window_->GetHost()->GetAcceleratedWidget(); | 1781 parent = window_->GetHost()->GetAcceleratedWidget(); |
1763 } | 1782 } |
1764 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 1783 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
1765 EnumChildWindows(parent, WindowDestroyingCallback, lparam); | 1784 EnumChildWindows(parent, WindowDestroyingCallback, lparam); |
1766 legacy_render_widget_host_HWND_ = NULL; | 1785 |
| 1786 // The LegacyRenderWidgetHostHWND instance is destroyed when its window is |
| 1787 // destroyed. Normally we control when that happens via the Destroy call |
| 1788 // in the dtor. However there may be cases where the window is destroyed |
| 1789 // by Windows, i.e. the parent window is destroyed before the |
| 1790 // RenderWidgetHostViewAura instance goes away etc. To avoid that we |
| 1791 // destroy the LegacyRenderWidgetHostHWND instance here. |
| 1792 if (legacy_render_widget_host_HWND_) { |
| 1793 legacy_render_widget_host_HWND_->set_host(NULL); |
| 1794 legacy_render_widget_host_HWND_->Destroy(); |
| 1795 // The Destroy call above will delete the LegacyRenderWidgetHostHWND |
| 1796 // instance. |
| 1797 legacy_render_widget_host_HWND_ = NULL; |
| 1798 } |
1767 #endif | 1799 #endif |
1768 | 1800 |
1769 // Make sure that the input method no longer references to this object before | 1801 // Make sure that the input method no longer references to this object before |
1770 // this object is removed from the root window (i.e. this object loses access | 1802 // this object is removed from the root window (i.e. this object loses access |
1771 // to the input method). | 1803 // to the input method). |
1772 ui::InputMethod* input_method = GetInputMethod(); | 1804 ui::InputMethod* input_method = GetInputMethod(); |
1773 if (input_method) | 1805 if (input_method) |
1774 input_method->DetachTextInputClient(this); | 1806 input_method->DetachTextInputClient(this); |
1775 | 1807 |
1776 if (overscroll_controller_) | 1808 if (overscroll_controller_) |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2257 popup_child_host_view_->popup_parent_host_view_ = NULL; | 2289 popup_child_host_view_->popup_parent_host_view_ = NULL; |
2258 } | 2290 } |
2259 event_filter_for_popup_exit_.reset(); | 2291 event_filter_for_popup_exit_.reset(); |
2260 aura::client::SetTooltipText(window_, NULL); | 2292 aura::client::SetTooltipText(window_, NULL); |
2261 gfx::Screen::GetScreenFor(window_)->RemoveObserver(this); | 2293 gfx::Screen::GetScreenFor(window_)->RemoveObserver(this); |
2262 | 2294 |
2263 // This call is usually no-op since |this| object is already removed from the | 2295 // This call is usually no-op since |this| object is already removed from the |
2264 // Aura root window and we don't have a way to get an input method object | 2296 // Aura root window and we don't have a way to get an input method object |
2265 // associated with the window, but just in case. | 2297 // associated with the window, but just in case. |
2266 DetachFromInputMethod(); | 2298 DetachFromInputMethod(); |
| 2299 |
| 2300 #if defined(OS_WIN) |
| 2301 // The LegacyRenderWidgetHostHWND window should have been destroyed in |
| 2302 // RenderWidgetHostViewAura::OnWindowDestroying and the pointer should |
| 2303 // be set to NULL. |
| 2304 DCHECK(!legacy_render_widget_host_HWND_); |
| 2305 #endif |
2267 } | 2306 } |
2268 | 2307 |
2269 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { | 2308 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { |
2270 const gfx::Point screen_point = | 2309 const gfx::Point screen_point = |
2271 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | 2310 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); |
2272 aura::Window* root_window = window_->GetRootWindow(); | 2311 aura::Window* root_window = window_->GetRootWindow(); |
2273 if (!root_window) | 2312 if (!root_window) |
2274 return; | 2313 return; |
2275 | 2314 |
2276 gfx::Point root_window_point = screen_point; | 2315 gfx::Point root_window_point = screen_point; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2413 // a Window::SetBoundsInternal call. | 2452 // a Window::SetBoundsInternal call. |
2414 if (!in_bounds_changed_) | 2453 if (!in_bounds_changed_) |
2415 window_->SetBounds(rect); | 2454 window_->SetBounds(rect); |
2416 host_->WasResized(); | 2455 host_->WasResized(); |
2417 delegated_frame_host_->WasResized(); | 2456 delegated_frame_host_->WasResized(); |
2418 if (touch_editing_client_) { | 2457 if (touch_editing_client_) { |
2419 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_, | 2458 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_, |
2420 selection_focus_); | 2459 selection_focus_); |
2421 } | 2460 } |
2422 #if defined(OS_WIN) | 2461 #if defined(OS_WIN) |
| 2462 // Create the legacy dummy window which corresponds to the bounds of the |
| 2463 // webcontents. This will be passed as the container window for windowless |
| 2464 // plugins. |
| 2465 // Plugins like Flash assume the container window which is returned via the |
| 2466 // NPNVnetscapeWindow property corresponds to the bounds of the webpage. |
| 2467 // This is not true in Aura where we have only HWND which is the main Aura |
| 2468 // window. If we return this window to plugins like Flash then it causes the |
| 2469 // coordinate translations done by these plugins to break. |
| 2470 // Additonally the legacy dummy window is needed for accessibility and for |
| 2471 // scrolling to work in legacy drivers for trackpoints/trackpads, etc. |
| 2472 if (!legacy_window_destroyed_ && GetNativeViewId()) { |
| 2473 if (!legacy_render_widget_host_HWND_) { |
| 2474 legacy_render_widget_host_HWND_ = LegacyRenderWidgetHostHWND::Create( |
| 2475 reinterpret_cast<HWND>(GetNativeViewId())); |
| 2476 } |
| 2477 if (legacy_render_widget_host_HWND_) { |
| 2478 legacy_render_widget_host_HWND_->set_host(this); |
| 2479 legacy_render_widget_host_HWND_->SetBounds( |
| 2480 window_->GetBoundsInRootWindow()); |
| 2481 // There are cases where the parent window is created, made visible and |
| 2482 // the associated RenderWidget is also visible before the |
| 2483 // LegacyRenderWidgetHostHWND instace is created. Ensure that it is shown |
| 2484 // here. |
| 2485 if (!host_->is_hidden()) |
| 2486 legacy_render_widget_host_HWND_->Show(); |
| 2487 } |
| 2488 } |
| 2489 |
2423 if (mouse_locked_) | 2490 if (mouse_locked_) |
2424 UpdateMouseLockRegion(); | 2491 UpdateMouseLockRegion(); |
2425 #endif | 2492 #endif |
2426 } | 2493 } |
2427 | 2494 |
2428 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( | 2495 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( |
2429 const gfx::Rect& rect, | 2496 const gfx::Rect& rect, |
2430 const gfx::Rect& clip) { | 2497 const gfx::Rect& clip) { |
2431 if (!clip.IsEmpty()) { | 2498 if (!clip.IsEmpty()) { |
2432 gfx::Rect to_paint = gfx::SubtractRects(rect, clip); | 2499 gfx::Rect to_paint = gfx::SubtractRects(rect, clip); |
(...skipping 25 matching lines...) Expand all Loading... |
2458 if (cursor_client) { | 2525 if (cursor_client) { |
2459 cursor_client->AddObserver(this); | 2526 cursor_client->AddObserver(this); |
2460 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 2527 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
2461 } | 2528 } |
2462 if (HasFocus()) { | 2529 if (HasFocus()) { |
2463 ui::InputMethod* input_method = GetInputMethod(); | 2530 ui::InputMethod* input_method = GetInputMethod(); |
2464 if (input_method) | 2531 if (input_method) |
2465 input_method->SetFocusedTextInputClient(this); | 2532 input_method->SetFocusedTextInputClient(this); |
2466 } | 2533 } |
2467 | 2534 |
| 2535 #if defined(OS_WIN) |
| 2536 // The parent may have changed here. Ensure that the legacy window is |
| 2537 // reparented accordingly. |
| 2538 if (legacy_render_widget_host_HWND_) |
| 2539 legacy_render_widget_host_HWND_->UpdateParent( |
| 2540 reinterpret_cast<HWND>(GetNativeViewId())); |
| 2541 #endif |
| 2542 |
2468 delegated_frame_host_->AddedToWindow(); | 2543 delegated_frame_host_->AddedToWindow(); |
2469 } | 2544 } |
2470 | 2545 |
2471 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 2546 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
2472 aura::client::CursorClient* cursor_client = | 2547 aura::client::CursorClient* cursor_client = |
2473 aura::client::GetCursorClient(window_->GetRootWindow()); | 2548 aura::client::GetCursorClient(window_->GetRootWindow()); |
2474 if (cursor_client) | 2549 if (cursor_client) |
2475 cursor_client->RemoveObserver(this); | 2550 cursor_client->RemoveObserver(this); |
2476 | 2551 |
2477 DetachFromInputMethod(); | 2552 DetachFromInputMethod(); |
2478 | 2553 |
2479 window_->GetHost()->RemoveObserver(this); | 2554 window_->GetHost()->RemoveObserver(this); |
2480 delegated_frame_host_->RemovingFromWindow(); | 2555 delegated_frame_host_->RemovingFromWindow(); |
| 2556 |
| 2557 #if defined(OS_WIN) |
| 2558 // Update the legacy window's parent temporarily to the desktop window. It |
| 2559 // will eventually get reparented to the right root. |
| 2560 if (legacy_render_widget_host_HWND_) |
| 2561 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); |
| 2562 #endif |
2481 } | 2563 } |
2482 | 2564 |
2483 void RenderWidgetHostViewAura::DetachFromInputMethod() { | 2565 void RenderWidgetHostViewAura::DetachFromInputMethod() { |
2484 ui::InputMethod* input_method = GetInputMethod(); | 2566 ui::InputMethod* input_method = GetInputMethod(); |
2485 if (input_method && input_method->GetTextInputClient() == this) | 2567 if (input_method && input_method->GetTextInputClient() == this) |
2486 input_method->SetFocusedTextInputClient(NULL); | 2568 input_method->SetFocusedTextInputClient(NULL); |
2487 } | 2569 } |
2488 | 2570 |
2489 void RenderWidgetHostViewAura::ForwardKeyboardEvent( | 2571 void RenderWidgetHostViewAura::ForwardKeyboardEvent( |
2490 const NativeWebKeyboardEvent& event) { | 2572 const NativeWebKeyboardEvent& event) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2568 | 2650 |
2569 //////////////////////////////////////////////////////////////////////////////// | 2651 //////////////////////////////////////////////////////////////////////////////// |
2570 // RenderWidgetHostViewBase, public: | 2652 // RenderWidgetHostViewBase, public: |
2571 | 2653 |
2572 // static | 2654 // static |
2573 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2655 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2574 GetScreenInfoForWindow(results, NULL); | 2656 GetScreenInfoForWindow(results, NULL); |
2575 } | 2657 } |
2576 | 2658 |
2577 } // namespace content | 2659 } // namespace content |
OLD | NEW |