Skip to content

RichTextBlock - #23731

Merged
MartinZikmund merged 189 commits into
masterfrom
dev/mazi/richtextblock-winui
Sep 20, 2026
Merged

MartinZikmund merged 189 commits into
masterfrom
dev/mazi/richtextblock-winui

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #81

PR Type:

✨ Feature

What changed? 🚀

Before: Uno's RichTextBlock was a flat, Uno-original managed implementation. It measured and drew paragraphs directly, and much of the WinUI surface was stubbed as [NotImplemented]: RichTextBlockOverflow chaining, TextPointer, TextHighlighters, TextTrimming, InlineUIContainer and the UIA Text pattern.

After: RichTextBlock and RichTextBlockOverflow run on a port of WinUI's core text stack (dxaml/xcp/core/text). Uno's Skia text engine replaces WinUI's Line Services formatter underneath it:

  • Block layout. BlockLayoutEngine with the PageNode / ContainerNode / ParagraphNode tree, breaks, and drawing contexts. The formatter contract (TextFormatter / TextLine / TextSource) is bridged onto ParsedText by SkiaTextFormatter / SkiaTextLine. That bridge is the only Uno-specific layer.
  • Views and overflow. RichTextBlockView, LinkedRichTextBlockView and RichTextBlockBreak. Content flows from the master into linked RichTextBlockOverflow columns, which also handle input, links, selection and highlighter painting.
  • Selection. Ported TextSelectionManager: pointer and keyboard selection, SelectAll, copy, and double-tap word selection.
  • Text model and pointers. ITextContainer, the run model, TextPointer, TextElement.ContentStart / ContentEnd / ElementStart / ElementEnd, RichTextBlock.Select / GetPositionFromPoint, and TextHighlighters through the ported highlight merge.
  • Layout features. Character and word ellipsis trimming, MaxLines, LineHeight / LineStackingStrategy, TextLineBounds, BaselineOffset, and InlineUIContainer hosting.
  • Accessibility. The UIA Text pattern (TextAdapter / TextRangeAdapter) for RichTextBlock and RichTextBlockOverflow, Hyperlink automation peers, and keyboard activation of a focused Hyperlink.

Design notes, the port plan and a member-by-member validation against WinUI are in specs/richtextblock-winui-port/.

Remaining gaps are tracked as follow-ups: #24336, #24337, #24338, #24339, #24340, #24341, #24342, #24343, #24344, #24345 and #24347.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable)
    • Runtime tests: Given_RichTextBlock*, Given_RichTextBlockOverflow, Given_BlockLayoutEngine, Given_RichTextBlockView, Given_SkiaTextFormatter, Given_TextElement_Mutation
    • Unit tests: Given_InlineCollection_RunModel, Given_TextContainer_Invalidation, Given_TextHighlightMerge
    • Samples: SamplesApp/.../RichTextBlockTests/*
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features)
  • 🖼️ Validated PR Screenshots Compare Test Run results.
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

🤖 Generated with Claude Code

https://claude.ai/code/session_01EJ2tM5KVZK7Qv7oHKNnfwu

@github-actions github-actions Bot added 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 Jul 13, 2026
@github-actions

github-actions Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 5m 21s —— View job


PR Review: WIP RichTextBlock

  • Gather context and understand request
  • Review core implementation files
  • Review DependencyProperty correctness
  • Review async/cancellation discipline
  • Review cross-platform correctness
  • Review hot-path allocations
  • Review test coverage
  • Review XAML samples
  • Post inline comments
  • Write summary

Summary

This is a large, well-structured faithful port of the WinUI RichTextBlock stack onto Uno's Skia target. The architecture (BlockLayout node tree → ITextView → TextSelectionManager) follows WinUI's layering closely, the test suite is solid, and the DependencyProperty registrations are correct. The PR is marked WIP and several issues confirm it isn't ready to merge; the ones below need to be addressed first.

6 findings — 1 correctness bug, 2 resource/performance concerns, 3 cleanliness/policy issues:

# Severity File Summary
1 🔴 Bug TextSelectionManager.skia.cs:869 GetSelectionBoundingRect computes Max(Width) instead of Max(Right)−MinX; underreports bounding rect for multi-line selections
2 🟠 Resource leak RichTextBlock.skia.cs:173 Old PageNode replaced every Measure without calling Dispose(), so InlineUIContainer children accumulate as orphaned visual-tree elements
3 🟡 Performance RichTextBlock.skia.cs:307 GetParagraphHighlighters builds a Enumerable.Empty().Append() chain on every render frame — O(n) heap allocations in the paint path
4 🟡 Policy ParagraphNode.skia.cs:6, PageNode.skia.cs:6, BlockLayoutHelpers.skia.cs:6 File-wide #pragma warning disable CS8600,CS8602,CS8604,CS8618 suppress all nullable analysis with a WIP note; must be narrowed or resolved before merge
5 🟡 Repo hygiene doc/dev/richtextblock-*.md (6 files) Internal porting stage plans and work-logs committed to doc/dev/; should stay in PR body / issue, not repo tree
6 ℹ️ Note Various Multiple // TODO Uno (Stage X) stubs (caret browsing, high-contrast system colours, gripper host, ClearEmbeddedElements) — expected for WIP, but worth tracking as follow-up issues before marking the PR non-WIP

Cross-cutting observations (no inline comment needed):

  • DependencyProperty registrations look correct: right owner types, nameof, correct FrameworkPropertyMetadataOptions (including AffectsMeasure/Inherits where appropriate).
  • No async void, .Result/.GetAwaiter().GetResult() blocking calls, or event Action in the new files.
  • Platform file suffixes are correct (.skia.cs for all Skia-only code; the crossruntime.cs stubs are one-liner delegates — fine).
  • OnUnloaded properly destroys the TextSelectionManager to avoid event/reference leaks.
  • Test coverage is solid: unit tests for InlineCollection_RunModel and TextHighlightMerge, plus runtime tests for text pointer, formatter, overflow, and InlineUIContainer scenarios.

Verdict: fix-first — address items 1–4 before removing the WIP tag. Item 5 (doc files) can be done as a clean-up commit. Item 6 is expected for a staged port.

@github-actions

Copy link
Copy Markdown
Contributor

XAML Styler drift detected on 3c9152e

XAML files under src/SamplesApp/ are not formatted according to src/SamplesApp/Settings.XamlStyler.

To apply automatically (PRs from branches in this repo only): comment /apply-xaml-style on this PR and a bot will push chore: Apply XAML styler to the head branch.

To apply manually (required for PRs from forks):

  1. Download the xaml-style-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply xaml-style.patch
    git add -A
    git commit -m "chore: Apply XAML styler"
    git push
    

Or re-run the formatter locally: dotnet tool restore && dotnet xstyler -d src/SamplesApp -r.

@github-actions

github-actions Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 4m 56s —— View job


PR Review: WIP RichTextBlock

Tasks

  • Gather context and understand request
  • Review core implementation files (RichTextBlock.skia.cs, BlockLayout, etc.)
  • Review DependencyProperty correctness
  • Review async/cancellation discipline
  • Review cross-platform correctness
  • Review test coverage
  • Review XAML samples
  • Post inline comments
  • Write summary

Overall Verdict: fix-first (before landing, not before further WIP iteration)

This is a large, well-structured port of the WinUI RichTextBlock core. The layering (control → view → BlockLayout node tree → selection manager) faithfully mirrors the WinUI architecture, the MUX attribution headers are consistent, the DP declarations follow Uno conventions, no event Action violations were found, and the cross-platform file-suffix discipline is correct (.skia.cs / .crossruntime.cs / shared partials). The test suite breadth is good.


Issues found (7 total)

# Severity Location Description
1 🔴 Bug TextRangeAdapter.skia.cs:792 ScrollIntoView rect height is computed as Y0 + Y1 + H1 (sum of Y coords) instead of Y1 + H1 - Y0 (span)
2 🟠 Perf RichTextBlock.skia.cs:307 GetParagraphHighlighters builds IEnumerable via .Append() chains in the paint path — heap allocation per paragraph per frame
3 🟠 Quality TextRangeAdapter.skia.cs:509 Bare catch { } swallows all exceptions in GetBoundingRectangles with no logging
4 🟡 Quality TextBlockView.skia.cs:163 GetAdjustedPosition/GetCharacterIndex throw NotSupportedException for in-range positions — UIA automation path on TextBlock crashes for any non-trivial document
5 🟡 Maintainability RichTextBlock.skia.cs:249 Magic 2 for inter-paragraph separator should reference (or at minimum name) the InterParagraphSeparatorLength constant already in RichTextBlockView
6 🟡 Tests Given_RichTextBlock_Input.skia.cs:245,265,276,305 Assert.Inconclusive for platform skips should use [PlatformCondition] per Uno runtime-test conventions
7 🟡 Hygiene doc/dev/richtextblock-*.md Six internal planning/port documents committed to the tree; these are ephemeral working notes that shouldn't land in main
8 🟡 Hygiene RichTextBlockTests/ Multiple sample files are byte-for-byte identical to their RichTextBlockControl/ counterparts (same SHA) — consolidate or differentiate

Cross-cutting observations

  • DependencyProperties — all well-formed: FrameworkPropertyMetadata, correct option flags, change-handler wiring. RichTextBlockOverflow.MaxLines/Padding correctly rely on AffectsMeasure without an explicit callback, which is sufficient for those properties.
  • Async / cancellation — GetDefaultFontDetails ContinueWith correctly marshals back to the main thread via NativeDispatcher.Main.Enqueue. No .Result/.GetAwaiter().GetResult() found.
  • Platform correctness — ILinkedTextContainer overflow chain, LinkedRichTextBlockView, and the master/overflow selection manager wiring are correctly Skia-only via file suffixes; the cross-runtime partial (RichTextBlock.crossruntime.cs) is appropriately minimal.
  • WIP TODOs — many // TODO Uno (Stage N) comments are expected in a WIP branch. The TextBlock automation crash (Navigation view control doesn't work #4 above) is the one that should be audited for call-site guards before landing.
  • XAML Styler — CI already flagged formatting drift; the /apply-xaml-style bot comment can handle that automatically.

@github-actions

Copy link
Copy Markdown
Contributor

XAML Styler drift detected on 753734e

XAML files under src/SamplesApp/ are not formatted according to src/SamplesApp/Settings.XamlStyler.

To apply automatically (PRs from branches in this repo only): comment /apply-xaml-style on this PR and a bot will push chore: Apply XAML styler to the head branch.

To apply manually (required for PRs from forks):

  1. Download the xaml-style-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply xaml-style.patch
    git add -A
    git commit -m "chore: Apply XAML styler"
    git push
    

Or re-run the formatter locally: dotnet tool restore && dotnet xstyler -d src/SamplesApp -r.

@github-actions

github-actions Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 6m 59s —— View job


PR Review: WIP RichTextBlock

Tasks

  • Gather context and understand request
  • Review core implementation files (RichTextBlock.skia.cs, BlockLayout, etc.)
  • Review DependencyProperty correctness
  • Review async/cancellation discipline
  • Review cross-platform correctness
  • Review test coverage
  • Review XAML samples
  • Post inline comments
  • Write summary

Overall Verdict: fix-first

This is a substantial, well-structured port — the BlockLayout engine integration, overflow chain linking, selection manager wiring, and automation adapter are all architecturally sound and faithful to the WinUI reference. The test coverage across unit tests, runtime tests, and samples is commendable for a WIP PR of this scope. Below are the cross-cutting concerns; specific findings are in the inline comments.


Issues by Severity

High (3 findings)

  1. Performance — LINQ iterator chaining on the render hot path (RichTextBlock.skia.cs:307)
    GetParagraphHighlighters() is called from Draw() every paint frame. The Enumerable.Empty().Append() pattern chains LINQ iterator objects — one allocation per matching range, per paragraph, per frame. Swap for a List<TextHighlighter>.

  2. NotSupportedException thrown on normal operation in TextBlockView (TextBlockView.skia.cs:106,163,187)
    TextSelectionToTextBounds, GetAdjustedPosition, and GetCharacterIndex throw for all non-edge-case inputs. Any automation or selection path through TextBlock (which supports selection on Skia today) will crash. Degrade gracefully (return position 0 / empty array) or add [PlatformCondition] guards on affected tests.

  3. ContinueWith without cancellation keeps element alive post-unload (RichTextBlock.skia.cs:275)
    The font-load callback fires after unload, and multiple closures accumulate if MeasureOverride is called repeatedly before the font resolves. Use a WeakReference<RichTextBlock> in the closure.

Medium (4 findings)

  1. OverflowContentTarget = null! — null-forgiving on non-nullable property write (RichTextBlockOverflow.skia.cs:93)
    The property should be RichTextBlockOverflow?; the null! suppression is a silent contract violation.

  2. GetBoundsCollectionForElement throws unconditionally (RichTextBlockView.skia.cs:505)
    UIA automation clients calling GetBoundingRectangle on inline elements will get an unhandled exception. Return Array.Empty<Rect>() as a degraded fallback.

  3. PlainTextPosition.GetHashCode() ignores container (PlainTextPosition.skia.cs:238)
    All invalid positions hash to 0; positions in different containers at the same offset collide. If this struct is ever stored in a Dictionary/HashSet, behavior is incorrect. Include m_pContainer in the hash.

  4. ContentSource returns RichTextBlock? from a RichTextBlock-typed property (RichTextBlockOverflow.Properties.cs:133)
    GetMaster() is nullable; the property is non-nullable. Callers that trust the annotation will dereference null before the overflow is linked.

Low (2 findings)

  1. Duplicate sample files (RichTextBlockControl/ vs RichTextBlockTests/)
    Six XAML files are byte-identical between folders (same blob SHA). Auto-discovery registers them twice, producing duplicate entries in the sample browser.

  2. doc/dev/*.md internal planning documents (doc/dev/richtextblock-*.md)
    Six WIP stage-plan documents committed to the public repo. Convert the useful bits to doc/articles/ architecture docs or remove before merge.


Cross-cutting notes

  • DependencyProperties are correctly registered with nameof, proper owner types, and AffectsMeasure/Inherits flags. No issues found.
  • Events all use EventHandler/RoutedEventHandler/TypedEventHandler — no event Action violations.
  • #pragma warning disable CS0109 at file scope in RichTextBlock.cs and RichTextBlockOverflow.Properties.cs — consider scoping narrowly to the new members (the pragma affects the entire file and silences unrelated future warnings).
  • m_textPattern in RichTextBlockAutomationPeer.cs:18 should be Text.TextAdapter? (see inline comment).
  • The many // TODO Uno (Stage N) markers are well-documented; the runtime-crash risk from NotSupportedException (finding Paths are either not shown or shown not as in the UWP Designer #2 and The Uno.UI package break UWP compilation when using SDK 16299 and later #5 above) is the only one that needs attention before this can be marked non-WIP.

@github-actions

Copy link
Copy Markdown
Contributor

XAML Styler drift detected on 4a1033f

XAML files under src/SamplesApp/ are not formatted according to src/SamplesApp/Settings.XamlStyler.

To apply automatically (PRs from branches in this repo only): comment /apply-xaml-style on this PR and a bot will push chore: Apply XAML styler to the head branch.

To apply manually (required for PRs from forks):

  1. Download the xaml-style-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply xaml-style.patch
    git add -A
    git commit -m "chore: Apply XAML styler"
    git push
    

Or re-run the formatter locally: dotnet tool restore && dotnet xstyler -d src/SamplesApp -r.

@github-actions

Copy link
Copy Markdown
Contributor

WinAppSDK sync generator drift detected on 3c9152e

The Uno.WinAppSDKSyncGenerator produced changes that are not committed on this PR.

To apply automatically (PRs from branches in this repo only): comment /apply-sync-gen on this PR and a bot will push chore: Sync generator run to the head branch.

To apply manually (required for PRs from forks):

  1. Download the sync-generator-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply sync-generator.patch
    git add -A
    git commit -m "chore: Sync generator run"
    git push
    

Or re-run the generator locally on Windows via build\run-api-sync-tool.cmd.

@github-actions

Copy link
Copy Markdown
Contributor

WinAppSDK sync generator drift detected on 4a1033f

The Uno.WinAppSDKSyncGenerator produced changes that are not committed on this PR.

To apply automatically (PRs from branches in this repo only): comment /apply-sync-gen on this PR and a bot will push chore: Sync generator run to the head branch.

To apply manually (required for PRs from forks):

  1. Download the sync-generator-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply sync-generator.patch
    git add -A
    git commit -m "chore: Sync generator run"
    git push
    

Or re-run the generator locally on Windows via build\run-api-sync-tool.cmd.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Hyperlink keyboard state and automation geometry have unresolved correctness and accessibility defects.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Accessibility boundary handling, overflow hyperlink geometry, keyboard-state cleanup, and TextPointer lifetime semantics remain incorrect.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

MartinZikmund and others added 6 commits September 20, 2026 13:43
The peer returned an empty rect, so automation clients saw a focusable link with zero bounds. Union the link range's text bounds and transform them to screen space, as CCoreServices::GetTextElementBoundingRect does, and round the clickable point's Y up like WinUI.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KgHGJja8qcSFT2iHrm9teq
InputManager type-tested Hyperlink, which put control-specific handling in a general location. WinUI has CHyperlink register its own KeyDown/KeyUp listeners; Uno raises routed events on UIElements only, so the focused TextElement now takes the key through a virtual it overrides.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KgHGJja8qcSFT2iHrm9teq
Measure runs repeatedly while the shared font task is pending, and each pass attached another continuation that strongly captured the control, so an unloaded RichTextBlock stayed alive until the font resolved and OnFontLoaded could fire several times. Register one continuation per task and hold the control weakly.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KgHGJja8qcSFT2iHrm9teq
Uno.UI builds once for Skia, so #if __SKIA__ is always true and #if !__WASM__ never selects the other branch.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KgHGJja8qcSFT2iHrm9teq
GeneralTransform.Inverse never returns null, so the fallback was unreachable while a singular transform silently produced NaN coordinates. Check the result instead. Also state the PlainTextPosition identity invariant, which follows CPlainTextPosition::Equals comparing the offset alone.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KgHGJja8qcSFT2iHrm9teq
@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 9m 2s —— View job


PR Review: WIP RichTextBlock (re-review of commits since the last pass)

Tasks

  • Gather context and understand request
  • Identify the incremental diff since the last review (branch was rebased; used commit-timestamp discontinuity to find the true new-work boundary at ade19c9a..HEAD, 24 files / +514 / -207)
  • Review new/changed code against AGENTS.md rules
  • Post inline comments for findings
  • Write summary

Overall verdict: fix-first (one carry-over item), otherwise clean

This batch is almost entirely fix/refactor/test commits closing out items from prior review rounds, plus dead-#if cleanup now that Uno.UI is Skia-only. I verified each by inspection against the actual runtime semantics (flat vs. container character-position space, Matrix3x2.Invert NaN-on-singular behavior, EnterImpl/LeaveImpl virtuals, etc.) rather than taking the commit messages at face value.

1 finding — 1 nullable-annotation issue (carry-over, not new):

# Severity File Summary
1 🟡 Nullable RichTextBlockOverflow.Properties.cs:159 ContentSource still declared non-nullable RichTextBlock while GetMaster() returns RichTextBlock? — flagged in several earlier review passes, touched again by this #if __SKIA__ cleanup but still not fixed

Confirmed correct (verified by inspection, not just trusting commit messages)

  • GetSelectedText rewrite (RichTextBlock.mux.cs) — replaces plain GetPlainText()[start..end] slicing with a flat-position-aware walk that treats LineBreak as 1 flat char / 2 text chars (\r\n) and inserts a 2-char paragraph separator. Traced the arithmetic against TextBlockViewHelpers.AdjustPositionByCharacterCount (the established flat-space reference): InlineUIContainer and Span open/close markers correctly contribute zero flat characters, matching that helper's documented convention ("InlineUIContainer does not have any characters..."). The trailing per-paragraph separator is naturally excluded when end lands exactly at the paragraph boundary (to = 0), which the existing When_SelectAll_Multiple_Paragraphs test already confirms ("First\r\nSecond", no trailing CRLF). No bug found here despite the complexity.
  • Font-load continuation fix (RichTextBlock.mux.cs) — root-causes the previously-flagged resource-lifetime issue: dedupes registration per-task via _pendingFontLoad, and holds the control through a WeakReference<RichTextBlock> so an unloaded control isn't kept alive by a slow font load. Correct.
  • Trimmer-safety fix (DependencyProperty.cs, DependencyObject.Store.cs, FrameworkElement.Theming.cs) — replaces == RichTextBlock.ForegroundProperty (reading the static field roots RichTextBlock's cctor and the whole type for apps that never touch it) with an owner-type+name comparison (IsRichTextBlockProperty) / DependencyProperty.GetProperty(typeof(...), name) lookup that avoids the static reference. Verified both ForegroundProperty and SelectionFlyoutProperty are real (non-inherited) registrations on RichTextBlock, so the identity check is sound.
  • ReverseTransformFromRoot NaN fix (TextAdapter.cs) — the prior code's .Inverse is { } inverse null check was dead: traced GeneralTransform.InverseCore → Transform.InverseCore → Matrix3x2.Invert, and a non-invertible matrix produces NaN components, never null. The new double.IsNaN(...) check is the real fallback condition; this is a genuine correctness fix, not cosmetic.
  • Hyperlink bounding-rectangle fix (HyperlinkAutomationPeer.cs) — unions per-line text bounds via Rect.Union (confirmed it mutates this in place, so the union.Union(bounds[i]) loop is correct) and transforms to screen space; backed by a new runtime test that loads a link after leading text and asserts non-zero, in-bounds geometry.
  • Overflow link-capture muting fix (RichTextBlockOverflow.Input.cs) — now tracks _linkPressPointerId and only silences PointerCaptureLost for the release matching the pointer that actually took a link-press capture, leaving a selection-drag's own capture release unmuted. A new complementary test (When_Selection_Drag_In_Overflow_Is_Released_CaptureLost_Is_Raised) confirms the drag case still raises the event, so the fix isn't overcorrected.
  • EnterImpl/LeaveImpl migration — moves TextSelectionManager teardown from OnUnloaded to LeaveImpl (checked IsLive), matching CRichTextBlock::EnterImpl/LeaveImpl invalidating inherited content on live tree attach/detach. Confirmed EnterImpl(EnterParams, int) / LeaveImpl(LeaveParams) are the real virtual signatures on UIElement.
  • Test quality — Assert.Inconclusive for the macOS Ctrl-key skips (a repeatedly-flagged issue) is now replaced with [PlatformCondition(ConditionMode.Exclude, RuntimeTestPlatforms.SkiaMacOS)]. The rewritten When_ShiftClick_Extends_Selection uses deterministic click points derived from TextPointer.GetCharacterRect instead of pixel-guessing, and injected-timestamp mouse steps instead of a wall-clock Task.Delay. A native-WinUI-only test gap (When_Reloaded_SelectAll_Selects_Content) is correctly documented with a TODO and excluded only for the native comparison target, not silently skipped.

Cross-cutting notes

  • No event Action, .Result/.GetAwaiter().GetResult(), or new async void in this batch.
  • Commit messages in this range are properly Conventional-Commits formatted.
  • Dead #if __SKIA__ / #if !__WASM__ removal across RichTextBlock.cs, InlineCollection.cs, Paragraph.cs, Span.cs, and the automation peers is consistent with Uno.UI now being Skia-only — no behavior change, just removing now-unreachable branches.

Verdict: fix-first — item 1 is a one-line nullable-annotation fix (RichTextBlock?) that's been carried across several review rounds; nothing else in this batch needs changes before landing this increment.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The large cross-cutting port changes layout, input, accessibility, rendering, and public API behavior across many interdependent components.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 234688 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2310, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • DisplayInformation.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Examples.png-dark
  • skia-windows-screenshots: 2310 changed over 2440

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png
    • AppBarToggleButtonTest.png-dark
    • ApplicationViewSizing.png
    • AppWindowPresenters.png-dark
    • AppXamlDefinedResources.png
    • Attributed_text_Simple.png-dark
    • AutoBorderStretchwithbottommargin.png-dark
    • AutoBorderStretchwithleftmargin.png
    • AutoSuggestBoxChosenSuggestion.png-dark
    • AutoSuggestBoxChosenSuggestion.png
    • AutoSuggestBox_SoftKeboard.png-dark
    • AutoSuggestBox_SoftKeboard.png
    • Basics_Automated.png-dark
    • Basics_Automated.png
    • BeginTime_MultipleAnimations.png-dark
    • BeginTime_MultipleAnimations.png
    • BitmapImage_vs_SvgImageSource.png-dark
    • BitmapImage_vs_SvgImageSource.png
    • BorderLeftwithmargins.png-dark
    • BorderLeftwithmargins.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Uno_Web.Http.CookieManagerTests
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

The engine awaits a test body unbounded unless the method declares [Timeout], so an injected pointer or key that never arrives on a CI emulator hangs the whole job: Android groups burned the 45-minute cap three times on this branch (a healthy group runs ~11 min) with no test named anywhere. 120s per test keeps a hang a named failure.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KgHGJja8qcSFT2iHrm9teq
@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 7m 32s —— View job


PR Review: RichTextBlock (re-review after b526dea7)

Tasks

  • Gather context and understand request
  • Check what changed since the last review pass
  • Review new/changed code against AGENTS.md rules
  • Post inline comments for new findings
  • Write summary

Scope of this pass

The branch was rebased onto a newer base on 2026-09-18 (all commits from e687ebbe..9a59f6ab carry that day's timestamp and match content already covered by prior review rounds). The genuinely new work since the last review is the 24-file diff from 9a0caeb8 to HEAD (b526dea7) — 20 commits landed 2026-09-19/20. This pass focuses on that delta.

What the new commits do

  • d85f4536 fixes the long-standing ContinueWith resource-leak finding: RichTextBlock.mux.cs now tracks _pendingFontLoad to dedupe continuations per font-load task and captures this through a WeakReference<RichTextBlock>, clearing the pending marker before invoking OnFontLoaded. Correct and matches the invariant (one continuation per pending task, no leak on unload).
  • fe6444cd/dedddec3 implement HyperlinkAutomationPeer.GetBoundingRectangleCore() (previously a TODO/default stub) by unioning the link's text bounds and transforming to screen space, with a new runtime test (When_Hyperlink_Reports_A_Bounding_Rectangle) asserting non-empty, in-bounds geometry.
  • 692f5664 fixes TextAdapter.ReverseTransformFromRoot: the old Inverse is { } inverse check never actually detected a non-invertible transform (Inverse isn't nullable there), so the "fallback" path was dead. It now transforms first and checks double.IsNaN(...), matching WinUI's ReverseTransform behavior for a zero-scale transform.
  • ad336e2b generalizes keyboard activation from a Hyperlink-specific check in InputManager.Keyboard.cs to a TextElement.OnKeyDown/OnKeyUp virtual pair — cleaner than the prior is Hyperlink special case, and matches WinUI's model where each text element (not just Hyperlink) can register its own key listeners.
  • 8a1fb03c fixes overflow-column pointer capture: RichTextBlockOverflow.Input.cs now tracks _linkPressPointerId so only a link-press capture is released with muteEvent: true; a selection-drag capture (owned by the selection manager) still raises PointerCaptureLost on release, matching WinUI. Covered by two new tests exercising both capture-release paths.
  • be275f6b/56454a0e fix and test selection-manager recreation across an unload/reload cycle (EnterImpl/LeaveImpl overrides added, matching the established pattern used by Button/ContentPresenter/FlipView), including a [PlatformCondition(Exclude, NativeWinUI)]-gated parity test with a documented, tracked WinUI discrepancy rather than a silent skip.
  • b7f39ac6 fixes SelectedText to walk the inline tree instead of substring-slicing flat text, correctly handling the LineBreak (1 flat char ↔ "\r\n") and inter-paragraph separator (2 flat chars ↔ "\r\n") impedance mismatch. Traced through the logic — it's bounded by iteration rather than raw index slicing, so it can't throw on out-of-range start/end.
  • 0dbe8089 replaces two Assert.Inconclusive macOS skips with [PlatformCondition(ConditionMode.Exclude, RuntimeTestPlatforms.SkiaMacOS)] — closes a long-standing finding from earlier review rounds.
  • 6d1d74bf/97494c43/a0577b4c/ee30217a are trimming/dead-code cleanup: replacing direct RichTextBlock.ForegroundProperty/SelectionFlyoutProperty static-getter references in the hot, general-purpose DependencyObject.Store.cs/DependencyProperty.cs paths with a typeof(RichTextBlock) + nameof()-based comparison. Verified this is a real trimming improvement (not just churn): nameof() is resolved entirely at compile time and doesn't reference the property getter, so it avoids force-keeping the whole RichTextBlock static-constructor/Register() graph for every app that touches any DependencyObject. The rest of the #if __SKIA__/#if !__WASM__ removals in RichTextBlock.cs/Paragraph.cs/Span.cs/InlineCollection.cs are dead-code cleanup consistent with Uno.UI being Skia-only per AGENTS.md.

Findings

1 minor finding, posted inline:

  • Given_RichTextBlock_Input.skia.cs — the new class-level doc comment duplicates an existing paragraph almost verbatim (both explain the CI-hang/timeout rationale). Cosmetic only.

Cross-cutting notes

  • No .Result/.GetAwaiter().GetResult(), no unguarded async void, no event Action introduced in this delta.
  • No new DependencyProperty registrations in this diff.
  • Test coverage for each behavioral fix is present and uses proper skip/gating mechanisms ([PlatformCondition], not Assert.Inconclusive); no newly [Ignore]d tests.
  • The known carry-over items from earlier review rounds (ScrollIntoView height math — actually already fixed in an earlier round per the thread history; RichTextBlockOverflow.Properties.cs ContentSource non-nullable-vs-GetMaster()-nullable mismatch; RichTextBlockAutomationPeer.cs nullable field) either remain as previously-threaded, already-triaged items or were addressed in commits outside this delta — not re-flagged here to avoid duplicate threads.

Verdict: no blocking issues in this delta. The fixes are root-cause corrections (state/lifecycle invariants for selection-manager recreation and font-load continuations, not guard-only patches) with matching test coverage.
(branch dev/mazi/richtextblock-winui)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Text-schema validation is not wired into collection mutations, and generated files are committed contrary to repository rules.

Review effort: Balanced
Findings: None

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 234690 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2310, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • DisplayInformation.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Focus_FocusVisual_Properties.png-dark
    • ImageIconPage.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
  • skia-windows-screenshots: 2310 changed over 2440

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • AppBar_KeyBoard.png
    • AppWindowClosing.png-dark
    • AppWindowPositionAndSize.png
    • ArcSegment.png-dark
    • Attributed_text_Simple.png
    • AutoBorderStretchwithbottommargin.png-dark
    • AutomationProperties_Name.png-dark
    • AutoSuggestBoxChosenSuggestion.png
    • AutoSuggestBox_BitmapIcon.png-dark
    • BackGesture.png-dark
    • BackGesture.png
    • Basics Pivot Test.png-dark
    • Basics Pivot Test.png
    • Battery.png-dark
    • Battery.png
    • BezierSegment.png-dark
    • BezierSegment.png
    • BitmapIcon_Sizing.png-dark
    • BitmapIcon_Sizing.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

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/build Categorizes an issue or PR as relevant to build infrastructure area/skia ✏️ Categorizes an issue or PR as relevant to Skia kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

♥️ Support for RichTextBlock

6 participants