flutter/packages
LongCatIsLooong ea5b97286e
Make TextSpan hit testing precise. (#139717)
Fixes https://github.com/flutter/flutter/issues/131435, #104594, #43400
Needs https://github.com/flutter/engine/pull/48774 (to fix the web test failure).

Currently the method we use for text span hit testing `TextPainter.getPositionForOffset` always returns the closest `TextPosition`, even when the given offset is far away from the text. 

The new TextPaintes method tells you the layout bounds (`width =  letterspacing / 2 + x_advance + letterspacing / 2`, `height = font ascent + font descent`) of a character, the PR changes the hit testing implementation such that a TextSpan is only considered hit if the point-down event landed in one of it's character's layout bounds.

Potential issues:

1. In theory since the text is baseline aligned, we should use the max ascent and max descent of each character to calculate the height of the text span's hit-test region, in case some characters in the span have to fall back to a different font, but that will be slower and it typically doesn't make a huge difference. 

This is a breaking change. It also introduces a new finder and a new method `WidgetTester.tapOnText`: `await tester.tapOnText('string to match')` for ease of migration.
2023-12-20 03:23:29 +00:00
..
flutter Make TextSpan hit testing precise. (#139717) 2023-12-20 03:23:29 +00:00
flutter_driver Upgrade to version of leak tracker that does not depend on test_widgets. (#140247) 2023-12-19 04:28:09 +00:00
flutter_goldens Upgrade to version of leak tracker that does not depend on test_widgets. (#140247) 2023-12-19 04:28:09 +00:00
flutter_goldens_client Reverts "Make tests more resilient to Skia gold failures and refactor flutter_goldens for extensive technical debt removal" (#140085) 2023-12-13 20:20:20 +00:00
flutter_localizations Upgrade to version of leak tracker that does not depend on test_widgets. (#140247) 2023-12-19 04:28:09 +00:00
flutter_test Make TextSpan hit testing precise. (#139717) 2023-12-20 03:23:29 +00:00
flutter_tools [flutter_tools] handle FileSystemException trying to delete temp directory from core_devices.dart (#140415) 2023-12-20 00:08:54 +00:00
flutter_web_plugins Upgrade to version of leak tracker that does not depend on test_widgets. (#140247) 2023-12-19 04:28:09 +00:00
fuchsia_remote_debug_protocol Upgrade to version of leak tracker that does not depend on test_widgets. (#140247) 2023-12-19 04:28:09 +00:00
integration_test Upgrade to version of leak tracker that does not depend on test_widgets. (#140247) 2023-12-19 04:28:09 +00:00
analysis_options.yaml