Changes

Jump to: navigation, search

WebAPI/KeboardIME

1,996 bytes added, 04:33, 19 July 2013
comments of Yuan
// [JJ] What is removeFocus doing here. Everything that interacts with form elements
// happens in the inputContext, so this should be there too.
// [yxl] Agree with JJ. It needs be under InputContext.
void removeFocus();
};
* [JJ] Do we have any case where loading the full text is required?
* I don't see it in the example code.
* [yxl] No, but in case any IME needs.
*/
Promise<DOMString> getText();
* [JJ] I think that this method should return the same info as the selectionchange event
* rather than a boolean.
* [yxl] I don't think so. We could get selection range info by checking the attributes of
* selectionStart and selectionEnd.
*/
Promise<boolean> setSelectionRange(long start, long length);
* in the end, every onselectionchange event will also generate a surrounding
* text change event.
* [yxl] remove this and merge with onsurroundingtextchange
attribute EventHandler onselectionchange;
* App is encouraged to use this instead of getText() above to prevent getting to much things clogged in memory.
* TODO: how to return two values in one Promise object? as two arguments to the callback?
* [yxl] Impossible to return two value, but can wrap the two value with an object.
* Another option is to divide this method into two methods - getTextBeforeCursor and getTextAfterCursor.
*
* [JJ] Would be useful to also include other state info (cursor position, selection pos, etc.)
* So we have 1 state object that gets returned regardless of operation
* (same one as in the change handlers and setSelectionRange) * [yxl] Not necessary. cursor position or selection pos can be get by the attributes of selectionStart * and selectionEnd.
*/
Promise<DOMString beforeText, DOMString afterText> getSurroundingText();
* [JJ] Rather do a replaceSurroundingText(long offset, long length, optional DOMString text)
* If text is null or empty, it behaves the same
* [yxl] We changed the name of replaceSurroundingText to commitText. commitText will do the
* work of updateSurroundingText.
*/
Promise<boolean> deleteSurroundingText(long offset, long length);
* @param beforeString Text before and including cursor position.
* @param afterString Text after and excluing cursor position.
* [yxl] To combine with onselectionchange, we need add two extra paramters - selectionStart, selectionEnd
* function(DOMString beforeText, DOMString afterText) {
* ...
* }
* TODO: Is this a DOM Event or an attribute allows callback attachment? We should align the wording here.
* [yxl]: An attribute allows callback attachment.
* TODO2: should this be |oncursorpositionchange|?
* [yxl]: No, the cursor may not move when the surrounding text changes.
*/
attribute SurroundingTextChangeEventHandler onsurroundingtextchange;
* TODO: what does Promise object returns?
* TODO2: what are the modifiers?
* [yxl] http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/base/nsIDOMWindowUtils.idl#206
* Alternative: sendKey(KeyboardEvent event), but we will likely waste memory for creating the KeyboardEvent object.
* [JJ] Why does this return anything?
* [yxl] sendKey may fail if the input context becomes void.
*/
Promise<boolean> sendKey(long keyCode, long charCode, long modifiers);
/*
* [yx] I'd like to replace this method with commitText and add clearComposition to allow IME
* to cancel composition.
* endComposition and actually commit the text.
* Ending the composition with an empty string will not send any text.
*/
Promise<boolean> endComposition(DOMString text);
 
/*
* [yxl]
* Commit text to current input field and replace text around cursor position. It will clear the current composition.
*
* @param text The string to be replaced with.
* @param offset The offset from the cursor position where replacing starts. Defaults to 0.
* @param length The length of text to replace. Defaults to 0.
*/
Promise<boolean> commitText(DOMString text, [optional] long offset, [optional] long length);
};
* For a simple virtual keyboard action (send a character and key events w/ each user action), use <code>sendKey()</code>. TODO: should we allow backspace key to be sent from the method? If not, how do send these non-printable characters and it's effect with key events?
*[yxl] I perfer to allowing non-printable character, such as backspace key, to be sent, if there is no security issue. This
* would give the IME more flexibility.
* For spellcheck, autocomplete etc, use surrounding text methods.
* For cursor moment helper features, use <code>setSelectionRange()</code> and related attributes.
Confirm
58
edits

Navigation menu