Skip to content

fix(wasm): Chain BrowserHtmlElement scrolling to the enclosing ScrollViewer (backport #24138) - #24253

Merged
kazo0 merged 18 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24138
Aug 28, 2026
Merged

kazo0 merged 18 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24138

Conversation

@mergify

@mergify mergify Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue: related to #24134

PR Type:

🐞 Bugfix

What changed? 🚀

Current behavior. On Skia WebAssembly, a touch gesture that begins inside a BrowserHtmlElement does not participate in the enclosing Uno ScrollViewer. A scrollable native child consumes the whole gesture and dead-stops at its own boundary, and a drag that starts over non-scrollable native HTML does not scroll the enclosing ScrollViewer at all. This is most visible on tablets, where an embedded editor or grid can occupy most of the viewport and effectively traps the page.

There are two independent causes:

  1. The Uno ScrollViewer is painted onto the canvas and is not a DOM scroll container, so overscroll-behavior and the browser's own scroll chaining have nothing to chain into.
  2. BrowserPointerInputSource.onPointerEventReceived early-returns for any event targeting #uno-native-element-host, so Uno never observes the gesture.

This PR adds an opt-in BrowserHtmlElement.InputPolicy:

var element = BrowserHtmlElement.CreateHtmlElement("div");
element.InputPolicy = BrowserHtmlElementInputPolicy.Negotiated; // default is NativeOnly

With Negotiated, a scrollable native child scrolls first and transfers only what it could not consume at its boundary to the enclosing ScrollViewer, chaining outwards; a gesture over non-scrollable native content goes to the ScrollViewer directly. Taps, focus, text selection and native control interaction stay native. The default (NativeOnly) preserves today's behavior exactly.

Managed side

ScrollViewer.ChainScrollFromDescendant walks the ScrollViewer ancestry and hands each one the residual the previous could not take. Two details matter:

  • Deltas are applied through the user-input path (ClearOffsetIntents() + the presenter's Set), not ScrollViewer.ChangeView. ChangeView arms the ScrollViewer's offset intent, which the post-layout recompute re-applies — so overshooting at a boundary (as every fling does) parked an intent past the end of the content, and the next extent growth snapped the view to it. This is covered by a regression test that fails against the ChangeView implementation.
  • In-flight deltas are reported as IsTouch: true, IsIntermediate: true, with a single non-intermediate change when the gesture ends. Reporting every frame as terminal fired ViewChanged(IsIntermediate: false) at 60–120 Hz and restarted the snap-points timer mid-fling.

Chaining honors IsHorizontalScrollChainingEnabled / IsVerticalScrollChainingEnabled, per-axis, matching IDirectManipulationHandler.OnUpdated.

Browser side

Gesture detection, native-first scrolling and the residual bridge live in BrowserPointerInputSource.ts. Notable hardening over a naive implementation:

  • The input policy and the negotiation root are resolved from a JS-side map keyed by element reference, and by position in the tree (direct child of #uno-native-element-host) — never by reading a data- attribute off the event target. Hosted HTML is app- or third-party-supplied and must not be able to opt itself into a policy the app did not set. The managed host registry is keyed on the GCHandle, not the caller-settable ElementId string.
  • OnNativeScrollDelta is wrapped in try/catch with an IsEnabled-guarded error log and applies NativeDispatcher.Main.SynchronizationContext, matching the neighbouring OnNativeEvent. Non-finite deltas are rejected before reaching ValidateInputOffset, which throws on NaN.
  • Form controls (input, textarea, select) and contenteditable regions — and their descendants — keep full native touch behavior and never participate in chaining. The CSS and TypeScript exclusion lists are deliberately kept in sync; a mismatch produces a subtree that neither the browser nor Uno will pan.
  • touch-action: pinch-zoom rather than none, so multi-finger zoom survives. A second pointer abandons negotiation and hands the interaction back to the browser.
  • ctrl+wheel is left to the normal pipeline so browser zoom keeps working when isBrowserZoomEnabled.
  • Inertia is cancelled when the element is detached or leaves the document, and a wheel burst supersedes a running fling.

Iframes remain native-only: pointer events do not cross the frame boundary, so an embedded document's scroll residual cannot be observed.

The first commit is cherry-picked from an external contributor's branch with authorship preserved; the remainder is rework following an internal review.

Validation

Runtime tests (Skia Desktop) — 13 tests in Given_ScrollViewer_ScrollChaining, all passing, covering forward/backward chaining, boundary residual, chaining-disabled absorption, horizontal, non-finite deltas, and the intermediate/terminal ViewChanged sequence. The offset-intent regression guard was verified to fail against the pre-fix implementation and pass after.

Regression — 241/243 passing across Given_ScrollViewer, Given_ScrollViewer_Anchoring, Given_ScrollViewer_Zoom, Given_ListView* and Given_FlipView (16 skipped). The one failure, Given_ListViewBase.When_ThemeChange, was verified to fail identically on clean master on the same machine and is unrelated.

Manual, iPadOS Safari — the core scenarios pass on device: drag over non-scrollable native content scrolls the page, the native scroller hands over residual at its boundary without stalling, reverse chaining works, and flick inertia carries across the handoff.

⚠️ Not yet validated on device: the native-interaction cases (text input focus and drag-selection, pinch-zoom, multi-touch handoff, button tap delivery). These exercise the exclusion lists and the touch-action change. Marked as draft until they are covered.

PR Checklist ✅


This is an automatic backport of pull request #24138 done by [Mergify](https://mergify.com).

jbourque-kahua and others added 18 commits August 27, 2026 19:07
(cherry picked from commit 05091c4)
(cherry picked from commit 9c504fd)
@unodevops

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot added platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform area/skia ✏️ Categorizes an issue or PR as relevant to Skia area/automation Categorizes an issue or PR as relevant to project automation kind/documentation labels Aug 27, 2026
@kazo0

kazo0 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 230673 did not find any UI Test snapshots differences.

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 230673 has failed on Uno.UI - CI.

@kazo0
kazo0 enabled auto-merge August 28, 2026 12:38
@mergify

mergify Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@kazo0
kazo0 merged commit ad6cd12 into release/stable/6.7 Aug 28, 2026
51 checks passed
@kazo0
kazo0 deleted the mergify/bp/release/stable/6.7/pr-24138 branch August 28, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/skia ✏️ Categorizes an issue or PR as relevant to Skia kind/documentation platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants