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

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

Issue 240443006: Remove native VK window height logic and wait for resizeTo to setup VK window height (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | « ui/keyboard/keyboard_util.h ('k') | ui/keyboard/resources/constants.js » ('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_util.h" 5 #include "ui/keyboard/keyboard_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 25 matching lines...) Expand all
36 CHECK(!details.dispatcher_destroyed); 36 CHECK(!details.dispatcher_destroyed);
37 } 37 }
38 38
39 base::LazyInstance<base::Time> g_keyboard_load_time_start = 39 base::LazyInstance<base::Time> g_keyboard_load_time_start =
40 LAZY_INSTANCE_INITIALIZER; 40 LAZY_INSTANCE_INITIALIZER;
41 41
42 bool g_accessibility_keyboard_enabled = false; 42 bool g_accessibility_keyboard_enabled = false;
43 43
44 base::LazyInstance<GURL> g_override_content_url = LAZY_INSTANCE_INITIALIZER; 44 base::LazyInstance<GURL> g_override_content_url = LAZY_INSTANCE_INITIALIZER;
45 45
46 // The ratio between the height of the keyboard and the screen when using the
47 // usability keyboard.
48 const float kUsabilityKeyboardHeightRatio = 1.0f;
49
50 // The default ratio between the height of the keyboard and the screen.
51 const float kDefaultKeyboardHeightRatio = 0.41f;
52
53 // The ratio between the height of the keyboard and the screen when using the
54 // accessibility keyboard.
55 const float kAccessibilityKeyboardHeightRatio = 0.3f;
56
57 float GetKeyboardHeightRatio(){
58 if (keyboard::IsKeyboardUsabilityExperimentEnabled()) {
59 return kUsabilityKeyboardHeightRatio;
60 } else if (keyboard::GetAccessibilityKeyboardEnabled()) {
61 return kAccessibilityKeyboardHeightRatio;
62 }
63 return kDefaultKeyboardHeightRatio;
64 }
65
66 bool g_touch_keyboard_enabled = false; 46 bool g_touch_keyboard_enabled = false;
67 47
68 } // namespace 48 } // namespace
69 49
70 namespace keyboard { 50 namespace keyboard {
71 51
72 gfx::Rect DefaultKeyboardBoundsFromWindowBounds( 52 gfx::Rect DefaultKeyboardBoundsFromWindowBounds(
73 const gfx::Rect& window_bounds) { 53 const gfx::Rect& window_bounds) {
74 const float kKeyboardHeightRatio = GetKeyboardHeightRatio(); 54 // Initialize default keyboard height to 0. The keyboard window height should
55 // only be set by window.resizeTo in virtual keyboard web contents. Otherwise,
56 // the default height may conflict with the new height and causing some
57 // strange animation issues. For keyboard usability experiments, a full screen
58 // virtual keyboard window is always preferred.
75 int keyboard_height = 59 int keyboard_height =
76 static_cast<int>(window_bounds.height() * kKeyboardHeightRatio); 60 keyboard::IsKeyboardUsabilityExperimentEnabled() ?
61 window_bounds.height() : 0;
62
63 return KeyboardBoundsFromWindowBounds(window_bounds, keyboard_height);
64 }
65
66 gfx::Rect KeyboardBoundsFromWindowBounds(const gfx::Rect& window_bounds,
67 int keyboard_height) {
77 return gfx::Rect( 68 return gfx::Rect(
78 window_bounds.x(), 69 window_bounds.x(),
79 window_bounds.y() + window_bounds.height() - keyboard_height, 70 window_bounds.bottom() - keyboard_height,
80 window_bounds.width(), 71 window_bounds.width(),
81 keyboard_height); 72 keyboard_height);
82 } 73 }
83 74
84 void SetAccessibilityKeyboardEnabled(bool enabled) { 75 void SetAccessibilityKeyboardEnabled(bool enabled) {
85 g_accessibility_keyboard_enabled = enabled; 76 g_accessibility_keyboard_enabled = enabled;
86 } 77 }
87 78
88 bool GetAccessibilityKeyboardEnabled() { 79 bool GetAccessibilityKeyboardEnabled() {
89 return g_accessibility_keyboard_enabled; 80 return g_accessibility_keyboard_enabled;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 325 }
335 326
336 void LogKeyboardControlEvent(KeyboardControlEvent event) { 327 void LogKeyboardControlEvent(KeyboardControlEvent event) {
337 UMA_HISTOGRAM_ENUMERATION( 328 UMA_HISTOGRAM_ENUMERATION(
338 "VirtualKeyboard.KeyboardControlEvent", 329 "VirtualKeyboard.KeyboardControlEvent",
339 event, 330 event,
340 keyboard::KEYBOARD_CONTROL_MAX); 331 keyboard::KEYBOARD_CONTROL_MAX);
341 } 332 }
342 333
343 } // namespace keyboard 334 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/keyboard/keyboard_util.h ('k') | ui/keyboard/resources/constants.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698