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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 void KeyboardUIContent::LoadSystemKeyboard() { | 154 void KeyboardUIContent::LoadSystemKeyboard() { |
155 DCHECK(keyboard_contents_); | 155 DCHECK(keyboard_contents_); |
156 if (keyboard_contents_->GetURL() != default_url_) { | 156 if (keyboard_contents_->GetURL() != default_url_) { |
157 // TODO(bshe): The height of system virtual keyboard and IME virtual | 157 // TODO(bshe): The height of system virtual keyboard and IME virtual |
158 // keyboard may different. The height needs to be restored too. | 158 // keyboard may different. The height needs to be restored too. |
159 LoadContents(default_url_); | 159 LoadContents(default_url_); |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 void KeyboardUIContent::UpdateInsetsForWindow(aura::Window* window) { | 163 void KeyboardUIContent::UpdateInsetsForWindow(aura::Window* window) { |
164 // Added while we determine if RenderWidgetHostViewChildFrame can be | |
165 // changed to always return a non-null value: https://crbug.com/644726 . | |
166 // If we cannot guarantee a non-null value, then this may need to stay. | |
167 if (!window) | |
168 return; | |
Charlie Reis
2016/09/07 20:27:16
I think we probably shouldn't include this change.
wjmaclean
2016/09/07 20:40:57
Done.
| |
169 | |
164 aura::Window* keyboard_container = | 170 aura::Window* keyboard_container = |
165 keyboard_controller()->GetContainerWindow(); | 171 keyboard_controller()->GetContainerWindow(); |
166 if (!ShouldWindowOverscroll(window)) | 172 if (!ShouldWindowOverscroll(window)) |
167 return; | 173 return; |
168 | 174 |
169 std::unique_ptr<content::RenderWidgetHostIterator> widgets( | 175 std::unique_ptr<content::RenderWidgetHostIterator> widgets( |
170 content::RenderWidgetHost::GetRenderWidgetHosts()); | 176 content::RenderWidgetHost::GetRenderWidgetHosts()); |
171 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { | 177 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { |
172 content::RenderWidgetHostView* view = widget->GetView(); | 178 content::RenderWidgetHostView* view = widget->GetView(); |
173 if (view && window->Contains(view->GetNativeView())) { | 179 if (view && window->Contains(view->GetNativeView())) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 // TODO(kevers): Add EnvObserver to properly initialize insets if a | 237 // TODO(kevers): Add EnvObserver to properly initialize insets if a |
232 // window is created while the keyboard is visible. | 238 // window is created while the keyboard is visible. |
233 std::unique_ptr<content::RenderWidgetHostIterator> widgets( | 239 std::unique_ptr<content::RenderWidgetHostIterator> widgets( |
234 content::RenderWidgetHost::GetRenderWidgetHosts()); | 240 content::RenderWidgetHost::GetRenderWidgetHosts()); |
235 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { | 241 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { |
236 content::RenderWidgetHostView* view = widget->GetView(); | 242 content::RenderWidgetHostView* view = widget->GetView(); |
237 // Can be NULL, e.g. if the RenderWidget is being destroyed or | 243 // Can be NULL, e.g. if the RenderWidget is being destroyed or |
238 // the render process crashed. | 244 // the render process crashed. |
239 if (view) { | 245 if (view) { |
240 aura::Window* window = view->GetNativeView(); | 246 aura::Window* window = view->GetNativeView(); |
247 // Added while we determine if RenderWidgetHostViewChildFrame can be | |
248 // changed to always return a non-null value: https://crbug.com/644726 . | |
249 // If we cannot guarantee a non-null value, then this may need to stay. | |
250 if (!window) | |
251 return; | |
Charlie Reis
2016/09/07 20:27:16
This needs to be a continue and not an early retur
wjmaclean
2016/09/07 20:40:57
Ooops, I saw the enclosing if() but missed the whi
| |
252 | |
241 if (ShouldWindowOverscroll(window)) { | 253 if (ShouldWindowOverscroll(window)) { |
242 gfx::Rect window_bounds = window->GetBoundsInScreen(); | 254 gfx::Rect window_bounds = window->GetBoundsInScreen(); |
243 gfx::Rect intersect = gfx::IntersectRects(window_bounds, | 255 gfx::Rect intersect = gfx::IntersectRects(window_bounds, |
244 new_bounds); | 256 new_bounds); |
245 int overlap = intersect.height(); | 257 int overlap = intersect.height(); |
246 if (overlap > 0 && overlap < window_bounds.height()) | 258 if (overlap > 0 && overlap < window_bounds.height()) |
247 view->SetInsets(gfx::Insets(0, 0, overlap, 0)); | 259 view->SetInsets(gfx::Insets(0, 0, overlap, 0)); |
248 else | 260 else |
249 view->SetInsets(gfx::Insets()); | 261 view->SetInsets(gfx::Insets()); |
250 AddBoundsChangedObserver(window); | 262 AddBoundsChangedObserver(window); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 keyboard_controller()->keyboard_visible()); | 335 keyboard_controller()->keyboard_visible()); |
324 } | 336 } |
325 | 337 |
326 void KeyboardUIContent::AddBoundsChangedObserver(aura::Window* window) { | 338 void KeyboardUIContent::AddBoundsChangedObserver(aura::Window* window) { |
327 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; | 339 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; |
328 if (target_window) | 340 if (target_window) |
329 window_bounds_observer_->AddObservedWindow(target_window); | 341 window_bounds_observer_->AddObservedWindow(target_window); |
330 } | 342 } |
331 | 343 |
332 } // namespace keyboard | 344 } // namespace keyboard |
OLD | NEW |