2995 Commits

Author SHA1 Message Date
Jackson Gardner
aa7b3fcf98 Only use 8 cores for web test compilation. (flutter/engine#42321) 2023-05-25 19:14:06 +00:00
Dan Field
45c1fe4348 Implement PlatformDispatcher.displays on web (flutter/engine#42297)
I missed this before.
2023-05-25 16:46:58 +00:00
Mouad Debbar
3784b3880f [web] Remove comment about dart:html migration (flutter/engine#42290)
Migration has already happened in [this PR](https://github.com/flutter/engine/pull/33370/files#diff-30cfc07b03caec6d1c915b40a9e50a23d1f1a1c54c670d5996199d805b077daeR213) so the comment is not relevant anymore.
2023-05-24 20:35:15 +00:00
Mouad Debbar
04afaaf25e [web] Hide JS types from dart:ui_web (flutter/engine#42252)
In order to use the exported `PlatformLocation` cross-platform, we need to remove any JS types from the interface. Namely, `DomEventListener`.

Required by https://github.com/flutter/flutter/pull/126851
2023-05-24 20:26:23 +00:00
Ashish Myles
a96b23fa7e [web] Update a11y announcements to append divs instead of setting content. (flutter/engine#42258)
This also removes the appended divs after a short time so that screen readers don't navigate to it, especially when users are entering the DOM to enable accessiblity.

Fixes https://github.com/flutter/flutter/issues/127335.
2023-05-24 20:08:21 +00:00
Mouad Debbar
3a4677a6d7 [web] Cleanup assertionsEnabled (flutter/engine#41829)
For consistency with the rest of the flutter code, this PR explores the possibility of removing our proprietary `assertionsEnabled`.
2023-05-24 15:08:50 +00:00
Brandon DeRosier
58ad391722 [Impeller] Start of Dart GPU prototype (flutter/engine#42228)
I've been slowly hacking on a prototype alongside a doc (public go link [imminent](https://github.com/flutter/website/pull/8716)) for a while (the doc has been changing a lot as a result of prototyping) and I think it's time to start landing parts of this prototype/experiment in-tree.

This initial PR just sets up the main context singleton on the UI thread. After this, I'll land the shader management stuff.

I re-used the existing experimental 3D flag for this, since this is meant to replace what can be done with Impeller Scene anyway.
2023-05-24 04:22:42 +00:00
Jonah Williams
52b5bc5340 Revert "[Impeller] use host image upload path on simulator" (flutter/engine#42212)
Reverts flutter/engine#42161

As reported by uses, this did not help with the issue.
2023-05-23 18:22:47 +00:00
Alexander Aprelev
90ee66eeaa Roll watcher dependency for web_ui to 1.1.0. (flutter/engine#42248)
Incoming dart sdk roll
https://dart.googlesource.com/sdk.git/+log/90b4df96e9dc..4881eadbade6
needs updated version of watcher due to FileSystemEvent becoming sealed.
2023-05-23 09:44:20 -07:00
Mouad Debbar
9aec8c5c62 [web] Move platformViewRegistry to ui_web (flutter/engine#41877)
In this PR, I'm leaving a getter for `platformViewRegistry` in `dart:ui` for backwards compatibility. At some point, we need to properly deprecate it (e.g. print a warning asking users to import it from `dart:ui_web` instead).

Next step is to migrate all call sites in flutter/flutter, flutter/packages and flutter/devtools (anything else?).

Issue: https://github.com/flutter/flutter/issues/126831

Fixes https://github.com/flutter/flutter/issues/41563
2023-05-23 16:17:56 +00:00
Jason Simmons
b4b589148b [Impeller] Return image decoder error messages to the Dart API (flutter/engine#42175)
Fixes https://github.com/flutter/flutter/issues/127061

See https://github.com/flutter/flutter/issues/126768
2023-05-22 20:43:05 +00:00
fzyzcjy
7387859481 Again a two-word super tiny typo (flutter/engine#42181)
Find this when reading source code today...

Btw, what about introducing a spell checker to Flutter source code? ;)

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I signed the [CLA].
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-05-22 13:28:16 -07:00
Jackson Gardner
8812268345 Implement ImageFilter/ColorFilter/MaskFilter in Skwasm (flutter/engine#42088)
This implements https://github.com/flutter/flutter/issues/126342

This implements `ImageFilter`, `ColorFilter` and `MaskFilter` in Skwasm. This includes support on the `Paint` object, as well as the `SceneBuilder` layers that use these types.
2023-05-20 00:46:10 +00:00
htoor3
1046b076ce [web] Fix event offset for transformed widgets (and text input nodes). (flutter/engine#41870)
Text inputs have moved outside of the shadowDOM and are now using the pointer event offset calculation algorithm that platform views use.  However, transforms (e.g. scaling) applied to the input element aren't currently accounted for, which leads to incorrect offsets and clicks being registered inaccurately.

This PR attempts to transform those offset coordinates using the transform matrix data that is included in the geometry information sent over to `text_editing.dart` from the framework.

## Issues

* Fixes https://github.com/flutter/flutter/issues/125948 (text editing)
* Fixes https://github.com/flutter/flutter/issues/126661 (platform view scaling)
* Fixes https://github.com/flutter/flutter/issues/126754

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-19 19:25:58 +00:00
Jonah Williams
edf62bb82b [Impeller] use host image upload path on simulator (flutter/engine#42161)
This might help with https://github.com/flutter/flutter/issues/126768#issuecomment-1554469333
2023-05-19 16:51:51 +00:00
Mouad Debbar
281dea65ad [web] Cleanup Vector3 (flutter/engine#42096)
We have limited use of `Vector3` in the engine, so I converted it into a record and removed almost all of its methods.

Converting it to a record also means it's not mutable anymore, which is a positive in my book. That required a few minor changes in `Matrix4` but nothing major.
2023-05-19 14:05:29 +00:00
Yegor
1811689d04 [web:a11y] support dialogs described by descendants (flutter/engine#42108)
Add a new `RouteName` semantic role for nodes with `namesRoute` set without a `scopesRoute`. Such nodes provide a description for the nearest ancestor dialog node. The web equivalent of this is when an element `role="dialog"` is described by pointing to one of its children using `aria-labelledby` and `aria-describedby`. Here's an example:

```
<div
  role="dialog"
  aria-labelledby="dialog1Title"
  aria-describedby="dialog1Desc">
  <h2 id="dialog1Title">Your personal details were successfully updated</h2>
  <p id="dialog1Desc">
    You can change your details at any time in the user account section.
  </p>
  <button>Close</button>
</div>
```

([Source](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/dialog_role))

Flutter currently does not distinguish between "labelled by" and "described by". In my testing, only `aria-describedby` resulted in an announcement of the dialog's description upon opening. `aria-labelledby` required that the dialog element itself be focusable, which is not the case. So I went with `aria-describedby`.

Fixes https://github.com/flutter/flutter/issues/126030
2023-05-19 00:25:19 +00:00
Mouad Debbar
46598122f7 [web] Simplify handling of custom url strategy (flutter/engine#42043)
Issue: https://github.com/flutter/flutter/issues/126831
2023-05-17 18:27:14 +00:00
Jackson Gardner
9d87a21795 Use client ICU data with skwasm. (flutter/engine#42018)
This implements https://github.com/flutter/flutter/issues/126340

For now, I am keeping this implementation simple without any extra caching. I may add caching later based on profiling results.
2023-05-16 22:07:16 +00:00
Jackson Gardner
d159d6cfc8 Initial support for images in Skwasm (flutter/engine#42019)
This partially implements https://github.com/flutter/flutter/issues/126341

It does not implement image codecs, because they are going to get complicated with transferring video frames to the web worker and so on. I am going to deal with image codecs in a subsequent change.
2023-05-16 18:35:17 +00:00
Jackson Gardner
148b626638 Use new unresolvedCodePoints API from skia. (flutter/engine#41991)
NOTE: this works off of a skia CL that is not merged yet, so we shouldn't merge this until it actually lands in skia and rolls into the engine. See https://skia-review.googlesource.com/c/skia/+/695716
2023-05-16 18:33:12 +00:00
Jason Simmons
6d1e5ca312 Convert public API NativeFieldWrapper classes to abstract interfaces (flutter/engine#41945)
See https://github.com/flutter/flutter/issues/123756
2023-05-16 18:13:07 +00:00
Jackson Gardner
4daa0909c2 Compile skwasm at -Oz. (flutter/engine#42002)
We want to start from a place of small size, and optimize from there with skwasm. Since there is no baseline expectation of performance at `-O3`, let's start with the smallest possible binary.
2023-05-15 19:59:14 +00:00
Kevin Lubick
0946d27add Migrate uses of SkSurface factories (flutter/engine#41978)
In http://review.skia.org/687639, many SkSurface static methods were moved and one was deleted (SkSurface::MakeRasterN32Premul). (SkSurface::MakeNull was omitted accidentally and http://review.skia.org/696537glesource.com/c/skia/+/696537 has not rolled into Flutter yet)

This changes the calls in Flutter to match those moved functions. There should be no functional difference and everything was done pretty mechanically (e.g. find and replace)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-15 16:41:10 +00:00
Mouad Debbar
7b3b362623 [web] Cleaner output on LUCI (flutter/engine#41989)
Using ansi colors in LUCI results in output that looks like:
```
00:00 +0: loading flutter_tester_emulation_golden_test.dart                                                                                                                                            
00:01 +0: loading flutter_tester_emulation_golden_test.dart                                                                                                                                            
00:02 +0: loading flutter_tester_emulation_golden_test.dart
```

This PR disables colors on LUCI so that we get clean output that's easily scannable and searchable.
2023-05-12 21:50:22 +00:00
Bruno Leroux
fea415faa0 [Web+Linux] Fix pressing Meta keys throws (flutter/engine#41694)
## Description

This PR fixes Meta keys throwing exception on Chrome Linux.

The assertions throws because the DOM event sent when Meta keys is pressed is not coherent when Meta is the only pressed key.

## Related Issue

Fixes https://github.com/flutter/flutter/issues/125672

## Tests

Adds 1 test.
2023-05-12 21:46:17 +00:00
Mouad Debbar
e87d7155d2 [web] Fix crash on old versions of Chrome (Intl.Segmenter missing) (flutter/engine#41986)
`Chrome < v87` have the `v8BreakIterator` API but don't have `Intl.Segmenter`. This caused crashes for some apps (see b/281377168).

This PR enhances our feature detection to take into account this API mismatch.
2023-05-12 19:59:30 +00:00
Kevin Lubick
0c3dbe50e1 Use moved SkImage procs (flutter/engine#41947)
Use relocated SkImages context typedefs

In http://review.skia.org/661059, we moved many SkImage related methods, including these typedefs. This updates Flutter to use the moved types.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-11 20:16:54 +00:00
Samuel
3b10a111f4 fix: platform_dispatcher documentation typo (flutter/engine#41739)
fixes [https://github.com/flutter/flutter/issues/126082](https://github.com/flutter/flutter/issues/126082) 

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-11 20:13:47 +00:00
Jackson Gardner
d03ba5aacb Return fonts in a deterministic order. (flutter/engine#41907)
We need to make sure to return fonts in the order we passed them in, so that unit tests don't flake if they load in a different order.
2023-05-11 05:13:03 +00:00
Srujan Gaddam
df4bd5d036 Turn @staticInterop tear-off into closure (flutter/engine#41885)
@staticInterop members will start disallowing tear-offs, so this member should turn into a closure.

The static check wasn't added in time, so this is modifying the source code again.

ee3ce32c7c was the original change, but the static error didn't make it into the Dart SDK, so this is fixing another tear-off.

- [] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests.
2023-05-11 00:18:14 +00:00
Mouad Debbar
9fce37c015 [web] Expose PlatformLocation and HashUrlStrategy through ui_web (flutter/engine#41163)
1. Expose `PlatformLocation` and its subclass `BrowserPlatformLocation` through the new `ui_web`.
2. Expose `HashUrlStrategy` too. It's useful for users who want to extend and customize it instead of building their own from scratch.
3. `ui_web/url_strategy.dart` => `ui_web/navigation/url_strategy.dart`.
2023-05-10 23:57:46 +00:00
Yegor
bdfce08b64 [web] generalize focusability in semantics (flutter/engine#41831)
Introduce 2 new classes for a11y focus management:

* `AccessibilityFocusManager`: a generic class that attaches "focus" and "blur" event handlers, and forwards the events to the framework as `SemanticsAction.didGainAccessibilityFocus` and `SemanticsAction.didLoseAccessibilityFocus` respectively. Provides the `changeFocus` method for the framework to move a11y focus to the target element.
* `Focusable`: a role manager that provides generic focus management functionality to `SemanticsObject`s that don't need anything special.

Rewrites focus management using the above two classes as follows:

* All focusable nodes except text fields and incrementables get the `Focusable` role (all custom focus stuff in `Tappable` was removed and delegated to `Focusable`).
* `Incrementable` uses a custom `<input>` internally and so it cannot use the `Focusable` role. Instead, it uses `AccessibilityFocusManager` to manage the focus on the `<input>` element.

Behavioral changes:

* Fixes https://github.com/flutter/flutter/issues/118737, but more generally fixes all nodes that use the `isFocusable` and `hasFocus` bits.
* `Tappable` only partially implemented focusability (e.g. it didn't generate the respective `SemanticsAction` events). Now by delegating to `Focusable`, it will inherit all the functionality.
* `Incrementable` and `Checkable` (checkboxes, radios, switches) get focus management features for the first time.
* Elements that are not inherently focusable (text, images) can now be focused if semantics requires them to be.
* `TextField` is left alone for now as focus and on-screen keyboard interact with each other in non-obvious ways.
2023-05-10 22:40:20 +00:00
Mouad Debbar
fdb4e5468d [web] Re-enable history tests on Safari (flutter/engine#41901)
Fixes https://github.com/flutter/flutter/issues/51169
2023-05-10 19:58:05 +00:00
Yegor
0e9f0ef05f [web] dialog a11y fixes (flutter/engine#41681)
Fixes two issues in dialog accessibility:

* Fixes https://github.com/flutter/flutter/issues/45207 by setting `role="dialog"` on nodes that have both `scopesRoute` and `namesRoute` set. There's no guarantee that this combination of flags is an actual dialog, but it's close enough, and it makes the screen reader announce the appearance of the dialog. Note that `scopesRoute` alone is not sufficient, because Flutter uses it for overlays that are not semantically dialogs, such as dismiss barriers.
* Fixes an issue with focus management, where focus fails to transfer to background content after the dialog is dismissed. This happened because `EngineSemanticsOwner._semanticsTree` retained descendants of parents that were removed. This is benign in many cases. However, for focus this is problematic because the HTML element can go away and come back (losing focus along the way), but its corresponding `SemanticsObject` is never marked as "dirty" and fails to update and request focus.

I'm hoping this is sufficient to fix b/251839784 as well. Will work with the relevant team to find out.
2023-05-10 05:02:22 +00:00
Jackson Gardner
3c85b2e565 Implement text rendering in Skwasm (flutter/engine#41832)
This implements full text rendering with the Skwasm renderer.

The font fallback logic has been refactored to decouple the font fallback manager from any CanvasKit-specific types and functions.

A chunk of CanvasKit text rendering tests have been ported over to the renderer-agnostic `ui` tests.

Fixes https://github.com/flutter/flutter/issues/126339
2023-05-09 23:37:21 +00:00
Jackson Gardner
5c98a397a2 Get rid of "outrageous" default text styles for HTML renderer. (flutter/engine#41822)
The CanvasKit renderer doesn't do this, so we should just remove the red text global style.
2023-05-08 22:59:21 +00:00
Jackson Gardner
16360e9e25 Reland "Skwasm Font Loading (flutter/engine#41756)
This relands https://github.com/flutter/engine/pull/41246, which had to be reverted due to some issues parsing the font manifest.
2023-05-08 18:17:22 +00:00
Michael Goderbauer
43516df2d1 Fix doc to fix engine roll (flutter/engine#41812)
The engine roll is currently failing (https://cirrus-ci.com/task/5475027185827840?logs=main#L172) because of a doc issue introduced by https://github.com/flutter/engine/pull/41685. This fixes the doc issue.
2023-05-08 10:57:19 +00:00
Dan Field
ea5131772d Add a Display API to dart:ui that reports the physical size, DPR, and refresh rate of the main display (flutter/engine#41685)
Fixes https://github.com/flutter/flutter/issues/123307 - for Android, iOS, and Web, for the main display only (https://github.com/flutter/flutter/issues/125938 tracks supporting multiple displays, https://github.com/flutter/flutter/issues/125939 for desktop).

Desktop will need to be implemented for this, but given priority for a couple of our customers targetting foldable devices on Android I'm inclined to get this in before desktop can be finished.

The main concern for this right now is that on some Android foldable devices, setting a preferred orientation will cause letterboxing and the `MediaQuery` will _never_ get the full screen size when unfolded. This causes apps to think the screen is smaller than it is, as they've mainly been using `MediaQueryData.size` to figure this out. Android's recommendation is to not set a preferred orientation, and if you must to use the new method introduced in `ViewUtil.java` to calculate the maximal window size.
2023-05-06 18:28:22 +00:00
Tong Mu
05036058d7 Remove single window assumption from SceneBuilder (flutter/engine#41559)
This PR fixes https://github.com/flutter/flutter/issues/112202. `Scene`
is no longer tied to views, but receives method arguments for view
properties, clearing the path to multiview Flutter.

`Scene` no longer creates a `LayerTree` on construction, but only part
of the config. When a output method is called (`toImage`, `toImageSync`,
or `takeLayerTree`), the `LayerTree` is constructed on the spot. In this
way, all `LayerTree`s return to being `unique_ptr`s instead of
`shared_ptr`s, reverting part of
https://github.com/flutter/engine/pull/35608 . And `Scene` no longer
needs to disfunction after one `takeLayerTree`, since the layer tree
config is never really taken away.

A `device_pixel_ratio` is now added to the parameter list of `Engine::Render` and `Animator::Render`.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [ ] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-05-05 11:25:55 -07:00
Jackson Gardner
f2970b73b0 Revert "Skwasm Font Loading" (flutter/engine#41750)
Reverts flutter/engine#41246

The new font manifest parsing fails in some cases.
2023-05-04 23:54:18 +00:00
Jackson Gardner
6f5ad9737e Skwasm Font Loading (flutter/engine#41246)
This implements font loading for the skwasm renderer.

In addition, it does some pretty major refactors:
1) Simplified the font collection interface to just have a single `loadAssetFonts` call, without the separate registration and debug fonts loading stuff
2) Debug fonts load now through http/asset mocking mechanisms instead of having a separate `downloadDebugTestFonts` call
3) Consolidated a few of our different unit test setup functions into a single `setUpUnitTests` function
2023-05-04 18:22:53 +00:00
Jackson Gardner
5189eda98b Populate fallback fonts from CIPD in tests (flutter/engine#41656)
This fixes https://github.com/flutter/flutter/issues/85793

The script that generates the font fallback data also rolls a package to CIPD with these files and updates the DEPS to download those files from CIPD. This makes sure that these tests are hermetic.
2023-05-04 05:12:54 +00:00
Jonah Williams
dfff522046 Remove physical model layer (flutter/engine#41593)
Removes the physical model layer and associated engine code. This was already deprecated and removed in the framework. By removing it in the engine, we can also remove the need for layer tree diff/paint/preroll to have the device pixel ratio. This will simplify some of the multi-view work

Fixes https://github.com/flutter/flutter/issues/125720
2023-05-03 20:28:53 +00:00
Greg Spencer
18125adcfc Reland: "Determine lifecycle by looking at window focus also" (#41094) (flutter/engine#41702)
## Description

This reverts commit e49577708d9d5315fa6c001d7dc20ee80d04cd35 to re-land #41094 because the Google test failures have been fixed. There are no changes to the original PR, since the fixes were in the Google code.
2023-05-03 19:21:58 +00:00
Mouad Debbar
9ed3f6008e [web] Improve null safety for color->css (flutter/engine#41699)
Turning `colorToCssString` into an extension method on `ui.Color` improves null safety and developer ergonomics.
2023-05-03 18:15:04 +00:00
Mouad Debbar
9cb01b94d5 [web] Remove unused function parameter (flutter/engine#41700)
The `hasAutofillOverlay` and `cssSelectorPrefix` parameters aren't really used in any useful way. Let's remove them.
2023-05-03 17:57:21 +00:00
Bruno Leroux
d56b8bee57 Web - Fix selection jump on Chrome for Android (flutter/engine#41202)
## Description

This PR fixes cursor jump on Chrome for Android when the user taps in a multiline `TextField`.

Using the following code sample:

<details><summary>Code sample</summary>

```dart

import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Text Field Focus',
      home: MyCustomForm(),
    );
  }
}

// Define a custom Form widget.
class MyCustomForm extends StatelessWidget {
  const MyCustomForm({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Text Field Focus'),
      ),
      backgroundColor: Colors.amber,
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: TextField(
          decoration: const InputDecoration(
            fillColor: Colors.white,
            filled: true
          ),
          autofocus: true,
          maxLines: 3,
          controller: TextEditingController(text: '1\n2\n3\n4\n'),
        ),
      ),// This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

```
</details>

On a mobile browser, once the page is loaded, tap after the number 3: 

- Before this PR: the TextField content is automaticaly scrolled and the selection is set after number 1.

https://user-images.githubusercontent.com/840911/232051413-b913f890-6cb1-4c60-92d0-7a3bf74cc688.mov

## Implementation

A multiline `TextField` relies on an HTML `<textarea>` elements. When a tap occurs the selection should be updated from Flutter not by the HTML element itself. 
This PR prevents mouse events on Chrome for Android. Those events conflicts with Flutter selection changes.
Previously, mouse events were only prevented on desktop but they are also emitted on mobile, see https://bugs.chromium.org/p/chromium/issues/detail?id=119216#c11.

## Related Issue

Related to https://github.com/flutter/flutter/issues/124483 (partial fix because the issue is also reproducible on iOS/Safari).

## Tests

Adds 1 test.
2023-05-02 19:34:35 +00:00
Srujan Gaddam
08ab47dddf Turn @staticInterop tear-off into closure (flutter/engine#41643)
@staticInterop members will start disallowing tear-offs, so this member
should turn into a closure.

Unblocks a roll in the SDK that disallows tear-offs.

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I signed the [CLA].
- [X] All existing and new tests are passing.
2023-05-01 16:18:32 -07:00