mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 986992 - Remove navigator.mozKeyboard. r=fabrice
This commit is contained in:
parent
913fd17798
commit
bc5a409cfc
@ -1,6 +1,2 @@
|
||||
component {397a7fdf-2254-47be-b74e-76625a1a66d5} MozKeyboard.js
|
||||
contract @mozilla.org/b2g-keyboard;1 {397a7fdf-2254-47be-b74e-76625a1a66d5}
|
||||
category JavaScript-navigator-property mozKeyboard @mozilla.org/b2g-keyboard;1
|
||||
|
||||
component {4607330d-e7d2-40a4-9eb8-43967eae0142} MozKeyboard.js
|
||||
contract @mozilla.org/b2g-inputmethod;1 {4607330d-e7d2-40a4-9eb8-43967eae0142}
|
||||
|
@ -24,7 +24,6 @@ this.Keyboard = {
|
||||
],
|
||||
|
||||
_messageNames: [
|
||||
'SetValue', 'RemoveFocus', 'SetSelectedOption', 'SetSelectedOptions',
|
||||
'SetSelectionRange', 'ReplaceSurroundingText', 'ShowInputMethodPicker',
|
||||
'SwitchToNextInputMethod', 'HideInputMethod',
|
||||
'GetText', 'SendKey', 'GetContext',
|
||||
@ -167,7 +166,6 @@ this.Keyboard = {
|
||||
this.forwardEvent(name, msg);
|
||||
break;
|
||||
|
||||
case 'Keyboard:SetValue':
|
||||
case 'System:SetValue':
|
||||
this.setValue(msg);
|
||||
break;
|
||||
@ -175,11 +173,9 @@ this.Keyboard = {
|
||||
case 'System:RemoveFocus':
|
||||
this.removeFocus();
|
||||
break;
|
||||
case 'Keyboard:SetSelectedOption':
|
||||
case 'System:SetSelectedOption':
|
||||
this.setSelectedOption(msg);
|
||||
break;
|
||||
case 'Keyboard:SetSelectedOptions':
|
||||
case 'System:SetSelectedOptions':
|
||||
this.setSelectedOption(msg);
|
||||
break;
|
||||
|
@ -18,187 +18,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "tm",
|
||||
"@mozilla.org/thread-manager;1", "nsIThreadManager");
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// MozKeyboard
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
function MozKeyboard() { }
|
||||
|
||||
MozKeyboard.prototype = {
|
||||
classID: Components.ID("{397a7fdf-2254-47be-b74e-76625a1a66d5}"),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Ci.nsIB2GKeyboard, Ci.nsIDOMGlobalPropertyInitializer, Ci.nsIObserver
|
||||
]),
|
||||
|
||||
classInfo: XPCOMUtils.generateCI({
|
||||
"classID": Components.ID("{397a7fdf-2254-47be-b74e-76625a1a66d5}"),
|
||||
"contractID": "@mozilla.org/b2g-keyboard;1",
|
||||
"interfaces": [Ci.nsIB2GKeyboard],
|
||||
"flags": Ci.nsIClassInfo.DOM_OBJECT,
|
||||
"classDescription": "B2G Virtual Keyboard"
|
||||
}),
|
||||
|
||||
init: function mozKeyboardInit(win) {
|
||||
let principal = win.document.nodePrincipal;
|
||||
// Limited the deprecated mozKeyboard API to certified apps only
|
||||
let perm = Services.perms.testExactPermissionFromPrincipal(principal,
|
||||
"input-manage");
|
||||
if (perm != Ci.nsIPermissionManager.ALLOW_ACTION) {
|
||||
dump("No permission to use the keyboard API for " +
|
||||
principal.origin + "\n");
|
||||
return null;
|
||||
}
|
||||
|
||||
Services.obs.addObserver(this, "inner-window-destroyed", false);
|
||||
cpmm.addMessageListener('Keyboard:FocusChange', this);
|
||||
cpmm.addMessageListener('Keyboard:SelectionChange', this);
|
||||
|
||||
this._window = win;
|
||||
this._utils = win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
this.innerWindowID = this._utils.currentInnerWindowID;
|
||||
this._focusHandler = null;
|
||||
this._selectionHandler = null;
|
||||
this._selectionStart = -1;
|
||||
this._selectionEnd = -1;
|
||||
},
|
||||
|
||||
uninit: function mozKeyboardUninit() {
|
||||
Services.obs.removeObserver(this, "inner-window-destroyed");
|
||||
cpmm.removeMessageListener('Keyboard:FocusChange', this);
|
||||
cpmm.removeMessageListener('Keyboard:SelectionChange', this);
|
||||
|
||||
this._window = null;
|
||||
this._utils = null;
|
||||
this._focusHandler = null;
|
||||
this._selectionHandler = null;
|
||||
},
|
||||
|
||||
sendKey: function mozKeyboardSendKey(keyCode, charCode) {
|
||||
charCode = (charCode == undefined) ? keyCode : charCode;
|
||||
|
||||
let mainThread = tm.mainThread;
|
||||
let utils = this._utils;
|
||||
|
||||
function send(type) {
|
||||
mainThread.dispatch(function() {
|
||||
utils.sendKeyEvent(type, keyCode, charCode, null);
|
||||
}, mainThread.DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
send("keydown");
|
||||
send("keypress");
|
||||
send("keyup");
|
||||
},
|
||||
|
||||
setSelectedOption: function mozKeyboardSetSelectedOption(index) {
|
||||
cpmm.sendAsyncMessage('Keyboard:SetSelectedOption', {
|
||||
'index': index
|
||||
});
|
||||
},
|
||||
|
||||
setValue: function mozKeyboardSetValue(value) {
|
||||
cpmm.sendAsyncMessage('Keyboard:SetValue', {
|
||||
'value': value
|
||||
});
|
||||
},
|
||||
|
||||
setSelectedOptions: function mozKeyboardSetSelectedOptions(indexes) {
|
||||
cpmm.sendAsyncMessage('Keyboard:SetSelectedOptions', {
|
||||
'indexes': indexes
|
||||
});
|
||||
},
|
||||
|
||||
set onselectionchange(val) {
|
||||
this._selectionHandler = val;
|
||||
},
|
||||
|
||||
get onselectionchange() {
|
||||
return this._selectionHandler;
|
||||
},
|
||||
|
||||
get selectionStart() {
|
||||
return this._selectionStart;
|
||||
},
|
||||
|
||||
get selectionEnd() {
|
||||
return this._selectionEnd;
|
||||
},
|
||||
|
||||
setSelectionRange: function mozKeyboardSetSelectionRange(start, end) {
|
||||
cpmm.sendAsyncMessage('Keyboard:SetSelectionRange', {
|
||||
'selectionStart': start,
|
||||
'selectionEnd': end
|
||||
});
|
||||
},
|
||||
|
||||
removeFocus: function mozKeyboardRemoveFocus() {
|
||||
cpmm.sendAsyncMessage('Keyboard:RemoveFocus', {});
|
||||
},
|
||||
|
||||
set onfocuschange(val) {
|
||||
this._focusHandler = val;
|
||||
},
|
||||
|
||||
get onfocuschange() {
|
||||
return this._focusHandler;
|
||||
},
|
||||
|
||||
replaceSurroundingText: function mozKeyboardReplaceSurroundingText(
|
||||
text, beforeLength, afterLength) {
|
||||
cpmm.sendAsyncMessage('Keyboard:ReplaceSurroundingText', {
|
||||
'text': text || '',
|
||||
'beforeLength': (typeof beforeLength === 'number' ? beforeLength : 0),
|
||||
'afterLength': (typeof afterLength === 'number' ? afterLength: 0)
|
||||
});
|
||||
},
|
||||
|
||||
receiveMessage: function mozKeyboardReceiveMessage(msg) {
|
||||
if (msg.name == "Keyboard:FocusChange") {
|
||||
let msgJson = msg.json;
|
||||
if (msgJson.type != "blur") {
|
||||
this._selectionStart = msgJson.selectionStart;
|
||||
this._selectionEnd = msgJson.selectionEnd;
|
||||
} else {
|
||||
this._selectionStart = 0;
|
||||
this._selectionEnd = 0;
|
||||
}
|
||||
|
||||
let handler = this._focusHandler;
|
||||
if (!handler || !(handler instanceof Ci.nsIDOMEventListener))
|
||||
return;
|
||||
|
||||
let detail = {
|
||||
"detail": msgJson
|
||||
};
|
||||
|
||||
let evt = new this._window.CustomEvent("focuschanged",
|
||||
Cu.cloneInto(detail, this._window));
|
||||
handler.handleEvent(evt);
|
||||
} else if (msg.name == "Keyboard:SelectionChange") {
|
||||
let msgJson = msg.json;
|
||||
|
||||
this._selectionStart = msgJson.selectionStart;
|
||||
this._selectionEnd = msgJson.selectionEnd;
|
||||
|
||||
let handler = this._selectionHandler;
|
||||
if (!handler || !(handler instanceof Ci.nsIDOMEventListener))
|
||||
return;
|
||||
|
||||
let evt = new this._window.CustomEvent("selectionchange",
|
||||
Cu.cloneInto({}, this._window));
|
||||
handler.handleEvent(evt);
|
||||
}
|
||||
},
|
||||
|
||||
observe: function mozKeyboardObserve(subject, topic, data) {
|
||||
let wId = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
|
||||
if (wId == this.innerWindowID)
|
||||
this.uninit();
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* A WeakMap to map input method iframe window to its active status.
|
||||
*/
|
||||
@ -769,5 +588,4 @@ MozInputContext.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory(
|
||||
[MozKeyboard, MozInputMethod]);
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MozInputMethod]);
|
||||
|
@ -6,12 +6,6 @@
|
||||
|
||||
TEST_DIRS += ['mochitest']
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIB2GKeyboard.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'dom_inputmethod'
|
||||
|
||||
EXTRA_COMPONENTS += [
|
||||
'InputMethod.manifest',
|
||||
'MozKeyboard.js',
|
||||
@ -21,4 +15,4 @@ EXTRA_JS_MODULES += [
|
||||
'Keyboard.jsm',
|
||||
]
|
||||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
|
@ -1,71 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(40ad96b2-9efa-41fb-84c7-fbcec9b153f0)]
|
||||
interface nsIB2GKeyboard : nsISupports
|
||||
{
|
||||
void sendKey(in long keyCode, in long charCode);
|
||||
|
||||
// Select the <select> option specified by index.
|
||||
// If this method is called on a <select> that support multiple
|
||||
// selection, then the option specified by index will be added to
|
||||
// the selection.
|
||||
// If this method is called for a select that does not support multiple
|
||||
// selection the previous element will be unselected.
|
||||
void setSelectedOption(in jsval index);
|
||||
|
||||
// Select the <select> options specified by indexes. All other options
|
||||
// will be deselected.
|
||||
// If this method is called for a <select> that does not support multiple
|
||||
// selection, then the last index specified in indexes will be selected.
|
||||
void setSelectedOptions(in jsval indexes);
|
||||
|
||||
// Set the value on the currently focused element. This has to be used
|
||||
// for special situations where the value had to be chosen amongst a
|
||||
// list (type=month) or a widget (type=date, time, etc.).
|
||||
// If the value passed in parameter isn't valid (in the term of HTML5
|
||||
// Forms Validation), the value will simply be ignored by the element.
|
||||
void setValue(in jsval value);
|
||||
|
||||
void removeFocus();
|
||||
|
||||
attribute nsIDOMEventListener onfocuschange;
|
||||
|
||||
// Fires when user moves the cursor, changes the selection, or alters the
|
||||
// composing text length
|
||||
attribute nsIDOMEventListener onselectionchange;
|
||||
|
||||
// The start position of the selection.
|
||||
readonly attribute long selectionStart;
|
||||
|
||||
// The stop position of the selection.
|
||||
readonly attribute long selectionEnd;
|
||||
|
||||
/*
|
||||
* Set the selection range of the the editable text.
|
||||
*
|
||||
* @param start The beginning of the selected text.
|
||||
* @param end The end of the selected text.
|
||||
*
|
||||
* Note that the start position should be less or equal to the end position.
|
||||
* To move the cursor, set the start and end position to the same value.
|
||||
*/
|
||||
void setSelectionRange(in long start, in long end);
|
||||
|
||||
/*
|
||||
* Replace text around the beginning of the current selection range of the
|
||||
* editable text.
|
||||
*
|
||||
* @param text The string to be replaced with.
|
||||
* @param beforeLength The number of characters to be deleted before the
|
||||
* beginning of the current selection range. Defaults to 0.
|
||||
* @param afterLength The number of characters to be deleted after the
|
||||
* beginning of the current selection range. Defaults to 0.
|
||||
*/
|
||||
void replaceSurroundingText(in DOMString text,
|
||||
[optional] in long beforeLength,
|
||||
[optional] in long afterLength);
|
||||
};
|
Loading…
Reference in New Issue
Block a user