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

Side by Side Diff: ui/keyboard/resources/main.js

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: review 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 (function(exports) { 4 (function(exports) {
5 /** 5 /**
6 * Alignment options for a keyset. 6 * Alignment options for a keyset.
7 * @param {Object=} opt_keyset The keyset to calculate the dimensions for. 7 * @param {Object=} opt_keyset The keyset to calculate the dimensions for.
8 * Defaults to the current active keyset. 8 * Defaults to the current active keyset.
9 */ 9 */
10 var AlignmentOptions = function(opt_keyset) { 10 var AlignmentOptions = function(opt_keyset) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 else 198 else
199 return binarySearch_(array, mid + 1, end, testFn); 199 return binarySearch_(array, mid + 1, end, testFn);
200 } 200 }
201 201
202 /** 202 /**
203 * Calculate width and height of the window. 203 * Calculate width and height of the window.
204 * @private 204 * @private
205 * @return {Array.<String, number>} The bounds of the keyboard container. 205 * @return {Array.<String, number>} The bounds of the keyboard container.
206 */ 206 */
207 function getKeyboardBounds_() { 207 function getKeyboardBounds_() {
208 var keyboard = $('keyboard');
209 var ratio = DEFAULT_KEYBOARD_ASPECT_RATIO;
210 if (keyboard.config && keyboard.config.a11ymode) {
211 ratio = DEFAULT_A11Y_KEYBOARD_ASPECT_RATIO;
212 }
208 return { 213 return {
209 "width": window.innerWidth, 214 "width": screen.width,
210 "height": window.innerHeight, 215 "height": screen.height * ratio
211 }; 216 };
212 } 217 }
213 218
214 /** 219 /**
215 * Calculates the desired key aspect ratio based on screen size. 220 * Calculates the desired key aspect ratio based on screen size.
216 * @return {number} The aspect ratio to use. 221 * @return {number} The aspect ratio to use.
217 */ 222 */
218 function getKeyAspectRatio() { 223 function getKeyAspectRatio() {
219 return (screen.width > screen.height) ? 224 return (screen.width > screen.height) ?
220 KEY_ASPECT_RATIO_LANDSCAPE : KEY_ASPECT_RATIO_PORTRAIT; 225 KEY_ASPECT_RATIO_LANDSCAPE : KEY_ASPECT_RATIO_PORTRAIT;
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 } 564 }
560 } 565 }
561 566
562 /** 567 /**
563 * Resizes the keyboard container if needed. 568 * Resizes the keyboard container if needed.
564 * @params {AlignmentOptions=} opt_params Optional parameters to use. Defaults 569 * @params {AlignmentOptions=} opt_params Optional parameters to use. Defaults
565 * to the parameters of the current active keyset. 570 * to the parameters of the current active keyset.
566 */ 571 */
567 function resizeKeyboardContainer(opt_params) { 572 function resizeKeyboardContainer(opt_params) {
568 var params = opt_params ? opt_params : new AlignmentOptions(); 573 var params = opt_params ? opt_params : new AlignmentOptions();
569 var bounds = getKeyboardBounds(); 574 if (Math.abs(window.innerHeight - params.height) > RESIZE_THRESHOLD) {
570 if (Math.abs(bounds.height - params.height) > RESIZE_THRESHOLD) {
571 // Cannot resize more than 50% of screen height due to crbug.com/338829. 575 // Cannot resize more than 50% of screen height due to crbug.com/338829.
572 window.resizeTo(params.width, params.height); 576 window.resizeTo(params.width, params.height);
573 } 577 }
574 } 578 }
575 579
576 addEventListener('resize', onResize); 580 addEventListener('resize', onResize);
577 addEventListener('load', onResize); 581 addEventListener('load', onResize);
578 582
579 exports.getKeyboardBounds = getKeyboardBounds_; 583 exports.getKeyboardBounds = getKeyboardBounds_;
580 exports.binarySearch = binarySearch_; 584 exports.binarySearch = binarySearch_;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 addEventListener('touchend', function(e) { e.preventDefault() }); 632 addEventListener('touchend', function(e) { e.preventDefault() });
629 addEventListener('touchmove', function(e) { e.preventDefault() }); 633 addEventListener('touchmove', function(e) { e.preventDefault() });
630 addEventListener('polymer-ready', function(e) { 634 addEventListener('polymer-ready', function(e) {
631 flattenKeysets(); 635 flattenKeysets();
632 resolveAudio(); 636 resolveAudio();
633 }); 637 });
634 addEventListener('stateChange', function(e) { 638 addEventListener('stateChange', function(e) {
635 if (e.detail.value == $('keyboard').activeKeysetId) 639 if (e.detail.value == $('keyboard').activeKeysetId)
636 realignAll(); 640 realignAll();
637 }) 641 })
OLDNEW
« ui/keyboard/keyboard_controller_unittest.cc ('K') | « ui/keyboard/resources/constants.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698