| 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 16 matching lines...) Expand all Loading... |
| 27 #include "content/browser/renderer_host/compositor_resize_lock_aura.h" | 27 #include "content/browser/renderer_host/compositor_resize_lock_aura.h" |
| 28 #include "content/browser/renderer_host/dip_util.h" | 28 #include "content/browser/renderer_host/dip_util.h" |
| 29 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" | 29 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" |
| 30 #include "content/browser/renderer_host/overscroll_controller.h" | 30 #include "content/browser/renderer_host/overscroll_controller.h" |
| 31 #include "content/browser/renderer_host/render_view_host_delegate.h" | 31 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 32 #include "content/browser/renderer_host/render_widget_host_impl.h" | 32 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 33 #include "content/browser/renderer_host/ui_events_helper.h" | 33 #include "content/browser/renderer_host/ui_events_helper.h" |
| 34 #include "content/browser/renderer_host/web_input_event_aura.h" | 34 #include "content/browser/renderer_host/web_input_event_aura.h" |
| 35 #include "content/common/gpu/client/gl_helper.h" | 35 #include "content/common/gpu/client/gl_helper.h" |
| 36 #include "content/common/gpu/gpu_messages.h" | 36 #include "content/common/gpu/gpu_messages.h" |
| 37 #include "content/common/input_messages.h" |
| 37 #include "content/common/view_messages.h" | 38 #include "content/common/view_messages.h" |
| 38 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" | 39 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" |
| 39 #include "content/port/browser/render_widget_host_view_port.h" | 40 #include "content/port/browser/render_widget_host_view_port.h" |
| 40 #include "content/public/browser/content_browser_client.h" | 41 #include "content/public/browser/content_browser_client.h" |
| 41 #include "content/public/browser/render_process_host.h" | 42 #include "content/public/browser/render_process_host.h" |
| 42 #include "content/public/browser/render_view_host.h" | 43 #include "content/public/browser/render_view_host.h" |
| 43 #include "content/public/browser/user_metrics.h" | 44 #include "content/public/browser/user_metrics.h" |
| 44 #include "content/public/common/content_switches.h" | 45 #include "content/public/common/content_switches.h" |
| 45 #include "media/base/video_util.h" | 46 #include "media/base/video_util.h" |
| 46 #include "skia/ext/image_operations.h" | 47 #include "skia/ext/image_operations.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 #if defined(OS_WIN) | 84 #if defined(OS_WIN) |
| 84 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 85 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
| 85 #include "content/browser/accessibility/browser_accessibility_win.h" | 86 #include "content/browser/accessibility/browser_accessibility_win.h" |
| 86 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" | 87 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" |
| 87 #include "content/common/plugin_constants_win.h" | 88 #include "content/common/plugin_constants_win.h" |
| 88 #include "ui/base/win/hidden_window.h" | 89 #include "ui/base/win/hidden_window.h" |
| 89 #include "ui/gfx/gdi_util.h" | 90 #include "ui/gfx/gdi_util.h" |
| 90 #include "ui/gfx/win/dpi.h" | 91 #include "ui/gfx/win/dpi.h" |
| 91 #endif | 92 #endif |
| 92 | 93 |
| 94 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 95 #include "content/public/browser/keybinding_handler_aurax11.h" |
| 96 #include "content/public/browser/keybinding_handler_factory_aurax11.h" |
| 97 #endif |
| 98 |
| 93 using gfx::RectToSkIRect; | 99 using gfx::RectToSkIRect; |
| 94 using gfx::SkIRectToRect; | 100 using gfx::SkIRectToRect; |
| 95 | 101 |
| 96 using blink::WebScreenInfo; | 102 using blink::WebScreenInfo; |
| 97 using blink::WebTouchEvent; | 103 using blink::WebTouchEvent; |
| 98 | 104 |
| 99 namespace content { | 105 namespace content { |
| 100 | 106 |
| 101 namespace { | 107 namespace { |
| 102 | 108 |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 // RenderWidgetHostViewAndroid should also be moved at the same time. | 519 // RenderWidgetHostViewAndroid should also be moved at the same time. |
| 514 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, | 520 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, |
| 515 OnTextInputStateChanged) | 521 OnTextInputStateChanged) |
| 516 IPC_MESSAGE_UNHANDLED(handled = false) | 522 IPC_MESSAGE_UNHANDLED(handled = false) |
| 517 IPC_END_MESSAGE_MAP() | 523 IPC_END_MESSAGE_MAP() |
| 518 return handled; | 524 return handled; |
| 519 } | 525 } |
| 520 | 526 |
| 521 void RenderWidgetHostViewAura::InitAsChild( | 527 void RenderWidgetHostViewAura::InitAsChild( |
| 522 gfx::NativeView parent_view) { | 528 gfx::NativeView parent_view) { |
| 529 DoSharedInit(); |
| 523 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 530 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
| 524 window_->Init(aura::WINDOW_LAYER_TEXTURED); | 531 window_->Init(aura::WINDOW_LAYER_TEXTURED); |
| 525 window_->SetName("RenderWidgetHostViewAura"); | 532 window_->SetName("RenderWidgetHostViewAura"); |
| 526 } | 533 } |
| 527 | 534 |
| 528 void RenderWidgetHostViewAura::InitAsPopup( | 535 void RenderWidgetHostViewAura::InitAsPopup( |
| 529 RenderWidgetHostView* parent_host_view, | 536 RenderWidgetHostView* parent_host_view, |
| 530 const gfx::Rect& bounds_in_screen) { | 537 const gfx::Rect& bounds_in_screen) { |
| 531 popup_parent_host_view_ = | 538 popup_parent_host_view_ = |
| 532 static_cast<RenderWidgetHostViewAura*>(parent_host_view); | 539 static_cast<RenderWidgetHostViewAura*>(parent_host_view); |
| 540 DoSharedInit(); |
| 533 | 541 |
| 534 // TransientWindowClient may be NULL during tests. | 542 // TransientWindowClient may be NULL during tests. |
| 535 aura::client::TransientWindowClient* transient_window_client = | 543 aura::client::TransientWindowClient* transient_window_client = |
| 536 aura::client::GetTransientWindowClient(); | 544 aura::client::GetTransientWindowClient(); |
| 537 RenderWidgetHostViewAura* old_child = | 545 RenderWidgetHostViewAura* old_child = |
| 538 popup_parent_host_view_->popup_child_host_view_; | 546 popup_parent_host_view_->popup_child_host_view_; |
| 539 if (old_child) { | 547 if (old_child) { |
| 540 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or | 548 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or |
| 541 // similar mechanism to ensure a second popup doesn't cause the first one | 549 // similar mechanism to ensure a second popup doesn't cause the first one |
| 542 // to never get a chance to filter events. See crbug.com/160589. | 550 // to never get a chance to filter events. See crbug.com/160589. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 567 #if !defined(OS_WIN) && !defined(OS_CHROMEOS) | 575 #if !defined(OS_WIN) && !defined(OS_CHROMEOS) |
| 568 if (NeedsInputGrab()) | 576 if (NeedsInputGrab()) |
| 569 window_->SetCapture(); | 577 window_->SetCapture(); |
| 570 #endif | 578 #endif |
| 571 | 579 |
| 572 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); | 580 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); |
| 573 } | 581 } |
| 574 | 582 |
| 575 void RenderWidgetHostViewAura::InitAsFullscreen( | 583 void RenderWidgetHostViewAura::InitAsFullscreen( |
| 576 RenderWidgetHostView* reference_host_view) { | 584 RenderWidgetHostView* reference_host_view) { |
| 585 DoSharedInit(); |
| 577 is_fullscreen_ = true; | 586 is_fullscreen_ = true; |
| 578 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 587 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 579 window_->Init(aura::WINDOW_LAYER_TEXTURED); | 588 window_->Init(aura::WINDOW_LAYER_TEXTURED); |
| 580 window_->SetName("RenderWidgetHostViewAura"); | 589 window_->SetName("RenderWidgetHostViewAura"); |
| 581 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 590 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 582 | 591 |
| 583 aura::Window* parent = NULL; | 592 aura::Window* parent = NULL; |
| 584 gfx::Rect bounds; | 593 gfx::Rect bounds; |
| 585 if (reference_host_view) { | 594 if (reference_host_view) { |
| 586 aura::Window* reference_window = | 595 aura::Window* reference_window = |
| (...skipping 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2369 | 2378 |
| 2370 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547 | 2379 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547 |
| 2371 if (host_ && (accept_return_character_ || ch != ui::VKEY_RETURN)) { | 2380 if (host_ && (accept_return_character_ || ch != ui::VKEY_RETURN)) { |
| 2372 double now = ui::EventTimeForNow().InSecondsF(); | 2381 double now = ui::EventTimeForNow().InSecondsF(); |
| 2373 // Send a blink::WebInputEvent::Char event to |host_|. | 2382 // Send a blink::WebInputEvent::Char event to |host_|. |
| 2374 NativeWebKeyboardEvent webkit_event(ui::ET_KEY_PRESSED, | 2383 NativeWebKeyboardEvent webkit_event(ui::ET_KEY_PRESSED, |
| 2375 true /* is_char */, | 2384 true /* is_char */, |
| 2376 ch, | 2385 ch, |
| 2377 flags, | 2386 flags, |
| 2378 now); | 2387 now); |
| 2379 host_->ForwardKeyboardEvent(webkit_event); | 2388 ForwardKeyboardEvent(webkit_event); |
| 2380 } | 2389 } |
| 2381 } | 2390 } |
| 2382 | 2391 |
| 2383 gfx::NativeWindow RenderWidgetHostViewAura::GetAttachedWindow() const { | 2392 gfx::NativeWindow RenderWidgetHostViewAura::GetAttachedWindow() const { |
| 2384 return window_; | 2393 return window_; |
| 2385 } | 2394 } |
| 2386 | 2395 |
| 2387 ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const { | 2396 ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const { |
| 2388 return text_input_type_; | 2397 return text_input_type_; |
| 2389 } | 2398 } |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2810 } | 2819 } |
| 2811 | 2820 |
| 2812 // We don't have to communicate with an input method here. | 2821 // We don't have to communicate with an input method here. |
| 2813 if (!event->HasNativeEvent()) { | 2822 if (!event->HasNativeEvent()) { |
| 2814 NativeWebKeyboardEvent webkit_event( | 2823 NativeWebKeyboardEvent webkit_event( |
| 2815 event->type(), | 2824 event->type(), |
| 2816 event->is_char(), | 2825 event->is_char(), |
| 2817 event->is_char() ? event->GetCharacter() : event->key_code(), | 2826 event->is_char() ? event->GetCharacter() : event->key_code(), |
| 2818 event->flags(), | 2827 event->flags(), |
| 2819 ui::EventTimeForNow().InSecondsF()); | 2828 ui::EventTimeForNow().InSecondsF()); |
| 2820 host_->ForwardKeyboardEvent(webkit_event); | 2829 ForwardKeyboardEvent(webkit_event); |
| 2821 } else { | 2830 } else { |
| 2822 NativeWebKeyboardEvent webkit_event(event); | 2831 NativeWebKeyboardEvent webkit_event(event); |
| 2823 host_->ForwardKeyboardEvent(webkit_event); | 2832 ForwardKeyboardEvent(webkit_event); |
| 2824 } | 2833 } |
| 2825 } | 2834 } |
| 2826 event->SetHandled(); | 2835 event->SetHandled(); |
| 2827 } | 2836 } |
| 2828 | 2837 |
| 2829 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { | 2838 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { |
| 2830 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent"); | 2839 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent"); |
| 2831 | 2840 |
| 2832 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 2841 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) |
| 2833 return; | 2842 return; |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3362 } | 3371 } |
| 3363 active_frame_subscriber_textures_.clear(); | 3372 active_frame_subscriber_textures_.clear(); |
| 3364 | 3373 |
| 3365 #if defined(OS_WIN) | 3374 #if defined(OS_WIN) |
| 3366 legacy_render_widget_host_HWND_.reset(NULL); | 3375 legacy_render_widget_host_HWND_.reset(NULL); |
| 3367 #endif | 3376 #endif |
| 3368 | 3377 |
| 3369 DCHECK(!vsync_manager_); | 3378 DCHECK(!vsync_manager_); |
| 3370 } | 3379 } |
| 3371 | 3380 |
| 3381 void RenderWidgetHostViewAura::DoSharedInit() { |
| 3382 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 3383 key_bindings_handler_.reset(KeybindingHandlerFactoryAuraX11::Build()); |
| 3384 #endif |
| 3385 } |
| 3386 |
| 3372 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { | 3387 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { |
| 3373 const gfx::Point screen_point = | 3388 const gfx::Point screen_point = |
| 3374 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | 3389 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); |
| 3375 aura::Window* root_window = window_->GetRootWindow(); | 3390 aura::Window* root_window = window_->GetRootWindow(); |
| 3376 if (!root_window) | 3391 if (!root_window) |
| 3377 return; | 3392 return; |
| 3378 | 3393 |
| 3379 gfx::Point root_window_point = screen_point; | 3394 gfx::Point root_window_point = screen_point; |
| 3380 aura::client::ScreenPositionClient* screen_position_client = | 3395 aura::client::ScreenPositionClient* screen_position_client = |
| 3381 aura::client::GetScreenPositionClient(root_window); | 3396 aura::client::GetScreenPositionClient(root_window); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3586 aura::WindowTreeHost* host = window_->GetHost(); | 3601 aura::WindowTreeHost* host = window_->GetHost(); |
| 3587 return host ? host->compositor() : NULL; | 3602 return host ? host->compositor() : NULL; |
| 3588 } | 3603 } |
| 3589 | 3604 |
| 3590 void RenderWidgetHostViewAura::DetachFromInputMethod() { | 3605 void RenderWidgetHostViewAura::DetachFromInputMethod() { |
| 3591 ui::InputMethod* input_method = GetInputMethod(); | 3606 ui::InputMethod* input_method = GetInputMethod(); |
| 3592 if (input_method && input_method->GetTextInputClient() == this) | 3607 if (input_method && input_method->GetTextInputClient() == this) |
| 3593 input_method->SetFocusedTextInputClient(NULL); | 3608 input_method->SetFocusedTextInputClient(NULL); |
| 3594 } | 3609 } |
| 3595 | 3610 |
| 3611 void RenderWidgetHostViewAura::ForwardKeyboardEvent( |
| 3612 const NativeWebKeyboardEvent& event) { |
| 3613 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 3614 EditCommands edit_commands; |
| 3615 if (!event.skip_in_browser && |
| 3616 key_bindings_handler_ && |
| 3617 key_bindings_handler_->Match(event, &edit_commands)) { |
| 3618 host_->Send(new InputMsg_SetEditCommandsForNextKeyEvent( |
| 3619 host_->GetRoutingID(), edit_commands)); |
| 3620 NativeWebKeyboardEvent copy_event(event); |
| 3621 copy_event.match_edit_command = true; |
| 3622 host_->ForwardKeyboardEvent(copy_event); |
| 3623 return; |
| 3624 } |
| 3625 #endif |
| 3626 |
| 3627 host_->ForwardKeyboardEvent(event); |
| 3628 } |
| 3629 |
| 3596 void RenderWidgetHostViewAura::LockResources() { | 3630 void RenderWidgetHostViewAura::LockResources() { |
| 3597 DCHECK(frame_provider_); | 3631 DCHECK(frame_provider_); |
| 3598 delegated_frame_evictor_->LockFrame(); | 3632 delegated_frame_evictor_->LockFrame(); |
| 3599 } | 3633 } |
| 3600 | 3634 |
| 3601 void RenderWidgetHostViewAura::UnlockResources() { | 3635 void RenderWidgetHostViewAura::UnlockResources() { |
| 3602 DCHECK(frame_provider_); | 3636 DCHECK(frame_provider_); |
| 3603 delegated_frame_evictor_->UnlockFrame(); | 3637 delegated_frame_evictor_->UnlockFrame(); |
| 3604 } | 3638 } |
| 3605 | 3639 |
| 3606 SkBitmap::Config RenderWidgetHostViewAura::PreferredReadbackFormat() { | 3640 SkBitmap::Config RenderWidgetHostViewAura::PreferredReadbackFormat() { |
| 3607 return SkBitmap::kARGB_8888_Config; | 3641 return SkBitmap::kARGB_8888_Config; |
| 3608 } | 3642 } |
| 3609 | 3643 |
| 3610 //////////////////////////////////////////////////////////////////////////////// | 3644 //////////////////////////////////////////////////////////////////////////////// |
| 3611 // RenderWidgetHostView, public: | 3645 // RenderWidgetHostView, public: |
| 3612 | 3646 |
| 3613 // static | 3647 // static |
| 3614 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( | 3648 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
| 3615 RenderWidgetHost* widget) { | 3649 RenderWidgetHost* widget) { |
| 3616 return new RenderWidgetHostViewAura(widget); | 3650 return new RenderWidgetHostViewAura(widget); |
| 3617 } | 3651 } |
| 3618 | 3652 |
| 3619 // static | 3653 // static |
| 3620 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3654 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3621 GetScreenInfoForWindow(results, NULL); | 3655 GetScreenInfoForWindow(results, NULL); |
| 3622 } | 3656 } |
| 3623 | 3657 |
| 3624 } // namespace content | 3658 } // namespace content |
| OLD | NEW |