Skip to content

[Epic] One text model for the Skia text controls: Unicode bidi, WinUI mirroring, a shared layout stack #26728

Backlog

Description

@mikernet

What would you like to be added? 💡

One text model for TextBlock, RichTextBlock, TextBox, PasswordBox and RichEditBox on Skia, the one WinUI has: a single engine with real Unicode bidi, WinUI's right-to-left coordinate convention for every text control, and one layout stack shared by TextBlock and RichTextBlock. I'm doing the work as a series of PRs, listed here in review order so they are easy to follow. Each PR stands on its own and can be taken when it's ready.

Phase 1. RichTextBlock on UnicodeText, with bidi (#24339)

RichTextBlock is the last control on the legacy ParsedText engine, which has no bidi. This phase moves it to UnicodeText, the engine the other controls use, and fixes that engine's own bidi problems on the way.

#26724, #26725 and #26726 are independent of each other. #26727 needs #26726, and the rest need all four.

Phase 2. One coordinate convention for every text control

WinUI mirrors a right-to-left element, and its text layout code is written for that mirrored space. Uno cancels the mirror for text controls (isMirroredTextSurface in UIElement.GetFlowDirectionTransform) and has each feature compensate, which is where bugs like #24748 come from. Phase 1 puts RichTextBlock on WinUI's convention, with one small helper that mirrors back at the engine boundary. This phase does the same for TextBlock, TextBox, PasswordBox and RichEditBox, and deletes the exception.

  • Design, then PRs (to be listed).

Phase 3. TextBlock on the shared layout stack

In WinUI, TextBlock and RichTextBlock share one layout stack. In Uno, the ported stack (BlockLayoutEngine, PageNode, ParagraphNode, TextSelectionManager) serves RichTextBlock only, TextBlockView is ported but unused, and TextBlock has its own selection, hit-testing and automation code beside it. This phase moves TextBlock onto the shared stack, which removes that duplication and gives TextBlock TextPointer support, text-view automation and TextReadingOrder.

Plain text keeps a fast path, as WinUI's TextBlock does, so a label doesn't pay for the node tree. A benchmark of plain TextBlock measure, arrange and paint gates every PR of this phase: it must not regress.

  • Design, then PRs (to be listed).

Why is this needed? 🤔

For which platforms 📱💻🖥️

All platforms 🌍

Anything else we need to know? 💬

Is this the direction you want? 👍

I've settled the three points below myself, so the work isn't waiting on anyone, and each is the WinUI-parity choice. If you agree, a 👍 on this issue is enough. If you see a problem with one of them, or have work in progress it would collide with, tell me before that phase gets far.

  1. WinUI's mirror convention for every text control (phase 2). A right-to-left text control stays mirrored like any other element, and the text is mirrored back in one place at the engine boundary. I chose it because the layout, selection and automation code ported from WinUI is written for that space, and because the current exception has to be compensated for in every feature that reads a text coordinate.
  2. TextBlock on the shared layout stack (phase 3). The port notes call this "Stage 9". If someone has already started on it, I'd rather build on that than duplicate it.
  3. Performance and ordering for phase 3. It rewrites the measure, arrange and paint paths that the open TextBlock performance PRs optimize. I'm designing it to keep those optimizations whichever merges first, with a fast path for plain text and a benchmark that gates every PR. If Add a cross-platform performance benchmark suite with CI tracking #26516 (the benchmark suite) lands, that benchmark goes into it. If you'd rather phase 3 waits until those PRs are merged, or there is a benchmark you want it to hold, say which.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions