3599 Commits

Author SHA1 Message Date
Jackson Gardner
e2b3f88cac [skwasm] Fix platform view placement. (flutter/engine#53845)
Previously, each platform view contained styling/placement information from the entire stack of the layer builder. This caused issues when using `addRetained`, since it would contain stale styling/placement information from its old parent layers. I have changed it so that platform views only contain local styling information, and that styling is combined with the parent only when the layers are merged.
2024-07-12 21:55:19 +00:00
Juanjo Tugores
93de0249f9 Relax the event assumptions for keydown events. (flutter/engine#53830)
This PR addresses an issue where autocompleting a text field, even without direct keyboard input, unexpectedly triggers keydown events. To resolve this, the code now relaxes the casting assumptions to accommodate a wider range of event types, not just keyboard events.

By just adding the following script to the console, and filling the text field using autocomplete, you can see that indeed the fired event is not of type `KeyboardEvent` but `Event`. 

```javascript
document.body.addEventListener('keydown', console.log)
```

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

*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
2024-07-12 17:54:55 +00:00
Jason Simmons
604637e41f Manual roll Dart SDK from fb546f313557 to 797d3df745d1 (8 revisions) (flutter/engine#53832)
Includes patches needed for the dart:concurrent package (see https://dart.googlesource.com/sdk/+/d2bc055651cf62c549933ed379d6b23d84a07598)

Manual roll requested by jsimmons@google.com

https://dart.googlesource.com/sdk.git/+log/fb546f313557..797d3df745d1

2024-07-11 dart-internal-merge@dart-ci-internal.iam.gserviceaccount.com Version 3.6.0-34.0.dev 2024-07-11 dart-internal-merge@dart-ci-internal.iam.gserviceaccount.com Version 3.6.0-33.0.dev 2024-07-11 dart-internal-merge@dart-ci-internal.iam.gserviceaccount.com Version 3.6.0-32.0.dev 2024-07-11 dart-internal-merge@dart-ci-internal.iam.gserviceaccount.com Version 3.6.0-31.0.dev 2024-07-11 dart-internal-merge@dart-ci-internal.iam.gserviceaccount.com Version 3.6.0-30.0.dev 2024-07-11 dart-internal-merge@dart-ci-internal.iam.gserviceaccount.com Version 3.6.0-29.0.dev 2024-07-11 dart-internal-merge@dart-ci-internal.iam.gserviceaccount.com Version 3.6.0-28.0.dev 2024-07-11 dart-internal-merge@dart-ci-internal.iam.gserviceaccount.com Version 3.6.0-27.0.dev

If this roll has caused a breakage, revert this CL and stop the roller using the controls here:
https://autoroll.skia.org/r/dart-sdk-flutter-engine Please CC bdero@google.com,dart-vm-team@google.com,jsimmons@google.com on the revert to ensure that a human is aware of the problem.

To file a bug in Flutter Engine: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
2024-07-12 01:28:10 +00:00
Pavel Mazhnik
d809a1db38 [web] retrieve hostElement for an implicit view (flutter/engine#53296)
This PR updates `ui_web.views.getHostElement` API to also return `hostElement` for implicit view.

Resolves https://github.com/flutter/flutter/issues/150075
2024-07-11 22:15:20 +00:00
Jonah Williams
ac871bacc2 [dart:ui] remove expensive index assertion in Vertices. (flutter/engine#53558)
Iterating through every index value is really, really expensive. Especially if users are suppllying hundreds of thousands of vertices.
2024-07-11 22:13:04 +00:00
Srujan Gaddam
b33b900e77 Remove casts for toDartObject (flutter/engine#53621)
ExternalDartReference is now generic, so we can just type it and
toDartObject will do the cast for us if needed. Also removes now-stale
ignores.
2024-07-10 15:47:39 -07:00
Jackson Gardner
76caabd2c4 Reland (x2) "Output .js files as ES6 modules. (flutter#52023)" (flutter/engine#53718)
Second attempt to reland https://github.com/flutter/engine/pull/52023

Fixes since the previous reland attempt:
* We need to pass the skwasm main JS URI when loading the module so that it can pass that along to the worker. Since the worker uses the workaround to allow a cross script worker, it has trouble locating the main JS URI in relation to itself in a way that actually works for dynamic imports, so passing it along fixes that issue.
* Some of the Google3 tests relied on the relative default canvaskit path. Dynamic module imports seems to not handle relative paths the way we expect, so we do our own URL resolution using the URL constructor before passing it into the dynamic import API. Also cleaned up some of the other relative pathing stuff that we do around the base URI. in flutter.js
2024-07-10 16:19:28 +00:00
auto-submit[bot]
5a218a1b99 Reverts "dart:ui - drop deprecated hash functions (#53787)" (flutter/engine#53794)
Reverts: flutter/engine#53787
Initiated by: jiahaog
Reason for reverting: There are still internal users of these hash functions (b/352191023). Flutter also exports it [here](72f83d3237/packages/flutter/lib/src/painting/basic_types.dart (L58)) so its easy for developers to use them even without importing `dart:ui`. Though it's an easy fix, I'd imagine this to be a breaking change for the OSS ecosystem a
Original PR Author: kevmoo

Reviewed By: {jonahwilliams}

This change reverts the following previous change:
These were deprecated a LONG time ago
2024-07-10 03:16:50 +00:00
auto-submit[bot]
6b738ccea4 Reverts "web_ui: drop internal hash code library (#53783)" (flutter/engine#53793)
Reverts: flutter/engine#53783
Initiated by: jiahaog
Reason for reverting: There are still internal users of these hash functions (b/352191023). Flutter also exports it [here](72f83d3237/packages/flutter/lib/src/painting/basic_types.dart (L58)) so its easy for developers to use them even without importing `dart:ui`. Though it's an easy fix, I'd imagine this to be a breaking change for the OSS ecosystem a
Original PR Author: kevmoo

Reviewed By: {yjbanov}

This change reverts the following previous change:
We moved to dart:core Object functions a while ago
2024-07-10 03:16:48 +00:00
John McDole
ea09bae632 Impeller really wants premultiplied alpha (flutter/engine#53770)
Fixes flutter/flutter#151210 by premultiplying alpha in the rare case we
get straight alpha.
2024-07-09 17:07:31 -07:00
Kevin Moore
3ac0cca053 dart:ui - drop deprecated hash functions (flutter/engine#53787)
These were deprecated a LONG time ago
2024-07-09 23:50:06 +00:00
Kevin Moore
7c90831f07 web_ui: drop internal hash code library (flutter/engine#53783)
We moved to dart:core Object functions a while ago
2024-07-09 21:52:28 +00:00
Yegor
b75d1ddcac [web] use semantic tags for headings (h1, h2, etc), and fix missing secondary roles (flutter/engine#53703)
Switch to using semantic heading tags (h1, h2, etc).

Fix missing secondary roles: focus, live region, route name, and label.
Improves indexability (https://github.com/flutter/flutter/issues/46789)
2024-07-05 17:59:22 +00:00
auto-submit[bot]
a918c608b8 Reverts "fix: mask disappeared when having nested mask filter on Flutter web HTML (#45166)" (flutter/engine#53725)
Reverts: flutter/engine#45166
Initiated by: jiahaog
Reason for reverting: This commit seems to cause the debug banner of a material app to be unnecessarily blurred. For example, one of the tests runs the following flutter app:

<details>

<summary>Code</summary>

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Materia
Original PR Author: Kingtous

Reviewed By: {yjbanov, harryterkelsen}

This change reverts the following previous change:
Hi from [Dora team](https://www.dora.run/), which powers web developers to build their 3d websites in just a few seconds.

This PR fixes: https://github.com/flutter/flutter/issues/133443, related: https://github.com/flutter/flutter/issues/58546

The original codes attempts to cache the css string but it causes bugs when encountering nested the same mask filter blur. We should also set `filter` properties when currentFilter == incoming mask filter using the cached css string, not just ignore it. 

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-07-04 07:04:25 +00:00
Yegor
a314952184 [web] ignore pointer events on plain text spans (flutter/engine#53694)
A semantic node may be tappable without having a more concrete role set on it, such as "button". It will just have a tap handler. This could lead to the sized span to be chosen as the label representation. However, when pointer events land on the span the DOM `target` becomes the span rather than the tappable element, and that breaks the debouncing logic in `pointer_binding.dart`.

This PR removes pointer event handling from inert text spans. This fixes the click debounce logic.

Fixes https://github.com/flutter/flutter/issues/151265
2024-07-03 22:00:05 +00:00
Mouad Debbar
5fb88851d5 Add Semantics Property linkUrl (flutter/engine#53507)
The new property allows the user to specify a URI for their semantics link node. It's plumbed through for both web and non-web engines, but it's only used in the web engine currently. It sets the `href` of the anchor element associated with semantics node.

This is going to unlock better semantics support in the Link widget on web ([PR](https://github.com/flutter/packages/pull/6711)).

Framework counterpart: https://github.com/flutter/flutter/pull/150639

Part of https://github.com/flutter/flutter/issues/150263
2024-07-03 21:12:26 +00:00
Kingtous
2ee4fd4317 [Flutter Web(HTML)] fix: shader mask is painted incorrectly on shared offscreen canvas (flutter/engine#44998)
Hi from [Dora team](https://www.dora.run/), which powers web developers to build their 3d websites in just a few seconds.

This PR fixes https://github.com/flutter/flutter/issues/133134.

The size of the shared canvas should not only be updated if both width and height are not the same.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-07-03 18:22:59 +00:00
Kingtous
86642a856c fix: mask disappeared when having nested mask filter on Flutter web HTML (flutter/engine#45166)
Hi from [Dora team](https://www.dora.run/), which powers web developers to build their 3d websites in just a few seconds.

This PR fixes: https://github.com/flutter/flutter/issues/133443, related: https://github.com/flutter/flutter/issues/58546

The original codes attempts to cache the css string but it causes bugs when encountering nested the same mask filter blur. We should also set `filter` properties when currentFilter == incoming mask filter using the cached css string, not just ignore it. 

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-07-03 18:22:56 +00:00
auto-submit[bot]
607d1e1bb5 Reverts "Reland "Output .js files as ES6 modules. (#52023)" (#53688)" (flutter/engine#53709)
Reverts: flutter/engine#53688
Initiated by: jiahaog
Reason for reverting: canvaskit.js cannot be loaded in an internal end to end test - see b/350885206
Original PR Author: eyebrowsoffire

Reviewed By: {ditman}

This change reverts the following previous change:
This is an attempt to reland https://github.com/flutter/engine/pull/52023. The issue previously is that if it was not specified by the user, the default CanvasKit base URL did not have a leading slash, which does not work when doing dynamic imports.
2024-07-03 08:39:47 +00:00
Jackson Gardner
18d37a44f5 Reland "Output .js files as ES6 modules. (#52023)" (flutter/engine#53688)
This is an attempt to reland https://github.com/flutter/engine/pull/52023. The issue previously is that if it was not specified by the user, the default CanvasKit base URL did not have a leading slash, which does not work when doing dynamic imports.
2024-07-03 00:56:13 +00:00
Jia Hao
1306b98121 Revert "[web] switch from .didGain/LoseAccessibilityFocus to .focus" (flutter/engine#53679)
Reverts flutter/engine#53360

Breaking google3 in b/350131288.

There is a test that does something like the following, to check if a radio button is selected.

```dart
      // Send a bunch of tabs to focus on the correct radio button
      await tester.sendKeyEvent(LogicalKeyboardKey.tab);
      await tester.pump();
      await tester.sendKeyEvent(LogicalKeyboardKey.tab);
      await tester.pump();
      await tester.sendKeyEvent(LogicalKeyboardKey.tab);
      await tester.pump();

      // Toggle the radio button with space
      await tester.sendKeyEvent(LogicalKeyboardKey.space);
      await tester.pump();

      final selectedRadio =
          tester.widget<Radio<bool>>(find.byType(Radio<bool>).at(1));
      expect(selectedRadio.value, isTrue);
```

After this commit, the above test fails. See the linked bug above for more details.
2024-07-02 17:02:06 +00:00
auto-submit[bot]
10ed9bfd7a Reverts "Output .js files as ES6 modules. (#52023)" (flutter/engine#53674)
Reverts: flutter/engine#52023
Initiated by: eyebrowsoffire
Reason for reverting: Causing issues in engine -> framework roll https://github.com/flutter/flutter/pull/151139
Original PR Author: eyebrowsoffire

Reviewed By: {ditman}

This change reverts the following previous change:
This changes CanvasKit and Skwasm to be compiled and loaded as ES6 modules instead of as vanilla script tags. Currently, the emscripten JS files try to register themselves with require.js or AMD module loading systems. We suspect this is causing issues (https://github.com/flutter/flutter/issues/149565) with DDC's module loading system, which itself uses require.js.

This is probably also the fix for https://github.com/flutter/flutter/issues/147731
2024-07-01 23:19:48 +00:00
Jackson Gardner
c91612ce11 Output .js files as ES6 modules. (flutter/engine#52023)
This changes CanvasKit and Skwasm to be compiled and loaded as ES6 modules instead of as vanilla script tags. Currently, the emscripten JS files try to register themselves with require.js or AMD module loading systems. We suspect this is causing issues (https://github.com/flutter/flutter/issues/149565) with DDC's module loading system, which itself uses require.js.

This is probably also the fix for https://github.com/flutter/flutter/issues/147731
2024-07-01 20:17:17 +00:00
David Iglesias
1b37c5441c [web] Fixes drag scrolling in embedded mode. (flutter/engine#53647)
When Flutter web runs embedded in a page, scrolling by dragging is interrupted very early by the browser.

It turns out that our `pointer` events receive a `pointercancel` + `pointerleave` by the browser because they happen in an area (the flutter glasspane) that is not really scrollable. [See documentation](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointercancel_event).

  > [!NOTE]
  > After the pointercancel event is fired, the browser will also send [pointerout](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerout_event) followed by [pointerleave](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerleave_event).

(Firefox is a good browser to test this, because the browser will cancel our events **only if there's scrollable areas around the embedded flutter app**.)

There's several solutions, but one of them (used by PixiJS as well) is to cancel the `touchstart` event that fires with the `pointerdown` event.

(This PR also removes an unnecessary call to `addEventListener` in the `Listener` helper class, and adds some testing to it).

## Testing

* Added a happy case test for the fix (preventDefault on 'touchstart' events)
* Deployed demo app here: https://dit-multiview-scroll.web.app

## Issues

* Fixes https://github.com/flutter/flutter/issues/138985
* Fixes https://github.com/flutter/flutter/issues/146732
* Related to https://github.com/flutter/flutter/issues/139263

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-06-29 03:47:25 +00:00
Yegor
c5a8a826ef [web] switch from .didGain/LoseAccessibilityFocus to .focus (flutter/engine#53360)
This is a repeat of https://github.com/flutter/engine/pull/53134, which was merged prematurely.

> [!WARNING]  
> Only land this after:
> * https://github.com/flutter/flutter/pull/149840 lands in the framework.
> * You have personally manually tested the change together with the latest framework on all browsers.

## Original PR description

Stop using `SemanticsAction.didGain/LoseAccessibilityFocus` on the web, start using `SemanticsAction.focus`. This is because on the web, a11y focus is not observable, only input focus is. Sending `SemanticsAction.focus` will guarantee that the framework move focus to the respective widget. There currently is no "unfocus" signal, because it seems to be already covered: either another widget gains focus, or an HTML DOM element outside the Flutter view does, both of which have their respective signals already.

More details in the discussion in the issue https://github.com/flutter/flutter/issues/83809.

Fixes https://github.com/flutter/flutter/issues/83809
Fixes https://github.com/flutter/flutter/issues/148285
Fixes https://github.com/flutter/flutter/issues/143337
2024-06-28 21:35:10 +00:00
Srujan Gaddam
554e637a35 Ignore lints that will be triggered by ExternalDartReference changes (flutter/engine#53572)
https://dart-review.googlesource.com/c/sdk/+/370663 makes
ExternalDartReference generic. By doing so, it triggers two
cast_nullable_to_non_nullable lints that need to be silenced for it to
land. Once the above SDK changes land, this can be refactored to utilize
the generic and avoid the manual cast altogether.
2024-06-26 09:32:08 -07:00
Jackson Gardner
8ab7c5d6e9 [skwasm] Fixes for getting pixels from an image. (flutter/engine#53561)
There were two issues here:

1) We have to stop using the emscripten thread scheduling APIs, as they can be invoked out of order from the rest of the messages that are posted. In some cases, out of order message handling can cause the request for reading pixels in an image to be serviced before some of the texture sources have been transfered to the web worker.

2) Skia's `readPixels` fails if there is is a lazy picture image made from a picture that contains a lazy texture image. The pertinent bug is here: https://g-issues.skia.org/issues/349201915

To work around the Skia bug, we just render the image itself onto our scratch canvas and pull the pixels out with `glReadPixels`.

This fixes https://github.com/flutter/flutter/issues/141326
2024-06-25 18:11:11 +00:00
Jason Parrott
384f44cafc fix: web canvaskit fragment shaders were not using updated uniform values (flutter/engine#53246)
This fixes an issue where in CanvasKit builds, uniforms set in setFloat function in the Paint class don't get updated after the initial render.
For example, like in the issue linked below, having a shader that animates a value over time and you want to reuse the Paint object that the shader is set to.

I'm no expert with CanvasKit nor with the Flutter Engine, but from what I could tell it seemed that the uniforms were only being sent to Skia on creation of the shader via _makeEffect.

However, any uniforms set afterwords were just stored in a local dart-side List<double> and forgotten about.

This PR changes the List<double> to use a WASM backed SkFloat32List to keep the references to the uniforms linked to dart-side.

fixes https://github.com/flutter/flutter/issues/149800
2024-06-25 17:59:24 +00:00
Jim Graham
34bb05029e [DisplayList] Switch to recording DrawVertices objects by reference (flutter/engine#53548)
The Vertices objects are already allocated in a shared object by default so copying them inline into the recording buffer is usually a waste of time rather than reusing the memory allocated for the shared object by recording a reference. Note that the shared DlVertices objects already inline all of their data so we have good data locality as it is without further copying the data into the buffer.

Might help with https://github.com/flutter/flutter/issues/150513
2024-06-25 17:41:14 +00:00
Mouad Debbar
2d762001d3 [web] Implement AppLifecycleState.detached as documented (flutter/engine#53506)
Currently, we are transitioning to the `AppLifecycleState.detached` incorrectly. This is causing the framework to stop pumping frames when the app is still active and visible.

This PR re-implements the transition to `AppLifecycleState.detached` as documented [here](https://api.flutter.dev/flutter/dart-ui/AppLifecycleState.html#detached) (based on whether the app has any views or not).

Fixes https://github.com/flutter/flutter/issues/150636
Fixes https://github.com/flutter/flutter/issues/149417
2024-06-25 14:14:17 +00:00
David Iglesias
0131b53f3c [web] Reland "Fix focus management for text fields (#51009)" (flutter/engine#53537)
Relands: [**Fix focus management for text fields** (#51009)](https://github.com/flutter/engine/pull/51009) by:

* Reverting commit: 249de68438 (https://github.com/flutter/engine/pull/53502).
* Keeping the new `ViewFocusBinding` disabled, as [suggested](https://github.com/flutter/engine/pull/51009#discussion_r1649500122).

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-06-24 22:15:11 +00:00
Chris Bracken
ab3c5ba987 [macOS] Generate universal gen_snapshots (flutter/engine#53524)
This reverts commit b16181fe6adf18f448058fd4e68ceb4f78f601ab (#52913).
This relands commit f73900ba16ab3873c7f631ab321d4f0ac0194a8e (#52885).

Previously, the `gen_snapshot_arm64` and `gen_snapshot_x64` binaries used by the tool were all built for x64 architecture. As such, developers building apps with Flutter rely on Rosetta translation with every build.

This refactors the gen_snapshot build rules on macOS hosts to consistently produce `gen_snapshot_arm64` and `gen_snapshot_x64` binaries with the target architecture of the build but with as universal binaries with both host architectures.

## arm64 host build

Prior to this patch we emitted:
* gen_snapshot_arm64 (arch: x64, target_arch: simarm64)

After this patch, we emit:
* artifacts_x64/gen_snapshot_arm64 (arch: x64, target_arch: simarm64)
* artifacts_arm64/gen_snapshot_arm64 (arch: arm64, target_arch: arm64)
* gen_snapshot_arm64 (universal binary composed of both of the above)

## x64 host build

Prior to this patch we emitted:
* gen_snapshot_x64 (arch: x64, target_arch: x64)

After this patch, we emit:
* artifacts_x64/gen_snapshot_x64 (arch: x64, target_arch: x64)
* artifacts_arm64/gen_snapshot_x64 (arch: arm64, target_arch: simx64)
* gen_snapshot_x64 (universal binary composed of both of the above)

Note that host builds on macOS currently default to a host architecture of x64 (can be overridden via `--force-mac-arm64`) regardless of host architecture and thus, the build itself relies on Rosetta translation when invoked on Apple Silicon arm64 hardware. This is to ensure a consistent build in CI regardless of bot architecture. See: 0d2b0cd0ed/tools/gn (L502-L505)

Issue: https://github.com/flutter/flutter/issues/101138
Issue: https://github.com/flutter/flutter/issues/69157

Related issue: https://github.com/flutter/flutter/issues/103386

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-06-24 22:01:09 +00:00
Jenn Magder
e517aa1ce2 Run safari-dart2js-html tests on macOS 13 (flutter/engine#53497)
https://github.com/flutter/engine/pull/53402 didn't work. Run these Safari tests on macOS 13 only until it can be fixed for macOS 14.
2024-06-21 20:50:57 +00:00
jezell
d1e6ca839c Add createImageFromTextureSource method to ui_web (flutter/engine#53483)
Adds createImageFromTextureSource for flutter web, exposed in dart:web_ui.

```dart
final ui.Image uiImage = renderer.createImageFromTextureSource(bitmap,
            width: 150, height: 150, transferOwnership: false);
```

In canvaskit renderer, this will use MakeLazyImageFromTextureSource. In SkWasmRenderer, it will call imageCreateFromTextureSource, which was already implemented in SkWasm for createImageFromImageBitmap to use, but was not exposed in a way that it could be taken advantage of.

By default, createImageFromTextureSource will create a copy of the object it is passed, but transferOwnership: true may be specified to allow transferable objects to be transferred to the renderer, avoiding the copy.

Fixes: https://github.com/flutter/flutter/issues/150479
Fixes: https://github.com/flutter/flutter/issues/144815
2024-06-21 20:28:55 +00:00
auto-submit[bot]
249de68438 Reverts "Fix focus management for text fields (#51009)" (flutter/engine#53502)
Reverts: flutter/engine#51009
Initiated by: jiahaog
Reason for reverting: This causes b/348598454. We're getting test failures with stack traces like the following after this PR:

```
Cannot get renderObject of inactive element.
In order for an element to have a valid renderObject, it must be active, which means it is part of the tree.
Instead, this element is in the _ElementLifecycle.inactive state.
If you called this method from a State object, consider guarding
```

Original PR Author: tugorez

Reviewed By: {mdebbar}

This change reverts the following previous change:
Fix focus management for text fields

This PR:

1. Refactors the DOM `focus` function to take [options][1]
2. Removes the timers sorrounding the `activeDomElement.focus()` so that the input elements get focused as immediate as possible.
3. Prevents the default on pointerdown in a Flutter View and schedules a `requestViewFocusChange` to claim focus in that view after some time. This gives `2` the opportunity to focus the right `<input />` or `<textarea />` element. This helps focus correctly transition from one input element to another (without jumping to a flutter view in between).
4. Deactivating a `TextField` doesn't blur the focused element anymore, it insteads schedules for later a call to move the focus to the flutter view if nothing inside it claimed focus first.
5. Prevents scroll in all the focus calls (this should help with the view jumping when focusing one text field after another).

## Sample apps

1. Full screen mode: https://tugorez.com/flutter_focus_web
2. Embedded mode: https://tugorez.com/flutter_focus_web?embedded

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-06-21 12:56:47 +00:00
Mouad Debbar
00389408cd [web] Add 'flt-semantics-identifier' attribute to semantics nodes (flutter/engine#53278)
Make [`Semantics(identifier: '...')`](https://api.flutter.dev/flutter/semantics/SemanticsProperties/identifier.html) useful on the web. This PR plugs the Semantics `identifier` property as an HTML attribute `semantics-identifier` onto semantics elements.

This is useful in some scenarios:
- In testing to check if a certain semantics node has made it to the page ([example](https://github.com/flutter/flutter/issues/97455)).
- In apps and/or packages to be able to lookup the DOM element that corresponds to a certain semantics node ([example](https://github.com/flutter/packages/pull/6711)).

Fixes https://github.com/flutter/flutter/issues/97455
2024-06-20 23:23:15 +00:00
Mouad Debbar
33e1bcf96f [web] Don't add href="#" to semantics links (flutter/engine#53395)
This is a stopgap for issues like https://github.com/flutter/flutter/issues/146291 until we land better link semantics (in https://github.com/flutter/flutter/issues/150263 and https://github.com/flutter/packages/pull/6711). For the time being, the `href="#"` isn't providing any extra value, and is causing the browser to navigate to to `#` whenever the semantics link is clicked, which is undesirable.

Fixes https://github.com/flutter/flutter/issues/146291
2024-06-20 23:21:36 +00:00
Bruno Leroux
481f292371 [Web] Fix extra new line when inputAction is not newline for a multil… (flutter/engine#53453)
## Description

This PR prevents new line key event from being dispatched for a multiline text field when `TextField.textInputAction` is not `TextInputAction.newline`.

Since https://github.com/flutter/engine/pull/33428, web engine does not prevent new line key events.
In https://github.com/flutter/engine/pull/36893, I fixed a similar issue for single line text fields. At that time I was not sure if we want to fix it for multiline text fields. I checked again on non-web platforms (macos, iOS, Android) and the new line is not added if the input action is not `TextInputAction.newline`.

For a **multiline field**, the default text input action is `TextInputAction.newline`.
If the developer sets text input action to another value:
- before this PR, the action is performed and a new line is added.
- after this PR, the action is performed but no new line is added.

## Related Issue

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

## Tests

Adds 1 tests, updates 3 tests.
2024-06-20 19:21:47 +00:00
Juanjo Tugores
b1469d7ed7 Fix focus management for text fields (flutter/engine#51009)
Fix focus management for text fields

This PR:

1. Refactors the DOM `focus` function to take [options][1]
2. Removes the timers sorrounding the `activeDomElement.focus()` so that the input elements get focused as immediate as possible.
3. Prevents the default on pointerdown in a Flutter View and schedules a `requestViewFocusChange` to claim focus in that view after some time. This gives `2` the opportunity to focus the right `<input />` or `<textarea />` element. This helps focus correctly transition from one input element to another (without jumping to a flutter view in between).
4. Deactivating a `TextField` doesn't blur the focused element anymore, it insteads schedules for later a call to move the focus to the flutter view if nothing inside it claimed focus first.
5. Prevents scroll in all the focus calls (this should help with the view jumping when focusing one text field after another).

## Sample apps

1. Full screen mode: https://tugorez.com/flutter_focus_web
2. Embedded mode: https://tugorez.com/flutter_focus_web?embedded

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-06-20 17:51:50 +00:00
Jim Graham
7f44004e56 [DisplayList] delete obsolete PathEffect sources (flutter/engine#53441)
As of https://github.com/flutter/engine/pull/53411 there are no more (non-test) references to path effects anywhere in the engine.

Deleting the dead code.
2024-06-18 07:45:01 +00:00
Jason Simmons
50586aac61 Manual roll of Dart SDK from e90b0a53e058 to dca20ab646c5 (flutter/engine#53410)
Updates dart2wasm invocation to add the --enable-experimental-wasm-interop flag.

(see https://dart.googlesource.com/sdk/+/6f21d19b02eb82c0b44b01dbdb21ec7a17e17120)
2024-06-15 00:52:56 +00:00
Jason Simmons
285c718c82 Roll web_ui dependencies to enable the next roll of the Dart SDK (flutter/engine#53399)
Dart has removed the UnmodifiableXXXView classes, which were used by older versions of the archive package.

See https://dart.googlesource.com/sdk/+/18994e6e46ec9fb2fac8368c43d448119abd579f
2024-06-14 20:52:04 +00:00
Jackson Gardner
5dd33ba48e Hack to prevent Safari from being backgrounded during unit tests. (flutter/engine#53402)
Safari actually pauses execution of our unit tests if the window becomes occluded or non-visible. As such, I am inserting this egregious hack which just makes the Safari window frontmost every 2 seconds so that the unit tests don't get stalled out.

This should fix https://github.com/flutter/flutter/issues/150023
2024-06-14 20:18:32 +00:00
gaaclarke
41f2a43998 [Impeller] makes bgra10xr test more comprehensive (flutter/engine#53320)
fixes https://github.com/flutter/flutter/issues/149946

depends on:
- https://skia-review.googlesource.com/c/skcms/+/864516
- https://skia-review.googlesource.com/c/skia/+/864536

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-06-11 22:34:19 +00:00
Yegor
c3f77aa187 Revert "[web] switch from .didGain/LoseAccessibilityFocus to .focus (… (flutter/engine#53342)
…#53134)"

This reverts commit f1978535f0355491a67a07ddaf87297361e90d83.

Reverting because the engine PR landed prematurely. It needs to wait for
a framework change, otherwise, things will break.
2024-06-11 13:27:53 -07:00
Jason Simmons
593a9d0da5 Fix character getter API usage in stripLeftSlashes/stripRightSlashes (flutter/engine#53299) 2024-06-11 19:08:22 +00:00
Yegor
f1978535f0 [web] switch from .didGain/LoseAccessibilityFocus to .focus (flutter/engine#53134)
Stop using `SemanticsAction.didGain/LoseAccessibilityFocus` on the web, start using `SemanticsAction.focus`. This is because on the web, a11y focus is not observable, only input focus is. Sending `SemanticsAction.focus` will guarantee that the framework move focus to the respective widget. There currently is no "unfocus" signal, because it seems to be already covered: either another widget gains focus, or an HTML DOM element outside the Flutter view does, both of which have their respective signals already.

More details in the discussion in the issue https://github.com/flutter/flutter/issues/83809.

Fixes https://github.com/flutter/flutter/issues/83809
Fixes https://github.com/flutter/flutter/issues/148285
Fixes https://github.com/flutter/flutter/issues/143337
2024-06-11 18:41:49 +00:00
Brandon DeRosier
f6559124a1 [Flutter GPU] Generate DescriptorSetLayouts for pipelines & export symbols on Android. (flutter/engine#53184)
Part of https://github.com/flutter/flutter/issues/145011.

This gets Flutter GPU working on Android.
2024-06-11 11:25:29 -07:00
Victoria Ashworth
91d74de0c6 Temporarily run Linux linux_web_engine Mac tests on Mac-13 only (flutter/engine#53318)
Temporary solution for https://github.com/flutter/flutter/issues/150023

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-06-10 23:11:17 +00:00
Martin Kustermann
d82c365da3 Use dart.library.html to distinguish dart2wasm from dart2js/ddc in conditional imports (flutter/engine#53307)
Users of packages that have specialized code for the VM (which supports
FFI) use conditional imports based on `dart.library.ffi`. We don't want
the VM-specific code to be used for web in dart2wasm.

As a result we're going to make `dart.library.ffi` be false in
conditional imports (as well as in
`const bool.fromEnvironment('dart.library.ffi')`).

Issue https://github.com/dart-lang/sdk/issues/55948
Issue https://github.com/flutter/flutter/issues/149984
2024-06-10 15:58:43 +02:00