@astryxdesign/core 0.7.7-canary.3b3052a → 0.7.7-canary.5f3198e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gestures/GestureArena.d.ts +21 -2
- package/dist/gestures/GestureArena.d.ts.map +1 -1
- package/dist/gestures/GestureArena.js +19 -2
- package/dist/gestures/GestureHost.d.ts +51 -1
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +148 -7
- package/dist/utils/selectionLock.d.ts +43 -0
- package/dist/utils/selectionLock.d.ts.map +1 -1
- package/dist/utils/selectionLock.js +394 -6
- package/package.json +4 -4
- package/src/gestures/GestureArena.ts +44 -4
- package/src/gestures/GestureHost.ts +184 -7
- package/src/gestures/README.md +19 -3
- package/src/utils/selectionLock.ts +501 -6
|
@@ -62,8 +62,15 @@ export interface ArenaBeganInput extends TouchBeganInput {
|
|
|
62
62
|
export interface GestureArenaOptions {
|
|
63
63
|
clock?: GestureClock;
|
|
64
64
|
environment?: GestureEnvironment;
|
|
65
|
-
/**
|
|
66
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Touches a recognizer now owns, and the recognizer that claimed them. A
|
|
67
|
+
* claim comes in any state: a recognizer that waits on another's failure
|
|
68
|
+
* claims while `possible`, and a swipe claims as `ended`. Each claim is
|
|
69
|
+
* reported once.
|
|
70
|
+
*/
|
|
71
|
+
onClaim?: (touchIds: ReadonlyArray<number>, claimer: GestureRecognizer) => void;
|
|
72
|
+
/** Claimed touches given back to the browser (releaseClaim). */
|
|
73
|
+
onRelease?: (touchIds: ReadonlyArray<number>) => void;
|
|
67
74
|
/** A click deferred at touch end resolved: replay it, or drop it. */
|
|
68
75
|
onDeferredClick?: (touch: GestureTouch, allowed: boolean) => void;
|
|
69
76
|
/**
|
|
@@ -72,6 +79,13 @@ export interface GestureArenaOptions {
|
|
|
72
79
|
* listening now (`spec:AST-094` FR24).
|
|
73
80
|
*/
|
|
74
81
|
onIdle?: () => void;
|
|
82
|
+
/**
|
|
83
|
+
* Whether the browser keeps a contact for itself while it is down. Then no
|
|
84
|
+
* claiming recognizer recognizes with it before its lift. So a mouse or pen
|
|
85
|
+
* drag that starts on selectable text selects that text. A recognition at
|
|
86
|
+
* the lift, such as a tap's, is unaffected.
|
|
87
|
+
*/
|
|
88
|
+
refusesClaim?: (touch: GestureTouch) => boolean;
|
|
75
89
|
/** Every recognizer transition, for debugging and tests. */
|
|
76
90
|
onTransition?: (recognizer: GestureRecognizer, from: GestureState, to: GestureState) => void;
|
|
77
91
|
}
|
|
@@ -169,6 +183,11 @@ export declare class GestureArena {
|
|
|
169
183
|
private attemptRecognition;
|
|
170
184
|
/** Whether `winner` being recognized prevents `other`. */
|
|
171
185
|
private conflicts;
|
|
186
|
+
/**
|
|
187
|
+
* Whether a recognizer that claims touches would take a contact the
|
|
188
|
+
* browser keeps while it is down (`refusesClaim`).
|
|
189
|
+
*/
|
|
190
|
+
private isRefusedByBrowser;
|
|
172
191
|
/** UIControl's rule: a control may veto an overlapping ancestor recognizer. */
|
|
173
192
|
private isVetoedByConsumer;
|
|
174
193
|
private fail;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GestureArena.d.ts","sourceRoot":"","sources":["../../src/gestures/GestureArena.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,kBAAkB,EAElB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,aAAa,EACb,UAAU,EAEX,MAAM,SAAS,CAAC;AAIjB,MAAM,WAAW,YAAY;IAC3B,GAAG,IAAI,MAAM,CAAC;IACd,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACtD,YAAY,CAAC,MAAM,EAAE,OAAO,GA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;IACH,OAAO,CAAC,GAAG;IAgCX,OAAO,CAAC,WAAW;IA+BnB,4EAA4E;IAC5E,OAAO,CAAC,IAAI;IAKZ,OAAO,CAAC,MAAM;IAyCd,OAAO,CAAC,iBAAiB;CAkC1B"}
|
|
@@ -471,7 +471,7 @@ export class GestureArena {
|
|
|
471
471
|
// --- Resolution ------------------------------------------------------------
|
|
472
472
|
|
|
473
473
|
attemptRecognition(recognizer, next) {
|
|
474
|
-
if (!internals(recognizer).shouldBegin() || this.isVetoedByConsumer(recognizer)) {
|
|
474
|
+
if (!internals(recognizer).shouldBegin() || this.isVetoedByConsumer(recognizer) || this.isRefusedByBrowser(recognizer)) {
|
|
475
475
|
this.fail(recognizer);
|
|
476
476
|
return;
|
|
477
477
|
}
|
|
@@ -535,6 +535,18 @@ export class GestureArena {
|
|
|
535
535
|
return winner.canPrevent(other) && other.canBePrevented(winner);
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
+
/**
|
|
539
|
+
* Whether a recognizer that claims touches would take a contact the
|
|
540
|
+
* browser keeps while it is down (`refusesClaim`).
|
|
541
|
+
*/
|
|
542
|
+
isRefusedByBrowser(recognizer) {
|
|
543
|
+
const refuses = this.options.refusesClaim;
|
|
544
|
+
if (refuses == null || !recognizer.claimsTouches) {
|
|
545
|
+
return false;
|
|
546
|
+
}
|
|
547
|
+
return recognizer.trackedTouches.some(touch => touch.phase !== 'ended' && touch.phase !== 'cancelled' && refuses(touch));
|
|
548
|
+
}
|
|
549
|
+
|
|
538
550
|
/** UIControl's rule: a control may veto an overlapping ancestor recognizer. */
|
|
539
551
|
isVetoedByConsumer(recognizer) {
|
|
540
552
|
for (const id of internals(recognizer).seenTouchIds) {
|
|
@@ -570,6 +582,7 @@ export class GestureArena {
|
|
|
570
582
|
* takes a touch another recognizer had.
|
|
571
583
|
*/
|
|
572
584
|
releaseClaim(recognizer, keep = new Set()) {
|
|
585
|
+
const released = [];
|
|
573
586
|
for (const touch of recognizer.trackedTouches) {
|
|
574
587
|
const record = this.records.get(touch.id);
|
|
575
588
|
if (record == null || !record.isClaimed || keep.has(touch.id)) {
|
|
@@ -580,8 +593,12 @@ export class GestureArena {
|
|
|
580
593
|
const isOwned = this.active.some(other => other !== recognizer && other.claimsTouches && (isActive(other.state) || other.state === 'ended' || internals(other).pending != null) && other.trackedTouches.some(tracked => tracked.id === touch.id));
|
|
581
594
|
if (!isOwned) {
|
|
582
595
|
record.isClaimed = false;
|
|
596
|
+
released.push(touch.id);
|
|
583
597
|
}
|
|
584
598
|
}
|
|
599
|
+
if (released.length > 0) {
|
|
600
|
+
this.options.onRelease?.(released);
|
|
601
|
+
}
|
|
585
602
|
}
|
|
586
603
|
apply(recognizer, next) {
|
|
587
604
|
const from = recognizer.state;
|
|
@@ -643,7 +660,7 @@ export class GestureArena {
|
|
|
643
660
|
}
|
|
644
661
|
}
|
|
645
662
|
if (claimed.length > 0) {
|
|
646
|
-
this.options.onClaim?.(claimed);
|
|
663
|
+
this.options.onClaim?.(claimed, recognizer);
|
|
647
664
|
}
|
|
648
665
|
}
|
|
649
666
|
|
|
@@ -65,6 +65,23 @@ export declare class GestureHost {
|
|
|
65
65
|
private cancelCallerRead;
|
|
66
66
|
/** The selection lock each contact holds, by host contact id. */
|
|
67
67
|
private readonly lockedBy;
|
|
68
|
+
/**
|
|
69
|
+
* The page's selection when each mouse or pen press began: a drag a
|
|
70
|
+
* recognizer claims keeps it.
|
|
71
|
+
*/
|
|
72
|
+
private readonly pressSelections;
|
|
73
|
+
/**
|
|
74
|
+
* Mouse and pen contacts that began on selectable text. Once one moves, the
|
|
75
|
+
* browser keeps the drag for a selection, and no recognizer claims it.
|
|
76
|
+
*/
|
|
77
|
+
private readonly selectingContacts;
|
|
78
|
+
/**
|
|
79
|
+
* Drag selection holds until their last task ends, a task after their lift
|
|
80
|
+
* (lockDragSelection); the last detach ends them at once.
|
|
81
|
+
*/
|
|
82
|
+
private readonly dragHolds;
|
|
83
|
+
/** Each claimed contact's drag hold, until its lift or a give-back. */
|
|
84
|
+
private readonly claimHolds;
|
|
68
85
|
private readonly presentedHitTesting;
|
|
69
86
|
/**
|
|
70
87
|
* Contacts sent to what is drawn instead of what the engine hit, by host
|
|
@@ -477,6 +494,28 @@ export declare class GestureHost {
|
|
|
477
494
|
* is subscribed.
|
|
478
495
|
*/
|
|
479
496
|
private latchWheel;
|
|
497
|
+
/**
|
|
498
|
+
* Hold the page's selection for a mouse or pen contact that a recognizer
|
|
499
|
+
* claims. Examples are a pan's drag and a press a group claims at its own
|
|
500
|
+
* pointerdown. While the contact is down, the claiming recognizers'
|
|
501
|
+
* elements refuse a new selection. The selection the page had at the press
|
|
502
|
+
* is put back over anything that replaced it. That includes the press's own
|
|
503
|
+
* collapse and a selection the drag made before its claim. The claiming
|
|
504
|
+
* recognizer's element holds from its claim, in any state: a waiting
|
|
505
|
+
* recognizer claims while possible, and a swipe claims as ended. The
|
|
506
|
+
* participants that already recognize hold too. A claim given back to the
|
|
507
|
+
* browser lets its hold go (releaseClaimedDrags). A drag that starts on
|
|
508
|
+
* selectable text never gets here, because no recognizer claims it
|
|
509
|
+
* (`selectingContacts`). A tap claims only at its lift, so a click keeps
|
|
510
|
+
* the selection it made. A finger keeps the touch-down lock alone.
|
|
511
|
+
*/
|
|
512
|
+
private lockClaimedDrags;
|
|
513
|
+
/**
|
|
514
|
+
* Claimed contacts the arena gave back. Their drag holds end at once, so
|
|
515
|
+
* the browser's drag selects again. A contact's press lock (lockSelection)
|
|
516
|
+
* is not a drag hold and stays.
|
|
517
|
+
*/
|
|
518
|
+
private releaseClaimedDrags;
|
|
480
519
|
/**
|
|
481
520
|
* End the trackpad pan a recognizer still drives, when the page loses focus
|
|
482
521
|
* or hides, and return its contacts to cancel. The rest of its stream is
|
|
@@ -495,7 +534,18 @@ export declare class GestureHost {
|
|
|
495
534
|
* not share it.
|
|
496
535
|
*/
|
|
497
536
|
private endWheel;
|
|
498
|
-
/**
|
|
537
|
+
/**
|
|
538
|
+
* At a mouse or pen press, mark one that lands on selectable text: once it
|
|
539
|
+
* moves, it is the browser's drag, and selects text.
|
|
540
|
+
* Text whose hold does something is locked at this press already
|
|
541
|
+
* (lockSelection), so it is not selectable text.
|
|
542
|
+
*/
|
|
543
|
+
private noteSelectingPress;
|
|
544
|
+
/**
|
|
545
|
+
* Undo a contact's selection locks, its press lock and its drag hold, at
|
|
546
|
+
* once for a cancel, and forget its press's selection; idempotent. A
|
|
547
|
+
* drag's hold keeps its last task after a lift (lockDragSelection).
|
|
548
|
+
*/
|
|
499
549
|
private unlockSelection;
|
|
500
550
|
/**
|
|
501
551
|
* Hold touches away from every participant while `gate(target)` answers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GestureHost.d.ts","sourceRoot":"","sources":["../../src/gestures/GestureHost.ts"],"names":[],"mappings":"AAmIA,OAAO,EAEL,YAAY,EAGZ,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAC,iBAAiB,EAAgB,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAqBhD,OAAO,KAAK,EAEV,YAAY,EAIZ,aAAa,EAGd,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"GestureHost.d.ts","sourceRoot":"","sources":["../../src/gestures/GestureHost.ts"],"names":[],"mappings":"AAmIA,OAAO,EAEL,YAAY,EAGZ,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAC,iBAAiB,EAAgB,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAqBhD,OAAO,KAAK,EAEV,YAAY,EAIZ,aAAa,EAGd,MAAM,SAAS,CAAC;AAgDjB,MAAM,WAAW,kBAAkB;IACjC,kDAAkD;IAClD,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB;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KxB;;;;OAIG;IACH,OAAO,CAAC,6BAA6B;IAQrC,+DAA+D;IAC/D,OAAO,CAAC,gBAAgB;CA0BzB;AAyBD,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,WAAW,CAOzD"}
|
|
@@ -135,7 +135,7 @@ import { internals } from "./recognizerInternals.js";
|
|
|
135
135
|
import { armClickGuard, disarmClickGuard, withoutClickGuard } from "../utils/clickGuard.js";
|
|
136
136
|
import { subscribeInput } from "../utils/inputStream.js";
|
|
137
137
|
import { isPrimaryClick } from "../utils/primaryClick.js";
|
|
138
|
-
import { locksSelectionFor } from "../utils/selectionLock.js";
|
|
138
|
+
import { lockDragSelection, locksSelectionFor, selectionRangesOf, startsOnSelectableText } from "../utils/selectionLock.js";
|
|
139
139
|
import { isCoarsePointer, watchCoarsePointer } from "../utils/coarsePointer.js";
|
|
140
140
|
import { gestureHosts } from "./hostRegistry.js";
|
|
141
141
|
const STYLE_PROPERTIES = {
|
|
@@ -404,6 +404,23 @@ export class GestureHost {
|
|
|
404
404
|
cancelCallerRead = null;
|
|
405
405
|
/** The selection lock each contact holds, by host contact id. */
|
|
406
406
|
lockedBy = new Map();
|
|
407
|
+
/**
|
|
408
|
+
* The page's selection when each mouse or pen press began: a drag a
|
|
409
|
+
* recognizer claims keeps it.
|
|
410
|
+
*/
|
|
411
|
+
pressSelections = new Map();
|
|
412
|
+
/**
|
|
413
|
+
* Mouse and pen contacts that began on selectable text. Once one moves, the
|
|
414
|
+
* browser keeps the drag for a selection, and no recognizer claims it.
|
|
415
|
+
*/
|
|
416
|
+
selectingContacts = new Set();
|
|
417
|
+
/**
|
|
418
|
+
* Drag selection holds until their last task ends, a task after their lift
|
|
419
|
+
* (lockDragSelection); the last detach ends them at once.
|
|
420
|
+
*/
|
|
421
|
+
dragHolds = new Set();
|
|
422
|
+
/** Each claimed contact's drag hold, until its lift or a give-back. */
|
|
423
|
+
claimHolds = new Map();
|
|
407
424
|
/**
|
|
408
425
|
* Contacts sent to what is drawn instead of what the engine hit, by host
|
|
409
426
|
* contact id, with where they landed (for their click).
|
|
@@ -581,7 +598,10 @@ export class GestureHost {
|
|
|
581
598
|
// A press whose decision waited on a timer (a tap waiting on a double
|
|
582
599
|
// tap) ends here: an armed press stops listening (FR24).
|
|
583
600
|
onIdle: () => this.releaseArmedPress(),
|
|
584
|
-
onTransition: options.onTransition
|
|
601
|
+
onTransition: options.onTransition,
|
|
602
|
+
onClaim: (ids, claimer) => this.lockClaimedDrags(ids, claimer),
|
|
603
|
+
onRelease: ids => this.releaseClaimedDrags(ids),
|
|
604
|
+
refusesClaim: touch => this.selectingContacts.has(touch.id) && (touch.x !== touch.startX || touch.y !== touch.startY)
|
|
585
605
|
});
|
|
586
606
|
const view = doc.defaultView;
|
|
587
607
|
// A test may pass its own read; otherwise the one coarse-pointer gate,
|
|
@@ -1422,6 +1442,15 @@ export class GestureHost {
|
|
|
1422
1442
|
}
|
|
1423
1443
|
this.ownScrollFrames.clear();
|
|
1424
1444
|
this.ownedScrolls.clear();
|
|
1445
|
+
// A drag's hold whose press lifted in this task ends now, not a task
|
|
1446
|
+
// later: nothing is attached to meet its mouseup or click.
|
|
1447
|
+
for (const release of [...this.dragHolds]) {
|
|
1448
|
+
release({
|
|
1449
|
+
isCancel: true
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
this.pressSelections.clear();
|
|
1453
|
+
this.selectingContacts.clear();
|
|
1425
1454
|
});
|
|
1426
1455
|
}
|
|
1427
1456
|
|
|
@@ -2051,6 +2080,79 @@ export class GestureHost {
|
|
|
2051
2080
|
}
|
|
2052
2081
|
}
|
|
2053
2082
|
|
|
2083
|
+
/**
|
|
2084
|
+
* Hold the page's selection for a mouse or pen contact that a recognizer
|
|
2085
|
+
* claims. Examples are a pan's drag and a press a group claims at its own
|
|
2086
|
+
* pointerdown. While the contact is down, the claiming recognizers'
|
|
2087
|
+
* elements refuse a new selection. The selection the page had at the press
|
|
2088
|
+
* is put back over anything that replaced it. That includes the press's own
|
|
2089
|
+
* collapse and a selection the drag made before its claim. The claiming
|
|
2090
|
+
* recognizer's element holds from its claim, in any state: a waiting
|
|
2091
|
+
* recognizer claims while possible, and a swipe claims as ended. The
|
|
2092
|
+
* participants that already recognize hold too. A claim given back to the
|
|
2093
|
+
* browser lets its hold go (releaseClaimedDrags). A drag that starts on
|
|
2094
|
+
* selectable text never gets here, because no recognizer claims it
|
|
2095
|
+
* (`selectingContacts`). A tap claims only at its lift, so a click keeps
|
|
2096
|
+
* the selection it made. A finger keeps the touch-down lock alone.
|
|
2097
|
+
*/
|
|
2098
|
+
lockClaimedDrags(ids, claimer) {
|
|
2099
|
+
for (const id of ids) {
|
|
2100
|
+
if (this.claimHolds.has(id)) {
|
|
2101
|
+
continue;
|
|
2102
|
+
}
|
|
2103
|
+
const touch = this.arena.touches.find(each => each.id === id);
|
|
2104
|
+
// A claim made at the contact's own lift (a tap's) holds nothing: the
|
|
2105
|
+
// drag is over, and a click keeps the selection it made. A wheel's
|
|
2106
|
+
// contact keeps the page's selection, as a scroll does.
|
|
2107
|
+
if (touch == null || touch.pointerType === 'touch' || touch.scrollType != null || touch.phase === 'ended' || touch.phase === 'cancelled') {
|
|
2108
|
+
continue;
|
|
2109
|
+
}
|
|
2110
|
+
const elements = new Set();
|
|
2111
|
+
for (const recognizer of this.arena.participantsOf(id)) {
|
|
2112
|
+
if ((recognizer.state === 'began' || recognizer.state === 'changed') && recognizer.view?.nodeType === 1) {
|
|
2113
|
+
elements.add(recognizer.view);
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
if (claimer.view?.nodeType === 1) {
|
|
2117
|
+
elements.add(claimer.view);
|
|
2118
|
+
}
|
|
2119
|
+
if (elements.size === 0) {
|
|
2120
|
+
continue;
|
|
2121
|
+
}
|
|
2122
|
+
const release = lockDragSelection(elements, this.doc.defaultView, this.pressSelections.get(id) ?? [], () => {
|
|
2123
|
+
this.dragHolds.delete(release);
|
|
2124
|
+
});
|
|
2125
|
+
this.dragHolds.add(release);
|
|
2126
|
+
// A press lock the contact took at its press stays in `lockedBy`. The
|
|
2127
|
+
// hold sits beside it, and the contact's end releases both.
|
|
2128
|
+
if (!this.lockedBy.has(id)) {
|
|
2129
|
+
this.lockedBy.set(id, release);
|
|
2130
|
+
}
|
|
2131
|
+
this.claimHolds.set(id, release);
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
/**
|
|
2136
|
+
* Claimed contacts the arena gave back. Their drag holds end at once, so
|
|
2137
|
+
* the browser's drag selects again. A contact's press lock (lockSelection)
|
|
2138
|
+
* is not a drag hold and stays.
|
|
2139
|
+
*/
|
|
2140
|
+
releaseClaimedDrags(ids) {
|
|
2141
|
+
for (const id of ids) {
|
|
2142
|
+
const release = this.claimHolds.get(id);
|
|
2143
|
+
if (release == null) {
|
|
2144
|
+
continue;
|
|
2145
|
+
}
|
|
2146
|
+
this.claimHolds.delete(id);
|
|
2147
|
+
if (this.lockedBy.get(id) === release) {
|
|
2148
|
+
this.lockedBy.delete(id);
|
|
2149
|
+
}
|
|
2150
|
+
release({
|
|
2151
|
+
isCancel: true
|
|
2152
|
+
});
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2054
2156
|
/**
|
|
2055
2157
|
* End the trackpad pan a recognizer still drives, when the page loses focus
|
|
2056
2158
|
* or hides, and return its contacts to cancel. The rest of its stream is
|
|
@@ -2132,10 +2234,40 @@ export class GestureHost {
|
|
|
2132
2234
|
}] : this.pinchContacts(gesture, time));
|
|
2133
2235
|
}
|
|
2134
2236
|
|
|
2135
|
-
/**
|
|
2136
|
-
|
|
2137
|
-
|
|
2237
|
+
/**
|
|
2238
|
+
* At a mouse or pen press, mark one that lands on selectable text: once it
|
|
2239
|
+
* moves, it is the browser's drag, and selects text.
|
|
2240
|
+
* Text whose hold does something is locked at this press already
|
|
2241
|
+
* (lockSelection), so it is not selectable text.
|
|
2242
|
+
*/
|
|
2243
|
+
noteSelectingPress(id, x, y, target) {
|
|
2244
|
+
if (!this.lockedBy.has(id) && startsOnSelectableText(this.doc, x, y, target)) {
|
|
2245
|
+
this.selectingContacts.add(id);
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
/**
|
|
2250
|
+
* Undo a contact's selection locks, its press lock and its drag hold, at
|
|
2251
|
+
* once for a cancel, and forget its press's selection; idempotent. A
|
|
2252
|
+
* drag's hold keeps its last task after a lift (lockDragSelection).
|
|
2253
|
+
*/
|
|
2254
|
+
unlockSelection(id, isCancel = false) {
|
|
2255
|
+
const lock = this.lockedBy.get(id);
|
|
2256
|
+
lock?.({
|
|
2257
|
+
isCancel
|
|
2258
|
+
});
|
|
2259
|
+
// A press lock keeps `lockedBy` when the contact also has a drag hold.
|
|
2260
|
+
// Release the hold too.
|
|
2261
|
+
const hold = this.claimHolds.get(id);
|
|
2262
|
+
if (hold != null && hold !== lock) {
|
|
2263
|
+
hold({
|
|
2264
|
+
isCancel
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2138
2267
|
this.lockedBy.delete(id);
|
|
2268
|
+
this.claimHolds.delete(id);
|
|
2269
|
+
this.pressSelections.delete(id);
|
|
2270
|
+
this.selectingContacts.delete(id);
|
|
2139
2271
|
}
|
|
2140
2272
|
|
|
2141
2273
|
// --- Touch events ----------------------------------------------------------
|
|
@@ -2830,6 +2962,11 @@ export class GestureHost {
|
|
|
2830
2962
|
target
|
|
2831
2963
|
});
|
|
2832
2964
|
}
|
|
2965
|
+
// Before the arena admits it: a press a group claims at its own
|
|
2966
|
+
// pointerdown keeps the selection the page has now.
|
|
2967
|
+
if (event.pointerType !== 'touch') {
|
|
2968
|
+
this.pressSelections.set(id, selectionRangesOf(this.doc.defaultView));
|
|
2969
|
+
}
|
|
2833
2970
|
this.arena.began([{
|
|
2834
2971
|
id,
|
|
2835
2972
|
x: event.clientX,
|
|
@@ -2846,6 +2983,10 @@ export class GestureHost {
|
|
|
2846
2983
|
// hit test may still see the motion's start.
|
|
2847
2984
|
this.lockSelection(id, this.arena.participantsOf(id), target, this.arena.consumerOf(id) ?? null, consumerElement);
|
|
2848
2985
|
}
|
|
2986
|
+
if (event.pointerType !== 'touch') {
|
|
2987
|
+
// The engine's own hit: the text its caret query and a drag select.
|
|
2988
|
+
this.noteSelectingPress(id, event.clientX, event.clientY, landed);
|
|
2989
|
+
}
|
|
2849
2990
|
};
|
|
2850
2991
|
onPointerMove = event => {
|
|
2851
2992
|
if (event.pointerType === 'touch' && this.usesTouchEvents) {
|
|
@@ -2981,7 +3122,7 @@ export class GestureHost {
|
|
|
2981
3122
|
const id = this.pointerIds.get(event.pointerId);
|
|
2982
3123
|
if (id != null) {
|
|
2983
3124
|
this.pointerIds.delete(event.pointerId);
|
|
2984
|
-
this.unlockSelection(id);
|
|
3125
|
+
this.unlockSelection(id, true);
|
|
2985
3126
|
this.retargeted.delete(id);
|
|
2986
3127
|
this.arena.cancelled([id], eventTime(event));
|
|
2987
3128
|
}
|
|
@@ -3185,7 +3326,7 @@ export class GestureHost {
|
|
|
3185
3326
|
cancelEverything(time) {
|
|
3186
3327
|
const ids = [...this.pointerIds.values()];
|
|
3187
3328
|
for (const id of ids) {
|
|
3188
|
-
this.unlockSelection(id);
|
|
3329
|
+
this.unlockSelection(id, true);
|
|
3189
3330
|
}
|
|
3190
3331
|
for (const identifier of [...this.touchIds.keys()]) {
|
|
3191
3332
|
// The browser may keep the touch alive: its lift must not click.
|
|
@@ -10,4 +10,47 @@ export declare function locksSelectionFor(pointerType: string): boolean;
|
|
|
10
10
|
* any holder holds. Idempotent release.
|
|
11
11
|
*/
|
|
12
12
|
export declare function lockSelection(elements: Iterable<Element>, target: EventTarget | null): () => void;
|
|
13
|
+
/** How a drag's selection hold ends: at a lift, or at a cancel. */
|
|
14
|
+
export interface DragSelectionReleaseOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The press was cancelled (a pointercancel, a blur, a detach), so no
|
|
17
|
+
* mouseup or click follows: the hold ends at once. Called again after a
|
|
18
|
+
* lift, it ends the hold's last task at once too.
|
|
19
|
+
*/
|
|
20
|
+
isCancel?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Refuse a new selection while a mouse or pen drag that a recognizer claimed
|
|
24
|
+
* runs, until the returned function runs. `kept` is the page's selection
|
|
25
|
+
* when the press began, and it stays. Anything that replaces it while the
|
|
26
|
+
* drag runs is put back to it. That includes the press's own collapse and a
|
|
27
|
+
* selection the drag started before its claim. So the drag takes no new
|
|
28
|
+
* selection and never clears an existing one. `elements` refuse a
|
|
29
|
+
* selection with inline styles, on every engine. The document refuses one
|
|
30
|
+
* too, because WebKit extends a drag's selection over text outside the
|
|
31
|
+
* elements without another `selectstart`. So a `selectstart` anywhere is
|
|
32
|
+
* refused, and the selection is put back. A `selectstart` does not leave its
|
|
33
|
+
* shadow tree. So the document refuses only one that starts outside every
|
|
34
|
+
* shadow tree, and a claiming element inside one refuses its own. The
|
|
35
|
+
* press's own `mouseup` and `click` come after its `pointerup` in the same
|
|
36
|
+
* task, and WebKit settles the drag's selection there. So the document's
|
|
37
|
+
* hold ends a task after a lift. A cancel ends it at once, because nothing
|
|
38
|
+
* follows a cancel. `onReleased` runs once the document's hold has ended.
|
|
39
|
+
* The page listeners exist only during a press. Idempotent.
|
|
40
|
+
*/
|
|
41
|
+
export declare function lockDragSelection(elements: Iterable<Element>, view: Window | null | undefined, kept: ReadonlyArray<AbstractRange>, onReleased?: () => void): (options?: DragSelectionReleaseOptions) => void;
|
|
42
|
+
/**
|
|
43
|
+
* The page's selection now, its ranges copied; none for a collapsed or empty
|
|
44
|
+
* one. A drag's hold keeps what this read when the press began.
|
|
45
|
+
*/
|
|
46
|
+
export declare function selectionRangesOf(view: Window | null | undefined): ReadonlyArray<AbstractRange>;
|
|
47
|
+
/**
|
|
48
|
+
* Whether a press at (`x`, `y`) lands on text a drag would select. That is a
|
|
49
|
+
* text field, or a character of non-empty text whose element allows a
|
|
50
|
+
* selection. A native button's label, slotted or not, is not selectable text,
|
|
51
|
+
* because the engine starts no selection from a drag inside a button. A point
|
|
52
|
+
* beside text, which a caret query snaps to the nearest character, lands on
|
|
53
|
+
* none. Where the engine has no caret query, nothing is selectable text.
|
|
54
|
+
*/
|
|
55
|
+
export declare function startsOnSelectableText(doc: Document, x: number, y: number, target: EventTarget | null): boolean;
|
|
13
56
|
//# sourceMappingURL=selectionLock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectionLock.d.ts","sourceRoot":"","sources":["../../src/utils/selectionLock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"selectionLock.d.ts","sourceRoot":"","sources":["../../src/utils/selectionLock.ts"],"names":[],"mappings":"AAoDA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAE9D;AAWD;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC3B,MAAM,EAAE,WAAW,GAAG,IAAI,GACzB,MAAM,IAAI,CA4BZ;AAED,mEAAmE;AACnE,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC3B,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,IAAI,EAAE,aAAa,CAAC,aAAa,CAAC,EAClC,UAAU,CAAC,EAAE,MAAM,IAAI,GACtB,CAAC,OAAO,CAAC,EAAE,2BAA2B,KAAK,IAAI,CA+EjD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC9B,aAAa,CAAC,aAAa,CAAC,CAiB9B;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,QAAQ,EACb,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,MAAM,EAAE,WAAW,GAAG,IAAI,GACzB,OAAO,CA+CT"}
|