| 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 <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 if (root) { | 550 if (root) { |
| 551 aura::client::CursorClient* cursor_client = | 551 aura::client::CursorClient* cursor_client = |
| 552 aura::client::GetCursorClient(root); | 552 aura::client::GetCursorClient(root); |
| 553 if (cursor_client) | 553 if (cursor_client) |
| 554 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 554 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
| 555 } | 555 } |
| 556 | 556 |
| 557 delegated_frame_host_->WasShown(browser_latency_info); | 557 delegated_frame_host_->WasShown(browser_latency_info); |
| 558 | 558 |
| 559 #if defined(OS_WIN) | 559 #if defined(OS_WIN) |
| 560 if (legacy_render_widget_host_HWND_) { | 560 UpdateLegacyWin(); |
| 561 // Reparent the legacy Chrome_RenderWidgetHostHWND window to the parent | |
| 562 // window before reparenting any plugins. This ensures that the plugin | |
| 563 // windows stay on top of the child Zorder in the parent and receive | |
| 564 // mouse events, etc. | |
| 565 legacy_render_widget_host_HWND_->UpdateParent( | |
| 566 GetNativeView()->GetHost()->GetAcceleratedWidget()); | |
| 567 legacy_render_widget_host_HWND_->SetBounds( | |
| 568 window_->GetBoundsInRootWindow()); | |
| 569 legacy_render_widget_host_HWND_->Show(); | |
| 570 } | |
| 571 #endif | 561 #endif |
| 572 } | 562 } |
| 573 | 563 |
| 574 void RenderWidgetHostViewAura::Hide() { | 564 void RenderWidgetHostViewAura::Hide() { |
| 575 window_->Hide(); | 565 window_->Hide(); |
| 576 | 566 |
| 577 // TODO(wjmaclean): can host_ ever be null? | 567 // TODO(wjmaclean): can host_ ever be null? |
| 578 if (host_ && !host_->is_hidden()) { | 568 if (host_ && !host_->is_hidden()) { |
| 579 host_->WasHidden(); | 569 host_->WasHidden(); |
| 580 delegated_frame_host_->WasHidden(); | 570 delegated_frame_host_->WasHidden(); |
| (...skipping 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2491 | 2481 |
| 2492 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { | 2482 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { |
| 2493 SnapToPhysicalPixelBoundary(); | 2483 SnapToPhysicalPixelBoundary(); |
| 2494 // Don't recursively call SetBounds if this bounds update is the result of | 2484 // Don't recursively call SetBounds if this bounds update is the result of |
| 2495 // a Window::SetBoundsInternal call. | 2485 // a Window::SetBoundsInternal call. |
| 2496 if (!in_bounds_changed_) | 2486 if (!in_bounds_changed_) |
| 2497 window_->SetBounds(rect); | 2487 window_->SetBounds(rect); |
| 2498 host_->WasResized(); | 2488 host_->WasResized(); |
| 2499 delegated_frame_host_->WasResized(); | 2489 delegated_frame_host_->WasResized(); |
| 2500 #if defined(OS_WIN) | 2490 #if defined(OS_WIN) |
| 2501 // Create the legacy dummy window which corresponds to the bounds of the | 2491 UpdateLegacyWin(); |
| 2502 // webcontents. It is needed for accessibility and for scrolling to work in | |
| 2503 // legacy drivers for trackpoints/trackpads, etc. | |
| 2504 if (!legacy_window_destroyed_ && GetHostWindowHWND()) { | |
| 2505 if (!legacy_render_widget_host_HWND_) { | |
| 2506 legacy_render_widget_host_HWND_ = | |
| 2507 LegacyRenderWidgetHostHWND::Create(GetHostWindowHWND()); | |
| 2508 } | |
| 2509 if (legacy_render_widget_host_HWND_) { | |
| 2510 legacy_render_widget_host_HWND_->set_host(this); | |
| 2511 legacy_render_widget_host_HWND_->SetBounds( | |
| 2512 window_->GetBoundsInRootWindow()); | |
| 2513 // There are cases where the parent window is created, made visible and | |
| 2514 // the associated RenderWidget is also visible before the | |
| 2515 // LegacyRenderWidgetHostHWND instace is created. Ensure that it is shown | |
| 2516 // here. | |
| 2517 if (!host_->is_hidden()) | |
| 2518 legacy_render_widget_host_HWND_->Show(); | |
| 2519 } | |
| 2520 } | |
| 2521 | 2492 |
| 2522 if (mouse_locked_) | 2493 if (mouse_locked_) |
| 2523 UpdateMouseLockRegion(); | 2494 UpdateMouseLockRegion(); |
| 2524 #endif | 2495 #endif |
| 2525 } | 2496 } |
| 2526 | 2497 |
| 2498 #if defined(OS_WIN) |
| 2499 void RenderWidgetHostViewAura::UpdateLegacyWin() { |
| 2500 if (legacy_window_destroyed_ || !GetHostWindowHWND()) |
| 2501 return; |
| 2502 |
| 2503 if (!legacy_render_widget_host_HWND_) { |
| 2504 legacy_render_widget_host_HWND_ = |
| 2505 LegacyRenderWidgetHostHWND::Create(GetHostWindowHWND()); |
| 2506 } |
| 2507 |
| 2508 if (legacy_render_widget_host_HWND_) { |
| 2509 legacy_render_widget_host_HWND_->set_host(this); |
| 2510 legacy_render_widget_host_HWND_->UpdateParent(GetHostWindowHWND()); |
| 2511 legacy_render_widget_host_HWND_->SetBounds( |
| 2512 window_->GetBoundsInRootWindow()); |
| 2513 // There are cases where the parent window is created, made visible and |
| 2514 // the associated RenderWidget is also visible before the |
| 2515 // LegacyRenderWidgetHostHWND instace is created. Ensure that it is shown |
| 2516 // here. |
| 2517 if (!host_->is_hidden()) |
| 2518 legacy_render_widget_host_HWND_->Show(); |
| 2519 } |
| 2520 } |
| 2521 #endif |
| 2522 |
| 2527 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( | 2523 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( |
| 2528 const gfx::Rect& rect, | 2524 const gfx::Rect& rect, |
| 2529 const gfx::Rect& clip) { | 2525 const gfx::Rect& clip) { |
| 2530 if (!clip.IsEmpty()) { | 2526 if (!clip.IsEmpty()) { |
| 2531 gfx::Rect to_paint = gfx::SubtractRects(rect, clip); | 2527 gfx::Rect to_paint = gfx::SubtractRects(rect, clip); |
| 2532 if (!to_paint.IsEmpty()) | 2528 if (!to_paint.IsEmpty()) |
| 2533 window_->SchedulePaintInRect(to_paint); | 2529 window_->SchedulePaintInRect(to_paint); |
| 2534 } else { | 2530 } else { |
| 2535 window_->SchedulePaintInRect(rect); | 2531 window_->SchedulePaintInRect(rect); |
| 2536 } | 2532 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2558 cursor_client->AddObserver(this); | 2554 cursor_client->AddObserver(this); |
| 2559 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 2555 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
| 2560 } | 2556 } |
| 2561 if (HasFocus()) { | 2557 if (HasFocus()) { |
| 2562 ui::InputMethod* input_method = GetInputMethod(); | 2558 ui::InputMethod* input_method = GetInputMethod(); |
| 2563 if (input_method) | 2559 if (input_method) |
| 2564 input_method->SetFocusedTextInputClient(this); | 2560 input_method->SetFocusedTextInputClient(this); |
| 2565 } | 2561 } |
| 2566 | 2562 |
| 2567 #if defined(OS_WIN) | 2563 #if defined(OS_WIN) |
| 2568 // The parent may have changed here. Ensure that the legacy window is | 2564 UpdateLegacyWin(); |
| 2569 // reparented accordingly. | |
| 2570 if (legacy_render_widget_host_HWND_) | |
| 2571 legacy_render_widget_host_HWND_->UpdateParent(GetHostWindowHWND()); | |
| 2572 #endif | 2565 #endif |
| 2573 | 2566 |
| 2574 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); | 2567 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); |
| 2575 } | 2568 } |
| 2576 | 2569 |
| 2577 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 2570 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
| 2578 aura::client::CursorClient* cursor_client = | 2571 aura::client::CursorClient* cursor_client = |
| 2579 aura::client::GetCursorClient(window_->GetRootWindow()); | 2572 aura::client::GetCursorClient(window_->GetRootWindow()); |
| 2580 if (cursor_client) | 2573 if (cursor_client) |
| 2581 cursor_client->RemoveObserver(this); | 2574 cursor_client->RemoveObserver(this); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2865 | 2858 |
| 2866 //////////////////////////////////////////////////////////////////////////////// | 2859 //////////////////////////////////////////////////////////////////////////////// |
| 2867 // RenderWidgetHostViewBase, public: | 2860 // RenderWidgetHostViewBase, public: |
| 2868 | 2861 |
| 2869 // static | 2862 // static |
| 2870 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2863 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2871 GetScreenInfoForWindow(results, NULL); | 2864 GetScreenInfoForWindow(results, NULL); |
| 2872 } | 2865 } |
| 2873 | 2866 |
| 2874 } // namespace content | 2867 } // namespace content |
| OLD | NEW |