Skip to content

Fixing few related editing issues with LTR/RTL text#188503

Merged
Rusino merged 14 commits into
flutter:masterfrom
Rusino:get_pos
Jun 29, 2026
Merged

Fixing few related editing issues with LTR/RTL text#188503
Rusino merged 14 commits into
flutter:masterfrom
Rusino:get_pos

Conversation

@Rusino

@Rusino Rusino commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #188314
Fixes #188315
Fixes #188316
Fixes #188318
Fixes #188319

Rusino added 5 commits June 11, 2026 14:11
1. GetBoxesForRange in RTL
2. GetPositionForGlyph in RTL
It might need some extra work for complex cases
Still wrong end pos for RTL text with Paragraph LTR
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 24, 2026
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team labels Jun 24, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors web paragraph layout, query, and painting logic, including strut style height calculations, text position offset resolution, and glyph info retrieval, alongside adding new paragraph tests. The reviewer feedback highlights several critical issues: the use of solo: true in tests which skips other test runs, potential runtime exceptions in layout.dart due to force-unwrapping nullable font sizes and potential division by zero, incorrect glyph retrieval at the end of text, performance regressions from commenting out assert wrappers around debug logging, and various leftover debug prints, typos, and commented-out code blocks.

Comment thread engine/src/flutter/lib/web_ui/test/webparagraph/paragraph_performance_test.dart Outdated
Comment thread engine/src/flutter/lib/web_ui/test/webparagraph/paragraph_queries_test.dart Outdated
Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/web_paragraph/layout.dart Outdated
Comment on lines +916 to +918
final ui.GlyphInfo? result = getGlyphInfoAt(
position.offset + (position.affinity == ui.TextAffinity.downstream ? 0 : -1),
);

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.

high

If position.offset is equal to text.length (which happens when clicking at the end of the text) and position.affinity is downstream, position.offset + 0 evaluates to text.length. Since there is no glyph at index text.length, getGlyphInfoAt will return null. We should adjust the offset to text.length - 1 in this case to correctly retrieve the last glyph's info.

    final int targetOffset = position.offset == text.length
        ? text.length - 1
        : position.offset + (position.affinity == ui.TextAffinity.downstream ? 0 : -1);
    final ui.GlyphInfo? result = getGlyphInfoAt(targetOffset);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is an expected behavior.

@mdebbar mdebbar Jun 25, 2026

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.

Can we double-check that this is an expected behavior? I think getClosestGlyphInfoForOffset is supposed to return the closest glyph, in this case the closest glyph is the last one, not null.

Answer:
The code in SkParagraph goes like this:
const PositionWithAffinity res = this->getGlyphPositionAtCoordinate(dx, dy);
SkASSERT(res.position != 0 || res.affinity != Affinity::kUpstream);
const size_t utf16Offset = res.position + (res.affinity == Affinity::kDownstream ? 0 : -1);
...
return this->getGlyphClusterAt(fUTF8IndexForUTF16Index[utf16Offset], glyphInfo);

Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/web_paragraph/debug.dart Outdated
Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/web_paragraph/layout.dart Outdated
Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/web_paragraph/paragraph.dart Outdated
Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/web_paragraph/paragraph.dart Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 24, 2026
@Rusino

Rusino commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors text layout, painting, and query logic in the Flutter Web engine, including updates to box height styles, block positioning, glyph info retrieval, and debug logging. However, two significant issues were identified in the review: first, resolving an offset to the right of a non-last line incorrectly uses the last line's blocks, causing an assertion failure; second, simplifying the codepoint position in getLineBoundary to ignore affinity introduces a regression for upstream positions at line breaks.

Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/web_paragraph/layout.dart Outdated
@Rusino Rusino self-assigned this Jun 24, 2026
@Rusino
Rusino requested a review from mdebbar June 24, 2026 16:54
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 24, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 25, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 25, 2026
@Rusino Rusino changed the title Get pos Fixing few related editing issues with LTR/RTL text Jun 25, 2026
Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/web_paragraph/layout.dart Outdated
Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/web_paragraph/layout.dart Outdated
Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/web_paragraph/paragraph.dart Outdated
Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/web_paragraph/paragraph.dart Outdated
Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/web_paragraph/paragraph.dart Outdated
Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/web_paragraph/layout.dart Outdated
Comment on lines +916 to +918
final ui.GlyphInfo? result = getGlyphInfoAt(
position.offset + (position.affinity == ui.TextAffinity.downstream ? 0 : -1),
);

@mdebbar mdebbar Jun 25, 2026

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.

Can we double-check that this is an expected behavior? I think getClosestGlyphInfoForOffset is supposed to return the closest glyph, in this case the closest glyph is the last one, not null.

Answer:
The code in SkParagraph goes like this:
const PositionWithAffinity res = this->getGlyphPositionAtCoordinate(dx, dy);
SkASSERT(res.position != 0 || res.affinity != Affinity::kUpstream);
const size_t utf16Offset = res.position + (res.affinity == Affinity::kDownstream ? 0 : -1);
...
return this->getGlyphClusterAt(fUTF8IndexForUTF16Index[utf16Offset], glyphInfo);

Comment thread engine/src/flutter/lib/web_ui/test/webparagraph/paragraph_performance_test.dart Outdated
Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/web_paragraph/painter.dart Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 25, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 25, 2026
@Rusino
Rusino requested a review from mdebbar June 25, 2026 17:13
@Rusino
Rusino requested a review from mdebbar June 26, 2026 19:19
@flutter-dashboard

Copy link
Copy Markdown

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #188503 at sha db455ed

@flutter-dashboard flutter-dashboard Bot added the will affect goldens Changes to golden files label Jun 26, 2026
@Rusino
Rusino added this pull request to the merge queue Jun 29, 2026
Merged via the queue into flutter:master with commit 8786818 Jun 29, 2026
200 checks passed
@Rusino
Rusino deleted the get_pos branch June 29, 2026 14:19
This was referenced Jun 29, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jul 7, 2026
…#12081)

Manual roll Flutter from 0c80830e465b to ca9f874f5284 (119 revisions)

Manual roll requested by [email protected]

flutter/flutter@0c80830...ca9f874

2026-06-30 [email protected] [tool] Don't require a Flutter compile task when staging jniLibs (flutter/flutter#188805)
2026-06-30 [email protected] [Impeller] Fix potential overflow when allocating buffers at the next power of two size (flutter/flutter#188742)
2026-06-30 [email protected] [Framework/Tool] Decouple preview theme imports (flutter/flutter#188176)
2026-06-30 [email protected] Add import of `dart:_js_interop_wasm` in sdk rewriter tool (flutter/flutter#188620)
2026-06-30 [email protected] Detach LLDB and print stack trace on process stop (flutter/flutter#188576)
2026-06-30 [email protected] [Linux] Fix FlCompositorOpenGL.pixels comment (flutter/flutter#188754)
2026-06-30 [email protected] [flutter_tools] Fix crash in flutter create when pubspec.yaml is empty (flutter/flutter#188385)
2026-06-30 [email protected] Roll Packages from 656ccaa to 274ed3e (23 revisions) (flutter/flutter#188792)
2026-06-30 [email protected] In AndroidImageGenerator, check that the destination pixel buffer has sufficient capacity for the decoded data (flutter/flutter#188752)
2026-06-30 [email protected] Roll pub packages (flutter/flutter#188773)
2026-06-30 [email protected] [Impeller] Add a flat VertexAttributeFormat for vertex inputs (flutter/flutter#188684)
2026-06-30 [email protected] Roll pub packages (flutter/flutter#188764)
2026-06-30 [email protected] Roll Dart SDK from 0cb483880b6b to e1bdb9ce3327 (2 revisions) (flutter/flutter#188763)
2026-06-29 [email protected] Handle 'no permissions' adb device state (flutter/flutter#187248)
2026-06-29 [email protected] [windows]: adjusts uniform buffers to hit hlsl optimization (flutter/flutter#188538)
2026-06-29 [email protected] Roll Skia from bfb7860cb9c7 to 71947c4110b0 (9 revisions) (flutter/flutter#188747)
2026-06-29 [email protected] ci: extract wait-for-engine-build logic into a reusable composite action (flutter/flutter#188748)
2026-06-29 [email protected] Provide guided migration logs when iOS app crashes on simulator (flutter/flutter#188736)
2026-06-29 [email protected] Revert "[flutter_tools] Track asset transformer dependencies for hot reload" (flutter/flutter#188751)
2026-06-29 [email protected] Migrate ABI splits to new AGP dsl (flutter/flutter#188369)
2026-06-29 [email protected] Add Impeller+OpenGLES startup benchmark for mokey (flutter/flutter#188495)
2026-06-29 [email protected] Increase macOS minimum supported version from 10.15 to 12 to support Xcode 27  (flutter/flutter#188520)
2026-06-29 [email protected] Moves test ownership validation to flutter/flutter (flutter/flutter#188655)
2026-06-29 [email protected] Add --flavor support for Windows desktop builds (flutter/flutter#187034)
2026-06-29 [email protected] Android_hardware_smoke_test: Enable pixel exact local file comparator to read goldens from flutter asset URI (flutter/flutter#188587)
2026-06-29 [email protected] [flutter_tools] Use DeviceHub.app for iOS simulator path on Xcode 27+ (flutter/flutter#187910)
2026-06-29 [email protected] Roll Skia from 111e7582d081 to bfb7860cb9c7 (2 revisions) (flutter/flutter#188731)
2026-06-29 [email protected] Use `revert` label instead of `revert_wf` (flutter/flutter#188639)
2026-06-29 [email protected] Properly await Dart Development Service shutdown with timeout (flutter/flutter#188387)
2026-06-29 [email protected] [flutter_tools] Track asset transformer dependencies for hot reload (flutter/flutter#187947)
2026-06-29 [email protected] [Tool] Tolerate malformed UTF-8 in process streaming decoders (flutter/flutter#188453)
2026-06-29 [email protected] [flutter_tools] Use new ddc modules in test (flutter/flutter#188240)
2026-06-29 [email protected] Roll Packages from c1f7d92 to 656ccaa (12 revisions) (flutter/flutter#188728)
2026-06-29 [email protected] Remove unused fields (flutter/flutter#188705)
2026-06-29 [email protected] Clear text input handler widget on view dispose (flutter/flutter#188701)
2026-06-29 [email protected] Free compositor in view renderer finalize to avoid use-after-free (flutter/flutter#188702)
2026-06-29 [email protected] [linux] Use GWeakRef in mock signal handler test helper (flutter/flutter#188700)
2026-06-29 [email protected] Fixing few related editing issues with LTR/RTL text (flutter/flutter#188503)
2026-06-29 [email protected] [Flutter GPU] Add Texture.fromImage to wrap a ui.Image texture (flutter/flutter#188605)
2026-06-29 [email protected] [Flutter GPU] Honor the enable argument in RenderPass.setDepthWriteEnable (flutter/flutter#188715)
2026-06-29 [email protected] Roll Skia from ba1942d8c3e1 to 111e7582d081 (1 revision) (flutter/flutter#188721)
2026-06-29 [email protected] Roll Skia from 587d8befe1ee to ba1942d8c3e1 (6 revisions) (flutter/flutter#188717)
2026-06-29 [email protected] Remove some refs to package:intl (flutter/flutter#188504)
2026-06-29 [email protected] [VPAT] Update a11y assessment app FAB example to announce value change when it's updated. (flutter/flutter#188466)
...
kalyujniy pushed a commit to brickit-app/camera that referenced this pull request Jul 8, 2026
…flutter#12081)

Manual roll Flutter from 0c80830e465b to ca9f874f5284 (119 revisions)

Manual roll requested by [email protected]

flutter/flutter@0c80830...ca9f874

2026-06-30 [email protected] [tool] Don't require a Flutter compile task when staging jniLibs (flutter/flutter#188805)
2026-06-30 [email protected] [Impeller] Fix potential overflow when allocating buffers at the next power of two size (flutter/flutter#188742)
2026-06-30 [email protected] [Framework/Tool] Decouple preview theme imports (flutter/flutter#188176)
2026-06-30 [email protected] Add import of `dart:_js_interop_wasm` in sdk rewriter tool (flutter/flutter#188620)
2026-06-30 [email protected] Detach LLDB and print stack trace on process stop (flutter/flutter#188576)
2026-06-30 [email protected] [Linux] Fix FlCompositorOpenGL.pixels comment (flutter/flutter#188754)
2026-06-30 [email protected] [flutter_tools] Fix crash in flutter create when pubspec.yaml is empty (flutter/flutter#188385)
2026-06-30 [email protected] Roll Packages from 656ccaa to 274ed3e (23 revisions) (flutter/flutter#188792)
2026-06-30 [email protected] In AndroidImageGenerator, check that the destination pixel buffer has sufficient capacity for the decoded data (flutter/flutter#188752)
2026-06-30 [email protected] Roll pub packages (flutter/flutter#188773)
2026-06-30 [email protected] [Impeller] Add a flat VertexAttributeFormat for vertex inputs (flutter/flutter#188684)
2026-06-30 [email protected] Roll pub packages (flutter/flutter#188764)
2026-06-30 [email protected] Roll Dart SDK from 0cb483880b6b to e1bdb9ce3327 (2 revisions) (flutter/flutter#188763)
2026-06-29 [email protected] Handle 'no permissions' adb device state (flutter/flutter#187248)
2026-06-29 [email protected] [windows]: adjusts uniform buffers to hit hlsl optimization (flutter/flutter#188538)
2026-06-29 [email protected] Roll Skia from bfb7860cb9c7 to 71947c4110b0 (9 revisions) (flutter/flutter#188747)
2026-06-29 [email protected] ci: extract wait-for-engine-build logic into a reusable composite action (flutter/flutter#188748)
2026-06-29 [email protected] Provide guided migration logs when iOS app crashes on simulator (flutter/flutter#188736)
2026-06-29 [email protected] Revert "[flutter_tools] Track asset transformer dependencies for hot reload" (flutter/flutter#188751)
2026-06-29 [email protected] Migrate ABI splits to new AGP dsl (flutter/flutter#188369)
2026-06-29 [email protected] Add Impeller+OpenGLES startup benchmark for mokey (flutter/flutter#188495)
2026-06-29 [email protected] Increase macOS minimum supported version from 10.15 to 12 to support Xcode 27  (flutter/flutter#188520)
2026-06-29 [email protected] Moves test ownership validation to flutter/flutter (flutter/flutter#188655)
2026-06-29 [email protected] Add --flavor support for Windows desktop builds (flutter/flutter#187034)
2026-06-29 [email protected] Android_hardware_smoke_test: Enable pixel exact local file comparator to read goldens from flutter asset URI (flutter/flutter#188587)
2026-06-29 [email protected] [flutter_tools] Use DeviceHub.app for iOS simulator path on Xcode 27+ (flutter/flutter#187910)
2026-06-29 [email protected] Roll Skia from 111e7582d081 to bfb7860cb9c7 (2 revisions) (flutter/flutter#188731)
2026-06-29 [email protected] Use `revert` label instead of `revert_wf` (flutter/flutter#188639)
2026-06-29 [email protected] Properly await Dart Development Service shutdown with timeout (flutter/flutter#188387)
2026-06-29 [email protected] [flutter_tools] Track asset transformer dependencies for hot reload (flutter/flutter#187947)
2026-06-29 [email protected] [Tool] Tolerate malformed UTF-8 in process streaming decoders (flutter/flutter#188453)
2026-06-29 [email protected] [flutter_tools] Use new ddc modules in test (flutter/flutter#188240)
2026-06-29 [email protected] Roll Packages from c1f7d92 to 656ccaa (12 revisions) (flutter/flutter#188728)
2026-06-29 [email protected] Remove unused fields (flutter/flutter#188705)
2026-06-29 [email protected] Clear text input handler widget on view dispose (flutter/flutter#188701)
2026-06-29 [email protected] Free compositor in view renderer finalize to avoid use-after-free (flutter/flutter#188702)
2026-06-29 [email protected] [linux] Use GWeakRef in mock signal handler test helper (flutter/flutter#188700)
2026-06-29 [email protected] Fixing few related editing issues with LTR/RTL text (flutter/flutter#188503)
2026-06-29 [email protected] [Flutter GPU] Add Texture.fromImage to wrap a ui.Image texture (flutter/flutter#188605)
2026-06-29 [email protected] [Flutter GPU] Honor the enable argument in RenderPass.setDepthWriteEnable (flutter/flutter#188715)
2026-06-29 [email protected] Roll Skia from ba1942d8c3e1 to 111e7582d081 (1 revision) (flutter/flutter#188721)
2026-06-29 [email protected] Roll Skia from 587d8befe1ee to ba1942d8c3e1 (6 revisions) (flutter/flutter#188717)
2026-06-29 [email protected] Remove some refs to package:intl (flutter/flutter#188504)
2026-06-29 [email protected] [VPAT] Update a11y assessment app FAB example to announce value change when it's updated. (flutter/flutter#188466)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team will affect goldens Changes to golden files

Projects

None yet

2 participants