Repository navigation
Description
What would you like to be added? 💡
On Skia WebAssembly, a touch gesture that begins inside a BrowserHtmlElement (native HTML hosted over the Skia canvas) does not participate in the enclosing Uno ScrollViewer:
- A scrollable native child consumes the whole gesture and stops dead at its own boundary — it never hands the remaining drag or inertia to the Uno parent.
- A drag that starts over non-scrollable native HTML does not scroll the enclosing
ScrollViewerat all.
This is most visible on tablets, where scrolling a page is the primary navigation gesture and embedded native content (rich-text editors, data grids, third-party widgets) occupies a large part of the viewport.
There are two independent causes, and both are structural rather than incidental:
- The Uno
ScrollVieweris not a DOM scroll container on Skia WASM — it is painted onto the canvas.overscroll-behaviorand the browser's own scroll chaining therefore have nothing to chain into. No CSS-only solution exists. - Uno never observes the gesture.
BrowserPointerInputSource.onPointerEventReceivedearly-returns for any event whose target is inside#uno-native-element-host, so the pointer never reaches the managed input pipeline.
The enhancement being requested is specifically about how the residual should be routed, not merely that it should be.
The natural implementation — and the one to avoid — is to detect the gesture in TypeScript, drive the native scroller from JS, and marshal the leftover delta into managed code to scroll the ancestor ScrollViewers. That works, but it means reimplementing drag thresholds, axis locking, velocity tracking and inertia decay in TypeScript, next to the equivalent logic Uno already owns in ScrollContentPresenter / GestureRecognizer. The result is two scroll physics in one app: different decay curves, no snap points, no over-scroll, no IsScrollInertiaEnabled, and a code path unreachable from the managed test suite.
Proposed direction: express the native element as a participant in the existing direct-manipulation pipeline instead.
DirectManipulation already implements exactly the chaining semantics needed — handlers are invoked in registration order, each consuming from a shared ref delta:
// src/Uno.UI/UI/Xaml/Internal/DirectManipulation.cs
var unhandledDelta = args.Delta;
foreach (var handler in Handlers)
{
handler.OnUpdated(sender, args, ref unhandledDelta);
}So the shape would be:
- An
IDirectManipulationHandlerfor the hosted native element, registered innermost (before the ancestorScrollContentPresenters register during the press bubble). - Its
OnUpdatedpushes the delta into the native DOM scroller and subtracts what was actually consumed. - Whatever is left chains outward to the ancestor
ScrollViewers through the path that already exists today. - Inertia, rails, snap points,
IsHorizontal/IsVerticalScrollChainingEnabledandIsScrollInertiaEnabledall come fromGestureRecognizer— one physics implementation, shared with every other scroll surface in the app. ContentPresenter.INativeElementHostingExtensionalready uses default interface methods for optional capabilities (SupportsZIndex), so an optionalTryConsumeScrollDeltacan be added without touching the Win32, X11, macOS, Android or UIKit implementations.
Why is this needed? 🤔
Embedding native HTML inside a scrolling Uno surface is a mainstream scenario for WebAssembly apps that host third-party editors, grids or document viewers. On a tablet the current behavior reads as a broken page: the user drags and the page simply refuses to move.
The reason to raise this as a design issue rather than just fixing it is that the choice is hard to reverse. Any solution needs a public opt-in on BrowserHtmlElement (the behavior cannot safely become the default without a deprecation path, since it changes how input is routed). Once that API ships, so does whatever scroll model sits behind it. If it ships backed by a separate TypeScript implementation, Uno owns two divergent scroll behaviors on its slowest target, in a code path the runtime tests cannot reach — and every later improvement to managed scrolling silently widens the gap.
Getting this onto the existing manipulation pipeline before the API is public avoids that permanently.
Renderer 🎨
- Skia
- Native
For which platforms 📱💻🖥️
WebAssembly
Anything else we need to know? 💬
Known blockers
These were found by reading the current code and are the substance of the work — each needs a decision, not just implementation:
1. Pointer events never reach the managed pipeline. BrowserPointerInputSource.onPointerEventReceived returns early for events targeting #uno-native-element-host. DirectManipulation is driven by ProcessDown/ProcessMove/ProcessUp from real PointerEventArgs, so these events have to be dispatched into PointerManager for any of this to work.
2. The blanket preventDefault() is the real risk. BrowserPointerInputSource.ts currently states the policy explicitly:
// pointer events may have some side effects (like changing focus or opening a context menu on right clicking)
// We blanket-disable all the native behaviour so we don't have to whack-a-mole all the edge cases.
Negotiated native content needs the opposite: focus, taps, caret placement, text selection and native control interaction must all keep working while Uno simultaneously observes the gesture for manipulation purposes. This is the item that decides whether the rest of the estimate holds and should be spiked before committing to the approach.
3. Hit-testing does not reach the hosting ContentPresenter. ContentPresenter.IsViewHit() delegates to Border.IsViewHitImpl, which returns true only when Background != null (or BorderBrush != null on Skia). A native-hosting ContentPresenter typically has neither, so a press over the native element does not hit-test to it and the "register the handler during the press bubble" approach does not hold as-is. Needs either forced hit-testability for native hosts or an explicit registration path.
4. This does not close the automated-coverage gap. Native elements do not exist on Skia Desktop, and a manipulation-based design needs a real pointer sequence, so it still cannot be covered by the existing runtime-test rig. The managed chaining logic can be tested directly today; the gesture arbitration cannot, under either design. Validation for the browser half remains manual, on-device.
Rough effort
| Work | Estimate |
|---|---|
| Spike: route pointers through Uno without breaking native focus / tap / selection | 1 day |
| Hit-testability or explicit registration for native hosts | 0.5 day |
Optional TryConsumeScrollDelta on INativeElementHostingExtension + sync JS bridge |
0.5 day |
The IDirectManipulationHandler implementation |
1 day |
Remove the interim JS scroll implementation, revise the touch-action CSS |
0.5 day |
| Device validation (iPadOS Safari, Android Chrome, desktop trackpad) | 0.5–1 day |
≈ 4–5 days, contingent on the day-one spike.
Behavioral questions to settle
touch-actionpolicy. Disabling browser panning over the negotiated subtree is required for Uno to drive it.touch-action: nonealso kills pinch-zoom;pinch-zoompreserves it but still loses double-tap-to-zoom — no value preserves both. Which is correct probably depends on the hosted content.- Form controls and
contenteditable. These should keep full native touch behavior (caret dragging, selection, their own scrolling) and stay out of chaining entirely. Whatever exclusion list is used has to be expressed once — a CSS copy and a JS copy will drift. - Multi-touch. A second finger should hand the interaction back to the browser rather than be arbitrated.
- Iframes. Pointer events do not cross the frame boundary and an embedded document's scroll position is not observable from the host, so framed content cannot participate without an explicit cross-frame bridge. Worth stating as an explicit non-goal unless that bridge is designed.
- Should this ever become the default? An opt-in leaves the behavior broken for everyone who never discovers the flag. If the intent is for it to become default eventually, that should shape the API name and shape now.
Prior work
An interim implementation of the JS-side approach exists and has been reviewed. Its managed half — chaining the residual outward across the ScrollViewer ancestry as intermediate touch input, honoring IsHorizontal/IsVerticalScrollChainingEnabled — is runtime-tested and would largely survive this redesign; it is the gesture detection and inertia half that this issue proposes replacing.
Two findings from that work worth carrying forward:
- Chained deltas must not be applied via
ScrollViewer.ChangeView.ChangeViewarms the ScrollViewer's offset intent, which the post-layout recompute re-applies; overshooting at a boundary (as every fling does) leaves an intent parked past the end of the content, and the next extent growth snaps the view to it. The user-input path (ClearOffsetIntents()+ the presenter'sSet, asPointerWheelScrollandTryEnableDirectManipulationdo) is the correct one. - In-flight deltas must be reported with
IsTouch: true, IsIntermediate: true, with a single non-intermediate change when the gesture ends. Reporting every frame as terminal firesViewChanged(IsIntermediate: false)at 60–120 Hz and restarts the snap-points timer mid-fling.
Activity