diff options
author | wnwen <wnwen@chromium.org> | 2015-03-17 15:03:49 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-17 22:04:16 +0000 |
commit | a13b511596a13af3b47785e283c42cd0d5520e84 (patch) | |
tree | b8b05548338c6bee882a2a572fbe5bec38bb0502 /third_party/google_input_tools | |
parent | aea1789c173cf5bda308acdb2a1fd68a54085d15 (diff) | |
download | chromium_src-a13b511596a13af3b47785e283c42cd0d5520e84.zip chromium_src-a13b511596a13af3b47785e283c42cd0d5520e84.tar.gz chromium_src-a13b511596a13af3b47785e283c42cd0d5520e84.tar.bz2 |
Update Google Input Tools.
BUG=450050
Review URL: https://codereview.chromium.org/1013263002
Cr-Commit-Position: refs/heads/master@{#320989}
Diffstat (limited to 'third_party/google_input_tools')
20 files changed, 589 insertions, 268 deletions
diff --git a/third_party/google_input_tools/README.chromium b/third_party/google_input_tools/README.chromium index e2ac725..fd2da1b 100644 --- a/third_party/google_input_tools/README.chromium +++ b/third_party/google_input_tools/README.chromium @@ -1,8 +1,8 @@ Name: Google Input Tools Short Name: google_input_tools URL: https://github.com/googlei18n/google-input-tools.git -Version: 1.0.6.2 -Revision: @1af2274f7a754bb3f18a3618f0e94981d682bc16 +Version: 1.0.4.3 +Revision: @3730e096a782f1c74a3db0831aff63fb74540b97 License: Apache 2.0 License File: LICENSE Security Critical: yes diff --git a/third_party/google_input_tools/inputview.gypi b/third_party/google_input_tools/inputview.gypi index a9821aa..77b8687 100644 --- a/third_party/google_input_tools/inputview.gypi +++ b/third_party/google_input_tools/inputview.gypi @@ -114,6 +114,7 @@ 'src/chrome/os/message/contexttype.js', 'src/chrome/os/message/event.js', 'src/chrome/os/message/name.js', + 'src/chrome/os/message/source.js', 'src/chrome/os/message/type.js', 'src/chrome/os/sounds/soundcontroller.js', 'src/chrome/os/sounds/sounds.js', diff --git a/third_party/google_input_tools/src/chrome/os/inputview/_locales/da/messages.json b/third_party/google_input_tools/src/chrome/os/inputview/_locales/da/messages.json index f0a8f4f..f292930 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/_locales/da/messages.json +++ b/third_party/google_input_tools/src/chrome/os/inputview/_locales/da/messages.json @@ -1704,10 +1704,10 @@ "message": "ledningsstik" }, "d83d_dd0d": { - "message": "forst\u00f8rrelsesglas (venstre)" + "message": "lup (venstre)" }, "d83d_dd0e": { - "message": "forst\u00f8rrelsesglas (h\u00f8jre)" + "message": "lup (h\u00f8jre)" }, "d83d_dd0f": { "message": "l\u00e5s med pen" diff --git a/third_party/google_input_tools/src/chrome/os/inputview/adapter.js b/third_party/google_input_tools/src/chrome/os/inputview/adapter.js index b666478..3c3eaaa 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/adapter.js +++ b/third_party/google_input_tools/src/chrome/os/inputview/adapter.js @@ -38,7 +38,6 @@ var ContextType = i18n.input.chrome.message.ContextType; var FeatureTracker = i18n.input.chrome.inputview.FeatureTracker; var FeatureName = i18n.input.chrome.inputview.FeatureName; var Name = i18n.input.chrome.message.Name; -var SizeSpec = i18n.input.chrome.inputview.SizeSpec; var Type = i18n.input.chrome.message.Type; @@ -369,7 +368,7 @@ Adapter.prototype.isGestureDeletionEnabled = function() { if (this.contextType == ContextType.URL) { return false; } - return this.features.isEnabled(FeatureName.GESTURE_EDITTING); + return this.features.isEnabled(FeatureName.GESTURE_DELETION); }; @@ -403,7 +402,7 @@ Adapter.prototype.queryCurrentSite = function() { var criteria = {'active': true, 'lastFocusedWindow': true}; if (chrome && chrome.tabs) { chrome.tabs.query(criteria, function(tabs) { - tabs[0] && adapter.setCurrentSite_(tabs[0].url); + tabs[0] && adapter.setCurrentSite_(tabs[0].url); }); } }; @@ -504,7 +503,8 @@ Adapter.prototype.initialize = function(languageCode) { this.maybeDispatchSettingsReadyEvent_(); }).bind(this)); inputview.getInputMethodConfig((function(config) { - this.isQPInputView = !!config['isNewQPInputViewEnabled']; + this.isQPInputView = !!config['isNewQPInputViewEnabled'] || + !!config['isNewMDInputViewEnabled']; var voiceEnabled = config['isVoiceInputEnabled']; if (goog.isDef(voiceEnabled)) { this.isVoiceInputEnabled = !!voiceEnabled; diff --git a/third_party/google_input_tools/src/chrome/os/inputview/controller.js b/third_party/google_input_tools/src/chrome/os/inputview/controller.js index 6d4bc10..e754cae 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/controller.js +++ b/third_party/google_input_tools/src/chrome/os/inputview/controller.js @@ -45,7 +45,6 @@ goog.require('i18n.input.chrome.inputview.elements.content.Candidate'); goog.require('i18n.input.chrome.inputview.elements.content.CandidateView'); goog.require('i18n.input.chrome.inputview.elements.content.ExpandedCandidateView'); goog.require('i18n.input.chrome.inputview.elements.content.MenuView'); -goog.require('i18n.input.chrome.inputview.events.DragEvent'); goog.require('i18n.input.chrome.inputview.events.EventType'); goog.require('i18n.input.chrome.inputview.events.KeyCodes'); goog.require('i18n.input.chrome.inputview.handler.PointerHandler'); @@ -60,7 +59,6 @@ goog.require('i18n.input.lang.InputToolCode'); goog.scope(function() { var CandidateType = i18n.input.chrome.inputview.elements.content.Candidate.Type; -var Candidate = i18n.input.chrome.inputview.elements.content.Candidate; var CandidateView = i18n.input.chrome.inputview.elements.content.CandidateView; var ConditionName = i18n.input.chrome.inputview.ConditionName; var ContextType = i18n.input.chrome.message.ContextType; @@ -78,9 +76,7 @@ var PerfTracker = i18n.input.chrome.inputview.PerfTracker; var SizeSpec = i18n.input.chrome.inputview.SizeSpec; var SpecNodeName = i18n.input.chrome.inputview.SpecNodeName; var StateType = i18n.input.chrome.inputview.StateType; -var content = i18n.input.chrome.inputview.elements.content; var SoundController = i18n.input.chrome.sounds.SoundController; -var Sounds = i18n.input.chrome.sounds.Sounds; var Type = i18n.input.chrome.message.Type; var util = i18n.input.chrome.inputview.util; @@ -410,7 +406,7 @@ Controller.prototype.passwordKeyset_ = ''; * The soft key map, because key configuration is loaded before layout, * controller needs this varaible to save it and hook into keyboard view. * - * @type {!Array.<!content.SoftKey>} + * @type {!Array.<!i18n.input.chrome.inputview.elements.content.SoftKey>} * @private */ Controller.prototype.softKeyList_; @@ -426,15 +422,6 @@ Controller.prototype.mapping_; /** - * The dead key. - * - * @type {string} - * @private - */ -Controller.prototype.deadKey_ = ''; - - -/** * The input tool name. * * @type {string} @@ -499,7 +486,6 @@ Controller.prototype.registerEventHandler_ = function() { * @private */ Controller.prototype.onVoiceStateChange_ = function(e) { - var elem = this.container_.getElement(); if (!e.msg[Name.VOICE_STATE]) { this.container_.candidateView.switchToIcon( CandidateView.IconType.VOICE, true); @@ -610,7 +596,7 @@ Controller.prototype.onSettingsReady_ = function() { this.setDefaultKeyset_(newKeyset); } this.container_.selectView.setVisible( - this.adapter_.features.isEnabled(FeatureName.GESTURE_EDITTING)); + this.adapter_.features.isEnabled(FeatureName.GESTURE_SELECTION)); // Loads resources in case the default keyset is changed. this.loadAllResources_(); this.maybeCreateViews_(); @@ -620,7 +606,7 @@ Controller.prototype.onSettingsReady_ = function() { /** * Gets the data for spatial module. * - * @param {!content.SoftKey} key . + * @param {!i18n.input.chrome.inputview.elements.content.SoftKey} key . * @param {number} x The x-offset of the touch point. * @param {number} y The y-offset of the touch point. * @return {!Object} . @@ -656,19 +642,21 @@ Controller.prototype.getSpatialData_ = function(key, x, y) { /** * Gets the key content. * - * @param {!content.SoftKey} key . + * @param {!i18n.input.chrome.inputview.elements.content.SoftKey} key . * @return {string} . * @private */ Controller.prototype.getKeyContent_ = function(key) { if (key.type == i18n.input.chrome.inputview.elements.ElementType. CHARACTER_KEY) { - key = /** @type {!content.CharacterKey} */ (key); + key = /** @type {!i18n.input.chrome.inputview.elements.content. + CharacterKey} */ (key); return key.getActiveCharacter(); } if (key.type == i18n.input.chrome.inputview.elements.ElementType. COMPACT_KEY) { - key = /** @type {!content.FunctionalKey} */ (key); + key = /** @type {!i18n.input.chrome.inputview.elements.content. + FunctionalKey} */ (key); return key.text; } return ''; @@ -769,7 +757,8 @@ Controller.prototype.handleSwipeAction_ = function(view, e) { } if (view.type == ElementType.CHARACTER_KEY) { - view = /** @type {!content.CharacterKey} */ (view); + view = /** @type {!i18n.input.chrome.inputview.elements.content. + CharacterKey} */ (view); if (direction & i18n.input.chrome.inputview.SwipeDirection.UP || direction & i18n.input.chrome.inputview.SwipeDirection.DOWN) { var ch = view.getCharacterByGesture(!!(direction & @@ -781,7 +770,9 @@ Controller.prototype.handleSwipeAction_ = function(view, e) { } if (view.type == ElementType.COMPACT_KEY) { - view = /** @type {!content.CompactKey} */ (view); + + view = /** @type {!i18n.input.chrome.inputview.elements.content. + CompactKey} */ (view); if ((direction & i18n.input.chrome.inputview.SwipeDirection.UP) && view.hintText) { view.flickerredCharacter = view.hintText; @@ -858,7 +849,7 @@ Controller.prototype.handlePointerAction_ = function(view, e) { } if (e.type == EventType.SWIPE) { - e = /** @type {!i18n.input.chrome.inputview.events.SwipeEvent} */ (e); + e = /** @type {!i18n.input.chrome.inputview.events.SwipeEvent} */ (e); this.handleSwipeAction_(view, e); } switch (view.type) { @@ -893,7 +884,8 @@ Controller.prototype.handlePointerAction_ = function(view, e) { } return; case ElementType.CANDIDATE: - view = /** @type {!Candidate} */ (view); + view = /** @type {!i18n.input.chrome.inputview.elements.content. + Candidate} */ (view); if (e.type == EventType.POINTER_UP) { if (view.candidateType == CandidateType.CANDIDATE) { this.adapter_.selectCandidate(view.candidate); @@ -912,7 +904,8 @@ Controller.prototype.handlePointerAction_ = function(view, e) { return; case ElementType.ALTDATA_VIEW: - view = /** @type {!content.AltDataView} */ (view); + view = /** @type {!i18n.input.chrome.inputview.elements.content. + AltDataView} */ (view); if (e.type == EventType.POINTER_DOWN && e.target == view.getCoverElement()) { view.hide(); @@ -930,7 +923,8 @@ Controller.prototype.handlePointerAction_ = function(view, e) { return; case ElementType.MENU_ITEM: - view = /** @type {!content.MenuItem} */ (view); + view = /** @type {!i18n.input.chrome.inputview.elements.content. + MenuItem} */ (view); if (e.type == EventType.CLICK) { this.executeCommand_.apply(this, view.getCommand()); this.container_.menuView.hide(); @@ -943,7 +937,8 @@ Controller.prototype.handlePointerAction_ = function(view, e) { return; case ElementType.MENU_VIEW: - view = /** @type {!MenuView} */ (view); + view = /** @type {!i18n.input.chrome.inputview.elements.content. + MenuView} */ (view); if (e.type == EventType.POINTER_DOWN && e.target == view.getCoverElement()) { @@ -1043,8 +1038,9 @@ Controller.prototype.handlePointerAction_ = function(view, e) { view.setHighlighted(false); } } - this.handlePointerEventForSoftKey_( - /** @type {!content.SoftKey} */ (view), e); + view = /** @type {!i18n.input.chrome.inputview.elements.content. + SoftKey} */ (view); + this.handlePointerEventForSoftKey_(view, e); this.updateContextModifierState_(); }; @@ -1052,7 +1048,7 @@ Controller.prototype.handlePointerAction_ = function(view, e) { /** * Handles softkey of the pointer action. * - * @param {!content.SoftKey} softKey . + * @param {!i18n.input.chrome.inputview.elements.content.SoftKey} softKey . * @param {!i18n.input.chrome.inputview.events.PointerEvent} e . * @private */ @@ -1070,7 +1066,8 @@ Controller.prototype.handlePointerEventForSoftKey_ = function(softKey, e) { } break; case ElementType.CHARACTER_KEY: - key = /** @type {!content.CharacterKey} */ (softKey); + key = /** @type {!i18n.input.chrome.inputview.elements.content. + CharacterKey} */ (softKey); if (e.type == EventType.LONG_PRESS) { this.container_.altDataView.show( key, goog.i18n.bidi.isRtlLanguage(this.languageCode_)); @@ -1085,7 +1082,8 @@ Controller.prototype.handlePointerEventForSoftKey_ = function(softKey, e) { break; case ElementType.MODIFIER_KEY: - key = /** @type {!content.ModifierKey} */ (softKey); + key = /** @type {!i18n.input.chrome.inputview.elements.content. + ModifierKey} */(softKey); var isStateEnabled = this.model_.stateManager.hasState(key.toState); var isChording = this.model_.stateManager.isChording(key.toState); if (e.type == EventType.POINTER_DOWN) { @@ -1112,7 +1110,8 @@ Controller.prototype.handlePointerEventForSoftKey_ = function(softKey, e) { break; case ElementType.BACKSPACE_KEY: - key = /** @type {!content.FunctionalKey} */ (softKey); + key = /** @type {!i18n.input.chrome.inputview.elements.content. + FunctionalKey} */(softKey); if (e.type == EventType.POINTER_DOWN) { this.backspaceTick_(); } else if (e.type == EventType.POINTER_UP || e.type == EventType. @@ -1124,7 +1123,8 @@ Controller.prototype.handlePointerEventForSoftKey_ = function(softKey, e) { break; case ElementType.TAB_KEY: - key = /** @type {!content.FunctionalKey} */ (softKey); + key = /** @type {!i18n.input.chrome.inputview.elements.content. + FunctionalKey} */ (softKey); if (e.type == EventType.POINTER_DOWN) { this.adapter_.sendKeyDownEvent('\u0009', KeyCodes.TAB); } else if (e.type == EventType.POINTER_UP) { @@ -1133,7 +1133,8 @@ Controller.prototype.handlePointerEventForSoftKey_ = function(softKey, e) { break; case ElementType.ENTER_KEY: - key = /** @type {!content.FunctionalKey} */ (softKey); + key = /** @type {!i18n.input.chrome.inputview.elements.content. + FunctionalKey} */ (softKey); if (e.type == EventType.POINTER_UP) { this.adapter_.sendKeyDownAndUpEvent('\u000D', KeyCodes.ENTER); } @@ -1172,14 +1173,16 @@ Controller.prototype.handlePointerEventForSoftKey_ = function(softKey, e) { break; case ElementType.EN_SWITCHER: if (e.type == EventType.POINTER_UP) { - key = /** @type {!content.EnSwitcherKey} */ (softKey); + key = /** @type {!i18n.input.chrome.inputview.elements.content. + EnSwitcherKey} */ (softKey); this.adapter_.toggleLanguageState(this.model_.stateManager.isEnMode); this.model_.stateManager.isEnMode = !this.model_.stateManager.isEnMode; key.update(); } break; case ElementType.SPACE_KEY: - key = /** @type {!content.SpaceKey} */ (softKey); + key = /** @type {!i18n.input.chrome.inputview.elements.content. + SpaceKey} */ (softKey); var doubleSpacePeriod = this.model_.settings.doubleSpacePeriod && this.currentKeyset_ != Controller.HANDWRITING_VIEW_CODE_ && this.currentKeyset_ != Controller.EMOJI_VIEW_CODE_; @@ -1194,7 +1197,8 @@ Controller.prototype.handlePointerEventForSoftKey_ = function(softKey, e) { break; case ElementType.SWITCHER_KEY: - key = /** @type {!content.SwitcherKey} */ (softKey); + key = /** @type {!i18n.input.chrome.inputview.elements.content. + SwitcherKey} */ (softKey); if (e.type == EventType.POINTER_UP) { this.recordStatsForClosing_( 'InputMethod.VirtualKeyboard.LayoutSwitch', 1, 25, 25); @@ -1217,7 +1221,8 @@ Controller.prototype.handlePointerEventForSoftKey_ = function(softKey, e) { break; case ElementType.COMPACT_KEY: - key = /** @type {!content.CompactKey} */ (softKey); + key = /** @type {!i18n.input.chrome.inputview.elements.content. + CompactKey} */(softKey); if (e.type == EventType.LONG_PRESS) { this.container_.altDataView.show( key, goog.i18n.bidi.isRtlLanguage(this.languageCode_)); @@ -1249,7 +1254,8 @@ Controller.prototype.handlePointerEventForSoftKey_ = function(softKey, e) { break; case ElementType.MENU_KEY: - key = /** @type {!content.MenuKey} */ (softKey); + key = /** @type {!i18n.input.chrome.inputview.elements.content. + MenuKey} */ (softKey); if (e.type == EventType.POINTER_DOWN) { var isCompact = this.currentKeyset_.indexOf('compact') != -1; // Gets the default full keyboard instead of default keyset because @@ -1264,7 +1270,6 @@ Controller.prototype.handlePointerEventForSoftKey_ = function(softKey, e) { // Hides 'switch to compact' for zhuyin when not in experimental env. enableCompact = false; } - var self = this; var hasHwt = !this.adapter_.isPasswordBox() && !Controller.DISABLE_HWT && goog.object.contains( InputToolCode, this.getHwtInputToolCode_()); @@ -1290,7 +1295,8 @@ Controller.prototype.handlePointerEventForSoftKey_ = function(softKey, e) { } break; case ElementType.IME_SWITCH: - key = /** @type {!content.FunctionalKey} */ (softKey); + key = /** @type {!i18n.input.chrome.inputview.elements.content. + FunctionalKey} */ (softKey); this.adapter_.sendKeyDownAndUpEvent('', key.id); break; } @@ -1390,7 +1396,6 @@ Controller.prototype.resetAll_ = function() { this.model_.stateManager.reset(); this.container_.update(); this.updateContextModifierState_(); - this.deadKey_ = ''; this.resize(); this.container_.expandedCandidateView.close(); this.container_.menuView.hide(); @@ -1454,7 +1459,6 @@ Controller.prototype.onSurroundingTextChanged_ = function(e) { */ Controller.prototype.onContextBlur_ = function() { this.container_.cleanStroke(); - this.deadKey_ = ''; this.container_.menuView.hide(); }; @@ -1732,7 +1736,6 @@ Controller.prototype.switchToKeyset = function(keyset) { } var contextType = this.adapter_.contextType; - var lastKeysetView = this.container_.currentKeysetView; var ret = this.container_.switchToKeyset(this.getRemappedKeyset_(keyset), this.title_, this.adapter_.isPasswordBox(), this.adapter_.isA11yMode, keyset, this.contextTypeToLastKeysetMap_[contextType] || diff --git a/third_party/google_input_tools/src/chrome/os/inputview/css.js b/third_party/google_input_tools/src/chrome/os/inputview/css.js index 87f657f..cf559ab 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/css.js +++ b/third_party/google_input_tools/src/chrome/os/inputview/css.js @@ -35,6 +35,7 @@ i18n.input.chrome.inputview.Css = { BACK_TO_KEYBOARD_ICON: goog.getCssName('inputview-back-to-keyboard'), BOLD_ICON: goog.getCssName('inputview-bold-icon'), CANDIDATE: goog.getCssName('inputview-candidate'), + CANDIDATE_NUMBER: goog.getCssName('inputview-candidate-number'), CANDIDATES_LINE: goog.getCssName('inputview-candidates-line'), CANDIDATES_TOP_LINE: goog.getCssName('inputview-candidates-top-line'), CANDIDATE_AUTOCORRECT: goog.getCssName('inputview-candidate-autocorrect'), diff --git a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/altdataview.js b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/altdataview.js index aa0af28..2856f4f 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/altdataview.js +++ b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/altdataview.js @@ -17,10 +17,9 @@ goog.require('goog.array'); goog.require('goog.dom'); goog.require('goog.dom.TagName'); goog.require('goog.dom.classlist'); -goog.require('goog.math.Box'); goog.require('goog.math.Coordinate'); +goog.require('goog.object'); goog.require('goog.style'); -goog.require('i18n.input.chrome.inputview.Accents'); goog.require('i18n.input.chrome.inputview.Css'); goog.require('i18n.input.chrome.inputview.content.constants'); goog.require('i18n.input.chrome.inputview.elements.Element'); @@ -49,6 +48,7 @@ function convertToScreenCoordinate(coordinate) { }; + /** * The view for alt data. * @@ -203,11 +203,12 @@ AltDataView.prototype.show = function(key, isRTL) { var height = key.availableHeight; var characters; var fixedColumns = 0; + var isCompact = key.type == ElementType.COMPACT_KEY; if (key.type == ElementType.CHARACTER_KEY) { key = /** @type {!i18n.input.chrome.inputview.elements.content. CharacterKey} */ (key); characters = key.getAltCharacters(); - } else if (key.type == ElementType.COMPACT_KEY) { + } else if (isCompact) { key = /** @type {!i18n.input.chrome.inputview.elements.content. CompactKey} */ (key); characters = key.getMoreCharacters(); @@ -229,6 +230,8 @@ AltDataView.prototype.show = function(key, isRTL) { goog.style.setElementShown(this.getElement(), true); this.getDomHelper().removeChildren(this.getElement()); + var w = isCompact ? Math.round(width * 0.8) : Math.round(width * 0.9); + var h = isCompact ? Math.round(height * 0.8) : Math.round(height * 0.9); this.useIMEWindow_ = !!(chrome.app.window && chrome.app.window.create); if (this.useIMEWindow_) { if (this.altdataWindow_) { @@ -243,11 +246,11 @@ AltDataView.prototype.show = function(key, isRTL) { var startKeyIndex = this.getStartKeyIndex_(parentKeyLeftTop.x, numOfColumns, width, screen.width); - var altDataWindowWidth = numOfColumns * width; - var altDataWindowHeight = numOfRows * height; + var altDataWindowWidth = numOfColumns * w; + var altDataWindowHeight = numOfRows * h; var windowTop = parentKeyLeftTop.y - altDataWindowHeight - AltDataView.PADDING_; - var windowLeft = parentKeyLeftTop.x - startKeyIndex * width; + var windowLeft = parentKeyLeftTop.x - startKeyIndex * w; var screenCoordinate = convertToScreenCoordinate( new goog.math.Coordinate(windowLeft, windowTop)); var windowBounds = goog.object.create('left', screenCoordinate.x, @@ -263,10 +266,10 @@ AltDataView.prototype.show = function(key, isRTL) { var contentWindow = self.altdataWindow_.contentWindow; contentWindow.addEventListener('load', function() { contentWindow.accents.setAccents(characters, numOfColumns, - numOfRows, width, height, startKeyIndex); + numOfRows, w, h, startKeyIndex); self.highlightItem( - Math.ceil(parentKeyLeftTop.x + width / 2), - Math.ceil(parentKeyLeftTop.y + height / 2)); + Math.ceil(parentKeyLeftTop.x + w / 2), + Math.ceil(parentKeyLeftTop.y + h / 2)); var marginBox = goog.style.getMarginBox( contentWindow.document.body); // Adjust the window bounds to compensate body's margin. The margin @@ -283,33 +286,33 @@ AltDataView.prototype.show = function(key, isRTL) { } else { // The total width of the characters + the separators, every separator has // width = 1. - var altDataWindowWidth = width * characters.length; - var altDataWindowHeight = height; + var altDataWindowWidth = w * characters.length; + var altDataWindowHeight = h; var left = parentKeyLeftTop.x; if ((left + altDataWindowWidth) > screen.width) { // If no enough space at the right, then make it to the left. - left = parentKeyLeftTop.x + width - altDataWindowWidth; + left = parentKeyLeftTop.x + w - altDataWindowWidth; characters.reverse(); } var elemTop = parentKeyLeftTop.y - altDataWindowHeight - AltDataView.PADDING_; if (elemTop < 0) { // If no enough top space, then display below the key. - elemTop = parentKeyLeftTop.y + height + AltDataView.PADDING_; + elemTop = parentKeyLeftTop.y + h + AltDataView.PADDING_; } for (var i = 0; i < characters.length; i++) { var keyElem = this.addKey_(characters[i], isRTL); - goog.style.setSize(keyElem, width, height); + goog.style.setSize(keyElem, w, h); this.altdataElements_.push(keyElem); if (i != characters.length - 1) { this.addSeparator_(height); } } goog.style.setPosition(this.getElement(), left, elemTop); - this.highlightItem(Math.ceil(parentKeyLeftTop.x + width / 2), - Math.ceil(parentKeyLeftTop.y + height / 2)); + this.highlightItem(Math.ceil(parentKeyLeftTop.x + w / 2), + Math.ceil(parentKeyLeftTop.y + h / 2)); } goog.style.setElementShown(this.coverElement_, true); diff --git a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/candidate.js b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/candidate.js index 0e57c14..96ade6b 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/candidate.js +++ b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/candidate.js @@ -90,6 +90,9 @@ Candidate.prototype.createDom = function() { if (this.candidate['isEmoji']) { goog.dom.classlist.add(elem, Css.EMOJI_FONT); } + if (this.candidateType == Candidate.Type.NUMBER) { + goog.dom.classlist.add(elem, Css.CANDIDATE_NUMBER); + } this.wrapper_ = dom.createDom('div', { 'class': Css.CANDIDATE_INTERNAL_WRAPPER }, this.candidate[Name.CANDIDATE]); diff --git a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/canvasview.js b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/canvasview.js index a1a28a7..0871651 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/canvasview.js +++ b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/canvasview.js @@ -108,7 +108,7 @@ CanvasView.INK_WIDTH_ = 6; * @type {string} * @private */ -CanvasView.INK_COLOR_ = '#111111'; +CanvasView.INK_COLOR_ = '#37474f'; /** diff --git a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/gesturecanvasview.js b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/gesturecanvasview.js index 4661e2c..05b6507 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/gesturecanvasview.js +++ b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/gesturecanvasview.js @@ -17,11 +17,11 @@ goog.provide('i18n.input.chrome.inputview.elements.content.GestureCanvasView.Poi goog.require('goog.async.Delay'); goog.require('goog.dom.TagName'); goog.require('goog.dom.classlist'); +goog.require('goog.style'); goog.require('i18n.input.chrome.inputview.Css'); goog.require('i18n.input.chrome.inputview.elements.Element'); goog.require('i18n.input.chrome.inputview.elements.ElementType'); - goog.scope(function() { var Css = i18n.input.chrome.inputview.Css; var ElementType = i18n.input.chrome.inputview.elements.ElementType; @@ -60,7 +60,7 @@ i18n.input.chrome.inputview.elements.content.GestureCanvasView = /** * A list of list of gesture points to be rendered on the canvas as strokes. * - * @private {!Array.<Array>} + * @private {!Array<GestureStroke>} */ this.strokeList_ = []; @@ -72,12 +72,225 @@ var GestureCanvasView = goog.inherits(GestureCanvasView, i18n.input.chrome.inputview.elements.Element); + +/** + * A single stroke on the canvas. + * + * @constructor + */ +i18n.input.chrome.inputview.elements.content.GestureCanvasView.GestureStroke = + function() { + /** + * The list of points that make up this stroke. + * + * @type {!Array.<!Point>} + */ + this.points = []; + + /** + * Whether or not this stroke is considered active. i.e. whether or not it + * should be considered for rendering and decoding. + * + * @private {boolean} + */ + this.isActive_ = false; +}; +var GestureStroke = + i18n.input.chrome.inputview.elements.content.GestureCanvasView + .GestureStroke; + + /** * Rate at which the ttl should degrade for the fading stroke effect. * * @const {number} */ -GestureCanvasView.DEGRADATION_RATE = 5; +GestureStroke.DEGRADATION_RATE = 5; + + +/** + * Starting time-to-live value. + * + * @const {number} + */ +GestureStroke.STARTING_TTL = 255; + + +// TODO(stevet): This is temporary and needs to be updated with a dynamic value +// that considers other parameters like the width of character keys. +/** + * Distance threshold for when a stroke is considered active, in pixels. + * + * @const {number} + */ +GestureStroke.ACTIVE_THRESHOLD = 40; + + +/** + * Calculates the color of the point based on the ttl. + * + * @param {number} ttl The time to live of the point. + * @return {string} The color to use for the point. + * @private + */ +GestureStroke.calculateColor_ = function(ttl) { + var shade = GestureStroke.STARTING_TTL - ttl; + if (shade < 0) { + shade = 0; + } + return 'rgb(' + shade + ', ' + shade + ', ' + shade + ')'; +}; + + +/** + * Calculates the distance between two points. + * + * @param {!Point} first The first point. + * @param {!Point} second The second point. + * @return {number} The number of pixels between first and second. + * @private + */ +GestureStroke.calculateDistance_ = function(first, second) { + // Simply use the Pythagorean. + var a = Math.abs(first.x - second.x); + var b = Math.abs(first.y - second.y); + return Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); +}; + + +/** + * Calculates the line width of the point based on the ttl. + * + * @param {number} ttl The time to live of the point. + * @return {number} The line width to use for the point. + * @private + */ +GestureStroke.calculateLineWidth_ = function(ttl) { + var ratio = ttl / GestureStroke.STARTING_TTL; + if (ratio < 0) { + ratio = 0; + } + return 9 * ratio; +}; + + +/** + * Degrades all the points in this stroke. + * + * @return {boolean} Returns true if it was possible to degrade one or more + * points, otherwise it means that this stroke is now empty. + */ +GestureStroke.prototype.degrade = function() { + var all_empty = true; + for (var i = 0; i < this.points.length; i++) { + if (this.points[i].ttl > 0) { + this.points[i].ttl -= GestureStroke.DEGRADATION_RATE; + all_empty = false; + } + } + return !all_empty; +}; + + +/** + * Draw the gesture trail for this stroke onto the canvas context. + * + * @param {!CanvasRenderingContext2D} context The drawing context to render to. + */ +GestureStroke.prototype.draw = function(context) { + // Only start drawing active strokes. Note that TTL still updates even if a + // stroke is not yet active. + if (!this.isActive()) { + return; + } + + for (var i = 1; i < this.points.length; i++) { + var first = this.points[i - 1]; + var second = this.points[i]; + // All rendering calculations are based on the second point in the segment + // because there must be at least two points for something to be rendered. + var ttl = second.ttl; + if (ttl <= 0) { + continue; + } + + context.beginPath(); + context.moveTo(first.x, first.y); + context.lineTo(second.x, second.y); + // TODO(stevet): Use alpha and #00B4CC. + context.strokeStyle = GestureStroke.calculateColor_(ttl); + context.fillStyle = 'none'; + context.lineWidth = GestureStroke.calculateLineWidth_(ttl); + context.lineCap = 'round'; + context.lineJoin = 'round'; + context.stroke(); + } +}; + + +/** + * Returns true iff this stroke is considered "active". This means that it has + * passed a certain threshold and should be considered for rendering and + * decoding. + * + * @return {boolean} Whether or not the stroke is active. + */ +GestureStroke.prototype.isActive = function() { + // Once a stroke is active, it remains active. + if (this.isActive_) { + return this.isActive_; + } + + if (this.points.length < 2) { + return false; + } + + // Calculate the distance between the first point and the latest one. + this.isActive_ = GestureStroke.calculateDistance_( + this.points[0], this.points[this.points.length - 1]) > + GestureStroke.ACTIVE_THRESHOLD; + + return this.isActive_; +}; + + + +/** + * One point in the gesture stroke. + * + * This class is used for both rendering the gesture stroke, and also for + * transmitting the stroke coordinates to the recognizer for decoding. + * + * @param {number} x The x coordinate. + * @param {number} y The y coordinate. + * @constructor + */ +i18n.input.chrome.inputview.elements.content.GestureCanvasView.Point = + function(x, y) { + /** + * The left offset relative to the canvas. + * + * @type {number} + */ + this.x = x; + + /** + * The top offset relative to the canvas. + * + * @type {number} + */ + this.y = y; + + /** + * The time-to-live value of the point, used to render the trail fading + * effect. + * + * @type {number} + */ + this.ttl = GestureStroke.STARTING_TTL; +}; +var Point = + i18n.input.chrome.inputview.elements.content.GestureCanvasView.Point; /** @@ -91,29 +304,7 @@ GestureCanvasView.prototype.draw_ = function() { 0, 0, this.drawingCanvas_.width, this.drawingCanvas_.height); for (var i = 0; i < this.strokeList_.length; i++) { - var pointList = this.strokeList_[i]; - - for (var j = 1; j < pointList.length; j++) { - var first = pointList[j - 1]; - var second = pointList[j]; - // All rendering calculations are based on the second point in the segment - // because there must be at least two points for something to be rendered. - var ttl = second.ttl; - if (ttl <= 0) { - continue; - } - - this.drawingContext_.beginPath(); - this.drawingContext_.moveTo(first.x, first.y); - this.drawingContext_.lineTo(second.x, second.y); - // TODO(stevet): Use alpha and #00B4CC. - this.drawingContext_.strokeStyle = this.calculateColor_(ttl); - this.drawingContext_.fillStyle = 'none'; - this.drawingContext_.lineWidth = this.calculateLineWidth_(ttl); - this.drawingContext_.lineCap = 'round'; - this.drawingContext_.lineJoin = 'round'; - this.drawingContext_.stroke(); - } + this.strokeList_[i].draw(this.drawingContext_); } }; @@ -153,10 +344,10 @@ GestureCanvasView.prototype.resize = function(width, height) { */ GestureCanvasView.prototype.addPoint = function(e) { if (this.strokeList_.length == 0) { - this.strokeList_.push([]); + this.strokeList_.push(new GestureStroke()); } - this.strokeList_[this.strokeList_.length - 1].push( + this.strokeList_[this.strokeList_.length - 1].points.push( this.createGesturePoint_(e)); }; @@ -171,6 +362,25 @@ GestureCanvasView.prototype.clear = function() { /** + * Returns true iff there is a stroke that is currently active. + * + * @return {boolean} Whether or not there was an active stroke. + */ +GestureCanvasView.prototype.hasActiveStroke = function() { + for (var i = 0; i < this.strokeList_.length; i++) { + // TODO(stevet): Fix this approximation with a change that takes into + // account strokes that are still active because they are degrading, but the + // user has already finished the gesture (i.e. touched up). + if (this.strokeList_[i].isActive()) { + return true; + } + } + + return false; +}; + + +/** * Begins a new gesture. * * @param {!i18n.input.chrome.inputview.events.PointerEvent} e Drag event to @@ -178,9 +388,9 @@ GestureCanvasView.prototype.clear = function() { */ GestureCanvasView.prototype.startStroke = function(e) { // Always start a new array to separate previous strokes from this new one. - this.strokeList_.push([]); + this.strokeList_.push(new GestureStroke()); - this.strokeList_[this.strokeList_.length - 1].push( + this.strokeList_[this.strokeList_.length - 1].points.push( this.createGesturePoint_(e)); }; @@ -202,52 +412,17 @@ GestureCanvasView.prototype.animateGestureTrail_ = function() { /** - * Calculates the line width of the point based on the ttl. - * - * @param {number} ttl The time to live of the point. - * @return {number} The line width to use for the point. - * @private - */ -GestureCanvasView.prototype.calculateLineWidth_ = function(ttl) { - var ratio = ttl / 255.0; - if (ratio < 0) { - ratio = 0; - } - return 9 * ratio; -}; - - -/** - * Calculates the color of the point based on the ttl. - * - * @param {number} ttl The time to live of the point. - * @return {string} The color to use for the point. - * @private - */ -GestureCanvasView.prototype.calculateColor_ = function(ttl) { - var shade = 225 - ttl; - if (shade < 0) { - shade = 0; - } - return 'rgb(' + shade + ', ' + shade + ', ' + shade + ')'; -}; - - -/** * Returns a gesture point for a given event, with the correct coordinates. * * @param {!i18n.input.chrome.inputview.events.DragEvent| - * i18n.input.chrome.inputview.events.PointerEvent} e The event to - * convert. - * @return {i18n.input.chrome.inputview.elements.content. - * GestureCanvasView.Point} The converted gesture point. + * i18n.input.chrome.inputview.events.PointerEvent} e The event to + * convert. + * @return {Point} The converted gesture point. * @private */ GestureCanvasView.prototype.createGesturePoint_ = function(e) { var offset = goog.style.getPageOffset(this.drawingCanvas_); - return new - i18n.input.chrome.inputview.elements.content.GestureCanvasView.Point( - e.x - offset.x, e.y - offset.y); + return new Point(e.x - offset.x, e.y - offset.y); }; @@ -258,17 +433,8 @@ GestureCanvasView.prototype.createGesturePoint_ = function(e) { */ GestureCanvasView.prototype.degradeStrokes_ = function() { for (var i = 0; i < this.strokeList_.length; i++) { - var all_empty = true; - var pointList = this.strokeList_[i]; - for (var j = 0; j < pointList.length; j++) { - if (pointList[j].ttl > 0) { - pointList[j].ttl -= GestureCanvasView.DEGRADATION_RATE; - all_empty = false; - } - } - // In the case where all points in the list are empty, dispose of the first. - if (all_empty) { + if (!this.strokeList_[i].degrade()) { this.strokeList_.splice(i, 1); i--; } @@ -276,40 +442,4 @@ GestureCanvasView.prototype.degradeStrokes_ = function() { }; -/** - * One point in the gesture stroke. - * - * This class is used for both rendering the gesture stroke, and also for - * transmitting the stroke coordinates to the recognizer for decoding. - * - * @param {number} x The x coordinate. - * @param {number} y The y coordinate. - * @constructor - */ -i18n.input.chrome.inputview.elements.content.GestureCanvasView.Point = - function(x, y) { - /** - * The left offset relative to the canvas. - * - * @type {number} - */ - this.x = x; - - /** - * The top offset relative to the canvas. - * - * @type {number} - */ - this.y = y; - - /** - * The time-to-live value of the point, used to render the trail fading - * effect. - * - * @type {number} - */ - this.ttl = 225; -}; - - }); // goog.scope diff --git a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/material/spacekey.js b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/material/spacekey.js index a927fd4..479db6b 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/material/spacekey.js +++ b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/material/spacekey.js @@ -184,7 +184,7 @@ SpaceKey.prototype.resize = function(width, height) { goog.style.setSize(this.wrapper_, width, SpaceKey.HEIGHT); // Positions the wrapper in the middle. - this.wrapper_.style.top = (height - SpaceKey.HEIGHT) / 2 + 'px'; + this.wrapper_.style.top = (this.availableHeight - SpaceKey.HEIGHT) / 2 + 'px'; }; }); // goog.scope diff --git a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/swipeview.js b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/swipeview.js index 069dc7e..91ba8c7 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/swipeview.js +++ b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/swipeview.js @@ -13,12 +13,8 @@ // goog.provide('i18n.input.chrome.inputview.elements.content.SwipeView'); -goog.require('goog.array'); -goog.require('goog.dom'); goog.require('goog.dom.TagName'); goog.require('goog.dom.classlist'); -goog.require('goog.events.EventType'); -goog.require('goog.math.Coordinate'); goog.require('goog.style'); goog.require('i18n.input.chrome.inputview.Accents'); goog.require('i18n.input.chrome.inputview.Css'); @@ -31,7 +27,6 @@ goog.require('i18n.input.chrome.inputview.handler.PointerHandler'); goog.require('i18n.input.chrome.inputview.util'); goog.require('i18n.input.chrome.message.ContextType'); - goog.scope(function() { var ContextType = i18n.input.chrome.message.ContextType; var Css = i18n.input.chrome.inputview.Css; @@ -42,6 +37,7 @@ var content = i18n.input.chrome.inputview.elements.content; var util = i18n.input.chrome.inputview.util; + /** * The view for alt data. * @@ -62,7 +58,6 @@ i18n.input.chrome.inputview.elements.content.SwipeView = function( */ this.adapter_ = adapter; - /** * The swipe elements. * @@ -71,13 +66,6 @@ i18n.input.chrome.inputview.elements.content.SwipeView = function( this.trackElements_ = []; /** - * The window that shows the swipe field. - * - * @private {Object} - */ - this.trackWindow_ = null; - - /** * The text before the current focus. * * @private {string} @@ -108,8 +96,7 @@ i18n.input.chrome.inputview.elements.content.SwipeView = function( /** * The pointer handler. * - * @type {!i18n.input.chrome.inputview.handler.PointerHandler} - * @private + * @private {!i18n.input.chrome.inputview.handler.PointerHandler} */ this.pointerHandler_ = new i18n.input.chrome.inputview.handler. PointerHandler(); @@ -123,8 +110,8 @@ var SwipeView = i18n.input.chrome.inputview.elements.content.SwipeView; /** * The number of swipe elements. * - * @type {number} - * @private + * @private {number} + * @const */ SwipeView.LENGTH_ = 7; @@ -133,8 +120,8 @@ SwipeView.LENGTH_ = 7; * Index of highlighted accent. Use this index to represent no highlighted * accent. * - * @type {number} - * @private + * @private {number} + * @const */ SwipeView.INVALIDINDEX_ = -1; @@ -143,19 +130,45 @@ SwipeView.INVALIDINDEX_ = -1; * The distance between finger to track view which will cancel the track * view. * - * @type {number} - * @private + * @private {number} + * @const */ SwipeView.FINGER_DISTANCE_TO_CANCEL_SWIPE_ = 20; /** + * The width of a regular track segment. + * + * @private {number} + * @const + */ +SwipeView.SEGMENT_WIDTH_ = 70; + + +/** + * The width of a large track segment + * + * @private {number} + * @const + */ +SwipeView.LARGE_SEGMENT_WIDTH_ = 100; + + +/** + * The maximum surrounding text length that's provided. + * + * @private {number} + * @const + */ +SwipeView.MAX_SURROUNDING_TEXT_LENGTH_ = 100; + + +/** * The cover element. * Note: The reason we use a separate cover element instead of the view is * because of the opacity. We can not reassign the opacity in child element. * - * @type {!Element} - * @private + * @private {!Element} */ SwipeView.prototype.coverElement_; @@ -163,8 +176,7 @@ SwipeView.prototype.coverElement_; /** * The index of the alternative element which is highlighted. * - * @type {number} - * @private + * @private {number} */ SwipeView.prototype.highlightIndex_ = SwipeView.INVALIDINDEX_; @@ -180,8 +192,7 @@ SwipeView.prototype.triggeredBy; /** * Whether finger movement is being tracked. * - * @type {boolean} - * @private + * @private {boolean} */ SwipeView.prototype.tracking_ = false; @@ -189,8 +200,7 @@ SwipeView.prototype.tracking_ = false; /** * Whether to deploy the tracker on swipe events. * - * @type {boolean} - * @private + * @private {boolean} */ SwipeView.prototype.armed_ = false; @@ -240,14 +250,14 @@ SwipeView.prototype.onSurroundingTextChanged_ = function(e) { this.deletedWords_.push(lastDelete.slice(1)); } } - } else if (e.text.length == 100 || oldText.length == 100) { + } else if (e.text.length == SwipeView.MAX_SURROUNDING_TEXT_LENGTH_ || + oldText.length == SwipeView.MAX_SURROUNDING_TEXT_LENGTH_) { // Check if a word was deleted from oldText. - var candidate = oldText.trim().split(' ').pop(); - if (util.isPossibleDelete(oldText, text, candidate)) { - var location = oldText.lastIndexOf(candidate); - var intersectingText = oldText.slice(0, location); - diff = oldText.slice(location); - } + var candidate = oldText.trim().split(' ').pop(); + if (util.isPossibleDelete(oldText, text, candidate)) { + var location = oldText.lastIndexOf(candidate); + diff = oldText.slice(location); + } } else { diff = oldText.substring(text.length); } @@ -285,8 +295,9 @@ SwipeView.prototype.handleSwipeAction_ = function(e) { // Swiped right, cancel the deletion. if (direction & i18n.input.chrome.inputview.SwipeDirection.RIGHT) { word = this.deletedWords_.pop(); - if (word) - this.adapter_.commitText(word); + if (word) { + this.adapter_.commitText(word); + } } } return; @@ -297,7 +308,7 @@ SwipeView.prototype.handleSwipeAction_ = function(e) { '\u0008', KeyCodes.BACKSPACE, undefined, undefined, { ctrl: true, shift: false - }); + }); } else if (direction & i18n.input.chrome.inputview.SwipeDirection.RIGHT) { var word = this.deletedWords_.pop(); if (word) @@ -341,14 +352,14 @@ SwipeView.prototype.handleSwipeAction_ = function(e) { // Do not move carat at all, as this will either have no effect or cause // us to splice the word. if (!selectWord) { - return; + return; } } this.adapter_.sendKeyDownAndUpEvent( '', code, undefined, undefined, { - ctrl: selectWord, - shift: selectWord - }); + ctrl: selectWord, + shift: selectWord + }); return; } return; @@ -422,6 +433,7 @@ SwipeView.prototype.handlePointerAction_ = function(e) { } }; + /** @override */ SwipeView.prototype.createDom = function() { goog.base(this, 'createDom'); @@ -442,17 +454,17 @@ SwipeView.prototype.createDom = function() { SwipeView.prototype.enterDocument = function() { goog.base(this, 'enterDocument'); this.getHandler(). - listen(this.adapter_, - i18n.input.chrome.inputview.events.EventType. - SURROUNDING_TEXT_CHANGED, - this.onSurroundingTextChanged_). - listen(this.pointerHandler_, [ - EventType.SWIPE], this.handleSwipeAction_). - listen(this.pointerHandler_, [ - EventType.LONG_PRESS, - EventType.POINTER_UP, - EventType.POINTER_DOWN, - EventType.POINTER_OUT], this.handlePointerAction_); + listen(this.adapter_, + i18n.input.chrome.inputview.events.EventType. + SURROUNDING_TEXT_CHANGED, + this.onSurroundingTextChanged_). + listen(this.pointerHandler_, [ + EventType.SWIPE], this.handleSwipeAction_). + listen(this.pointerHandler_, [ + EventType.LONG_PRESS, + EventType.POINTER_UP, + EventType.POINTER_DOWN, + EventType.POINTER_OUT], this.handlePointerAction_); goog.style.setElementShown(this.getElement(), false); }; @@ -582,14 +594,14 @@ SwipeView.prototype.showDeletionTrack = function(key) { var coordinate = goog.style.getClientPosition(key.getElement()); if (key.type == ElementType.BACKSPACE_KEY) { this.showDeletionTrack_( - coordinate.x + key.availableWidth, - coordinate.y, - 70, - key.availableHeight, - key.availableWidth, - 100, - undefined, - Css.BACKSPACE_ICON); + coordinate.x + key.availableWidth, + coordinate.y, + SwipeView.SEGMENT_WIDTH_, + key.availableHeight, + key.availableWidth, + SwipeView.LARGE_SEGMENT_WIDTH_, + undefined, + Css.BACKSPACE_ICON); } }; @@ -602,13 +614,15 @@ SwipeView.prototype.showDeletionTrack = function(key) { */ SwipeView.prototype.showSelectionTrack = function(x, y) { var ltr = x <= (screen.width / 2); - + // Center track on finger but force containment. + var width = Math.max(y - (SwipeView.SEGMENT_WIDTH_ / 2), + SwipeView.SEGMENT_WIDTH_ / 2); this.showSelectionTrack_( - ltr ? 0 : screen.width, - Math.max(y - 35, 35), // Center track on finger press but force containment. - 70, - 70, - x > (screen.width / 2) ? '<' : '>'); + ltr ? 0 : screen.width, + width, + SwipeView.SEGMENT_WIDTH_, + SwipeView.SEGMENT_WIDTH_, + x > (screen.width / 2) ? '<' : '>'); }; diff --git a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/switcherkey.js b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/switcherkey.js index 9aa0fed..b634d31 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/switcherkey.js +++ b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/switcherkey.js @@ -76,7 +76,7 @@ SwitcherKey.prototype.createDom = function() { this.setAriaLabel(this.getChromeVoxMessage()); if (this.textElem) { - goog.dom.classlist.add(this.getElement(), Css.SWITCHER_KEY_NAME); + goog.dom.classlist.add(this.textElem, Css.SWITCHER_KEY_NAME); } }; diff --git a/third_party/google_input_tools/src/chrome/os/inputview/featurename.js b/third_party/google_input_tools/src/chrome/os/inputview/featurename.js index e777483..1893b82 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/featurename.js +++ b/third_party/google_input_tools/src/chrome/os/inputview/featurename.js @@ -20,7 +20,8 @@ goog.provide('i18n.input.chrome.inputview.FeatureName'); */ i18n.input.chrome.inputview.FeatureName = { // List all features. - GESTURE_EDITTING: 'gesture-editting', + GESTURE_SELECTION: 'gestureselection', + GESTURE_DELETION: 'gesturedeletion', GESTURE_TYPING: 'gesturetyping', OPTIMIZED_LAYOUTS: 'optimized-layouts', EXPERIMENTAL: 'experimental' diff --git a/third_party/google_input_tools/src/chrome/os/inputview/imewindows/accents.js b/third_party/google_input_tools/src/chrome/os/inputview/imewindows/accents.js index 8a89e88..f9ecf80 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/imewindows/accents.js +++ b/third_party/google_input_tools/src/chrome/os/inputview/imewindows/accents.js @@ -16,7 +16,6 @@ goog.provide('i18n.input.chrome.inputview.Accents'); goog.require('goog.dom'); goog.require('goog.dom.TagName'); goog.require('goog.dom.classlist'); -goog.require('goog.math.Coordinate'); goog.require('goog.style'); goog.require('i18n.input.chrome.inputview.Css'); goog.require('i18n.input.chrome.inputview.util'); @@ -61,7 +60,7 @@ Accents.highlightItem_ = function(x, y, offset) { if (Accents.highlightedItem_ != highlightedItem) { if (Accents.highlightedItem_) { goog.dom.classlist.remove(Accents.highlightedItem_, - i18n.input.chrome.inputview.Css.ELEMENT_HIGHLIGHT); + i18n.input.chrome.inputview.Css.ELEMENT_HIGHLIGHT); } Accents.highlightedItem_ = highlightedItem; if (Accents.highlightedItem_ && @@ -78,6 +77,7 @@ Accents.highlightItem_ = function(x, y, offset) { * @param {number} x The x position of finger in screen coordinate system. * @param {number} y The y position of finger in screen coordinate system. * @param {number} offset The offset to cancel highlight. + * @return {Element} . * @private */ Accents.getHighlightedItem_ = function(x, y, offset) { @@ -130,9 +130,6 @@ Accents.setAccents_ = function(accents, numOfColumns, numOfRows, width, var TagName = goog.dom.TagName; var dom = goog.dom.getDomHelper(); var container = dom.createDom(TagName.DIV, Css.ACCENT_CONTAINER); - goog.dom.setProperties(container, { - 'id' : 'container' - }); container.id = 'container'; var orderedAccents = Accents.reorderAccents_(accents, numOfColumns, numOfRows, @@ -179,6 +176,7 @@ Accents.setAccents_ = function(accents, numOfColumns, numOfRows, width, * @param {!number} numOfColumns The number of colums of this accents window. * @param {!number} numOfRows The number of rows of this accents window. * @param {number} startKeyIndex The index of the start key in bottom row. + * @return {!Array.<string>} . * @private */ Accents.reorderAccents_ = function(accents, numOfColumns, numOfRows, diff --git a/third_party/google_input_tools/src/chrome/os/inputview/layouts/material/spacerow.js b/third_party/google_input_tools/src/chrome/os/inputview/layouts/material/spacerow.js index 858c86c..0399d63 100644 --- a/third_party/google_input_tools/src/chrome/os/inputview/layouts/material/spacerow.js +++ b/third_party/google_input_tools/src/chrome/os/inputview/layouts/material/spacerow.js @@ -71,7 +71,7 @@ material.SpaceRow.create = function() { }); var spaceKeyRow = material.util.createLinearLayout({ 'id': 'spaceKeyrow', - 'children': [globeKey, menuKey, ctrlKey, altKey, spaceKey, + 'children': [ctrlKey, altKey, globeKey, menuKey, spaceKey, enSwitcher, altGrKey, leftKey, rightKey, hideKeyboardKey] }); return spaceKeyRow; diff --git a/third_party/google_input_tools/src/chrome/os/message/name.js b/third_party/google_input_tools/src/chrome/os/message/name.js index 481a7b3..e81fd93 100644 --- a/third_party/google_input_tools/src/chrome/os/message/name.js +++ b/third_party/google_input_tools/src/chrome/os/message/name.js @@ -22,6 +22,8 @@ goog.provide('i18n.input.chrome.message.Name'); i18n.input.chrome.message.Name = { ALT_KEY: 'altKey', ANCHOR: 'anchor', + AUXILIARY_TEXT: 'auxiliaryText', + AUXILIARY_TEXT_VISIBLE: 'auxiliaryTextVisible', CANDIDATE: 'candidate', CANDIDATES: 'candidates', CANDIDATE_ID: 'candidateID', diff --git a/third_party/google_input_tools/src/chrome/os/message/source.js b/third_party/google_input_tools/src/chrome/os/message/source.js new file mode 100644 index 0000000..78cf9a1 --- /dev/null +++ b/third_party/google_input_tools/src/chrome/os/message/source.js @@ -0,0 +1,33 @@ +// Copyright 2015 The ChromeOS IME Authors. All Rights Reserved. +// limitations under the License. +// See the License for the specific language governing permissions and +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// distributed under the License is distributed on an "AS-IS" BASIS, +// Unless required by applicable law or agreed to in writing, software +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// You may obtain a copy of the License at +// you may not use this file except in compliance with the License. +// Licensed under the Apache License, Version 2.0 (the "License"); +// +goog.provide('i18n.input.chrome.message.Source'); + + +/** + * Define the message source. + * + * @enum {string} + */ +i18n.input.chrome.message.Source = { + BG_BG: 'bg->bg', + BG_VK: 'bg->vk', + BG_OP: 'bg->op', + VK_BG: 'vk->bg', + VK_OP: 'vk->op', + VK_VK: 'vk->vk', + OP_BG: 'op->bg', + OP_VK: 'op->vk', + OP_OP: 'op->op', + UNKNOWN: 'unknown' +}; diff --git a/third_party/google_input_tools/src/chrome/os/message/type.js b/third_party/google_input_tools/src/chrome/os/message/type.js index ba730cd..6e27940 100644 --- a/third_party/google_input_tools/src/chrome/os/message/type.js +++ b/third_party/google_input_tools/src/chrome/os/message/type.js @@ -14,6 +14,12 @@ goog.provide('i18n.input.chrome.message'); goog.provide('i18n.input.chrome.message.Type'); +goog.require('i18n.input.chrome.message.Source'); + + +goog.scope(function() { +var Source = i18n.input.chrome.message.Source; + /** * The message type. "Background->Inputview" don't allow to share the same @@ -76,6 +82,7 @@ i18n.input.chrome.message.Type = { // Background->Background HEARTBEAT: 'heart_beat' }; +var Type = i18n.input.chrome.message.Type; /** @@ -85,8 +92,21 @@ i18n.input.chrome.message.Type = { * @return {boolean} . */ i18n.input.chrome.message.isFromBackground = function(type) { - var Type = i18n.input.chrome.message.Type; + var source = i18n.input.chrome.message.getMessageSource(type); + return source == Source.BG_BG || source == Source.BG_OP || + source == Source.BG_VK; +}; + + +/** + * Returns whether the message type belong to "Background->Inputview" group; + * + * @param {string} type The message type. + * @return {i18n.input.chrome.message.Source} The source. + */ +i18n.input.chrome.message.getMessageSource = function(type) { switch (type) { + // Background -> Inputview case Type.CANDIDATES_BACK: case Type.CONTEXT_BLUR: case Type.CONTEXT_FOCUS: @@ -94,10 +114,58 @@ i18n.input.chrome.message.isFromBackground = function(type) { case Type.HWT_NETWORK_ERROR: case Type.SURROUNDING_TEXT_CHANGED: case Type.UPDATE_SETTINGS: - case Type.USER_DICT_ENTRIES: case Type.VOICE_STATE_CHANGE: - return true; + return Source.BG_VK; + + // Inputview -> Background + case Type.COMMIT_TEXT: + case Type.COMPLETION: + case Type.CONNECT: + case Type.DATASOURCE_READY: + case Type.DISCONNECT: + case Type.DOUBLE_CLICK_ON_SPACE_KEY: + case Type.EXEC_ALL: + case Type.HWT_REQUEST: + case Type.KEY_CLICK: + case Type.KEY_EVENT: + case Type.OPTION_CHANGE: + case Type.PREDICTION: + case Type.SELECT_CANDIDATE: + case Type.SEND_KEY_EVENT: + case Type.SET_COMPOSITION: + case Type.SET_LANGUAGE: + case Type.SWITCH_KEYSET: + case Type.TOGGLE_LANGUAGE_STATE: + case Type.VISIBILITY_CHANGE: + case Type.SET_CONTROLLER: + case Type.UNSET_CONTROLLER: + case Type.VOICE_VIEW_STATE_CHANGE: + return Source.VK_BG; + + // Inputview -> Elements + case Type.HWT_PRIVACY_GOT_IT: + case Type.VOICE_PRIVACY_GOT_IT: + return Source.VK_VK; + + // Options -> Background + case Type.USER_DICT_ADD_ENTRY: + case Type.USER_DICT_CLEAR: + case Type.USER_DICT_LIST: + case Type.USER_DICT_SET_THRESHOLD: + case Type.USER_DICT_START: + case Type.USER_DICT_STOP: + case Type.USER_DICT_REMOVE_ENTRY: + return Source.OP_BG; + + // Background -> Options + case Type.USER_DICT_ENTRIES: + return Source.BG_OP; + + // Background->Background + case Type.HEARTBEAT: + return Source.BG_BG; default: - return false; + return Source.UNKNOWN; } }; +}); // goog.scope diff --git a/third_party/google_input_tools/src/chrome/os/statistics.js b/third_party/google_input_tools/src/chrome/os/statistics.js index d08a004..26fc3f5 100644 --- a/third_party/google_input_tools/src/chrome/os/statistics.js +++ b/third_party/google_input_tools/src/chrome/os/statistics.js @@ -87,6 +87,40 @@ Statistics.prototype.charactersBetweenBackspaces_ = 0; /** + * Maximum pause duration in milliseconds. + * + * @private {number} + * @const + */ +Statistics.prototype.MAX_PAUSE_DURATION_ = 3000; + + +/** + * Minimum words typed before committing the WPM statistic. + * + * @private {number} + * @const + */ +Statistics.prototype.MIN_WORDS_FOR_WPM_ = 10; + + +/** + * Timestamp of last activity. + * + * @private {number} + */ +Statistics.prototype.lastActivityTimeStamp_ = 0; + + +/** + * Time spent typing. + * + * @private {number} + */ +Statistics.prototype.typingDuration_ = 0; + + +/** * Whether recording for physical keyboard specially. * * @private {boolean} @@ -111,6 +145,14 @@ Statistics.prototype.charactersCommitted_ = 0; /** + * The number of characters to ignore when calculating WPM. + * + * @private {number} + */ +Statistics.prototype.droppedKeys_ = 0; + + +/** * Sets whether recording for physical keyboard. * * @param {boolean} isPhysicalKeyboard . @@ -175,11 +217,20 @@ Statistics.prototype.recordSessionEnd = function() { // excudes the focus loss-gain on the new tab page from being counted. if (this.charactersCommitted_ > 0) { this.recordValue('InputMethod.VirtualKeyboard.CharactersCommitted', - this.charactersCommitted_, 16384, 50); - // TODO: Add WPM metrics. + this.charactersCommitted_, 16384, 50); + var words = (this.charactersCommitted_ - this.droppedKeys_) / 5; + if (this.typingDuration_ > 0 && words > this.MIN_WORDS_FOR_WPM_) { + // Milliseconds to minutes. + var minutes = this.typingDuration_ / 60000; + this.recordValue('InputMethod.VirtualKeyboard.WordsPerMinute', + Math.round(words / minutes), 100, 100); + } } + this.droppedKeys_ = 0; this.charactersCommitted_ = 0; this.lastCommitLength_ = 0; + this.typingDuration_ = 0; + this.lastActivityTimeStamp_ = 0; }; @@ -363,6 +414,19 @@ Statistics.prototype.recordValue = function( * Records a key down. */ Statistics.prototype.recordCharacterKey = function() { + var now = Date.now(); + if (this.lastActivityTimeStamp_) { + if (now < (this.lastActivityTimeStamp_ + this.MAX_PAUSE_DURATION_)) { + this.typingDuration_ += (now - this.lastActivityTimeStamp_); + } else { + // Exceeded pause duration. Ignore this character. + this.droppedKeys_++; + } + } else { + // Ignore the first character in the new session. + this.droppedKeys_++; + } + this.lastActivityTimeStamp_ = now; this.charactersBetweenBackspaces_++; }; |