From d1887a50cd1c3b9cecf688f91d09c81e0a4f2193 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Tue, 27 Sep 2022 11:03:22 +0700 Subject: [PATCH 1/4] chore(web): drops alignInputs, hideInputs --- web/source/kmwbase.ts | 4 +-- web/source/kmwembedded.ts | 8 ----- web/source/kmwnative.ts | 20 ------------ web/source/kmwrotation.ts | 2 -- web/source/osk/oskView.ts | 3 -- web/source/osk/visualKeyboard.ts | 53 ------------------------------- web/testing/inline-osk/index.html | 1 - 7 files changed, 2 insertions(+), 89 deletions(-) diff --git a/web/source/kmwbase.ts b/web/source/kmwbase.ts index d1ccd15c6ad..2898e6f5019 100644 --- a/web/source/kmwbase.ts +++ b/web/source/kmwbase.ts @@ -113,9 +113,9 @@ namespace com.keyman { getKeyboardPath(f, p?){return f;} KC_(n, ln, Pelem){return '';} handleRotationEvents(){} - // Will serve as an API function for a workaround, in case of future touch-alignment issues. + // Legacy API function for touch-alias issue workarounds + // Touch-aliases have been eliminated, though. ['alignInputs'](eleList?: HTMLElement[]){} - hideInputs() {}; namespaceID(Pstub) {}; preserveID(Pk) {}; diff --git a/web/source/kmwembedded.ts b/web/source/kmwembedded.ts index 4b1ee767fd7..84081d1a7dd 100644 --- a/web/source/kmwembedded.ts +++ b/web/source/kmwembedded.ts @@ -228,14 +228,6 @@ namespace com.keyman.text { */ keymanweb.domManager._SetTargDir = function(Ptarg){}; - /** - * Align input fields (should not be needed with KMEI, KMEA) - * - * @param {object} eleList A list of specific elements to align. If nil, selects all elements. - * - **/ - keymanweb.alignInputs = function(eleList: HTMLElement[]) {}; - /** * Use rotation events to adjust OSK element positions and scaling if necessary */ diff --git a/web/source/kmwnative.ts b/web/source/kmwnative.ts index 0af29d2ae28..793396e1486 100644 --- a/web/source/kmwnative.ts +++ b/web/source/kmwnative.ts @@ -90,26 +90,6 @@ if(!window['keyman']['initialized']) { return (rx.test(Lfilename) ? '' : keymanweb.options['keyboards']) + Lfilename; } - /** - * Align input fields (should not be needed with KMEI, KMEA), making them visible if previously hidden. - * - * @param {object} eleList A list of specific elements to align. If nil, selects all elements. - * - **/ - keymanweb.alignInputs = function(eleList: HTMLElement[]) { - // no-op - } - - /** - * Programatically hides all input fields with underlying elements. Restore with .alignInputs. - * - * @param {boolean} align align and make visible, else hide - * - **/ - keymanweb.hideInputs = function() { - // no-op. - } - /** * Test if caret position is determined from the active element, or * from the synthesized overlay element (touch devices) diff --git a/web/source/kmwrotation.ts b/web/source/kmwrotation.ts index c098996dea0..1ce4cc636a5 100644 --- a/web/source/kmwrotation.ts +++ b/web/source/kmwrotation.ts @@ -42,8 +42,6 @@ namespace com.keyman { } resolve() { - this.keyman.alignInputs(); - var osk = this.keyman.osk; osk.hideLanguageMenu(); diff --git a/web/source/osk/oskView.ts b/web/source/osk/oskView.ts index 523dbd4cf47..5748b5b05a0 100644 --- a/web/source/osk/oskView.ts +++ b/web/source/osk/oskView.ts @@ -505,9 +505,6 @@ namespace com.keyman.osk { bs.height = 'auto'; bs.maxWidth = bs.maxHeight = ''; } - - let keyman = com.keyman.singleton; - keyman.alignInputs(); } public refreshLayoutIfNeeded(pending?: boolean) { diff --git a/web/source/osk/visualKeyboard.ts b/web/source/osk/visualKeyboard.ts index 10dd443ddfb..74d735da560 100644 --- a/web/source/osk/visualKeyboard.ts +++ b/web/source/osk/visualKeyboard.ts @@ -1349,9 +1349,6 @@ namespace com.keyman.osk { util.addFontFaceStyleSheet(kfd); util.addFontFaceStyleSheet(ofd); - // Temporarily hide duplicated elements on non-desktop browsers - keymanweb.hideInputs(); - // Build the style string and append (or replace) the font style sheet // Note: Some browsers do not download the font-face font until it is applied, // so must apply style before testing for font availability @@ -1361,11 +1358,6 @@ namespace com.keyman.osk { customStyle = customStyle + activeKeyboard.oskStyling; this.styleSheet = util.addStyleSheet(customStyle); //Build 360 - - // Wait until font is loaded then align duplicated input elements with page elements - if (this.waitForFonts(kfd, ofd)) { - keymanweb.alignInputs(); - } } /** @@ -1718,51 +1710,6 @@ namespace com.keyman.osk { } }; - /** - * Wait until font is loaded before applying stylesheet - test each 100 ms - * @param {Object} kfd main font descriptor - * @param {Object} ofd secondary font descriptor (OSK only) - * @return {boolean} - */ - waitForFonts(kfd, ofd) { - let keymanweb = com.keyman.singleton; - let util = keymanweb.util; - - let fontDefined = !!(kfd && kfd['files']); - kfd = fontDefined ? kfd : undefined; - - let oskFontDefined = !!(ofd && ofd['files']); - ofd = oskFontDefined ? ofd : undefined; - - // Automatically 'ready' if the descriptor is explicitly `undefined`. - // Thus, also covers the case where both are undefined. - var kReady = util.checkFontDescriptor(kfd), oReady = util.checkFontDescriptor(ofd); - if (kReady && oReady) { - return true; - } - - keymanweb.fontCheckTimer = window.setInterval(function () { - if (util.checkFontDescriptor(kfd) && util.checkFontDescriptor(ofd)) { - window.clearInterval(keymanweb.fontCheckTimer); - keymanweb.fontCheckTimer = null; - keymanweb.alignInputs(); - } - }, 100); - - // Align anyway as best as can if font appears to remain uninstalled after 5 seconds - window.setTimeout(function () { - if (keymanweb.fontCheckTimer) { - window.clearInterval(keymanweb.fontCheckTimer); - keymanweb.fontCheckTimer = null; - keymanweb.alignInputs(); - // Don't notify - this is a management issue, not anything the user needs to deal with - // TODO: Consider having an icon in the OSK with a bubble that indicates missing font - //util.alert('Unable to download the font normally used with '+ks['KN']+'.'); - } - }, 5000); - return false; - }; - shutdown() { let keyman = com.keyman.singleton; diff --git a/web/testing/inline-osk/index.html b/web/testing/inline-osk/index.html index 01bf80a84f5..5d3e1d9ad3c 100644 --- a/web/testing/inline-osk/index.html +++ b/web/testing/inline-osk/index.html @@ -47,7 +47,6 @@ document.getElementById('KeymanWebControl').appendChild(newOSK.element); keyman.osk = newOSK; newOSK.activeKeyboard = keyman.core.activeKeyboard; - keyman.alignInputs(); document.getElementById('ta1').focus(); } From 7de043021d3373c9aa8aef7e5e240d89cfba9628 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Thu, 29 Sep 2022 10:41:38 +0700 Subject: [PATCH 2/4] fix(web): forgot to remove kmwembedded ref --- web/source/kmwembedded.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/web/source/kmwembedded.ts b/web/source/kmwembedded.ts index 84081d1a7dd..a27b5abdd37 100644 --- a/web/source/kmwembedded.ts +++ b/web/source/kmwembedded.ts @@ -80,11 +80,6 @@ namespace com.keyman.osk { }; } - VisualKeyboard.prototype.waitForFonts = function(this: VisualKeyboard, kfd, ofd) { - // a dummy function; it's only really used for 'native' KMW. - return true; - } - SuggestionManager.prototype.platformHold = function(this: SuggestionManager, suggestionObj: BannerSuggestion, isCustom: boolean) { // Parallels VisualKeyboard.prototype.touchHold, but for predictive suggestions instead of keystrokes. let suggestionEle = suggestionObj.div; From 312b19c3ef9cfdb5d87fcbb7248b17feccbc88c2 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Fri, 30 Sep 2022 11:49:03 +0700 Subject: [PATCH 3/4] chore(web): drops testString, checkFont* funcs --- web/source/kmwbase.ts | 12 ----- web/source/kmwutils.ts | 113 ----------------------------------------- 2 files changed, 125 deletions(-) diff --git a/web/source/kmwbase.ts b/web/source/kmwbase.ts index 2898e6f5019..3ef17d0946a 100644 --- a/web/source/kmwbase.ts +++ b/web/source/kmwbase.ts @@ -56,7 +56,6 @@ namespace com.keyman { warned = false; // Warning flag (to prevent multiple warnings) baseFont = 'sans-serif'; // Default font for mapped input elements appliedFont = ''; // Chain of fonts to be applied to mapped input elements - fontCheckTimer = null; // Timer for testing loading of embedded fonts srcPath = ''; // Path to folder containing executing keymanweb script rootPath = ''; // Path to server root protocol = ''; // Protocol used for the KMW script. @@ -229,17 +228,6 @@ namespace com.keyman { return metadata; } - /** - * Expose font testing to allow checking that SpecialOSK or custom font has - * been correctly loaded by browser - * - * @param {string} fName font-family name - * @return {boolean} true if available - **/ - ['isFontAvailable'](fName: string): boolean { - return this.util.checkFont({'family':fName}); - } - /** * Function addEventListener * Scope Public diff --git a/web/source/kmwutils.ts b/web/source/kmwutils.ts index 020d309a5c6..6b7f26f7880 100644 --- a/web/source/kmwutils.ts +++ b/web/source/kmwutils.ts @@ -1021,119 +1021,6 @@ namespace com.keyman { return this.keyman.protocol+'//'+path; } } - - /** - * Return the appropriate test string for a given font - * - * TODO: Tidy up and remove arrays once 'sample' included in font metadata - * - * @param {Object} fd font meta-data object - * @return {string} string to compare width - * - */ - testString(fd): string { - var fontName=fd['family'], - i,s='BESbswy'; - - if('sample' in fd && typeof(fd['sample']) == 'string') { - return s+fd['sample']; - } - - var f=['TamilWeb','TibetanWeb','LatinWeb','CherokeeWeb', - 'EgyptianWeb','SinhalaWeb','KhmerWeb','ArabicWeb', - 'BurmeseWeb','LaoWeb','OriyaWeb','GeezWeb'], - t=['\u0BBE\u0BF5','\u0F7F\u0FD0','\u02B0\u02A4','\u13D0\u13C9', - '\uA723\uF7D3','\u0DD8\u0DA3','\u17D6\u178E','\u0639\u06B3', - '\u1038\u1024','\u0EC0\u0EDD','\u0B03\u0B06','\u1361\u132C']; - - for(i=0; i Date: Fri, 30 Sep 2022 12:46:57 +0700 Subject: [PATCH 4/4] docs(web): re-documents a couple of vars (see #7387) --- web/source/kmwbase.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/source/kmwbase.ts b/web/source/kmwbase.ts index 3ef17d0946a..0cfd1b5b623 100644 --- a/web/source/kmwbase.ts +++ b/web/source/kmwbase.ts @@ -54,8 +54,8 @@ namespace com.keyman { _MasterDocument = null; // Document with controller (to allow iframes to distinguish local/master control) _HotKeys = []; // Array of document-level hotkey objects warned = false; // Warning flag (to prevent multiple warnings) - baseFont = 'sans-serif'; // Default font for mapped input elements - appliedFont = ''; // Chain of fonts to be applied to mapped input elements + baseFont = 'sans-serif'; // Default page font (utilized by the OSK) + appliedFont = ''; // Chain of fonts to be applied to OSK elements srcPath = ''; // Path to folder containing executing keymanweb script rootPath = ''; // Path to server root protocol = ''; // Protocol used for the KMW script.