Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Bug 944009 - [B2G][Keyboard] Keyboard does not always display when tapping on a text field. #14172

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion apps/keyboard/js/keyboard.js
Expand Up @@ -331,6 +331,7 @@ const SWIPE_VELOCICTY_THRESHOLD = 0.4;
window.addEventListener('load', getKeyboardSettings);

function getKeyboardSettings() {
console.log('kms getKeyboardSettings');
// Before we can initialize the keyboard we need to know the current
// value of all keyboard-related settings. These are the settings
// we want to query, with the default values we'll use if the query fails
Expand Down Expand Up @@ -383,6 +384,7 @@ function getKeyboardSettings() {

function initKeyboard() {
// First, register handlers to track settings changes
console.log('kms init');
navigator.mozSettings.addObserver('keyboard.current', function(e) {
// Switch to the language associated keyboard
// everything.me also uses this setting to improve searches
Expand Down Expand Up @@ -459,6 +461,7 @@ function initKeyboard() {

dimensionsObserver = new MutationObserver(function() {
updateTargetWindowHeight();
console.log('kms dimensionsObserver');
});

// And observe mutation events on the renderer element
Expand All @@ -484,7 +487,8 @@ function initKeyboard() {
window.addEventListener('mozvisibilitychange', function visibilityHandler() {
var inputMethodName = window.location.hash.substring(1);
setKeyboardName(inputMethodName, function() {
if (!document.mozHidden && inputContext) {
console.log('kms mozvisibilitychange:' + inputContext);
if (!document.mozHidden && inputcontext) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this line changed?

showKeyboard();
} else {
hideKeyboard();
Expand All @@ -494,6 +498,7 @@ function initKeyboard() {

window.navigator.mozInputMethod.oninputcontextchange = function() {
inputContext = navigator.mozInputMethod.inputcontext;
console.log('kms change:' + inputContext);
if (!document.mozHidden && inputContext) {
showKeyboard();
} else {
Expand All @@ -507,7 +512,9 @@ function initKeyboard() {
// Finally, if we are only loaded by keyboard manager when the user
// have already focused, the keyboard should show right away.
inputContext = navigator.mozInputMethod.inputcontext;
console.log('kms inputcontext:' + inputContext);
if (!document.mozHidden && inputContext) {
console.log('kms showKeyboard');
showKeyboard();
}
}
Expand Down Expand Up @@ -984,6 +991,7 @@ function updateTargetWindowHeight(hide) {
var imeHeight = IMERender.ime.scrollHeight;
var imeWidth = IMERender.getWidth();
window.resizeTo(imeWidth, imeHeight);
console.log('kms updateTargetWindowHeight');
}

// Sends a delete code to remove last character
Expand Down
41 changes: 36 additions & 5 deletions apps/system/js/keyboard_manager.js
Expand Up @@ -82,7 +82,7 @@ var KeyboardManager = {
this.index = 0;
}
},

currentType: null,
focusChangeTimeout: 0,
switchChangeTimeout: 0,
_onDebug: false,
Expand Down Expand Up @@ -242,7 +242,7 @@ var KeyboardManager = {

inputFocusChange: function km_inputFocusChange(evt) {
var type = evt.detail.inputType;

console.log('keyboard inputFocusChange' + type);
// Skip the <select> element and inputs with type of date/time,
// handled in system app for now
if (!type || type in IGNORED_INPUT_TYPES)
Expand All @@ -269,6 +269,7 @@ var KeyboardManager = {
if (group !== self.showingLayout.type) {
self.resetShowingKeyboard();
}
console.log('km mini showKeyboard' + group);
self.setKeyboardToShow(group);

// We also want to show the permanent notification
Expand All @@ -290,6 +291,7 @@ var KeyboardManager = {
// if target group (input type) does not exist, use text for default
if (!self.keyboardLayouts[group]) {
// ensure the helper has apps and settings data first:
console.log('keyboard no group');
KeyboardHelper.getLayouts(showKeyboard);
} else {
showKeyboard();
Expand Down Expand Up @@ -329,6 +331,7 @@ var KeyboardManager = {
if (!(layout.origin in this.runningLayouts))
this.runningLayouts[layout.origin] = {};

console.log('km' + layout.origin);
this.runningLayouts[layout.origin][layout.id] = layoutFrame;
return layoutFrame;
},
Expand All @@ -345,10 +348,12 @@ var KeyboardManager = {

loadKeyboardLayout: function km_loadKeyboardLayout(layout) {
// Generate a <iframe mozbrowser> containing the keyboard.
console.log('km Generate a <iframe mozbrowser> containing the keyboard');
var keyboardURL = layout.origin + layout.path;
var manifestURL = layout.origin + '/manifest.webapp';
var keyboard = document.createElement('iframe');
keyboard.src = keyboardURL;
console.log('keyboard.src' + keyboard.src);
keyboard.setAttribute('mozapptype', 'inputmethod');
keyboard.setAttribute('mozbrowser', 'true');
keyboard.setAttribute('mozpasspointerevents', 'true');
Expand Down Expand Up @@ -401,6 +406,7 @@ var KeyboardManager = {
var self = this;
switch (evt.type) {
case 'mozbrowserresize':
console.log('km mozbrowserresize');
this.resizeKeyboard(evt);
break;
case 'attentionscreenshow':
Expand All @@ -416,19 +422,21 @@ var KeyboardManager = {
break;
case 'mozbrowsererror': // OOM
var origin = evt.target.dataset.frameOrigin;
this.removeKeyboard(origin);
this.removeKeyboard(origin, true);
break;
}
},

removeKeyboard: function km_removeKeyboard(origin) {
removeKeyboard: function km_removeKeyboard(origin, oom) {
if (!this.runningLayouts.hasOwnProperty(origin)) {
console.log('=== keyboard removeKeyboard ===');
return;
}

if (this.showingLayout.frame &&
this.showingLayout.frame.dataset.frameOrigin === origin) {
this.hideKeyboard();
this.hideKeyboardImmediately();
console.log('=== keyboard removeKeyboard hideKeyboard ===');
}

for (var id in this.runningLayouts[origin]) {
Expand All @@ -442,6 +450,27 @@ var KeyboardManager = {
}

delete this.runningLayouts[origin];

// make a fake click
if (oom) {
if (this.currentType === null) {
this.currentType = 'text';
}
var evt = {
detail: {
inputType: this.currentType
}
};
this.inputFocusChange(evt);
}

// var cancel = {
// 'title': 'ok'
// };
// cancel.callback = function onCancel() {
// CustomDialog.hide();
// };
// CustomDialog.show('keyboard error', 'keyboard error', cancel);
},

setKeyboardToShow: function km_setKeyboardToShow(group, index, launchOnly) {
Expand Down Expand Up @@ -474,6 +503,7 @@ var KeyboardManager = {
this.setLayoutFrameActive(this.showingLayout.frame, true);
this.showingLayout.frame.addEventListener(
'mozbrowserresize', this, true);
console.log('km add mozbrowserresize');
},

showKeyboard: function km_showKeyboard(callback) {
Expand Down Expand Up @@ -556,6 +586,7 @@ var KeyboardManager = {
this.setLayoutFrameActive(this.showingLayout.frame, false);
this.showingLayout.frame.removeEventListener(
'mozbrowserresize', this, true);
console.log('km remove mozbrowserresize');
this.showingLayout.reset();
},

Expand Down