| 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/content/keyboard_ui_content.h" | 5 #include "ui/keyboard/content/keyboard_ui_content.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "content/public/browser/render_widget_host.h" | 10 #include "content/public/browser/render_widget_host.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // TODO(kevers): Add EnvObserver to properly initialize insets if a | 231 // TODO(kevers): Add EnvObserver to properly initialize insets if a |
| 232 // window is created while the keyboard is visible. | 232 // window is created while the keyboard is visible. |
| 233 std::unique_ptr<content::RenderWidgetHostIterator> widgets( | 233 std::unique_ptr<content::RenderWidgetHostIterator> widgets( |
| 234 content::RenderWidgetHost::GetRenderWidgetHosts()); | 234 content::RenderWidgetHost::GetRenderWidgetHosts()); |
| 235 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { | 235 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { |
| 236 content::RenderWidgetHostView* view = widget->GetView(); | 236 content::RenderWidgetHostView* view = widget->GetView(); |
| 237 // Can be NULL, e.g. if the RenderWidget is being destroyed or | 237 // Can be NULL, e.g. if the RenderWidget is being destroyed or |
| 238 // the render process crashed. | 238 // the render process crashed. |
| 239 if (view) { | 239 if (view) { |
| 240 aura::Window* window = view->GetNativeView(); | 240 aura::Window* window = view->GetNativeView(); |
| 241 // Added while we determine if RenderWidgetHostViewChildFrame can be |
| 242 // changed to always return a non-null value: https://crbug.com/644726 . |
| 243 // If we cannot guarantee a non-null value, then this may need to stay. |
| 244 if (!window) |
| 245 continue; |
| 246 |
| 241 if (ShouldWindowOverscroll(window)) { | 247 if (ShouldWindowOverscroll(window)) { |
| 242 gfx::Rect window_bounds = window->GetBoundsInScreen(); | 248 gfx::Rect window_bounds = window->GetBoundsInScreen(); |
| 243 gfx::Rect intersect = gfx::IntersectRects(window_bounds, | 249 gfx::Rect intersect = gfx::IntersectRects(window_bounds, |
| 244 new_bounds); | 250 new_bounds); |
| 245 int overlap = intersect.height(); | 251 int overlap = intersect.height(); |
| 246 if (overlap > 0 && overlap < window_bounds.height()) | 252 if (overlap > 0 && overlap < window_bounds.height()) |
| 247 view->SetInsets(gfx::Insets(0, 0, overlap, 0)); | 253 view->SetInsets(gfx::Insets(0, 0, overlap, 0)); |
| 248 else | 254 else |
| 249 view->SetInsets(gfx::Insets()); | 255 view->SetInsets(gfx::Insets()); |
| 250 AddBoundsChangedObserver(window); | 256 AddBoundsChangedObserver(window); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 keyboard_controller()->keyboard_visible()); | 329 keyboard_controller()->keyboard_visible()); |
| 324 } | 330 } |
| 325 | 331 |
| 326 void KeyboardUIContent::AddBoundsChangedObserver(aura::Window* window) { | 332 void KeyboardUIContent::AddBoundsChangedObserver(aura::Window* window) { |
| 327 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; | 333 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; |
| 328 if (target_window) | 334 if (target_window) |
| 329 window_bounds_observer_->AddObservedWindow(target_window); | 335 window_bounds_observer_->AddObservedWindow(target_window); |
| 330 } | 336 } |
| 331 | 337 |
| 332 } // namespace keyboard | 338 } // namespace keyboard |
| OLD | NEW |