Chromium Code Reviews| Index: chrome/browser/resources/keyboard/main.js |
| diff --git a/chrome/browser/resources/keyboard/main.js b/chrome/browser/resources/keyboard/main.js |
| index cf3f97a93505f5f8e95c1037f793d0255ff41f03..b440935f313e8517502df8faa6eb5a8c33b1a00a 100644 |
| --- a/chrome/browser/resources/keyboard/main.js |
| +++ b/chrome/browser/resources/keyboard/main.js |
| @@ -578,7 +578,7 @@ var allRows = []; // Populated during start() |
| */ |
| function getRowHeight() { |
| var x = window.innerWidth; |
| - var y = window.innerHeight - (imeui ? IME_HEIGHT - 2 : 0); |
| + var y = window.innerHeight - ((imeui && imeui.visible) ? IME_HEIGHT : 0); |
| return (x > kKeyboardAspect * y) ? |
| (height = Math.floor(y / 4)) : |
| (height = Math.floor(x / (kKeyboardAspect * 4))); |
| @@ -647,6 +647,8 @@ function sendKeyFunction(key) { |
| } |
| } |
| +var oldHeight = 0; |
| +var oldX = 0; |
|
bryeung
2011/06/03 19:14:52
I'm confused why this is necessary. Won't one of
Peng
2011/06/03 22:22:10
oldHeight is not the height of window. It may be t
|
| /** |
| * Resize the keyboard according to the new window size. |
| * @return {void} |
| @@ -655,16 +657,23 @@ window.onresize = function() { |
| var height = getRowHeight(); |
| var newX = document.documentElement.clientWidth; |
| - // All rows should have the same aspect, so just use the first one |
| - var totalWidth = Math.floor(height * allRows[0].aspect); |
| - var leftPadding = Math.floor((newX - totalWidth) / 2); |
| - document.getElementById('b').style.paddingLeft = leftPadding + 'px'; |
| + if (newX != oldX || height != oldHeight) { |
| + // All rows should have the same aspect, so just use the first one |
| + var totalWidth = Math.floor(height * allRows[0].aspect); |
| + var leftPadding = Math.floor((newX - totalWidth) / 2); |
| + document.getElementById('b').style.paddingLeft = leftPadding + 'px'; |
| + } |
| - for (var i = 0; i < allRows.length; ++i) { |
| - allRows[i].resize(height); |
| + if (height != oldHeight) { |
| + for (var i = 0; i < allRows.length; ++i) { |
| + allRows[i].resize(height); |
| + } |
| } |
| updateIme(); |
| + |
| + oldHeight = height; |
| + oldX = newX; |
| } |
| /** |
| @@ -680,10 +689,12 @@ window.onload = function() { |
| allRows.push(new Row(i, KEYS[i])); |
| } |
| + height = getRowHeight(); |
| for (var i = 0; i < allRows.length; ++i) { |
| - body.appendChild(allRows[i].makeDOM(getRowHeight())); |
| + body.appendChild(allRows[i].makeDOM(height)); |
| allRows[i].showMode(KEY_MODE); |
| } |
| + oldHeight = height; |
| window.onresize(); |
| } |