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
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.
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.
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
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.
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.
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
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.
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.
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.
Using ansi colors in LUCI results in output that looks like:
```
00:00 [32m+0[0m: [1m[90mloading flutter_tester_emulation_golden_test.dart[0m[0m
00:01 [32m+0[0m: [1m[90mloading flutter_tester_emulation_golden_test.dart[0m[0m
00:02 [32m+0[0m: [1m[90mloading flutter_tester_emulation_golden_test.dart[0m[0m
```
This PR disables colors on LUCI so that we get clean output that's easily scannable and searchable.
## 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.
`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.
@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.
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`.
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.
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.
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
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.
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
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.
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
## 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.
## 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.
@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.