Chromium Code Reviews| Index: ui/keyboard/resources/elements/kb-keyboard.html |
| diff --git a/ui/keyboard/resources/elements/kb-keyboard.html b/ui/keyboard/resources/elements/kb-keyboard.html |
| index d47ca6d9ebe97e7388686a85e0ac549e215e6f8b..08985acf32a3562de67f8d0576bd5519d1a5be65 100644 |
| --- a/ui/keyboard/resources/elements/kb-keyboard.html |
| +++ b/ui/keyboard/resources/elements/kb-keyboard.html |
| @@ -26,7 +26,7 @@ |
| -- allowing the shift and spacebar keys to be common across multiple |
| -- keyboard layouts. |
| --> |
| - <content id="content" select="#{{layout}}-{{keyset}}"></content> |
| + <content id="content"></content> |
| <kb-keyboard-overlay id="overlay" hidden></kb-keyboard-overlay> |
| <kb-key-codes id="keyCodeMetadata"></kb-key-codes> |
| </template> |
| @@ -337,40 +337,23 @@ |
| return false; |
| }, |
| + keysetChanged: function() { |
| + var keyset = this.activeKeyset; |
| + // Show the keyset if it has been initialized. |
| + if (keyset) |
| + keyset.show(); |
| + }, |
| + |
| ready: function() { |
| this.voiceInput_ = new VoiceInput(this); |
| this.swipeHandler = this.move.bind(this); |
| }, |
| /** |
| - * Registers a callback for state change events. Lazy initializes a |
| - * mutation observer used to detect when the keyset selection is changed. |
| + * Registers a callback for state change events. |
| * @param{!Function} callback Callback function to register. |
| */ |
| addKeysetChangedObserver: function(callback) { |
| - if (!this.keysetChangedObserver) { |
| - var target = this.$.content; |
| - var self = this; |
| - var observer = new MutationObserver(function(mutations) { |
| - mutations.forEach(function(m) { |
| - if (m.type == 'attributes' && m.attributeName == 'select') { |
| - var value = m.target.getAttribute('select'); |
| - self.fire('stateChange', { |
| - state: 'keysetChanged', |
| - value: value |
| - }); |
| - } |
| - }); |
| - }); |
| - |
| - observer.observe(target, { |
| - attributes: true, |
| - childList: true, |
| - subtree: true |
| - }); |
| - this.keysetChangedObserver = observer; |
| - |
| - } |
| this.addEventListener('stateChange', callback); |
| }, |
| @@ -833,6 +816,9 @@ |
| }); |
| } |
| } |
| + // New keyset has already been loaded, can show immediately. |
| + } else { |
| + this.activeKeyset.show(); |
| } |
| }, |
| @@ -897,8 +883,12 @@ |
| var keyset = this.activeKeyset; |
| if (!keyset) |
| return false; |
| - var content = this.$.content.getDistributedNodes()[0]; |
| - return content == keyset; |
| + var nodes = this.$.content.getDistributedNodes(); |
| + for (var i = 0; i < nodes.length; i++) { |
| + if (nodes[i].id && nodes[i].id == keyset.id) |
| + return true; |
| + } |
| + return false; |
| }, |
| /** |
| @@ -945,6 +935,13 @@ |
| // TODO(kevers): Investigate why this is the case. |
| if (keysets[i].isDefault || |
| keysets[i].getAttribute('isDefault') == 'true') { |
| + var allKeys = keysets[i].querySelectorAll('*').array(); |
|
kevers
2014/01/17 17:56:35
childNodes?
Also believe that this code belongs i
rsadam
2014/01/17 18:38:48
Done.
|
| + for (var j = 0; j< allKeys.length; j++) { |
| + var weight = allKeys[j].getAttribute('weight'); |
| + if (weight) { |
| + allKeys[j].style.webkitBoxFlex = weight; |
| + } |
| + } |
| this.keyset = matches[REGEX_KEYSET_INDEX]; |
| this.classList.remove('caps-locked'); |
| this.classList.remove('alt-active'); |