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

Side by Side Diff: ui/keyboard/keyboard_controller.cc

Issue 195793004: Implement overscroll support for the virtual keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge ToT Created 6 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_widget.cc ('k') | ui/keyboard/keyboard_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "content/public/browser/render_widget_host.h"
10 #include "content/public/browser/render_widget_host_iterator.h"
11 #include "content/public/browser/render_widget_host_view.h"
9 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
10 #include "ui/aura/window_delegate.h" 13 #include "ui/aura/window_delegate.h"
11 #include "ui/base/cursor/cursor.h" 14 #include "ui/base/cursor/cursor.h"
12 #include "ui/base/hit_test.h" 15 #include "ui/base/hit_test.h"
13 #include "ui/base/ime/input_method.h" 16 #include "ui/base/ime/input_method.h"
14 #include "ui/base/ime/text_input_client.h" 17 #include "ui/base/ime/text_input_client.h"
15 #include "ui/compositor/layer_animation_observer.h" 18 #include "ui/compositor/layer_animation_observer.h"
16 #include "ui/compositor/scoped_layer_animation_settings.h" 19 #include "ui/compositor/scoped_layer_animation_settings.h"
17 #include "ui/gfx/path.h" 20 #include "ui/gfx/path.h"
18 #include "ui/gfx/rect.h" 21 #include "ui/gfx/rect.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 return container_.get(); 230 return container_.get();
228 } 231 }
229 232
230 void KeyboardController::NotifyKeyboardBoundsChanging( 233 void KeyboardController::NotifyKeyboardBoundsChanging(
231 const gfx::Rect& new_bounds) { 234 const gfx::Rect& new_bounds) {
232 current_keyboard_bounds_ = new_bounds; 235 current_keyboard_bounds_ = new_bounds;
233 if (proxy_->HasKeyboardWindow() && proxy_->GetKeyboardWindow()->IsVisible()) { 236 if (proxy_->HasKeyboardWindow() && proxy_->GetKeyboardWindow()->IsVisible()) {
234 FOR_EACH_OBSERVER(KeyboardControllerObserver, 237 FOR_EACH_OBSERVER(KeyboardControllerObserver,
235 observer_list_, 238 observer_list_,
236 OnKeyboardBoundsChanging(new_bounds)); 239 OnKeyboardBoundsChanging(new_bounds));
240 if (keyboard::IsKeyboardOverscrollEnabled()) {
241 // Adjust the height of the viewport for visible windows on the primary
242 // display.
243 // TODO(kevers): Add EnvObserver to properly initialize insets if a
244 // window is created while the keyboard is visible.
245 scoped_ptr<content::RenderWidgetHostIterator> widgets(
246 content::RenderWidgetHost::GetRenderWidgetHosts());
247 aura::Window *keyboard_window = proxy_->GetKeyboardWindow();
248 aura::Window *root_window = keyboard_window->GetRootWindow();
249 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
250 content::RenderWidgetHostView* view = widget->GetView();
251 aura::Window *window = view->GetNativeView();
252 if (window != keyboard_window && window->GetRootWindow() == root_window)
253 {
254 gfx::Rect window_bounds = window->GetBoundsInScreen();
255 gfx::Rect intersect = gfx::IntersectRects(window_bounds, new_bounds);
256 int overlap = intersect.height();
257 if (overlap > 0 && overlap < window_bounds.height())
258 view->SetInsets(gfx::Insets(0, 0, overlap, 0));
259 else
260 view->SetInsets(gfx::Insets(0, 0, 0, 0));
261 // TODO(kevers): Add window observer to native window to update insets
262 // on a window move or resize.
263 }
264 }
265 }
237 } 266 }
238 } 267 }
239 268
240 void KeyboardController::HideKeyboard(HideReason reason) { 269 void KeyboardController::HideKeyboard(HideReason reason) {
241 keyboard_visible_ = false; 270 keyboard_visible_ = false;
242 ToggleTouchEventLogging(true); 271 ToggleTouchEventLogging(true);
243 272
244 keyboard::LogKeyboardControlEvent( 273 keyboard::LogKeyboardControlEvent(
245 reason == HIDE_REASON_AUTOMATIC ? 274 reason == HIDE_REASON_AUTOMATIC ?
246 keyboard::KEYBOARD_CONTROL_HIDE_AUTO : 275 keyboard::KEYBOARD_CONTROL_HIDE_AUTO :
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 // background during animation. 448 // background during animation.
420 NotifyKeyboardBoundsChanging(proxy_->GetKeyboardWindow()->bounds()); 449 NotifyKeyboardBoundsChanging(proxy_->GetKeyboardWindow()->bounds());
421 proxy_->EnsureCaretInWorkArea(); 450 proxy_->EnsureCaretInWorkArea();
422 } 451 }
423 452
424 void KeyboardController::HideAnimationFinished() { 453 void KeyboardController::HideAnimationFinished() {
425 proxy_->HideKeyboardContainer(container_.get()); 454 proxy_->HideKeyboardContainer(container_.get());
426 } 455 }
427 456
428 } // namespace keyboard 457 } // namespace keyboard
OLDNEW
« no previous file with comments | « content/renderer/render_widget.cc ('k') | ui/keyboard/keyboard_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698