Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 652793003: Close the select box when the parent RWHVA loses focus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 event->type() != ui::ET_TOUCH_PRESSED) { 380 event->type() != ui::ET_TOUCH_PRESSED) {
381 return; 381 return;
382 } 382 }
383 383
384 aura::Window* target = static_cast<aura::Window*>(event->target()); 384 aura::Window* target = static_cast<aura::Window*>(event->target());
385 if (target != window_ && 385 if (target != window_ &&
386 (!popup_parent_host_view_ || 386 (!popup_parent_host_view_ ||
387 target != popup_parent_host_view_->window_)) { 387 target != popup_parent_host_view_->window_)) {
388 // Note: popup_parent_host_view_ may be NULL when there are multiple 388 // Note: popup_parent_host_view_ may be NULL when there are multiple
389 // popup children per view. See: RenderWidgetHostViewAura::InitAsPopup(). 389 // popup children per view. See: RenderWidgetHostViewAura::InitAsPopup().
390 in_shutdown_ = true; 390 Shutdown();
391 host_->Shutdown();
392 } 391 }
393 } 392 }
394 393
395 // We have to implement the WindowObserver interface on a separate object 394 // We have to implement the WindowObserver interface on a separate object
396 // because clang doesn't like implementing multiple interfaces that have 395 // because clang doesn't like implementing multiple interfaces that have
397 // methods with the same name. This object is owned by the 396 // methods with the same name. This object is owned by the
398 // RenderWidgetHostViewAura. 397 // RenderWidgetHostViewAura.
399 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { 398 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver {
400 public: 399 public:
401 explicit WindowObserver(RenderWidgetHostViewAura* view) 400 explicit WindowObserver(RenderWidgetHostViewAura* view)
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 aura::WindowTracker tracker; 1811 aura::WindowTracker tracker;
1813 aura::Window* window = window_; 1812 aura::Window* window = window_;
1814 tracker.Add(window); 1813 tracker.Add(window);
1815 host->Focus(); 1814 host->Focus();
1816 if (!tracker.Contains(window)) { 1815 if (!tracker.Contains(window)) {
1817 event->SetHandled(); 1816 event->SetHandled();
1818 return; 1817 return;
1819 } 1818 }
1820 } 1819 }
1821 } 1820 }
1822 if (!in_shutdown_) { 1821 Shutdown();
1823 in_shutdown_ = true;
1824 host_->Shutdown();
1825 }
1826 } else { 1822 } else {
1827 if (event->key_code() == ui::VKEY_RETURN) { 1823 if (event->key_code() == ui::VKEY_RETURN) {
1828 // Do not forward return key release events if no press event was handled. 1824 // Do not forward return key release events if no press event was handled.
1829 if (event->type() == ui::ET_KEY_RELEASED && !accept_return_character_) 1825 if (event->type() == ui::ET_KEY_RELEASED && !accept_return_character_)
1830 return; 1826 return;
1831 // Accept return key character events between press and release events. 1827 // Accept return key character events between press and release events.
1832 accept_return_character_ = event->type() == ui::ET_KEY_PRESSED; 1828 accept_return_character_ = event->type() == ui::ET_KEY_PRESSED;
1833 } 1829 }
1834 1830
1835 // We don't have to communicate with an input method here. 1831 // We don't have to communicate with an input method here.
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
2205 // On Windows, if we are switching to a non Aura Window on a different 2201 // On Windows, if we are switching to a non Aura Window on a different
2206 // screen we should not close the fullscreen window. 2202 // screen we should not close the fullscreen window.
2207 if (!gained_focus) { 2203 if (!gained_focus) {
2208 POINT point = {0}; 2204 POINT point = {0};
2209 ::GetCursorPos(&point); 2205 ::GetCursorPos(&point);
2210 if (screen->GetDisplayNearestWindow(window_).id() != 2206 if (screen->GetDisplayNearestWindow(window_).id() !=
2211 screen->GetDisplayNearestPoint(gfx::Point(point)).id()) 2207 screen->GetDisplayNearestPoint(gfx::Point(point)).id())
2212 return; 2208 return;
2213 } 2209 }
2214 #endif 2210 #endif
2215 in_shutdown_ = true; 2211 Shutdown();
2216 host_->Shutdown(); 2212 return;
2217 } 2213 }
2214
2215 // Close the child popup window if we lose focus (e.g. due to a JS alert or
2216 // system modal dialog). This is particularly important if
2217 // |popup_child_host_view_| has mouse capture.
2218 if (popup_child_host_view_)
2219 popup_child_host_view_->Shutdown();
2218 } 2220 }
2219 } 2221 }
2220 2222
2221 //////////////////////////////////////////////////////////////////////////////// 2223 ////////////////////////////////////////////////////////////////////////////////
2222 // RenderWidgetHostViewAura, aura::WindowTreeHostObserver implementation: 2224 // RenderWidgetHostViewAura, aura::WindowTreeHostObserver implementation:
2223 2225
2224 void RenderWidgetHostViewAura::OnHostMoved(const aura::WindowTreeHost* host, 2226 void RenderWidgetHostViewAura::OnHostMoved(const aura::WindowTreeHost* host,
2225 const gfx::Point& new_origin) { 2227 const gfx::Point& new_origin) {
2226 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved", 2228 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved",
2227 "new_origin", new_origin.ToString()); 2229 "new_origin", new_origin.ToString());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 } 2300 }
2299 } 2301 }
2300 2302
2301 ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const { 2303 ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const {
2302 aura::Window* root_window = window_->GetRootWindow(); 2304 aura::Window* root_window = window_->GetRootWindow();
2303 if (!root_window) 2305 if (!root_window)
2304 return NULL; 2306 return NULL;
2305 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); 2307 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey);
2306 } 2308 }
2307 2309
2310 void RenderWidgetHostViewAura::Shutdown() {
2311 if (!in_shutdown_) {
2312 in_shutdown_ = true;
2313 host_->Shutdown();
2314 }
2315 }
2316
2308 bool RenderWidgetHostViewAura::NeedsInputGrab() { 2317 bool RenderWidgetHostViewAura::NeedsInputGrab() {
2309 return popup_type_ == blink::WebPopupTypeSelect; 2318 return popup_type_ == blink::WebPopupTypeSelect;
2310 } 2319 }
2311 2320
2312 bool RenderWidgetHostViewAura::NeedsMouseCapture() { 2321 bool RenderWidgetHostViewAura::NeedsMouseCapture() {
2313 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 2322 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
2314 return NeedsInputGrab(); 2323 return NeedsInputGrab();
2315 #endif 2324 #endif
2316 return false; 2325 return false;
2317 } 2326 }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
2606 2615
2607 //////////////////////////////////////////////////////////////////////////////// 2616 ////////////////////////////////////////////////////////////////////////////////
2608 // RenderWidgetHostViewBase, public: 2617 // RenderWidgetHostViewBase, public:
2609 2618
2610 // static 2619 // static
2611 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2620 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2612 GetScreenInfoForWindow(results, NULL); 2621 GetScreenInfoForWindow(results, NULL);
2613 } 2622 }
2614 2623
2615 } // namespace content 2624 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698