Repository navigation
Expand file tree
/
Copy pathscroll-gesture.ts
More file actions
559 lines (514 loc) · 21.7 KB
/
Copy pathscroll-gesture.ts
File metadata and controls
559 lines (514 loc) · 21.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
import { AppError } from '@agent-device/kernel/errors';
import { defineStringEnum } from './string-enum.ts';
import { isViewportRootNode } from './snapshot-visibility.ts';
import type { Rect, SnapshotNode } from '@agent-device/kernel/snapshot';
// What a caller may ASK for, as opposed to `ScrollDirection` (what the gesture resolves to):
// `top`/`bottom` are scroll-to-extreme requests with no direction of their own. Declared here
// rather than in the command runtime that resolves them, so the public `ScrollOptions` can be
// stated without depending on `commands/`.
export const SCROLL_INPUT_DIRECTIONS = ['up', 'down', 'left', 'right', 'top', 'bottom'] as const;
export type ScrollInputDirection = (typeof SCROLL_INPUT_DIRECTIONS)[number];
export const SCROLL_DIRECTIONS = ['up', 'down', 'left', 'right'] as const;
export type ScrollDirection = (typeof SCROLL_DIRECTIONS)[number];
export const SWIPE_PRESETS = ['left', 'right', 'left-edge', 'right-edge'] as const;
export type SwipePreset = (typeof SWIPE_PRESETS)[number];
const SCREEN_EDGE_SWIPE_PRESETS: ReadonlySet<SwipePreset> = new Set(['left-edge', 'right-edge']);
/** Edge presets drive screen-edge gestures, such as a back swipe. */
export function isScreenEdgeSwipePreset(preset: SwipePreset): boolean {
return SCREEN_EDGE_SWIPE_PRESETS.has(preset);
}
export const SWIPE_PATTERNS = ['one-way', 'ping-pong'] as const;
export type SwipePattern = (typeof SWIPE_PATTERNS)[number];
export const SWIPE_REPETITION_MAX = 200;
export const SWIPE_PAUSE_MAX_MS = 10_000;
export const SWIPE_SERIES_MAX_SCHEDULED_DURATION_MS = 60_000;
const SCROLL_DIRECTION_ENUM = defineStringEnum(SCROLL_DIRECTIONS, {
message: (direction) => `Unknown direction: ${direction}`,
});
export type TransformGestureParams = {
x: number;
y: number;
dx: number;
dy: number;
scale: number;
degrees: number;
durationMs?: number;
};
export type GestureReferenceFrame = {
referenceWidth: number;
referenceHeight: number;
};
type GesturePoint = {
x: number;
y: number;
};
export type ScrollGestureOptions = {
direction: ScrollDirection;
amount?: number;
pixels?: number;
referenceWidth: number;
referenceHeight: number;
/**
* The scroll container the swipe is meant for, in the reference frame's own zero-origin space.
* Both endpoints stay strictly inside its intersection with the padded frame (#2714): a span
* that already fits is unchanged, one that leaves it is moved in, and one longer than it is
* shortened. A container the padding leaves nothing of along the scrolled axis gets the padded
* swipe unchanged, since the safe bounds outrank the container.
*/
container?: Rect;
};
export type ScrollGesturePlan = {
direction: ScrollDirection;
x1: number;
y1: number;
x2: number;
y2: number;
referenceWidth: number;
referenceHeight: number;
amount?: number;
/** The span dispatched, which is less than `requestedPixels` when the container shortened it. */
pixels: number;
/** Present only when the container shortened the swipe: the span the padded frame would carry. */
requestedPixels?: number;
};
export type SwipePresetGesturePlan = {
preset: SwipePreset;
x1: number;
y1: number;
x2: number;
y2: number;
referenceWidth: number;
referenceHeight: number;
};
export type InPageSwipeGesturePlan = {
direction: ScrollDirection;
x1: number;
y1: number;
x2: number;
y2: number;
referenceWidth: number;
referenceHeight: number;
};
/**
* The finger-path fraction of the viewport axis one scroll covers when the caller names no
* distance. Exported because a backend with no viewport to measure against (the browser) scales its
* own default step by the ratio to this, and that ratio is only meaningful while both sides read
* the same number.
*/
export const DEFAULT_SCROLL_AMOUNT = 0.6;
// Scroll gestures never touch the outer 10% of either axis. Modern app windows are edge-to-edge,
// so the viewport includes the system bars: a swipe that starts inside the status bar (5.7% of a
// Pixel 7's height, 6.9% of an iPhone's with a Dynamic Island) pulls the notification shade or
// Notification Center down instead of scrolling. 10% clears both with margin (#1781 A1).
const DEFAULT_EDGE_PADDING_FRACTION = 0.1;
// Edge presets stay close to the system gesture boundary without emitting edge coordinates.
const SWIPE_PRESET_EDGE_MARGIN_PX = 8;
// A swipe kept inside a container stays this far off its edges, so the drag never starts on the
// container's boundary row.
const SCROLL_CONTAINER_EDGE_INSET = 8;
export function buildScrollGesturePlan(options: ScrollGestureOptions): ScrollGesturePlan {
const direction = options.direction;
const vertical = direction === 'up' || direction === 'down';
const axisLength = vertical ? options.referenceHeight : options.referenceWidth;
const crossLength = vertical ? options.referenceWidth : options.referenceHeight;
const requestedAmount = resolveRequestedAmount(options.amount);
const requestedPixels =
options.pixels !== undefined
? normalizeRequestedPixels(options.pixels)
: Math.round(axisLength * requestedAmount);
const edgePadding = scrollEdgePadding(axisLength);
const maxTravelPixels = Math.max(1, axisLength - edgePadding * 2);
const travelPixels = Math.max(1, Math.min(requestedPixels, maxTravelPixels));
const halfTravel = Math.round(travelPixels / 2);
const axisCenter = Math.round(axisLength / 2);
const unclamped = {
axisStart: axisCenter - halfTravel,
axisEnd: axisCenter + halfTravel,
cross: Math.round(crossLength / 2),
};
const crossPadding = scrollEdgePadding(crossLength);
const lane = options.container
? keepSwipeInContainer(unclamped, options.container, vertical, {
axis: { min: edgePadding, max: axisLength - edgePadding },
cross: { min: crossPadding, max: crossLength - crossPadding },
crossFrame: { min: 0, max: crossLength },
})
: unclamped;
const laneLength = lane.axisEnd - lane.axisStart;
// Centring rounds an odd span up by one, so only a lane shorter than the travel itself is short.
const shortened = laneLength < travelPixels;
return {
direction,
...laneEndpoints(direction, lane),
referenceWidth: options.referenceWidth,
referenceHeight: options.referenceHeight,
amount: options.amount,
pixels: shortened ? laneLength : travelPixels,
...(shortened ? { requestedPixels: travelPixels } : {}),
};
}
/** `up`/`left` drag from the lane's low end toward its high end; `down`/`right` drag the other way. */
function laneEndpoints(
direction: ScrollDirection,
lane: SwipeLane,
): Pick<ScrollGesturePlan, 'x1' | 'y1' | 'x2' | 'y2'> {
const vertical = direction === 'up' || direction === 'down';
const low = vertical
? { x: lane.cross, y: lane.axisStart }
: { x: lane.axisStart, y: lane.cross };
const high = vertical ? { x: lane.cross, y: lane.axisEnd } : { x: lane.axisEnd, y: lane.cross };
const [start, end] = direction === 'up' || direction === 'left' ? [low, high] : [high, low];
return { x1: start.x, y1: start.y, x2: end.x, y2: end.y };
}
type SwipeLane = { axisStart: number; axisEnd: number; cross: number };
type CoordinateRange = { min: number; max: number };
function scrollEdgePadding(length: number): number {
return Math.max(1, Math.round(length * DEFAULT_EDGE_PADDING_FRACTION));
}
/**
* Moves a centred swipe lane inside the container's intersection with the padded frame,
* shortening it only when that intersection is shorter than the lane. The container is half-open,
* as Android bounds and View hit-testing are, and inset from its edges, so every endpoint lands on
* a row the container owns. A container the padding leaves nothing of on the scrolled axis keeps
* the lane the padded frame planned: the safe bounds outrank the container, and the movement read
* reports the miss as `container-outside-swipe` when nothing else moved.
*/
function keepSwipeInContainer(
lane: SwipeLane,
container: Rect,
vertical: boolean,
padded: { axis: CoordinateRange; cross: CoordinateRange; crossFrame: CoordinateRange },
): SwipeLane {
const band = insetContainerRange(
vertical ? container.y : container.x,
vertical ? container.height : container.width,
padded.axis,
);
const crossStart = vertical ? container.x : container.y;
const crossSize = vertical ? container.width : container.height;
// The padding guards the scrolled axis against system bars. Across it, a rail or chip row that
// sits wholly in the padding is still the surface asked for, so the swipe runs along it there.
const crossBand =
insetContainerRange(crossStart, crossSize, padded.cross) ??
insetContainerRange(crossStart, crossSize, padded.crossFrame);
if (!band || !crossBand) return lane;
const cross =
lane.cross >= crossBand.min && lane.cross <= crossBand.max
? lane.cross
: Math.round((crossBand.min + crossBand.max) / 2);
const length = lane.axisEnd - lane.axisStart;
if (length >= band.max - band.min) return { axisStart: band.min, axisEnd: band.max, cross };
const shift =
lane.axisStart < band.min ? band.min - lane.axisStart : Math.min(0, band.max - lane.axisEnd);
return { axisStart: lane.axisStart + shift, axisEnd: lane.axisEnd + shift, cross };
}
/** The coordinates of `[start, start + size)` an inset swipe may use inside `padded`, if any. */
function insetContainerRange(
start: number,
size: number,
padded: CoordinateRange,
): CoordinateRange | undefined {
const min = Math.max(padded.min, Math.ceil(start) + SCROLL_CONTAINER_EDGE_INSET);
const max = Math.min(padded.max, Math.floor(start + size) - 1 - SCROLL_CONTAINER_EDGE_INSET);
return max > min ? { min, max } : undefined;
}
/**
* Validates pre-frame scroll inputs (amount/pixels) the same way buildScrollGesturePlan would,
* so the daemon throws INVALID_ARGS for bad inputs BEFORE sending the fused runner `scroll`
* command (previously validation ran between the frame request and the drag). The resolved
* values are discarded; only their throw-on-invalid behavior is reused.
*/
export function assertScrollGestureInput(options: { amount?: number; pixels?: number }): void {
resolveRequestedAmount(options.amount);
if (options.pixels !== undefined) {
normalizeRequestedPixels(options.pixels);
}
}
export function buildSwipePresetGesturePlan(
preset: SwipePreset,
frame: GestureReferenceFrame,
): SwipePresetGesturePlan {
if (preset === 'left' || preset === 'right') {
const plan = buildInPageSwipeGesturePlan(preset, frame);
return {
preset,
x1: plan.x1,
y1: plan.y1,
x2: plan.x2,
y2: plan.y2,
referenceWidth: plan.referenceWidth,
referenceHeight: plan.referenceHeight,
};
}
const [startPercent, endPercent] = preset === 'left-edge' ? [99, 15] : [1, 85];
const start = clampGesturePoint(
pointFromPercent(frame, startPercent, 50),
frame,
SWIPE_PRESET_EDGE_MARGIN_PX,
);
const end = clampGesturePoint(
pointFromPercent(frame, endPercent, 50),
frame,
SWIPE_PRESET_EDGE_MARGIN_PX,
);
return {
preset,
x1: start.x,
y1: start.y,
x2: end.x,
y2: end.y,
referenceWidth: frame.referenceWidth,
referenceHeight: frame.referenceHeight,
};
}
export function gestureDirectionDelta(direction: ScrollDirection, distance: number): GesturePoint {
switch (direction) {
case 'up':
return { x: 0, y: -distance };
case 'down':
return { x: 0, y: distance };
case 'left':
return { x: -distance, y: 0 };
case 'right':
return { x: distance, y: 0 };
}
}
/** Plans a centered, edge-inset finger motion that remains inside app content. */
export function buildInPageSwipeGesturePlan(
direction: ScrollDirection,
frame: GestureReferenceFrame,
): InPageSwipeGesturePlan {
// These insets avoid system-edge gestures while retaining enough travel for pagers.
const startPercent = 85;
const endPercent = 15;
const centerPercent = 50;
const forward = direction === 'left' || direction === 'up';
const startAxisPercent = forward ? startPercent : endPercent;
const endAxisPercent = forward ? endPercent : startPercent;
const vertical = direction === 'up' || direction === 'down';
const start = clampGesturePoint(
pointFromPercent(
frame,
vertical ? centerPercent : startAxisPercent,
vertical ? startAxisPercent : centerPercent,
),
frame,
SWIPE_PRESET_EDGE_MARGIN_PX,
);
const end = clampGesturePoint(
pointFromPercent(
frame,
vertical ? centerPercent : endAxisPercent,
vertical ? endAxisPercent : centerPercent,
),
frame,
SWIPE_PRESET_EDGE_MARGIN_PX,
);
return {
direction,
x1: start.x,
y1: start.y,
x2: end.x,
y2: end.y,
referenceWidth: frame.referenceWidth,
referenceHeight: frame.referenceHeight,
};
}
export function inferGestureReferenceFrame(
nodes: Array<Pick<SnapshotNode, 'type' | 'rect'>>,
): GestureReferenceFrame | undefined {
const viewportRect = inferViewportRect(nodes);
if (!viewportRect) return undefined;
return {
referenceWidth: viewportRect.width,
referenceHeight: viewportRect.height,
};
}
function pointFromPercent(
frame: GestureReferenceFrame,
xPercent: number,
yPercent: number,
): GesturePoint {
const x = Math.trunc((frame.referenceWidth * xPercent) / 100);
const y = Math.trunc((frame.referenceHeight * yPercent) / 100);
return {
x: Number.isFinite(x) ? x : 0,
y: Number.isFinite(y) ? y : 0,
};
}
function clampGesturePoint(
point: GesturePoint,
frame: GestureReferenceFrame,
marginPx: number,
): GesturePoint {
return {
x: clampGestureCoordinate(point.x, marginPx, frame.referenceWidth),
y: clampGestureCoordinate(point.y, marginPx, frame.referenceHeight),
};
}
export function parseScrollDirection(direction: string): ScrollDirection {
return SCROLL_DIRECTION_ENUM.parse(direction);
}
function inferViewportRect(nodes: Array<Pick<SnapshotNode, 'type' | 'rect'>>): Rect | undefined {
const candidate = nodes
.filter((node) => isViewportRootNode(node) && isValidRect(node.rect))
.map((node) => node.rect)
.sort(
(left, right) =>
(right?.width ?? 0) * (right?.height ?? 0) - (left?.width ?? 0) * (left?.height ?? 0),
)[0];
if (candidate) return candidate;
const rects = nodes.map((node) => node.rect).filter(isValidRect);
if (rects.length === 0) return undefined;
const width = Math.max(...rects.map((rect) => rect.x + rect.width));
const height = Math.max(...rects.map((rect) => rect.y + rect.height));
if (width <= 0 || height <= 0) return undefined;
return { x: 0, y: 0, width, height };
}
function isValidRect(rect: Rect | undefined): rect is Rect {
return !!rect && rect.width > 0 && rect.height > 0;
}
function resolveRequestedAmount(amount: number | undefined): number {
if (amount === undefined) return DEFAULT_SCROLL_AMOUNT;
if (!Number.isFinite(amount) || amount <= 0) {
throw new AppError('INVALID_ARGS', 'scroll amount must be a positive number');
}
return amount;
}
function normalizeRequestedPixels(pixels: number): number {
if (!Number.isFinite(pixels) || pixels <= 0) {
throw new AppError('INVALID_ARGS', 'scroll pixels must be a positive integer');
}
return Math.max(1, Math.round(pixels));
}
export function clampGestureCoordinate(value: number, marginPx: number, size: number): number {
const min = Math.round(marginPx);
if (!Number.isFinite(min)) return 0;
const max = Math.max(min, Math.round(size - marginPx));
if (!Number.isFinite(max) || !Number.isFinite(value)) return min;
return Math.min(max, Math.max(min, Math.round(value)));
}
/**
* What an on-screen keyboard leaves of the scroll viewport, and what happens when it leaves too
* little.
*
* `buildScrollGesturePlan` centres a directional swipe, so a focused field puts its lower endpoint
* under the keyboard: the gesture lands on keys, the surface never moves, and the edge loop reads a
* stuck container (#2499) instead of a refusal. Reducing the reference height BEFORE the planner
* runs keeps the swipe inside what is visible without touching the planner, so reported travel
* stays honest. The runner and the Android helper each read their own live keyboard frame; a frame
* threaded from the daemon would be a snapshot that predates the keyboard.
*
* Pure geometry, so the decision is proven against a golden table both this file and the Swift twin
* (`ScrollViewportPolicy` in apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/
* RunnerScrollViewportPolicy.swift) assert against, so drift turns CI red without a simulator. The
* table carries only frames representable in both languages: `CGRect` standardizes a negative
* extent into a positive height at a moved origin, so a negative `height` is tested here alone.
*/
/** Below this fraction of the viewport, the clipped band cannot hold a reliable swipe. */
export const SCROLL_KEYBOARD_MIN_VISIBLE_FRACTION = 0.15;
/**
* A fixed allowance kept above the keyboard's top edge, in the frame's own unit (points on iOS,
* pixels on Android). `keyboard.frame` reports the key plane, not the input accessory or composer
* bar riding above it, so a swipe that ends exactly at the reported edge can still land on a bar.
*/
export const SCROLL_KEYBOARD_ACCESSORY_ALLOWANCE = 12;
/**
* The one reason a directional scroll refuses to swipe at all (#2500), with the hint every owner
* publishes beside it: Android measures the occlusion in this process, and the iOS runner answers
* with its own runner code that the Apple scroll owner joins to these same details, so a
* caller branches on `reason` and reads one hint whichever owner refused. Avoidance never dismisses
* the keyboard: a dismiss drops focus, which breaks a `type`/`scroll`/`type` loop, is not idempotent
* across platforms, and mutates state session-action provenance does not record. So the hint names
* the tradeoff instead of paying it.
*/
export const SCROLL_KEYBOARD_OCCLUDES_SURFACE_REASON = 'scroll_keyboard_occludes_surface';
export const SCROLL_KEYBOARD_OCCLUDES_SURFACE_DETAILS = Object.freeze({
reason: SCROLL_KEYBOARD_OCCLUDES_SURFACE_REASON,
hint:
'The on-screen keyboard covers the surface this scroll would swipe, so it cannot reach it. ' +
'Run `keyboard dismiss` and retry, accepting that it drops focus (re-tap the field to keep typing), or scroll before focusing the field.',
});
export type ScrollKeyboardClip =
/** No keyboard, or one that does not own this surface: swipe the whole viewport. */
| { kind: 'unobstructed' }
/** The viewport trimmed above the keyboard. Report the reduced reference height honestly. */
| { kind: 'avoided'; viewport: Rect; keyboardMinY: number }
/**
* Too little surface left above the keyboard to swipe. Swiping anyway reads as a stuck
* container to the no-progress fingerprint, so the caller refuses with
* `SCROLL_KEYBOARD_OCCLUDES_SURFACE_REASON` instead.
*/
| { kind: 'occluded'; keyboardMinY: number; visibleHeight: number };
/** The numbers a refusing owner names about the surface it declined to swipe. */
export type ScrollKeyboardOcclusion = {
keyboardMinY: number;
visibleHeight: number;
viewportHeight: number;
};
/**
* Clips a scroll viewport to the band above an occluding keyboard.
*
* Fails open on an unusable frame: a keyboard the platform cannot measure is not evidence that the
* surface is blocked, and turning a missing frame into a refusal would refuse every scroll on a
* device with a broken keyboard query. The floor is the caller's refusal, not this rule.
*/
export function clipScrollViewportAboveKeyboard(
viewport: Rect,
keyboard: Rect,
): ScrollKeyboardClip {
if (!isMeasurableRect(viewport) || !isMeasurableRect(keyboard)) return { kind: 'unobstructed' };
// A vertical swipe runs along the viewport's centre line, which is the only part of the width the
// keyboard has to reach to be struck: a 320pt keyboard centred in an 834pt viewport is 38% of the
// width and sits exactly in the path. A horizontal swipe runs along the OTHER centre line, so
// clipping it too is early rather than wrong — it only lifts the swipe clear of the keys.
const swipeCenterX = viewport.x + viewport.width / 2;
if (swipeCenterX < keyboard.x || swipeCenterX >= keyboard.x + keyboard.width) {
return { kind: 'unobstructed' };
}
const keyboardMinY = keyboard.y;
if (keyboardMinY >= viewport.y + viewport.height || keyboard.y + keyboard.height <= viewport.y) {
return { kind: 'unobstructed' };
}
const visibleHeight = Math.max(
0,
keyboardMinY - SCROLL_KEYBOARD_ACCESSORY_ALLOWANCE - viewport.y,
);
if (visibleHeight < SCROLL_KEYBOARD_MIN_VISIBLE_FRACTION * viewport.height) {
return { kind: 'occluded', keyboardMinY, visibleHeight };
}
return {
kind: 'avoided',
viewport: { ...viewport, height: visibleHeight },
keyboardMinY,
};
}
/**
* The refusal an owner that measured the keyboard in this process reports. The iOS runner measures
* in its own coordinate space and answers with its runner code instead; the Apple scroll owner
* adds the same `SCROLL_KEYBOARD_OCCLUDES_SURFACE_DETAILS` to that error.
*/
export function scrollKeyboardOccludesSurfaceError(
direction: ScrollDirection,
occlusion: ScrollKeyboardOcclusion,
): AppError {
const percent = Math.round(SCROLL_KEYBOARD_MIN_VISIBLE_FRACTION * 100);
return new AppError(
'COMMAND_FAILED',
`scroll ${direction} refused: the keyboard leaves ${occlusion.visibleHeight}px of ${occlusion.viewportHeight}px visible, below the ${percent}% needed for a swipe`,
{
keyboardMinY: occlusion.keyboardMinY,
visibleHeight: occlusion.visibleHeight,
viewportHeight: occlusion.viewportHeight,
minVisibleFraction: SCROLL_KEYBOARD_MIN_VISIBLE_FRACTION,
...SCROLL_KEYBOARD_OCCLUDES_SURFACE_DETAILS,
},
);
}
function isMeasurableRect(rect: Rect): boolean {
return (
[rect.x, rect.y, rect.width, rect.height].every((value) => Number.isFinite(value)) &&
rect.width > 0 &&
rect.height > 0
);
}