| 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 if (transient_window_client) { | 529 if (transient_window_client) { |
| 530 transient_window_client->AddTransientChild( | 530 transient_window_client->AddTransientChild( |
| 531 popup_parent_host_view_->window_, window_); | 531 popup_parent_host_view_->window_, window_); |
| 532 } | 532 } |
| 533 | 533 |
| 534 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); | 534 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); |
| 535 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); | 535 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); |
| 536 | 536 |
| 537 SetBounds(bounds_in_screen); | 537 SetBounds(bounds_in_screen); |
| 538 Show(); | 538 Show(); |
| 539 if (NeedsMouseCapture()) | |
| 540 window_->SetCapture(); | |
| 541 | 539 |
| 542 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); | 540 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); |
| 543 } | 541 } |
| 544 | 542 |
| 545 void RenderWidgetHostViewAura::InitAsFullscreen( | 543 void RenderWidgetHostViewAura::InitAsFullscreen( |
| 546 RenderWidgetHostView* reference_host_view) { | 544 RenderWidgetHostView* reference_host_view) { |
| 547 is_fullscreen_ = true; | 545 is_fullscreen_ = true; |
| 548 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 546 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 549 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); | 547 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
| 550 window_->SetName("RenderWidgetHostViewAura"); | 548 window_->SetName("RenderWidgetHostViewAura"); |
| (...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 } | 1439 } |
| 1442 | 1440 |
| 1443 void RenderWidgetHostViewAura::InsertText(const base::string16& text) { | 1441 void RenderWidgetHostViewAura::InsertText(const base::string16& text) { |
| 1444 DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); | 1442 DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); |
| 1445 if (host_) | 1443 if (host_) |
| 1446 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false); | 1444 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false); |
| 1447 has_composition_text_ = false; | 1445 has_composition_text_ = false; |
| 1448 } | 1446 } |
| 1449 | 1447 |
| 1450 void RenderWidgetHostViewAura::InsertChar(base::char16 ch, int flags) { | 1448 void RenderWidgetHostViewAura::InsertChar(base::char16 ch, int flags) { |
| 1451 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { | |
| 1452 popup_child_host_view_->InsertChar(ch, flags); | |
| 1453 return; | |
| 1454 } | |
| 1455 | |
| 1456 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547 | 1449 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547 |
| 1457 if (host_ && (accept_return_character_ || ch != ui::VKEY_RETURN)) { | 1450 if (host_ && (accept_return_character_ || ch != ui::VKEY_RETURN)) { |
| 1458 double now = ui::EventTimeForNow().InSecondsF(); | 1451 double now = ui::EventTimeForNow().InSecondsF(); |
| 1459 // Send a blink::WebInputEvent::Char event to |host_|. | 1452 // Send a blink::WebInputEvent::Char event to |host_|. |
| 1460 NativeWebKeyboardEvent webkit_event(ui::ET_KEY_PRESSED, | 1453 NativeWebKeyboardEvent webkit_event(ui::ET_KEY_PRESSED, |
| 1461 true /* is_char */, | 1454 true /* is_char */, |
| 1462 ch, | 1455 ch, |
| 1463 flags, | 1456 flags, |
| 1464 now); | 1457 now); |
| 1465 ForwardKeyboardEvent(webkit_event); | 1458 ForwardKeyboardEvent(webkit_event); |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1795 } | 1788 } |
| 1796 | 1789 |
| 1797 //////////////////////////////////////////////////////////////////////////////// | 1790 //////////////////////////////////////////////////////////////////////////////// |
| 1798 // RenderWidgetHostViewAura, ui::EventHandler implementation: | 1791 // RenderWidgetHostViewAura, ui::EventHandler implementation: |
| 1799 | 1792 |
| 1800 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { | 1793 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { |
| 1801 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); | 1794 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); |
| 1802 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 1795 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) |
| 1803 return; | 1796 return; |
| 1804 | 1797 |
| 1805 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { | |
| 1806 popup_child_host_view_->OnKeyEvent(event); | |
| 1807 if (event->handled()) | |
| 1808 return; | |
| 1809 } | |
| 1810 | |
| 1811 // We need to handle the Escape key for Pepper Flash. | 1798 // We need to handle the Escape key for Pepper Flash. |
| 1812 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { | 1799 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { |
| 1813 // Focus the window we were created from. | 1800 // Focus the window we were created from. |
| 1814 if (host_tracker_.get() && !host_tracker_->windows().empty()) { | 1801 if (host_tracker_.get() && !host_tracker_->windows().empty()) { |
| 1815 aura::Window* host = *(host_tracker_->windows().begin()); | 1802 aura::Window* host = *(host_tracker_->windows().begin()); |
| 1816 aura::client::FocusClient* client = aura::client::GetFocusClient(host); | 1803 aura::client::FocusClient* client = aura::client::GetFocusClient(host); |
| 1817 if (client) { | 1804 if (client) { |
| 1818 // Calling host->Focus() may delete |this|. We create a local observer | 1805 // Calling host->Focus() may delete |this|. We create a local observer |
| 1819 // for that. In that case we exit without further access to any members. | 1806 // for that. In that case we exit without further access to any members. |
| 1820 aura::WindowTracker tracker; | 1807 aura::WindowTracker tracker; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 // have grabbed keyboard focus. | 1953 // have grabbed keyboard focus. |
| 1967 if (event->type() == ui::ET_MOUSE_PRESSED) | 1954 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 1968 SetKeyboardFocus(); | 1955 SetKeyboardFocus(); |
| 1969 } | 1956 } |
| 1970 | 1957 |
| 1971 switch (event->type()) { | 1958 switch (event->type()) { |
| 1972 case ui::ET_MOUSE_PRESSED: | 1959 case ui::ET_MOUSE_PRESSED: |
| 1973 window_->SetCapture(); | 1960 window_->SetCapture(); |
| 1974 break; | 1961 break; |
| 1975 case ui::ET_MOUSE_RELEASED: | 1962 case ui::ET_MOUSE_RELEASED: |
| 1976 if (!NeedsMouseCapture()) | 1963 window_->ReleaseCapture(); |
| 1977 window_->ReleaseCapture(); | |
| 1978 break; | 1964 break; |
| 1979 default: | 1965 default: |
| 1980 break; | 1966 break; |
| 1981 } | 1967 } |
| 1982 | 1968 |
| 1983 // Needed to propagate mouse event to |window_->parent()->delegate()|, but | 1969 // Needed to propagate mouse event to |window_->parent()->delegate()|, but |
| 1984 // note that it might be something other than a WebContentsViewAura instance. | 1970 // note that it might be something other than a WebContentsViewAura instance. |
| 1985 // TODO(pkotwicz): Find a better way of doing this. | 1971 // TODO(pkotwicz): Find a better way of doing this. |
| 1986 // In fullscreen mode which is typically used by flash, don't forward | 1972 // In fullscreen mode which is typically used by flash, don't forward |
| 1987 // the mouse events to the parent. The renderer and the plugin process | 1973 // the mouse events to the parent. The renderer and the plugin process |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2308 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); | 2294 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); |
| 2309 } | 2295 } |
| 2310 | 2296 |
| 2311 void RenderWidgetHostViewAura::Shutdown() { | 2297 void RenderWidgetHostViewAura::Shutdown() { |
| 2312 if (!in_shutdown_) { | 2298 if (!in_shutdown_) { |
| 2313 in_shutdown_ = true; | 2299 in_shutdown_ = true; |
| 2314 host_->Shutdown(); | 2300 host_->Shutdown(); |
| 2315 } | 2301 } |
| 2316 } | 2302 } |
| 2317 | 2303 |
| 2318 bool RenderWidgetHostViewAura::NeedsInputGrab() { | |
| 2319 return popup_type_ == blink::WebPopupTypeSelect; | |
| 2320 } | |
| 2321 | |
| 2322 bool RenderWidgetHostViewAura::NeedsMouseCapture() { | |
| 2323 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 2324 return NeedsInputGrab(); | |
| 2325 #endif | |
| 2326 return false; | |
| 2327 } | |
| 2328 | |
| 2329 void RenderWidgetHostViewAura::FinishImeCompositionSession() { | 2304 void RenderWidgetHostViewAura::FinishImeCompositionSession() { |
| 2330 if (!has_composition_text_) | 2305 if (!has_composition_text_) |
| 2331 return; | 2306 return; |
| 2332 if (host_) { | 2307 if (host_) { |
| 2333 host_->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), | 2308 host_->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), |
| 2334 false); | 2309 false); |
| 2335 } | 2310 } |
| 2336 ImeCancelComposition(); | 2311 ImeCancelComposition(); |
| 2337 } | 2312 } |
| 2338 | 2313 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2573 | 2548 |
| 2574 //////////////////////////////////////////////////////////////////////////////// | 2549 //////////////////////////////////////////////////////////////////////////////// |
| 2575 // RenderWidgetHostViewBase, public: | 2550 // RenderWidgetHostViewBase, public: |
| 2576 | 2551 |
| 2577 // static | 2552 // static |
| 2578 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2553 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2579 GetScreenInfoForWindow(results, NULL); | 2554 GetScreenInfoForWindow(results, NULL); |
| 2580 } | 2555 } |
| 2581 | 2556 |
| 2582 } // namespace content | 2557 } // namespace content |
| OLD | NEW |