You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/01/16 18:41:54 UTC

[08/23] guacamole-client git commit: GUACAMOLE-352: Rely on isComposing property of InputEvent to determine whether the event should be ignored.

GUACAMOLE-352: Rely on isComposing property of InputEvent to determine whether the event should be ignored.

Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/3d6a3aaa
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/3d6a3aaa
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/3d6a3aaa

Branch: refs/heads/master
Commit: 3d6a3aaa2a8bafa40b545c2dd9a5047f401601e2
Parents: 646f973
Author: Michael Jumper <mj...@apache.org>
Authored: Sun Dec 17 21:56:28 2017 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Jan 16 09:50:54 2018 -0800

----------------------------------------------------------------------
 .../src/main/webapp/modules/Keyboard.js         | 50 +-------------------
 1 file changed, 2 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/3d6a3aaa/guacamole-common-js/src/main/webapp/modules/Keyboard.js
----------------------------------------------------------------------
diff --git a/guacamole-common-js/src/main/webapp/modules/Keyboard.js b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
index 1df14e2..a11050f 100644
--- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js
+++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
@@ -1208,39 +1208,6 @@ Guacamole.Keyboard = function(element) {
     }, true);
 
     /**
-     * Returns whether the given string is fully composed. A string is fully
-     * composed if it does not end with combining characters.
-     *
-     * @private
-     * @param {String} str
-     *     The string to test.
-     *
-     * @returns {Boolean}
-     *     true of the string is fully composed, false otherwise.
-     */
-    var isComposed = function isComposed(str) {
-
-        // The empty string is fully composed
-        if (!str)
-            return true;
-
-        // Test whether the last character is within the "Combining
-        // Diacritical Marks" Unicode block (U+0300 through U+036F)
-        var lastCodepoint = str.charCodeAt(str.length - 1);
-        return !(lastCodepoint >= 0x0300 && lastCodepoint <= 0x036F);
-
-    };
-
-    /**
-     * The in-progress composition, if any, such as the intermediate result of
-     * pressing a series of dead keys.
-     *
-     * @private
-     * @type {String}
-     */
-    var inProgressComposition = '';
-
-    /**
      * Handles the given "input" event, typing the data within the input text.
      * If the event is complete (text is provided), handling of "compositionend"
      * events is suspended, as such events may conflict with input events.
@@ -1254,13 +1221,8 @@ Guacamole.Keyboard = function(element) {
         // Only intercept if handler set
         if (!guac_keyboard.onkeydown && !guac_keyboard.onkeyup) return;
 
-        // Ignore input events which represent the in-progress composition,
-        // as reported by composition events
-        if (e.data === inProgressComposition)
-            return;
-
         // Type all content written
-        if (e.data && isComposed(e.data)) {
+        if (e.data && !e.isComposing) {
             element.removeEventListener("compositionend", handleComposition, false);
             guac_keyboard.type(e.data);
         }
@@ -1283,7 +1245,7 @@ Guacamole.Keyboard = function(element) {
         if (!guac_keyboard.onkeydown && !guac_keyboard.onkeyup) return;
 
         // Type all content written
-        if (e.data && isComposed(e.data)) {
+        if (e.data) {
             element.removeEventListener("input", handleInput, false);
             guac_keyboard.type(e.data);
         }
@@ -1294,14 +1256,6 @@ Guacamole.Keyboard = function(element) {
     element.addEventListener("input", handleInput, false);
     element.addEventListener("compositionend", handleComposition, false);
 
-    element.addEventListener("compositionstart", function resetComposition() {
-        inProgressComposition = '';
-    }, false);
-
-    element.addEventListener("compositionupdate", function updateComposition(e) {
-        inProgressComposition = e.data;
-    }, false);
-
 };
 
 /**