Commit 1005f1f3 authored by rsadam@chromium.org's avatar rsadam@chromium.org

Work around for content select not supporting touch events on it's children.

BUG=327528

Review URL: https://codereview.chromium.org/140123002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245626 0039d316-1c4b-4281-b951-d872f2087c98
parent a4a90549
...@@ -152,7 +152,7 @@ ...@@ -152,7 +152,7 @@
*/ */
weightChanged: function() { weightChanged: function() {
if (this.weight > 0) if (this.weight > 0)
this.style['webkitBoxFlex'] = this.weight; this.style.webkitBoxFlex = this.weight;
}, },
}); });
</script> </script>
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
-- allowing the shift and spacebar keys to be common across multiple -- allowing the shift and spacebar keys to be common across multiple
-- keyboard layouts. -- keyboard layouts.
--> -->
<content id="content" select="#{{layout}}-{{keyset}}"></content> <content id="content"></content>
<kb-keyboard-overlay id="overlay" hidden></kb-keyboard-overlay> <kb-keyboard-overlay id="overlay" hidden></kb-keyboard-overlay>
<kb-key-codes id="keyCodeMetadata"></kb-key-codes> <kb-key-codes id="keyCodeMetadata"></kb-key-codes>
</template> </template>
...@@ -337,40 +337,23 @@ ...@@ -337,40 +337,23 @@
return false; return false;
}, },
keysetChanged: function() {
var keyset = this.activeKeyset;
// Show the keyset if it has been initialized.
if (keyset)
keyset.show();
},
ready: function() { ready: function() {
this.voiceInput_ = new VoiceInput(this); this.voiceInput_ = new VoiceInput(this);
this.swipeHandler = this.move.bind(this); this.swipeHandler = this.move.bind(this);
}, },
/** /**
* Registers a callback for state change events. Lazy initializes a * Registers a callback for state change events.
* mutation observer used to detect when the keyset selection is changed.
* @param{!Function} callback Callback function to register. * @param{!Function} callback Callback function to register.
*/ */
addKeysetChangedObserver: function(callback) { 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); this.addEventListener('stateChange', callback);
}, },
...@@ -833,6 +816,9 @@ ...@@ -833,6 +816,9 @@
}); });
} }
} }
// New keyset has already been loaded, can show immediately.
} else {
this.activeKeyset.show();
} }
}, },
...@@ -897,8 +883,12 @@ ...@@ -897,8 +883,12 @@
var keyset = this.activeKeyset; var keyset = this.activeKeyset;
if (!keyset) if (!keyset)
return false; return false;
var content = this.$.content.getDistributedNodes()[0]; var nodes = this.$.content.getDistributedNodes();
return content == keyset; for (var i = 0; i < nodes.length; i++) {
if (nodes[i].id && nodes[i].id == keyset.id)
return true;
}
return false;
}, },
/** /**
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
display: -webkit-box; display: -webkit-box;
} }
:host:not(.activeKeyset) {
display: none;
}
</style> </style>
<content select="kb-row"></content> <content select="kb-row"></content>
<content select="kb-altkey-container" id="altkeyContainer" <content select="kb-altkey-container" id="altkeyContainer"
...@@ -77,6 +80,26 @@ ...@@ -77,6 +80,26 @@
var nodes = activeAltKeySet.childNodes; var nodes = activeAltKeySet.childNodes;
nodes[activeAltKeySet.offset].classList.add('active'); nodes[activeAltKeySet.offset].classList.add('active');
altkeyContainer.hidden = false; altkeyContainer.hidden = false;
},
show: function() {
var old = $('keyboard').querySelector('.activeKeyset');
if (old && old != this)
old.classList.remove('activeKeyset');
this.classList.add('activeKeyset');
this.fire('stateChange', {
state: 'keysetChanged',
value: this.id
});
},
enteredView: function() {
if (this.isDefault) {
var self = this;
Platform.endOfMicrotask(function() {
self.show();
});
}
} }
}); });
</script> </script>
......
...@@ -53,6 +53,15 @@ function expandHTML(importedContent) { ...@@ -53,6 +53,15 @@ function expandHTML(importedContent) {
function flattenKeysets(content) { function flattenKeysets(content) {
var importedContent = importHTML(content); var importedContent = importHTML(content);
expandHTML(importedContent); expandHTML(importedContent);
var rows = importedContent.querySelectorAll('kb-row');
for (var i = 0 ; i < rows.length; i++) {
var allKeys = rows[i].children;
for (var j = 0; j< allKeys.length; j++) {
var weight = allKeys[j].getAttribute('weight');
if (weight)
allKeys[j].style.webkitBoxFlex = weight;
}
}
return importedContent; return importedContent;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment