| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "media/base/video_util.h" | 45 #include "media/base/video_util.h" |
| 46 #include "skia/ext/image_operations.h" | 46 #include "skia/ext/image_operations.h" |
| 47 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 47 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
| 48 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 48 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 49 #include "third_party/WebKit/public/web/WebInputEvent.h" | 49 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 50 #include "ui/aura/client/aura_constants.h" | 50 #include "ui/aura/client/aura_constants.h" |
| 51 #include "ui/aura/client/cursor_client.h" | 51 #include "ui/aura/client/cursor_client.h" |
| 52 #include "ui/aura/client/cursor_client_observer.h" | 52 #include "ui/aura/client/cursor_client_observer.h" |
| 53 #include "ui/aura/client/focus_client.h" | 53 #include "ui/aura/client/focus_client.h" |
| 54 #include "ui/aura/client/screen_position_client.h" | 54 #include "ui/aura/client/screen_position_client.h" |
| 55 #include "ui/aura/client/virtual_keyboard_client.h" |
| 55 #include "ui/aura/client/window_tree_client.h" | 56 #include "ui/aura/client/window_tree_client.h" |
| 56 #include "ui/aura/env.h" | 57 #include "ui/aura/env.h" |
| 57 #include "ui/aura/window.h" | 58 #include "ui/aura/window.h" |
| 58 #include "ui/aura/window_event_dispatcher.h" | 59 #include "ui/aura/window_event_dispatcher.h" |
| 59 #include "ui/aura/window_observer.h" | 60 #include "ui/aura/window_observer.h" |
| 60 #include "ui/aura/window_tracker.h" | 61 #include "ui/aura/window_tracker.h" |
| 61 #include "ui/aura/window_tree_host.h" | 62 #include "ui/aura/window_tree_host.h" |
| 62 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 63 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 63 #include "ui/base/hit_test.h" | 64 #include "ui/base/hit_test.h" |
| 64 #include "ui/base/ime/input_method.h" | 65 #include "ui/base/ime/input_method.h" |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 gl_helper->WaitSyncPoint(frame->gl_frame_data->sync_point); | 1709 gl_helper->WaitSyncPoint(frame->gl_frame_data->sync_point); |
| 1709 | 1710 |
| 1710 BuffersSwapped(frame->gl_frame_data->size, | 1711 BuffersSwapped(frame->gl_frame_data->size, |
| 1711 frame->gl_frame_data->sub_buffer_rect, | 1712 frame->gl_frame_data->sub_buffer_rect, |
| 1712 frame->metadata.device_scale_factor, | 1713 frame->metadata.device_scale_factor, |
| 1713 frame->gl_frame_data->mailbox, | 1714 frame->gl_frame_data->mailbox, |
| 1714 frame->metadata.latency_info, | 1715 frame->metadata.latency_info, |
| 1715 ack_callback); | 1716 ack_callback); |
| 1716 } | 1717 } |
| 1717 | 1718 |
| 1719 float RenderWidgetHostViewAura::GetOverdrawBottomHeight() const { |
| 1720 float overdraw = 0.f; |
| 1721 #if defined(OS_CHROMEOS) |
| 1722 gfx::Rect window_bounds = window_->GetBoundsInScreen(); |
| 1723 gfx::Rect intersect = gfx::IntersectRects(window_bounds, |
| 1724 virtual_keyboard_bounds_); |
| 1725 if (intersect.height() > 0 && intersect.height() < window_bounds.height()) |
| 1726 overdraw = intersect.height(); |
| 1727 #endif |
| 1728 return overdraw; |
| 1729 } |
| 1730 |
| 1718 #if defined(OS_WIN) | 1731 #if defined(OS_WIN) |
| 1719 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( | 1732 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( |
| 1720 gfx::NativeViewAccessible accessible_parent) { | 1733 gfx::NativeViewAccessible accessible_parent) { |
| 1721 if (GetBrowserAccessibilityManager()) { | 1734 if (GetBrowserAccessibilityManager()) { |
| 1722 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() | 1735 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() |
| 1723 ->set_parent_iaccessible(accessible_parent); | 1736 ->set_parent_iaccessible(accessible_parent); |
| 1724 } | 1737 } |
| 1725 } | 1738 } |
| 1726 | 1739 |
| 1727 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() | 1740 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() |
| (...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3098 } | 3111 } |
| 3099 | 3112 |
| 3100 //////////////////////////////////////////////////////////////////////////////// | 3113 //////////////////////////////////////////////////////////////////////////////// |
| 3101 // RenderWidgetHostViewAura, aura::client::CursorClientObserver implementation: | 3114 // RenderWidgetHostViewAura, aura::client::CursorClientObserver implementation: |
| 3102 | 3115 |
| 3103 void RenderWidgetHostViewAura::OnCursorVisibilityChanged(bool is_visible) { | 3116 void RenderWidgetHostViewAura::OnCursorVisibilityChanged(bool is_visible) { |
| 3104 NotifyRendererOfCursorVisibilityState(is_visible); | 3117 NotifyRendererOfCursorVisibilityState(is_visible); |
| 3105 } | 3118 } |
| 3106 | 3119 |
| 3107 //////////////////////////////////////////////////////////////////////////////// | 3120 //////////////////////////////////////////////////////////////////////////////// |
| 3121 // RenderWidgetHostViewAura, aura::client::VirtualKeyboardObserver |
| 3122 // implementation: |
| 3123 |
| 3124 void RenderWidgetHostViewAura::OnKeyboardBoundsChanging( |
| 3125 const gfx::Rect& new_bounds) { |
| 3126 #if defined(OS_CHROMEOS) |
| 3127 aura::client::VirtualKeyboardClient *keyboard_client = |
| 3128 aura::client::GetVirtualKeyboardClient(window_->GetRootWindow()); |
| 3129 if (!keyboard_client || !keyboard_client->IsOverscrollEnabled()) |
| 3130 return; |
| 3131 if (virtual_keyboard_bounds_ != new_bounds) { |
| 3132 virtual_keyboard_bounds_ = new_bounds; |
| 3133 host_->WasResized(); |
| 3134 } |
| 3135 #endif |
| 3136 } |
| 3137 |
| 3138 //////////////////////////////////////////////////////////////////////////////// |
| 3108 // RenderWidgetHostViewAura, aura::client::FocusChangeObserver implementation: | 3139 // RenderWidgetHostViewAura, aura::client::FocusChangeObserver implementation: |
| 3109 | 3140 |
| 3110 void RenderWidgetHostViewAura::OnWindowFocused(aura::Window* gained_focus, | 3141 void RenderWidgetHostViewAura::OnWindowFocused(aura::Window* gained_focus, |
| 3111 aura::Window* lost_focus) { | 3142 aura::Window* lost_focus) { |
| 3112 DCHECK(window_ == gained_focus || window_ == lost_focus); | 3143 DCHECK(window_ == gained_focus || window_ == lost_focus); |
| 3113 if (window_ == gained_focus) { | 3144 if (window_ == gained_focus) { |
| 3114 // We need to honor input bypass if the associated tab is does not want | 3145 // We need to honor input bypass if the associated tab is does not want |
| 3115 // input. This gives the current focused window a chance to be the text | 3146 // input. This gives the current focused window a chance to be the text |
| 3116 // input client and handle events. | 3147 // input client and handle events. |
| 3117 if (host_->ignore_input_events()) | 3148 if (host_->ignore_input_events()) |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3513 void RenderWidgetHostViewAura::AddedToRootWindow() { | 3544 void RenderWidgetHostViewAura::AddedToRootWindow() { |
| 3514 window_->GetHost()->AddObserver(this); | 3545 window_->GetHost()->AddObserver(this); |
| 3515 UpdateScreenInfo(window_); | 3546 UpdateScreenInfo(window_); |
| 3516 | 3547 |
| 3517 aura::client::CursorClient* cursor_client = | 3548 aura::client::CursorClient* cursor_client = |
| 3518 aura::client::GetCursorClient(window_->GetRootWindow()); | 3549 aura::client::GetCursorClient(window_->GetRootWindow()); |
| 3519 if (cursor_client) { | 3550 if (cursor_client) { |
| 3520 cursor_client->AddObserver(this); | 3551 cursor_client->AddObserver(this); |
| 3521 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 3552 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
| 3522 } | 3553 } |
| 3554 |
| 3555 aura::client::VirtualKeyboardClient* keyboard_client = |
| 3556 aura::client::GetVirtualKeyboardClient(window_->GetRootWindow()); |
| 3557 if (keyboard_client) |
| 3558 keyboard_client->AddObserver(this); |
| 3559 |
| 3523 if (current_surface_.get()) | 3560 if (current_surface_.get()) |
| 3524 UpdateExternalTexture(); | 3561 UpdateExternalTexture(); |
| 3525 if (HasFocus()) { | 3562 if (HasFocus()) { |
| 3526 ui::InputMethod* input_method = GetInputMethod(); | 3563 ui::InputMethod* input_method = GetInputMethod(); |
| 3527 if (input_method) | 3564 if (input_method) |
| 3528 input_method->SetFocusedTextInputClient(this); | 3565 input_method->SetFocusedTextInputClient(this); |
| 3529 } | 3566 } |
| 3530 | 3567 |
| 3531 #if defined(OS_WIN) | 3568 #if defined(OS_WIN) |
| 3532 // The parent may have changed here. Ensure that the legacy window is | 3569 // The parent may have changed here. Ensure that the legacy window is |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3543 vsync_manager_->AddObserver(this); | 3580 vsync_manager_->AddObserver(this); |
| 3544 } | 3581 } |
| 3545 } | 3582 } |
| 3546 | 3583 |
| 3547 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 3584 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
| 3548 aura::client::CursorClient* cursor_client = | 3585 aura::client::CursorClient* cursor_client = |
| 3549 aura::client::GetCursorClient(window_->GetRootWindow()); | 3586 aura::client::GetCursorClient(window_->GetRootWindow()); |
| 3550 if (cursor_client) | 3587 if (cursor_client) |
| 3551 cursor_client->RemoveObserver(this); | 3588 cursor_client->RemoveObserver(this); |
| 3552 | 3589 |
| 3590 aura::client::VirtualKeyboardClient* keyboard_client = |
| 3591 aura::client::GetVirtualKeyboardClient(window_->GetRootWindow()); |
| 3592 if (keyboard_client) |
| 3593 keyboard_client->RemoveObserver(this); |
| 3594 |
| 3553 DetachFromInputMethod(); | 3595 DetachFromInputMethod(); |
| 3554 | 3596 |
| 3555 window_->GetHost()->RemoveObserver(this); | 3597 window_->GetHost()->RemoveObserver(this); |
| 3556 ui::Compositor* compositor = GetCompositor(); | 3598 ui::Compositor* compositor = GetCompositor(); |
| 3557 if (current_surface_.get()) { | 3599 if (current_surface_.get()) { |
| 3558 // We can't get notification for commits after this point, which would | 3600 // We can't get notification for commits after this point, which would |
| 3559 // guarantee that the compositor isn't using an old texture any more, so | 3601 // guarantee that the compositor isn't using an old texture any more, so |
| 3560 // instead we force the layer to stop using any external resources which | 3602 // instead we force the layer to stop using any external resources which |
| 3561 // synchronizes with the compositor thread, and makes it safe to run the | 3603 // synchronizes with the compositor thread, and makes it safe to run the |
| 3562 // callback. | 3604 // callback. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3615 RenderWidgetHost* widget) { | 3657 RenderWidgetHost* widget) { |
| 3616 return new RenderWidgetHostViewAura(widget); | 3658 return new RenderWidgetHostViewAura(widget); |
| 3617 } | 3659 } |
| 3618 | 3660 |
| 3619 // static | 3661 // static |
| 3620 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3662 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3621 GetScreenInfoForWindow(results, NULL); | 3663 GetScreenInfoForWindow(results, NULL); |
| 3622 } | 3664 } |
| 3623 | 3665 |
| 3624 } // namespace content | 3666 } // namespace content |
| OLD | NEW |