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

Commit

Permalink
Merge pull request #12197 from comoyo/revert_supportsswitching
Browse files Browse the repository at this point in the history
Revert "Bug 912951 - Send content event from gaia -> chrome with layout info for supportsSwitching"
  • Loading branch information
janjongboom committed Sep 13, 2013
2 parents 5ab80f7 + 44d1a86 commit 4ad9fb3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 103 deletions.
13 changes: 0 additions & 13 deletions apps/system/js/keyboard_manager.js
Expand Up @@ -149,19 +149,6 @@ var KeyboardManager = {
var initType = self.showingLayout.type;
var initIndex = self.showingLayout.index;
self.launchLayoutFrame(self.keyboardLayouts[initType][initIndex]);

// Let chrome know about how many keyboards we have
var layouts = {};
Object.keys(self.keyboardLayouts).forEach(function(k) {
layouts[k] = self.keyboardLayouts[k].length;
});

var event = document.createEvent('CustomEvent');
event.initCustomEvent('mozContentEvent', true, true, {
type: 'inputmethod-update-layouts',
layouts: layouts
});
window.dispatchEvent(event);
}
KeyboardHelper.getInstalledKeyboards(resetLayoutList);
},
Expand Down
2 changes: 0 additions & 2 deletions tools/extensions/browser-helper@gaiamobile.org/bootstrap.js
Expand Up @@ -191,8 +191,6 @@ function startup(data, reason) {
mm.addMessageListener('Forms:SendKey:Result:OK', Keyboard);
mm.addMessageListener('Forms:SequenceError', Keyboard);
mm.addMessageListener('Forms:GetContext:Result:OK', Keyboard);
mm.addMessageListener('Forms:SetComposition:Result:OK', Keyboard);
mm.addMessageListener('Forms:EndComposition:Result:OK', Keyboard);
mm.loadFrameScript('chrome://keyboard.js/content/forms.js', true);
} catch(e) {
debug('Can\'t load Keyboard.jsm. Likely because the keyboard addon is not here.');
Expand Down
22 changes: 0 additions & 22 deletions tools/extensions/browser-helper@gaiamobile.org/content/shell.js
Expand Up @@ -12,7 +12,6 @@ let Cu = Components.utils;
let Cr = Components.results;

Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://gre/modules/Keyboard.jsm');

// Various helpers coming from /b2g/chrome/content/shell.js
function getContentWindow() {
Expand Down Expand Up @@ -165,24 +164,3 @@ SettingsListener.observe('language.current', 'en-US', function(value) {
});
}
});

/**
* This code comes from b2g/chrome/content/shell.js
* For now just the keyboard stuff, should copy everything over at some point
*/
getContentWindow().addEventListener('mozContentEvent', function(evt) {
let detail = evt.detail;
dump('XXX FIXME : Got a mozContentEvent: ' + detail.type + "\n");

switch(detail.type) {
case 'inputmethod-update-layouts':
KeyboardHelper.handleEvent(detail);
break;
}
});

let KeyboardHelper = {
handleEvent: function keyboard_handleEvent(aMessage) {
Keyboard.setLayouts(aMessage.layouts);
}
};
15 changes: 1 addition & 14 deletions tools/extensions/keyboard/components/MozKeyboard.js
Expand Up @@ -206,8 +206,6 @@ MozKeyboard.prototype = {
function MozInputMethodManager() { }

MozInputMethodManager.prototype = {
_supportsSwitching: false,

classID: Components.ID("{7e9d7280-ef86-11e2-b778-0800200c9a66}"),

QueryInterface: XPCOMUtils.generateQI([
Expand All @@ -231,7 +229,7 @@ MozInputMethodManager.prototype = {
},

supportsSwitching: function() {
return this._supportsSwitching;
return true;
},

hide: function() {
Expand All @@ -248,7 +246,6 @@ function MozInputMethod() { }

MozInputMethod.prototype = {
_inputcontext: null,
_layouts: {},

classID: Components.ID("{4607330d-e7d2-40a4-9eb8-43967eae0142}"),

Expand Down Expand Up @@ -286,7 +283,6 @@ MozInputMethod.prototype = {
cpmm.addMessageListener('Keyboard:FocusChange', this);
cpmm.addMessageListener('Keyboard:SelectionChange', this);
cpmm.addMessageListener('Keyboard:GetContext:Result:OK', this);
cpmm.addMessageListener('Keyboard:LayoutsChange', this);

// If there already is an active context, then this will trigger
// a GetContext:Result:OK event, and we can initialize ourselves.
Expand All @@ -299,7 +295,6 @@ MozInputMethod.prototype = {
cpmm.removeMessageListener('Keyboard:FocusChange', this);
cpmm.removeMessageListener('Keyboard:SelectionChange', this);
cpmm.removeMessageListener('Keyboard:GetContext:Result:OK', this);
cpmm.removeMessageListener('Keyboard:LayoutsChange', this);

this._window = null;
this._inputcontextHandler = null;
Expand All @@ -324,9 +319,6 @@ MozInputMethod.prototype = {
case 'Keyboard:GetContext:Result:OK':
this.setInputContext(json);
break;
case 'Keyboard:LayoutsChange':
this._layouts = json;
break;
}
},

Expand Down Expand Up @@ -356,14 +348,9 @@ MozInputMethod.prototype = {
if (this._inputcontext) {
this._inputcontext.destroy();
this._inputcontext = null;
this._mgmt._supportsSwitching = false;
}

if (data) {
this._mgmt._supportsSwitching = this._layouts[data.type] ?
this._layouts[data.type] > 1 :
false;

this._inputcontext = new MozInputContext(data);
this._inputcontext.init(this._window);
}
Expand Down
63 changes: 11 additions & 52 deletions tools/extensions/keyboard/content/Keyboard.jsm
Expand Up @@ -23,8 +23,7 @@ let Keyboard = {
'SetValue', 'RemoveFocus', 'SetSelectedOption', 'SetSelectedOptions',
'SetSelectionRange', 'ReplaceSurroundingText', 'ShowInputMethodPicker',
'SwitchToNextInputMethod', 'HideInputMethod',
'GetText', 'SendKey', 'GetContext',
'SetComposition', 'EndComposition'
'GetText', 'SendKey', 'GetContext'
],

get messageManager() {
Expand All @@ -38,12 +37,6 @@ let Keyboard = {
this._messageManager = mm;
},

sendAsyncMessage: function(name, data) {
try {
this.messageManager.sendAsyncMessage(name, data);
} catch(e) { }
},

init: function keyboardInit() {
Services.obs.addObserver(this, 'in-process-browser-or-app-frame-shown', false);
Services.obs.addObserver(this, 'remote-browser-frame-shown', false);
Expand Down Expand Up @@ -73,8 +66,6 @@ let Keyboard = {
mm.addMessageListener('Forms:SendKey:Result:OK', this);
mm.addMessageListener('Forms:SequenceError', this);
mm.addMessageListener('Forms:GetContext:Result:OK', this);
mm.addMessageListener('Forms:SetComposition:Result:OK', this);
mm.addMessageListener('Forms:EndComposition:Result:OK', this);

// When not running apps OOP, we need to load forms.js here since this
// won't happen from dom/ipc/preload.js
Expand Down Expand Up @@ -125,8 +116,6 @@ let Keyboard = {
case 'Forms:SendKey:Result:OK':
case 'Forms:SequenceError':
case 'Forms:GetContext:Result:OK':
case 'Forms:SetComposition:Result:OK':
case 'Forms:EndComposition:Result:OK':
let name = msg.name.replace(/^Forms/, 'Keyboard');
this.forwardEvent(name, msg);
break;
Expand Down Expand Up @@ -164,12 +153,6 @@ let Keyboard = {
case 'Keyboard:GetContext':
this.getContext(msg);
break;
case 'Keyboard:SetComposition':
this.setComposition(msg);
break;
case 'Keyboard:EndComposition':
this.endComposition(msg);
break;
}
},

Expand All @@ -192,27 +175,28 @@ let Keyboard = {
},

setSelectedOption: function keyboardSetSelectedOption(msg) {
this.sendAsyncMessage('Forms:Select:Choice', msg.data);
this.messageManager.sendAsyncMessage('Forms:Select:Choice', msg.data);
},

setSelectedOptions: function keyboardSetSelectedOptions(msg) {
this.sendAsyncMessage('Forms:Select:Choice', msg.data);
this.messageManager.sendAsyncMessage('Forms:Select:Choice', msg.data);
},

setSelectionRange: function keyboardSetSelectionRange(msg) {
this.sendAsyncMessage('Forms:SetSelectionRange', msg.data);
this.messageManager.sendAsyncMessage('Forms:SetSelectionRange', msg.data);
},

setValue: function keyboardSetValue(msg) {
this.sendAsyncMessage('Forms:Input:Value', msg.data);
this.messageManager.sendAsyncMessage('Forms:Input:Value', msg.data);
},

removeFocus: function keyboardRemoveFocus() {
this.sendAsyncMessage('Forms:Select:Blur', {});
this.messageManager.sendAsyncMessage('Forms:Select:Blur', {});
},

replaceSurroundingText: function keyboardReplaceSurroundingText(msg) {
this.sendAsyncMessage('Forms:ReplaceSurroundingText', msg.data);
this.messageManager.sendAsyncMessage('Forms:ReplaceSurroundingText',
msg.data);
},

showInputMethodPicker: function keyboardShowInputMethodPicker() {
Expand All @@ -230,40 +214,15 @@ let Keyboard = {
},

getText: function keyboardGetText(msg) {
this.sendAsyncMessage('Forms:GetText', msg.data);
this.messageManager.sendAsyncMessage('Forms:GetText', msg.data);
},

sendKey: function keyboardSendKey(msg) {
this.sendAsyncMessage('Forms:Input:SendKey', msg.data);
this.messageManager.sendAsyncMessage('Forms:Input:SendKey', msg.data);
},

getContext: function keyboardGetContext(msg) {
if (this._layouts) {
ppmm.broadcastAsyncMessage('Keyboard:LayoutsChange', this._layouts);
}

this.sendAsyncMessage('Forms:GetContext', msg.data);
},

setComposition: function keyboardSetComposition(msg) {
this.sendAsyncMessage('Forms:SetComposition', msg.data);
},

endComposition: function keyboardEndComposition(msg) {
this.sendAsyncMessage('Forms:EndComposition', msg.data);
},

/**
* Get the number of keyboard layouts active from keyboard_manager
*/
_layouts: null,
setLayouts: function keyboardSetLayoutCount(layouts) {
// The input method plugins may not have loaded yet,
// cache the layouts so on init we can respond immediately instead
// of going back and forth between keyboard_manager
this._layouts = layouts;

ppmm.broadcastAsyncMessage('Keyboard:LayoutsChange', layouts);
this.messageManager.sendAsyncMessage('Forms:GetContext', msg.data);
}
};

Expand Down

0 comments on commit 4ad9fb3

Please sign in to comment.