From 75bde80a054df1c0eaee61e9bfad4ed030b6cb2b Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Mon, 8 Apr 2024 14:44:32 +0700 Subject: [PATCH] fix(web): quick multitap-modipress use --- .../gestures/matchers/gestureMatcher.ts | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/common/web/gesture-recognizer/src/engine/headless/gestures/matchers/gestureMatcher.ts b/common/web/gesture-recognizer/src/engine/headless/gestures/matchers/gestureMatcher.ts index 4257ec8c25c..8a3c14fc6ee 100644 --- a/common/web/gesture-recognizer/src/engine/headless/gestures/matchers/gestureMatcher.ts +++ b/common/web/gesture-recognizer/src/engine/headless/gestures/matchers/gestureMatcher.ts @@ -157,14 +157,14 @@ export class GestureMatcher implements PredecessorMatch< return; case 'full': contact = srcContact.constructSubview(false, true); - this.addContactInternal(contact, srcContact.path.stats); + this.addContactInternal(contact, srcContact.path.stats, true); continue; case 'partial': preserveBaseItem = true; // Intentional fall-through case 'chop': contact = srcContact.constructSubview(true, preserveBaseItem); - this.addContactInternal(contact, srcContact.path.stats); + this.addContactInternal(contact, srcContact.path.stats, true); break; } } @@ -367,7 +367,7 @@ export class GestureMatcher implements PredecessorMatch< return this._result; } - private addContactInternal(simpleSource: GestureSourceSubview, basePathStats: CumulativePathStats) { + private addContactInternal(simpleSource: GestureSourceSubview, basePathStats: CumulativePathStats, whileInitializing?: boolean) { // The number of already-active contacts tracked for this gesture const existingContacts = this.pathMatchers.length; @@ -491,16 +491,22 @@ export class GestureMatcher implements PredecessorMatch< const result = contactModel.update(); if(result?.type == 'reject') { /* - Refer to the earlier comment in this method re: use of 'cancelled'; we need to - prevent any and all further attempts to match against this model We'd - instantly reject it anyway due to its rejected initial state. Failing to do so - can cause an infinite async loop. - - If we weren't using 'cancelled', 'path' would correspond best with a rejection - here, as the decision is made due to the GestureSource's current path being - rejected by one of the `PathModel`s comprising the `GestureModel`. + Refer to the earlier comment in this method re: use of 'cancelled'; we + need to prevent any and all further attempts to match against this model + We'd instantly reject it anyway due to its rejected initial state. + Failing to do so can cause an infinite async loop. + + If we weren't using 'cancelled', 'path' would correspond best with a + rejection here, as the decision is made due to the GestureSource's + current path being rejected by one of the `PathModel`s comprising the + `GestureModel`. + + If the model's already been initialized, it's possible that a _new_ + incoming touch needs special handling. We'll allow one reset. In the + case that it would try to restart itself, the restarted model will + instantly fail and thus cancel. */ - this.finalize(false, 'cancelled'); + this.finalize(false, whileInitializing ? 'cancelled' : 'path'); } // Standard path: trigger either resolution or rejection when the contact model signals either.