Repository navigation
Conversation
Character rects on the ink and the line where its alignment and padding put it, the position beside a line, line heights, and inline objects across paragraphs and page breaks, with values that match native WinUI. These are the regression net for moving RichTextBlock to another text engine.
…acle Given_SkiaTextFormatter becomes Given_TextFormatter and drives the real ParagraphTextSource and formatter through the TextFormatter contract, including a check that no line breaks before the next word would overflow. Given_BlockLayoutEngine compares the page with the formatter's own lines. Both keep holding when the engine behind the formatter changes.
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Issue: part of #24339 (epic: #26728)
PR Type:
💬 Other: tests only, no product change.
What changed? 🚀
I'm about to move
RichTextBlockfrom the legacyParsedTextengine toUnicodeText(tracked in #24339). Before touching the engine, this PR adds the regression net that change has to pass: tests that pin whatRichTextBlockalready gets right today, checked against native WinUI.New:
Given_RichTextBlock_Geometry(15 cases, run on Skia and on native WinUI)When_CharacterRect_On_Ink, 6 LTR rows (left, center, right, padding, two paragraphs, wrapped). On every line:TextPointer.GetCharacterRectlie within 4 px of the drawn ink's left and right edges;Both checks are relations, not coordinates, so they don't depend on the font.
When_GetPositionFromPoint_Beside_Line(01-plain): a point left of an LTR line maps to its reading start, a point right of it to its reading end.When_Line_Heights_Match_WinUI, rows H1, H4, H7 and H9 (plain,LineHeight40 withMaxHeight,LineHeight10 withBlockLineHeightover two lines,TextLineBounds.Tight): desired height andBaselineOffset, ±1 px, against values measured on native WinUI.When_Line_Height_With_Fallback_Font_Matches_WinUI(H3): Latin plus CJK must not grow the line. It needs a CJK fallback font, so it only runs on Skia Win32 and native WinUI.When_Object_Only_Paragraph_Keeps_Following_Paragraphs: a paragraph holding only anInlineUIContainerdoesn't stop the paragraph after it from being laid out and drawn, and that paragraph is drawn below the object, not over it.When_Object_At_Page_Break(false|true): with a linkedRichTextBlockOverflow, an inline object is drawn exactly once, on the page that holds its line.Rewritten without the
ParsedTextoracle (4 cases, Skia only, since they use Uno internals)Given_SkiaTextFormatterbecomesGiven_TextFormatter. Its tests used to feed the formatter a hand-madeISkiaParagraphSourceand compare its lines with a directParsedText.ParseTextcall. They now take the formatter,ParagraphTextSourceand paragraph properties the layout tree itself builds, and go through theTextFormattercontract only, so they keep holding when the engine behind the formatter changes:When_FormatLine_Vends_All_Lines, which checks that:Lines are formatted from where the previous one ended, as
ParagraphNodedoes.When_Paragraph_Properties_Change_At_Same_WidthandWhen_Clusters_Span_Several_Code_Units: same assertions as before, on the real pipeline.Given_BlockLayoutEngine.When_Measure_Single_Paragraph_Matches_ParsedTextbecomesWhen_Measure_Single_Paragraph: the page's desired width and height now come from the formatter's own lines, not fromParsedText.What the rewrites no longer check. The oracle gave an independent expectation for every line: the line count and each line's width and height came from a second layout of the same text. The rewrites can't do that without a second engine. They check the lines against each other, against the wrapping width, against the next word, and against the control's size. So a formatter whose lines are all consistently off by the same amount, for example all slightly too tall, would still pass them. Such a change would still show in the WinUI-backed geometry and height tests above.
Validation
Runtime, Skia Desktop (Win32):
The 19 new and rewritten cases pass, in 3 runs out of 3 (each run also includes the 2 unchanged
Given_BlockLayoutEnginecases, 21 in all).The
RichTextBlockgroup (Given_RichTextBlock|Given_SkiaTextFormatter|Given_TextFormatter|Given_BlockLayoutEngine|Given_HyperlinkAutomation): 222 of 222 pass. Against a master run of the same group (207 of 207), no case went from pass to fail. The only cases gone are the 4 replaced ones, and the 19 added cases all pass.Each test can fail. I added temporary product changes, switched by an environment variable, and checked that every test and every anchor fails under its own:
NoWrapor splits a surrogate pair;I then reverted them.
Runtime, native WinUI (WinAppSDK): the 15 cases of
Given_RichTextBlock_Geometrypass. The ink anchors hold on WinUI with the same 4 px tolerance.Compile: the runtime tests project builds with analyzers and code style on, with no warning or error.
Not in this PR: RTL, justified text, trailing spaces, links beside a line and the other line-height rows (H2, H5, H6, H8): they fail on master today, so they come with the engine change.
PR Checklist ✅
Screenshots Compare Test Runresults.