| 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 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 18 #include "cc/base/switches.h" |
| 18 #include "cc/layers/layer.h" | 19 #include "cc/layers/layer.h" |
| 19 #include "cc/output/copy_output_request.h" | 20 #include "cc/output/copy_output_request.h" |
| 20 #include "cc/output/copy_output_result.h" | 21 #include "cc/output/copy_output_result.h" |
| 21 #include "cc/resources/texture_mailbox.h" | 22 #include "cc/resources/texture_mailbox.h" |
| 22 #include "cc/trees/layer_tree_settings.h" | 23 #include "cc/trees/layer_tree_settings.h" |
| 23 #include "content/browser/accessibility/browser_accessibility_manager.h" | 24 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 24 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 25 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| 25 #include "content/browser/bad_message.h" | 26 #include "content/browser/bad_message.h" |
| 26 #include "content/browser/frame_host/frame_tree.h" | 27 #include "content/browser/frame_host/frame_tree.h" |
| 27 #include "content/browser/frame_host/frame_tree_node.h" | 28 #include "content/browser/frame_host/frame_tree_node.h" |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 paint_canvas_(NULL), | 467 paint_canvas_(NULL), |
| 467 synthetic_move_sent_(false), | 468 synthetic_move_sent_(false), |
| 468 cursor_visibility_state_in_renderer_(UNKNOWN), | 469 cursor_visibility_state_in_renderer_(UNKNOWN), |
| 469 #if defined(OS_WIN) | 470 #if defined(OS_WIN) |
| 470 legacy_render_widget_host_HWND_(NULL), | 471 legacy_render_widget_host_HWND_(NULL), |
| 471 legacy_window_destroyed_(false), | 472 legacy_window_destroyed_(false), |
| 472 showing_context_menu_(false), | 473 showing_context_menu_(false), |
| 473 #endif | 474 #endif |
| 474 has_snapped_to_boundary_(false), | 475 has_snapped_to_boundary_(false), |
| 475 is_guest_view_hack_(is_guest_view_hack), | 476 is_guest_view_hack_(is_guest_view_hack), |
| 476 begin_frame_observer_proxy_(this), | |
| 477 set_focus_on_mouse_down_(false), | 477 set_focus_on_mouse_down_(false), |
| 478 weak_ptr_factory_(this) { | 478 weak_ptr_factory_(this) { |
| 479 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 480 cc::switches::kEnableBeginFrameScheduling)) { |
| 481 begin_frame_observer_proxy_.reset(new BeginFrameObserverProxy(this)); |
| 482 } |
| 483 |
| 479 if (!is_guest_view_hack_) | 484 if (!is_guest_view_hack_) |
| 480 host_->SetView(this); | 485 host_->SetView(this); |
| 481 | 486 |
| 482 window_observer_.reset(new WindowObserver(this)); | 487 window_observer_.reset(new WindowObserver(this)); |
| 483 | 488 |
| 484 aura::client::SetTooltipText(window_, &tooltip_); | 489 aura::client::SetTooltipText(window_, &tooltip_); |
| 485 aura::client::SetActivationDelegate(window_, this); | 490 aura::client::SetActivationDelegate(window_, this); |
| 486 aura::client::SetFocusChangeObserver(window_, this); | 491 aura::client::SetFocusChangeObserver(window_, this); |
| 487 window_->set_layer_owner_delegate(delegated_frame_host_.get()); | 492 window_->set_layer_owner_delegate(delegated_frame_host_.get()); |
| 488 gfx::Screen::GetScreenFor(window_)->AddObserver(this); | 493 gfx::Screen::GetScreenFor(window_)->AddObserver(this); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 | 740 |
| 736 NOTIMPLEMENTED(); | 741 NOTIMPLEMENTED(); |
| 737 return static_cast<gfx::NativeViewAccessible>(NULL); | 742 return static_cast<gfx::NativeViewAccessible>(NULL); |
| 738 } | 743 } |
| 739 | 744 |
| 740 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { | 745 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { |
| 741 return this; | 746 return this; |
| 742 } | 747 } |
| 743 | 748 |
| 744 void RenderWidgetHostViewAura::OnSetNeedsBeginFrames(bool needs_begin_frames) { | 749 void RenderWidgetHostViewAura::OnSetNeedsBeginFrames(bool needs_begin_frames) { |
| 745 begin_frame_observer_proxy_.SetNeedsBeginFrames(needs_begin_frames); | 750 DCHECK(begin_frame_observer_proxy_); |
| 751 begin_frame_observer_proxy_->SetNeedsBeginFrames(needs_begin_frames); |
| 746 } | 752 } |
| 747 | 753 |
| 748 void RenderWidgetHostViewAura::SendBeginFrame(const cc::BeginFrameArgs& args) { | 754 void RenderWidgetHostViewAura::SendBeginFrame(const cc::BeginFrameArgs& args) { |
| 755 host_->FlushInput(args.frame_time); |
| 749 delegated_frame_host_->SetVSyncParameters(args.frame_time, args.interval); | 756 delegated_frame_host_->SetVSyncParameters(args.frame_time, args.interval); |
| 750 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); | 757 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); |
| 751 } | 758 } |
| 752 | 759 |
| 753 void RenderWidgetHostViewAura::SetKeyboardFocus() { | 760 void RenderWidgetHostViewAura::SetKeyboardFocus() { |
| 754 #if defined(OS_WIN) | 761 #if defined(OS_WIN) |
| 755 if (CanFocus()) { | 762 if (CanFocus()) { |
| 756 aura::WindowTreeHost* host = window_->GetHost(); | 763 aura::WindowTreeHost* host = window_->GetHost(); |
| 757 if (host) | 764 if (host) |
| 758 ::SetFocus(host->GetAcceleratedWidget()); | 765 ::SetFocus(host->GetAcceleratedWidget()); |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 // that requires both animation and a fling-end notification. However, the | 1368 // that requires both animation and a fling-end notification. However, the |
| 1362 // OverscrollController consumes a fling to stop its propagation; it doesn't | 1369 // OverscrollController consumes a fling to stop its propagation; it doesn't |
| 1363 // actually tick a fling animation. Report no consumer to convey this. | 1370 // actually tick a fling animation. Report no consumer to convey this. |
| 1364 if (consumed && input_event.type == blink::WebInputEvent::GestureFlingStart) | 1371 if (consumed && input_event.type == blink::WebInputEvent::GestureFlingStart) |
| 1365 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | 1372 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; |
| 1366 | 1373 |
| 1367 return consumed ? INPUT_EVENT_ACK_STATE_CONSUMED | 1374 return consumed ? INPUT_EVENT_ACK_STATE_CONSUMED |
| 1368 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 1375 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 1369 } | 1376 } |
| 1370 | 1377 |
| 1378 void RenderWidgetHostViewAura::OnSetNeedsFlushInput() { |
| 1379 if (begin_frame_observer_proxy_) { |
| 1380 begin_frame_observer_proxy_->SetNeedsOneBeginFrame(); |
| 1381 return; |
| 1382 } |
| 1383 RenderWidgetHostViewBase::OnSetNeedsFlushInput(); |
| 1384 } |
| 1385 |
| 1371 BrowserAccessibilityManager* | 1386 BrowserAccessibilityManager* |
| 1372 RenderWidgetHostViewAura::CreateBrowserAccessibilityManager( | 1387 RenderWidgetHostViewAura::CreateBrowserAccessibilityManager( |
| 1373 BrowserAccessibilityDelegate* delegate) { | 1388 BrowserAccessibilityDelegate* delegate) { |
| 1374 BrowserAccessibilityManager* manager = NULL; | 1389 BrowserAccessibilityManager* manager = NULL; |
| 1375 #if defined(OS_WIN) | 1390 #if defined(OS_WIN) |
| 1376 manager = new BrowserAccessibilityManagerWin( | 1391 manager = new BrowserAccessibilityManagerWin( |
| 1377 BrowserAccessibilityManagerWin::GetEmptyDocument(), delegate); | 1392 BrowserAccessibilityManagerWin::GetEmptyDocument(), delegate); |
| 1378 #else | 1393 #else |
| 1379 manager = BrowserAccessibilityManager::Create( | 1394 manager = BrowserAccessibilityManager::Create( |
| 1380 BrowserAccessibilityManager::GetEmptyDocument(), delegate); | 1395 BrowserAccessibilityManager::GetEmptyDocument(), delegate); |
| (...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2692 | 2707 |
| 2693 #if defined(OS_WIN) | 2708 #if defined(OS_WIN) |
| 2694 // The parent may have changed here. Ensure that the legacy window is | 2709 // The parent may have changed here. Ensure that the legacy window is |
| 2695 // reparented accordingly. | 2710 // reparented accordingly. |
| 2696 if (legacy_render_widget_host_HWND_) | 2711 if (legacy_render_widget_host_HWND_) |
| 2697 legacy_render_widget_host_HWND_->UpdateParent( | 2712 legacy_render_widget_host_HWND_->UpdateParent( |
| 2698 reinterpret_cast<HWND>(GetNativeViewId())); | 2713 reinterpret_cast<HWND>(GetNativeViewId())); |
| 2699 #endif | 2714 #endif |
| 2700 | 2715 |
| 2701 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); | 2716 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); |
| 2702 if (window_->GetHost()->compositor()) | 2717 if (window_->GetHost()->compositor() && begin_frame_observer_proxy_) { |
| 2703 begin_frame_observer_proxy_.SetCompositor(window_->GetHost()->compositor()); | 2718 begin_frame_observer_proxy_->SetCompositor( |
| 2719 window_->GetHost()->compositor()); |
| 2720 } |
| 2704 } | 2721 } |
| 2705 | 2722 |
| 2706 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 2723 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
| 2707 aura::client::CursorClient* cursor_client = | 2724 aura::client::CursorClient* cursor_client = |
| 2708 aura::client::GetCursorClient(window_->GetRootWindow()); | 2725 aura::client::GetCursorClient(window_->GetRootWindow()); |
| 2709 if (cursor_client) | 2726 if (cursor_client) |
| 2710 cursor_client->RemoveObserver(this); | 2727 cursor_client->RemoveObserver(this); |
| 2711 | 2728 |
| 2712 DetachFromInputMethod(); | 2729 DetachFromInputMethod(); |
| 2713 | 2730 |
| 2714 window_->GetHost()->RemoveObserver(this); | 2731 window_->GetHost()->RemoveObserver(this); |
| 2715 delegated_frame_host_->ResetCompositor(); | 2732 delegated_frame_host_->ResetCompositor(); |
| 2716 begin_frame_observer_proxy_.ResetCompositor(); | 2733 if (begin_frame_observer_proxy_) |
| 2734 begin_frame_observer_proxy_->ResetCompositor(); |
| 2717 | 2735 |
| 2718 #if defined(OS_WIN) | 2736 #if defined(OS_WIN) |
| 2719 // Update the legacy window's parent temporarily to the desktop window. It | 2737 // Update the legacy window's parent temporarily to the desktop window. It |
| 2720 // will eventually get reparented to the right root. | 2738 // will eventually get reparented to the right root. |
| 2721 if (legacy_render_widget_host_HWND_) | 2739 if (legacy_render_widget_host_HWND_) |
| 2722 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); | 2740 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); |
| 2723 #endif | 2741 #endif |
| 2724 } | 2742 } |
| 2725 | 2743 |
| 2726 void RenderWidgetHostViewAura::DetachFromInputMethod() { | 2744 void RenderWidgetHostViewAura::DetachFromInputMethod() { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2884 | 2902 |
| 2885 //////////////////////////////////////////////////////////////////////////////// | 2903 //////////////////////////////////////////////////////////////////////////////// |
| 2886 // RenderWidgetHostViewBase, public: | 2904 // RenderWidgetHostViewBase, public: |
| 2887 | 2905 |
| 2888 // static | 2906 // static |
| 2889 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2907 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2890 GetScreenInfoForWindow(results, NULL); | 2908 GetScreenInfoForWindow(results, NULL); |
| 2891 } | 2909 } |
| 2892 | 2910 |
| 2893 } // namespace content | 2911 } // namespace content |
| OLD | NEW |