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" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 return; | 338 return; |
339 } | 339 } |
340 | 340 |
341 aura::Window* target = static_cast<aura::Window*>(event->target()); | 341 aura::Window* target = static_cast<aura::Window*>(event->target()); |
342 if (target != window_ && | 342 if (target != window_ && |
343 (!popup_parent_host_view_ || | 343 (!popup_parent_host_view_ || |
344 target != popup_parent_host_view_->window_)) { | 344 target != popup_parent_host_view_->window_)) { |
345 // If we enter this code path it means that we did not receive any focus | 345 // If we enter this code path it means that we did not receive any focus |
346 // lost notifications for the popup window. Ensure that blink is aware | 346 // lost notifications for the popup window. Ensure that blink is aware |
347 // of the fact that focus was lost for the host window by sending a Blur | 347 // of the fact that focus was lost for the host window by sending a Blur |
348 // notification. We also set a flag in the view indicating that we need | 348 // notification. |
349 // to force a Focus notification on the next mouse down. | 349 if (popup_parent_host_view_ && popup_parent_host_view_->host_) |
350 if (popup_parent_host_view_ && popup_parent_host_view_->host_) { | |
351 popup_parent_host_view_->set_focus_on_mouse_down_ = true; | |
352 popup_parent_host_view_->host_->Blur(); | 350 popup_parent_host_view_->host_->Blur(); |
353 } | |
354 // Note: popup_parent_host_view_ may be NULL when there are multiple | 351 // Note: popup_parent_host_view_ may be NULL when there are multiple |
355 // popup children per view. See: RenderWidgetHostViewAura::InitAsPopup(). | 352 // popup children per view. See: RenderWidgetHostViewAura::InitAsPopup(). |
356 Shutdown(); | 353 Shutdown(); |
357 } | 354 } |
358 } | 355 } |
359 | 356 |
360 // We have to implement the WindowObserver interface on a separate object | 357 // We have to implement the WindowObserver interface on a separate object |
361 // because clang doesn't like implementing multiple interfaces that have | 358 // because clang doesn't like implementing multiple interfaces that have |
362 // methods with the same name. This object is owned by the | 359 // methods with the same name. This object is owned by the |
363 // RenderWidgetHostViewAura. | 360 // RenderWidgetHostViewAura. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 synthetic_move_sent_(false), | 462 synthetic_move_sent_(false), |
466 cursor_visibility_state_in_renderer_(UNKNOWN), | 463 cursor_visibility_state_in_renderer_(UNKNOWN), |
467 #if defined(OS_WIN) | 464 #if defined(OS_WIN) |
468 legacy_render_widget_host_HWND_(NULL), | 465 legacy_render_widget_host_HWND_(NULL), |
469 legacy_window_destroyed_(false), | 466 legacy_window_destroyed_(false), |
470 showing_context_menu_(false), | 467 showing_context_menu_(false), |
471 #endif | 468 #endif |
472 has_snapped_to_boundary_(false), | 469 has_snapped_to_boundary_(false), |
473 is_guest_view_hack_(is_guest_view_hack), | 470 is_guest_view_hack_(is_guest_view_hack), |
474 begin_frame_observer_proxy_(this), | 471 begin_frame_observer_proxy_(this), |
475 set_focus_on_mouse_down_(false), | |
476 weak_ptr_factory_(this) { | 472 weak_ptr_factory_(this) { |
477 if (!is_guest_view_hack_) | 473 if (!is_guest_view_hack_) |
478 host_->SetView(this); | 474 host_->SetView(this); |
479 | 475 |
480 window_observer_.reset(new WindowObserver(this)); | 476 window_observer_.reset(new WindowObserver(this)); |
481 | 477 |
482 aura::client::SetTooltipText(window_, &tooltip_); | 478 aura::client::SetTooltipText(window_, &tooltip_); |
483 aura::client::SetActivationDelegate(window_, this); | 479 aura::client::SetActivationDelegate(window_, this); |
484 aura::client::SetFocusChangeObserver(window_, this); | 480 aura::client::SetFocusChangeObserver(window_, this); |
485 window_->set_layer_owner_delegate(delegated_frame_host_.get()); | 481 window_->set_layer_owner_delegate(delegated_frame_host_.get()); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 } | 737 } |
742 | 738 |
743 void RenderWidgetHostViewAura::SetKeyboardFocus() { | 739 void RenderWidgetHostViewAura::SetKeyboardFocus() { |
744 #if defined(OS_WIN) | 740 #if defined(OS_WIN) |
745 if (CanFocus()) { | 741 if (CanFocus()) { |
746 aura::WindowTreeHost* host = window_->GetHost(); | 742 aura::WindowTreeHost* host = window_->GetHost(); |
747 if (host) | 743 if (host) |
748 ::SetFocus(host->GetAcceleratedWidget()); | 744 ::SetFocus(host->GetAcceleratedWidget()); |
749 } | 745 } |
750 #endif | 746 #endif |
751 if (host_ && set_focus_on_mouse_down_) { | |
752 set_focus_on_mouse_down_ = false; | |
753 host_->Focus(); | |
754 } | |
755 } | 747 } |
756 | 748 |
757 RenderFrameHostImpl* RenderWidgetHostViewAura::GetFocusedFrame() { | 749 RenderFrameHostImpl* RenderWidgetHostViewAura::GetFocusedFrame() { |
758 if (!host_->IsRenderView()) | 750 if (!host_->IsRenderView()) |
759 return NULL; | 751 return NULL; |
760 RenderViewHost* rvh = RenderViewHost::From(host_); | 752 RenderViewHost* rvh = RenderViewHost::From(host_); |
761 FrameTreeNode* focused_frame = | 753 FrameTreeNode* focused_frame = |
762 rvh->GetDelegate()->GetFrameTree()->GetFocusedFrame(); | 754 rvh->GetDelegate()->GetFrameTree()->GetFocusedFrame(); |
763 if (!focused_frame) | 755 if (!focused_frame) |
764 return NULL; | 756 return NULL; |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 | 1507 |
1516 void RenderWidgetHostViewAura::UnlockMouse() { | 1508 void RenderWidgetHostViewAura::UnlockMouse() { |
1517 tooltip_disabler_.reset(); | 1509 tooltip_disabler_.reset(); |
1518 | 1510 |
1519 aura::Window* root_window = window_->GetRootWindow(); | 1511 aura::Window* root_window = window_->GetRootWindow(); |
1520 if (!mouse_locked_ || !root_window) | 1512 if (!mouse_locked_ || !root_window) |
1521 return; | 1513 return; |
1522 | 1514 |
1523 mouse_locked_ = false; | 1515 mouse_locked_ = false; |
1524 | 1516 |
1525 #if !defined(OS_WIN) | 1517 if (window_->HasCapture()) |
1526 window_->ReleaseCapture(); | 1518 window_->ReleaseCapture(); |
1527 #else | 1519 |
| 1520 #if defined(OS_WIN) |
1528 ::ClipCursor(NULL); | 1521 ::ClipCursor(NULL); |
1529 #endif | 1522 #endif |
| 1523 |
1530 window_->MoveCursorTo(unlocked_mouse_position_); | 1524 window_->MoveCursorTo(unlocked_mouse_position_); |
1531 aura::client::CursorClient* cursor_client = | 1525 aura::client::CursorClient* cursor_client = |
1532 aura::client::GetCursorClient(root_window); | 1526 aura::client::GetCursorClient(root_window); |
1533 if (cursor_client) { | 1527 if (cursor_client) { |
1534 cursor_client->UnlockCursor(); | 1528 cursor_client->UnlockCursor(); |
1535 cursor_client->ShowCursor(); | 1529 cursor_client->ShowCursor(); |
1536 } | 1530 } |
1537 | 1531 |
1538 host_->LostMouseLock(); | 1532 host_->LostMouseLock(); |
1539 } | 1533 } |
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2837 | 2831 |
2838 //////////////////////////////////////////////////////////////////////////////// | 2832 //////////////////////////////////////////////////////////////////////////////// |
2839 // RenderWidgetHostViewBase, public: | 2833 // RenderWidgetHostViewBase, public: |
2840 | 2834 |
2841 // static | 2835 // static |
2842 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2836 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2843 GetScreenInfoForWindow(results, NULL); | 2837 GetScreenInfoForWindow(results, NULL); |
2844 } | 2838 } |
2845 | 2839 |
2846 } // namespace content | 2840 } // namespace content |
OLD | NEW |