96 Commits

Author SHA1 Message Date
Renzo Olivares
21ad7122a1
Implement SelectionArea single click/tap gestures (#132682)
This change collapses the selection at the clicked/tapped location on single click down for desktop platforms, and on single click/tap up for mobile platforms to match native.

This is a change from how `SelectionArea` previously worked. Before this change a single click down would clear the selection. From observing a native browser it looks like when tapping on static text the selection is not cleared but collapsed. A user can still attain the selection from static text using the `window.getSelection` API.

https://jsfiddle.net/juepasn3/11/ You can try this demo out here to observe this behavior yourself. When clicking on static text the selection will change.

This change also allows `Paragraph.selections` to return selections that are collapsed. This for testing purposes to confirm where the selection has been collapsed.

Partially fixes: #129583
2023-09-28 01:42:16 +00:00
LongCatIsLooong
45e4a0e525
Fix a TextSpan test (#135187)
`TextSpan.toStringDeep()` returns a string that contains a lengthy diagnostic message instead of the plain string.
2023-09-21 19:41:58 +00:00
LongCatIsLooong
b2e22d3558
Replaces textScaleFactor with TextScaler (#128522)
Deprecate `textScaleFactor` in favor of `textScaler`, in preparation for Android 14 [Non-linear font scaling to 200%](https://developer.android.com/about/versions/14/features#non-linear-font-scaling). The `TextScaler` class can be moved to `dart:ui` in the future, if we decide to use the Android platform API or AndroidX to get the scaling curve instead of hard coding the curve in the framework.

I haven't put the Flutter version in the deprecation message so the analyzer checks are failing. Will do so after I finish the migration guide.

**Why `TextScaler.textScaleFactor`**
The author of a `TextScaler` subclass should provide a fallback `textScaleFactor`. By making `TextScaler` also contain the `textScaleFactor` information it also makes it easier to migrate: if a widget overrides `MediaQueryData.textScaler` in the tree, for unmigrated widgets in the subtree it would also have to override `MediaQueryData.textScaleFactor`, and that makes it difficult to remove `MediaQueryData.textScaleFactor` in the future.

## A full list of affected APIs in this PR

Deprecated: The method/getter/setter/argument is annotated with a `@Deprecated()` annotation in this PR, and the caller should replace it with `textScaler` instead. Unless otherwise specified there will be a Flutter fix available to help with migration but it's still recommended to migrate case-by-case.
**Replaced**:  The method this `textScaleFactor` argument belongs to is rarely called directly by user code and is not overridden by any of the registered custom tests, so the argument is directly replaced by `TextScaler`.
**To Be Deprecated**:  The method/getter/setter/argument can't be deprecated in this PR because a registered customer test depends on it and a Flutter fix isn't available (or the test was run without applying flutter fixes first). This method/getter/setter/argument will be deprecated in a followup PR once the registered test is migrated.

### `Painting` Library

| Affected API | State of `textScaleFactor` | Comment | 
| --- | --- | --- |
| `InlineSpan.build({ double textScaleFactor = 1.0 })` argument | **Replaced** | | 
| `TextStyle.getParagraphStyle({ double TextScaleFactor = 1.0 })` argument | **Replaced** | |
| `TextStyle.getTextStyle({ double TextScaleFactor = 1.0 })`  argument| Deprecated | Can't replace: c47fd38dca/super_editor/lib/src/infrastructure/super_textfield/desktop/desktop_textfield.dart (L1903-L1905)|
| `TextPainter({ double TextScaleFactor = 1.0 })` constructor argument | Deprecated | |
| `TextPainter.textScaleFactor` getter and setter | Deprecated | No Flutter Fix, not expressible yet |
| `TextPainter.computeWidth({ double TextScaleFactor = 1.0 })` argument | Deprecated | |
| `TextPainter.computeMaxIntrinsicWidth({ double TextScaleFactor = 1.0 })` argument | Deprecated | |

### `Rendering` Library

| Affected API | State of `textScaleFactor` | Comment | 
| --- | --- | --- |
| `RenderEditable({ double TextScaleFactor = 1.0 })` constructor argument | Deprecated | |
| `RenderEditable.textScaleFactor` getter and setter | Deprecated | No Flutter Fix, not expressible yet |
| `RenderParagraph({ double TextScaleFactor = 1.0 })` constructor argument | Deprecated | |
| `RenderParagraph.textScaleFactor` getter and setter | Deprecated | No Flutter Fix, not expressible yet |

### `Widgets` Library

| Affected API | State of `textScaleFactor` | Comment | 
| --- | --- | --- |
| `MediaQueryData({ double TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | cd7b93532e/packages/flutter_markdown/test/text_scale_factor_test.dart (LL39C21-L39C35) |
| `MediaQueryData.textScaleFactor` getter | Deprecated | |
| `MediaQueryData.copyWith({ double? TextScaleFactor })` argument | Deprecated | |
| `MediaQuery.maybeTextScaleFactorOf(BuildContext context)` static method | Deprecated | No Flutter Fix, not expressible yet  |
| `MediaQuery.textScaleFactorOf(BuildContext context)` static method | **To Be Deprecated** | cd7b93532e/packages/flutter_markdown/lib/src/_functions_io.dart (L68-L70), No Flutter Fix, not expressible yet |
| `RichText({ double TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | cd7b93532e/packages/flutter_markdown/lib/src/builder.dart (L829-L843) |
| `RichText.textScaleFactor` getter | **To Be Deprecated** | A constructor argument can't be deprecated right away|
| `Text({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | 914d120da1/packages/rfw/lib/src/flutter/core_widgets.dart (L647) , No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `Text.rich({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | The default constructor has an argument that can't be deprecated right away. No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `Text.textScaleFactor` getter | **To Be Deprecated** | A constructor argument can't be deprecated right away |
| `EditableText({ double? TextScaleFactor = 1.0 })` constructor argument | Deprecated | No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `EditableText.textScaleFactor` getter | Deprecated | |

### `Material` Library

| Affected API | State of `textScaleFactor` | Comment | 
| --- | --- | --- |
| `SelectableText({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | cd7b93532e/packages/flutter_markdown/lib/src/builder.dart (L829-L843), No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `SelectableText.rich({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | The default constructor has an argument that can't be deprecated right away. No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `SelectableText.textScaleFactor` getter | **To Be Deprecated** | A constructor argument can't be deprecated right away |

A lot of material widgets (`Slider`, `RangeSlider`, `TimePicker`, and different types of buttons) also change their layout based on `textScaleFactor`. These need to be handled in a case-by-case fashion and will be migrated in follow-up PRs.
2023-07-17 17:56:07 +00:00
Jason Simmons
3e66c86ae4
Make a paragraph test involving Chinese characters work with inconsistent host system fonts (#129628)
Text tests are run using the Ahem font, and test host environments such
as LUCI may not provide a fallback font for Chinese glyphs.
2023-06-27 09:56:13 -07:00
hangyu
9459f1c517
Fix chinese text is not selected by long press (#129320)
issue:#126652

 in Chinese text, word length is 1 and (position.offset == word.end) happens a lot.

Update if (position.offset >= word.end) to if (position.offset > word.end) to resolve the issue that Chinese characters are not selected.
2023-06-27 01:15:38 +00:00
hangyu
63f4174638
Paint SelectableFragments before text (#128375)
fixes: #104703
2023-06-09 17:00:14 +00:00
LongCatIsLooong
b5df180a6f
Move shared inline widget logic to RenderInlineWidgetContainerDefaults (#127308)
- Added `InlineWidgetContainerDefaults` for deduping inline widget code
- Added a helper function `WidgetSpan.extractFromInlineSpan` for extracting `WidgetSpan`s and automatically applying text scaling (at widget level)
- Removed `TextPainter.inlinePlaceholderScales`. I'm going to deprecate the `scale` argument in `TextPainter.addPlaceholder` next, as scaling is now done at the widget level.
- Added runtime check and comments to make sure nobody is extending `PlaceholderSpan` directly (unfortunately we can't remove `PlaceholderSpan`  without moving RenderEditable and RenderParagraph to the widgets library).
2023-05-26 23:47:33 +00:00
LongCatIsLooong
482b5f63e9
Unskip #62819 Fixes #12357 (#122945)
Unskip #62819 Fixes #12357
2023-03-24 22:07:47 +00:00
LongCatIsLooong
f4551e6450
Reland "Update test font (#121306)" (#122068)
Reland "Update test font (#121306)"
2023-03-09 19:05:32 +00:00
LongCatIsLooong
33ffdd704f
Revert "Update test font (#121306)" (#122053)
This reverts commit 9f69a3679bc441d3ff985362e47b80ee2a51c60f.
2023-03-06 14:15:58 -08:00
LongCatIsLooong
9f69a3679b
Update test font (#121306)
Update test font
2023-03-06 21:46:51 +00:00
Lioness100
26b6c1bedd
Fix typos (#121171)
* Fix typos

* lowercase animated & opacity

* Undo typo fix

---------

Co-authored-by: Michael Goderbauer <goderbauer@google.com>
2023-02-23 19:43:21 +00:00
Mouad Debbar
902d86e09c
[web] Unify line boundary expectations on web and non-web (#121006)
* [web] Temporarily disable a line boundary test

* [web] Unify line boundary expectations on web and non-web
2023-02-21 17:28:13 +00:00
Mouad Debbar
f785136852
[web] Temporarily disable a line boundary test (#121005) 2023-02-17 21:50:11 +00:00
LongCatIsLooong
0a2e0a4730
Avoid using TextAffinity in TextBoundary (#117446)
* Avoid affinity like the plague

* ignore lint

* clean up

* fix test

* review

* Move wordboundary to text painter

* docs

* fix tests
2023-01-05 17:04:15 +00:00
Michael Goderbauer
fa3777bd3e
Enable sized_box_shrink_expand lint (#117371)
* Enable  lint

* note about discarded_futures

* note about use_decorated_box

* update note on require_trailing_commas
2022-12-20 19:07:15 +00:00
Lucas.Xu
b20a9e0a37
imporve gesture recognizer semantics test cases (#117257) 2022-12-17 21:00:46 +01:00
Lucas.Xu
80e1008cbc
fix: #110342 unable to update rich text widget gesture recognizer (#116849) 2022-12-16 09:32:09 +01:00
chunhtai
80bf355192
Support keyboard selection in SelectabledRegion (#112584)
* Support keyboard selection in selectable region

* fix some comments

* addressing comments
2022-11-04 10:55:28 -07:00
Alexandre Ardhuin
ccd33631e3
enable combinators_ordering (#107847) 2022-07-18 22:04:07 +00:00
Xilai Zhang
a7fe235c8c
Revert "Reland "Clipping if only one character text overflows (#99146)" (#102130)" (#106964)
This reverts commit 3f43d9f3d4105d4190c839e087c42d79ebe092e8.
2022-07-01 12:46:21 -07:00
xubaolin
3f43d9f3d4
Reland "Clipping if only one character text overflows (#99146)" (#102130)
Fixes a text clipping edge case.
2022-06-29 14:57:16 -07:00
chunhtai
efb9368573
Supports global selection for all devices (#95226)
* Support global selection

* addressing comments

* add new test

* Addressing review comments

* update

* addressing comments

* addressing comments

* Addressing comments

* fix build
2022-05-24 13:53:55 -07:00
Justin McCandless
8817521ad1
Revert "Clipping if only one character text overflows (#99146)" (#102092)
This reverts commit 08e467dde7a1c3906ce6f4231d9f1d1b36b64022 (Google test failures after merge).
2022-04-18 12:30:59 -07:00
xubaolin
08e467dde7
Clipping if only one character text overflows (#99146) 2022-04-14 10:24:13 -07:00
Michael Goderbauer
51bcdb9407
super parameters for framework (#100905) 2022-04-13 22:38:40 -07:00
Ian Hickson
ab89ce285f
Clean up the bindings APIs. (#89451) 2022-02-03 14:55:15 -08:00
Ian Hickson
61a0add286
Enable avoid_redundant_argument_values lint (#91409) (#91462) 2021-10-08 09:25:14 -07:00
Zachary Anderson
b9d2177da0
Revert "Enable avoid_redundant_argument_values lint (#91409)" (#91461)
This reverts commit 5fd259be244244e14ff87fee9b6a721625f952cd.
2021-10-07 21:11:07 -07:00
Ian Hickson
5fd259be24
Enable avoid_redundant_argument_values lint (#91409) 2021-10-07 20:13:02 -07:00
chunhtai
74ac7c476c
Fix empty textspan with spell out crashes (#88738) 2021-08-25 23:01:03 -07:00
chunhtai
b9908f6b86
Fixes renderparagraph crashes due to truncated semantics node (#88190)
* Fixes renderparagraph crashes due to truncated semantics node

* add period
2021-08-23 16:03:49 -07:00
Darren Austin
225a43d941
Updated skipped tests for rendering directory. (#87700) 2021-08-05 11:32:48 -07:00
olof-dev
f226c1eae9
Added parameters boxHeightStyle, boxWidthStyle to RenderParagraph.getBoxesForSelection (#87183) 2021-07-29 09:04:05 -07:00
Alexandre Ardhuin
59fc92168a
add missing trailing commas (#81065) 2021-04-23 22:47:40 +02:00
Sam Rawlins
dea1c46a3c
Remove "unnecessary" imports. (#75637) 2021-02-10 17:06:03 -08:00
Jason Simmons
a56584857f
Ignore text selection boxes when assembling semantics for placeholder runs (#70487) 2020-11-16 10:28:03 -08:00
Kate Lovett
019e90f7df
[NNBD] Migrates some rendering tests (#67449) 2020-10-07 16:27:06 -07:00
Jason Simmons
70973e0214
Handle empty selection box lists in RenderParagraph.assembleSemanticsNode (#67017) 2020-10-02 10:57:05 -07:00
Anatoly Pulyaevskiy
bb59993ac6
Expose 3 new methods with text metrics in RenderParagraph (#65150) 2020-09-09 15:45:03 -07:00
Chris Bracken
c0ea00ed3f
Prefer moreOrLessEquals over closeTo (#64915)
Flutter's `moreOrLessEquals` has a few advantages over `closeTo` from
the `matcher` package:

   * It emits the epsilon value in the test result on failure.
   * It uses a named parameter for epsilon, which improves readability
     at the call site.
   * It has a reasonable default for epsilon in cases where something
     more specific isn't required.

Using it also has the nice property that it aids in its own discovery
when when people go looking for such functionality in new tests.

This change also includes a couple unrelated whitespace formatting cleanups.
2020-08-30 22:20:16 -07:00
chunhtai
58e839223d
reland fix intrinsic height and width for widget span #61485 (#63118) 2020-08-07 21:01:03 -07:00
chunhtai
3577da53ff
Revert "fix intrinsic height and width for widget span (#61485)" (#61876)
This reverts commit fc09119d0af589ade9c7e0609777a46ed773f5d7.
2020-07-20 09:54:50 -07:00
chunhtai
fc09119d0a
fix intrinsic height and width for widget span (#61485) 2020-07-16 09:36:09 -07:00
Kate Lovett
ea777fea1b
Skip Audit - Rendering Library (#58640) 2020-07-09 13:36:03 -07:00
Alexandre Ardhuin
4d7525f05c
Opt out nnbd in packages/flutter (#59186)
* add language version 2.8 in packages/flutter

* enable non-nullable analyzer flag
2020-06-11 14:11:30 +02:00
Gary Qian
bef3512d14
DoubleTap recognizer support and improved error message (#56328) 2020-05-06 13:06:02 -07:00
Alexandre Ardhuin
f15c887c63
change quote to avoid escapes (#50368) 2020-02-11 20:58:27 +01:00
Ian Hickson
449f4a6673
License update (#45373)
* Update project.pbxproj files to say Flutter rather than Chromium

Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright.

* Update the copyright notice checker to require a standard notice on all files

* Update copyrights on Dart files. (This was a mechanical commit.)

* Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine.

Some were already marked "The Flutter Authors", not clear why. Their
dates have been normalized. Some were missing the blank line after the
license. Some were randomly different in trivial ways for no apparent
reason (e.g. missing the trailing period).

* Clean up the copyrights in non-Dart files. (Manual edits.)

Also, make sure templates don't have copyrights.

* Fix some more ORGANIZATIONNAMEs
2019-11-27 15:04:02 -08:00
Kate Lovett
1ec44a0c36
Incorporating Link Semantics (#41327) 2019-10-08 18:16:11 -07:00