@@ -59,6 +59,25 @@ enum ScrollGestureOutcome {
5959 case occluded( keyboardMinY: Double , visibleHeight: Double )
6060}
6161
62+ extension ScrollGestureDispatch {
63+ /// Reports the gesture against the band its plan ran inside, beside the keyboard evidence. The
64+ /// synthesis frame stays the full viewport so the coordinates rotate correctly, which leaves the
65+ /// payload measured against an axis the caller never planned on: `pixels` are a fraction of the
66+ /// band, so the band is what `referenceWidth` and `referenceHeight` have to name.
67+ func attachingEvidence( to response: Response ) -> Response {
68+ guard response. ok else { return response }
69+ var payload = response. data ?? DataPayload ( )
70+ payload. referenceWidth = Double ( planFrame. width)
71+ payload. referenceHeight = Double ( planFrame. height)
72+ guard let keyboardMinY else {
73+ return Response ( ok: response. ok, data: payload, error: response. error)
74+ }
75+ payload. keyboardAvoided = true
76+ payload. keyboardMinY = keyboardMinY
77+ return Response ( ok: response. ok, data: payload, error: response. error)
78+ }
79+ }
80+
6281extension RunnerScrollViewport {
6382 /// Plans the swipe inside the band the keyboard left and keeps the viewport as the coordinate basis,
6483 /// so a clip shortens the travel without moving the gesture's lane.
@@ -338,6 +357,22 @@ extension RunnerTests {
338357 " a landscape swipe must stay clear of the keys "
339358 )
340359
360+ let reported = gesture. attachingEvidence (
361+ to: Response (
362+ ok: true ,
363+ data: DataPayload ( referenceWidth: viewport. width, referenceHeight: viewport. height) ,
364+ error: nil
365+ )
366+ )
367+ XCTAssertEqual (
368+ reported. data? . referenceHeight,
369+ band. height,
370+ " the payload names the band the plan ran inside, not the synthesis frame "
371+ )
372+ XCTAssertEqual ( reported. data? . referenceWidth, viewport. width)
373+ XCTAssertEqual ( reported. data? . keyboardMinY, keyboardMinY)
374+ XCTAssertEqual ( reported. data? . keyboardAvoided, true )
375+
341376 let orientedStartY = gesture. planFrame. minY + gesture. plan. y1
342377 let dispatched = nativeSynthesizedPoint (
343378 orientedX: gesture. planFrame. minX + gesture. plan. x1,
0 commit comments