Repository navigation
Description
Current behavior 🐛
On Skia WebAssembly with accessibility enabled, the semantic <div> of a ScrollContentPresenter (overflow: scroll) doesn't mirror the ScrollViewer's geometry:
- Wrong scroll range. The DOM scroll range comes from the semantic children only, not from the XAML extent. Content without a semantic node (a plain
Border, spacing, etc.) adds nothing. The range also shifts while scrolling, because the children'stopvalues change. - Children are shifted twice.
AddSemanticElement/OnSizeOrOffsetChangedposition each semantic child withUIElement.GetTransform(child, semanticParent). On Skia that isVisual.TotalMatrix-based and already includes the presenter's scroll translation, so a child at content y=400 withVerticalOffset=300getstop: 100px(viewport coordinates). ThenUpdateNativeScrollOffsetsalso setsscrollTopon the same<div>(up to whatever the browser allows), which moves the children again. - AT-initiated scrolls map to the wrong XAML offset. When a browser or screen reader scrolls the semantic scroller (for example by focusing an off-screen node), the absolute DOM
scrollTopis applied as the XAML offset inOnScroll. That value is in a different coordinate space and range than the XAML offset.
The feedback loop that made ScrollViewer offsets snap back is tracked in #24596 (fix in #24597). This issue is the remaining geometry mismatch that #24596 calls out as a follow-up. Filtering the echoes doesn't fix it.
Expected behavior 🎯
The semantic scroller should mirror the ScrollViewer 1:1:
- its scrollable area equals the XAML extent (
scrollHeight == ExtentHeight,scrollWidth == ExtentWidth), scrollTop/scrollLeftequalVerticalOffset/HorizontalOffset,- semantic children are positioned in content coordinates (the scroll offset is applied once, by the DOM scroll).
How to reproduce it (as minimally and precisely as possible) 🔬
Runtime test (add to Given_AccessibleScrollViewer, run on Skia WebAssembly):
- Enable accessibility (
EnsureAccessibilityEnabledAsync()fromWasmSemanticDomHelper). - Create a 200x200
ScrollViewercontaining aStackPanelwith 20Buttons (Height = 40, each with anAutomationProperties.Name). Extent is 800. scrollViewer.ChangeView(null, 300, null, disableAnimation: true)and wait for idle.- Read the presenter's semantic
<div>(uno-semantics-<Visual.Handle>): comparescrollHeight/scrollTopwithExtentHeight/VerticalOffset, and compare button 10's top (content y=400, expected 100px below the viewport top) with its semantic rect relative to the scroller.
[TestMethod]
[RunsOnUIThread]
[PlatformCondition(ConditionMode.Include, RuntimeTestPlatforms.SkiaWasm)]
public async Task When_Scrolled_Then_Semantic_Scroller_Matches_ScrollViewer_Geometry()
{
await EnsureAccessibilityEnabledAsync();
var panel = new StackPanel();
Button? target = null;
for (var i = 0; i < 20; i++)
{
var button = new Button { Content = "Item " + i, Height = 40, Width = 150 };
AutomationProperties.SetName(button, "Item " + i);
panel.Children.Add(button);
if (i == 10) { target = button; }
}
var scrollViewer = new ScrollViewer { Width = 200, Height = 200, Content = panel };
await UITestHelper.Load(scrollViewer);
await UITestHelper.WaitFor(() => SemanticElementExists(target!), timeoutMS: 5000);
var presenter = (UIElement)scrollViewer.Presenter!;
string Js(string expr) => InvokeBrowserJs(
$"(function(){{const e=document.getElementById('{GetSemanticElementId(presenter)}'); return e ? String({expr}) : 'null';}})()");
scrollViewer.ChangeView(null, 300, null, disableAnimation: true);
await UITestHelper.WaitForIdle();
await Task.Delay(500);
var scrollHeight = double.Parse(Js("e.scrollHeight"), CultureInfo.InvariantCulture);
var scrollTop = double.Parse(Js("e.scrollTop"), CultureInfo.InvariantCulture);
var itemTop = GetSemanticElementRect(target!)!.Value.Y - GetSemanticElementRect(presenter)!.Value.Y;
Assert.AreEqual(scrollViewer.ExtentHeight, scrollHeight, 1); // 800
Assert.AreEqual(scrollViewer.VerticalOffset, scrollTop, 1); // 300
Assert.AreEqual(100, itemTop, 1);
}Note: this WebAssembly test is the intended repro. I could not run it in my environment (no wasm-tools workload), so the DOM-side numbers are not measured. The XAML side below was run.
What I did run on Skia Desktop: the same layout, reading the transform from the button to the presenter, the same matrix the accessibility code uses for top/left:
Extent=800 Viewport=200 Offset=300
item 10, TransformToVisual(presenter) y: before scroll = 400, after ChangeView(300) = 100
So the position handed to the semantic DOM already has the scroll offset subtracted, and scrollTop = VerticalOffset is applied on top of it.
Workaround 🛠️
None for apps that enable accessibility.
Works on UWP/WinUI
N/A (Uno-specific WebAssembly accessibility layer).
Renderer 🎨
- Skia
- Native
Affected platforms 📱💻🖥️
WebAssembly
Uno.Sdk version (and other relevant versions) 📦
master at 47267e7 (7.0), net11.0-browserwasm
IDE version 🧑💻
No response
Anything else we need to know? 💬
Confirmed by code inspection on master (47267e7) plus the Skia Desktop transform check above. Root cause:
- Positioning uses the scroll-inclusive transform:
OnSizeOrOffsetChangedandAddSemanticElementcallUIElement.GetTransform(child, semanticParent), which on Skia isVisual.TotalMatrix-based. - The scroll offset is mirrored again into the DOM:
UpdateNativeScrollOffsets->updateNativeScrollOffsetssetsscrollTop/scrollLeft, while the element isoverflow: scroll(Accessibility.ts) with nothing sizing it to the extent. - The browser's
scrollevent goes back throughOnScroll, which callsScrollContentPresenter.Set(scrollLeft, scrollTop)with a DOM value that doesn't correspond to the XAML offset.
Suggested direction: position the direct semantic children of a scroll port in content coordinates (undo the presenter's offset), and size the scrollable area to the XAML extent. Don't add an extra child to do it, because that would shift the addSemanticElement child indices. A CSS custom property on the scroller driving an ::after sizer would work. Then scrollTop mirrors the offset 1:1.
Related: #24596 (echo revert), #24597 (echo filter), #24605 (focus mirroring scrolls the scroller).
Help us help you
No response
Activity
fix(wasm-a11y): Mirror scroll geometry in semantic DOM