OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/keyboard/keyboard_controller.h" | 5 #include "ui/keyboard/keyboard_controller.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 FOR_EACH_OBSERVER(KeyboardControllerObserver, | 264 FOR_EACH_OBSERVER(KeyboardControllerObserver, |
265 observer_list_, | 265 observer_list_, |
266 OnKeyboardBoundsChanging(new_bounds)); | 266 OnKeyboardBoundsChanging(new_bounds)); |
267 if (keyboard::IsKeyboardOverscrollEnabled()) { | 267 if (keyboard::IsKeyboardOverscrollEnabled()) { |
268 // Adjust the height of the viewport for visible windows on the primary | 268 // Adjust the height of the viewport for visible windows on the primary |
269 // display. | 269 // display. |
270 // TODO(kevers): Add EnvObserver to properly initialize insets if a | 270 // TODO(kevers): Add EnvObserver to properly initialize insets if a |
271 // window is created while the keyboard is visible. | 271 // window is created while the keyboard is visible. |
272 scoped_ptr<content::RenderWidgetHostIterator> widgets( | 272 scoped_ptr<content::RenderWidgetHostIterator> widgets( |
273 content::RenderWidgetHost::GetRenderWidgetHosts()); | 273 content::RenderWidgetHost::GetRenderWidgetHosts()); |
274 aura::Window* keyboard_window = proxy_->GetKeyboardWindow(); | 274 aura::Window* root_window = proxy_->GetKeyboardWindow()->GetRootWindow(); |
275 aura::Window* root_window = keyboard_window->GetRootWindow(); | |
276 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { | 275 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { |
277 content::RenderWidgetHostView* view = widget->GetView(); | 276 content::RenderWidgetHostView* view = widget->GetView(); |
278 // Can be NULL, e.g. if the RenderWidget is being destroyed or | 277 // Can be NULL, e.g. if the RenderWidget is being destroyed or |
279 // the render process crashed. | 278 // the render process crashed. |
280 if (view) { | 279 if (view) { |
281 aura::Window* window = view->GetNativeView(); | 280 aura::Window* window = view->GetNativeView(); |
282 // If virtual keyboard failed to load, a widget that displays error | 281 if (proxy_->ShouldWindowOverscroll(window) && |
283 // message will be created and adds as a child of the virtual keyboard | |
284 // window. We want to avoid add BoundsChangedObserver to that window. | |
285 if (!keyboard_window->Contains(window) && | |
286 window->GetRootWindow() == root_window) { | 282 window->GetRootWindow() == root_window) { |
oshima
2015/09/23 19:57:27
looks like this check is a dup?
bshe
2015/09/24 11:56:15
I think this check preventing overscoll on windows
oshima
2015/09/24 17:28:07
Yeah,that sounds better because it's checking agai
bshe
2015/09/28 14:42:40
Done.
| |
287 gfx::Rect window_bounds = window->GetBoundsInScreen(); | 283 gfx::Rect window_bounds = window->GetBoundsInScreen(); |
288 gfx::Rect intersect = gfx::IntersectRects(window_bounds, | 284 gfx::Rect intersect = gfx::IntersectRects(window_bounds, |
289 new_bounds); | 285 new_bounds); |
290 int overlap = intersect.height(); | 286 int overlap = intersect.height(); |
291 if (overlap > 0 && overlap < window_bounds.height()) | 287 if (overlap > 0 && overlap < window_bounds.height()) |
292 view->SetInsets(gfx::Insets(0, 0, overlap, 0)); | 288 view->SetInsets(gfx::Insets(0, 0, overlap, 0)); |
293 else | 289 else |
294 view->SetInsets(gfx::Insets()); | 290 view->SetInsets(gfx::Insets()); |
295 AddBoundsChangedObserver(window); | 291 AddBoundsChangedObserver(window); |
296 } | 292 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
469 | 465 |
470 bool KeyboardController::ShouldEnableInsets(aura::Window* window) { | 466 bool KeyboardController::ShouldEnableInsets(aura::Window* window) { |
471 aura::Window* keyboard_window = proxy_->GetKeyboardWindow(); | 467 aura::Window* keyboard_window = proxy_->GetKeyboardWindow(); |
472 return (keyboard_window->GetRootWindow() == window->GetRootWindow() && | 468 return (keyboard_window->GetRootWindow() == window->GetRootWindow() && |
473 keyboard::IsKeyboardOverscrollEnabled() && | 469 keyboard::IsKeyboardOverscrollEnabled() && |
474 keyboard_window->IsVisible() && keyboard_visible_); | 470 keyboard_window->IsVisible() && keyboard_visible_); |
475 } | 471 } |
476 | 472 |
477 void KeyboardController::UpdateWindowInsets(aura::Window* window) { | 473 void KeyboardController::UpdateWindowInsets(aura::Window* window) { |
478 aura::Window* keyboard_window = proxy_->GetKeyboardWindow(); | 474 aura::Window* keyboard_window = proxy_->GetKeyboardWindow(); |
479 if (window == keyboard_window) | 475 if (!proxy_->ShouldWindowOverscroll(window)) |
480 return; | 476 return; |
481 | 477 |
482 scoped_ptr<content::RenderWidgetHostIterator> widgets( | 478 scoped_ptr<content::RenderWidgetHostIterator> widgets( |
483 content::RenderWidgetHost::GetRenderWidgetHosts()); | 479 content::RenderWidgetHost::GetRenderWidgetHosts()); |
484 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { | 480 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { |
485 content::RenderWidgetHostView* view = widget->GetView(); | 481 content::RenderWidgetHostView* view = widget->GetView(); |
486 if (view && window->Contains(view->GetNativeView())) { | 482 if (view && window->Contains(view->GetNativeView())) { |
487 gfx::Rect window_bounds = view->GetNativeView()->GetBoundsInScreen(); | 483 gfx::Rect window_bounds = view->GetNativeView()->GetBoundsInScreen(); |
488 gfx::Rect intersect = | 484 gfx::Rect intersect = |
489 gfx::IntersectRects(window_bounds, keyboard_window->bounds()); | 485 gfx::IntersectRects(window_bounds, keyboard_window->bounds()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
602 proxy_->HideKeyboardContainer(container_.get()); | 598 proxy_->HideKeyboardContainer(container_.get()); |
603 } | 599 } |
604 | 600 |
605 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { | 601 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { |
606 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; | 602 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; |
607 if (target_window) | 603 if (target_window) |
608 window_bounds_observer_->AddObservedWindow(target_window); | 604 window_bounds_observer_->AddObservedWindow(target_window); |
609 } | 605 } |
610 | 606 |
611 } // namespace keyboard | 607 } // namespace keyboard |
OLD | NEW |