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_ || | |
2501 !GetHostWindowHWND() || | |
2502 window_->GetBoundsInRootWindow().IsEmpty()) { | |
2503 return; | |
2504 } | |
2505 | |
2506 if (!legacy_render_widget_host_HWND_) { | |
2507 legacy_render_widget_host_HWND_ = | |
2508 LegacyRenderWidgetHostHWND::Create(GetHostWindowHWND()); | |
2509 } | |
2510 | |
2511 if (legacy_render_widget_host_HWND_) { | |
ananta
2016/05/23 22:49:54
We can remove this if check
dmazzoni
2016/05/23 22:57:23
I don't think that's safe, since Legacy...HWND::Cr
| |
2512 legacy_render_widget_host_HWND_->set_host(this); | |
2513 legacy_render_widget_host_HWND_->UpdateParent(GetHostWindowHWND()); | |
2514 legacy_render_widget_host_HWND_->SetBounds( | |
2515 window_->GetBoundsInRootWindow()); | |
2516 // There are cases where the parent window is created, made visible and | |
2517 // the associated RenderWidget is also visible before the | |
2518 // LegacyRenderWidgetHostHWND instace is created. Ensure that it is shown | |
2519 // here. | |
2520 if (!host_->is_hidden()) | |
2521 legacy_render_widget_host_HWND_->Show(); | |
2522 } | |
2523 } | |
2524 #endif | |
2525 | |
2527 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( | 2526 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( |
2528 const gfx::Rect& rect, | 2527 const gfx::Rect& rect, |
2529 const gfx::Rect& clip) { | 2528 const gfx::Rect& clip) { |
2530 if (!clip.IsEmpty()) { | 2529 if (!clip.IsEmpty()) { |
2531 gfx::Rect to_paint = gfx::SubtractRects(rect, clip); | 2530 gfx::Rect to_paint = gfx::SubtractRects(rect, clip); |
2532 if (!to_paint.IsEmpty()) | 2531 if (!to_paint.IsEmpty()) |
2533 window_->SchedulePaintInRect(to_paint); | 2532 window_->SchedulePaintInRect(to_paint); |
2534 } else { | 2533 } else { |
2535 window_->SchedulePaintInRect(rect); | 2534 window_->SchedulePaintInRect(rect); |
2536 } | 2535 } |
(...skipping 21 matching lines...) Expand all Loading... | |
2558 cursor_client->AddObserver(this); | 2557 cursor_client->AddObserver(this); |
2559 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 2558 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
2560 } | 2559 } |
2561 if (HasFocus()) { | 2560 if (HasFocus()) { |
2562 ui::InputMethod* input_method = GetInputMethod(); | 2561 ui::InputMethod* input_method = GetInputMethod(); |
2563 if (input_method) | 2562 if (input_method) |
2564 input_method->SetFocusedTextInputClient(this); | 2563 input_method->SetFocusedTextInputClient(this); |
2565 } | 2564 } |
2566 | 2565 |
2567 #if defined(OS_WIN) | 2566 #if defined(OS_WIN) |
2568 // The parent may have changed here. Ensure that the legacy window is | 2567 UpdateLegacyWin(); |
2569 // reparented accordingly. | |
2570 if (legacy_render_widget_host_HWND_) | |
2571 legacy_render_widget_host_HWND_->UpdateParent(GetHostWindowHWND()); | |
2572 #endif | 2568 #endif |
2573 | 2569 |
2574 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); | 2570 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); |
2575 } | 2571 } |
2576 | 2572 |
2577 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 2573 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
2578 aura::client::CursorClient* cursor_client = | 2574 aura::client::CursorClient* cursor_client = |
2579 aura::client::GetCursorClient(window_->GetRootWindow()); | 2575 aura::client::GetCursorClient(window_->GetRootWindow()); |
2580 if (cursor_client) | 2576 if (cursor_client) |
2581 cursor_client->RemoveObserver(this); | 2577 cursor_client->RemoveObserver(this); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2865 | 2861 |
2866 //////////////////////////////////////////////////////////////////////////////// | 2862 //////////////////////////////////////////////////////////////////////////////// |
2867 // RenderWidgetHostViewBase, public: | 2863 // RenderWidgetHostViewBase, public: |
2868 | 2864 |
2869 // static | 2865 // static |
2870 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2866 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2871 GetScreenInfoForWindow(results, NULL); | 2867 GetScreenInfoForWindow(results, NULL); |
2872 } | 2868 } |
2873 | 2869 |
2874 } // namespace content | 2870 } // namespace content |
OLD | NEW |