3308 Commits

Author SHA1 Message Date
Bartek Pacia
d3b6e4044d SemanticsUpdateBuilder migration: introduce identifier (flutter/engine#48882)
This PR adds `String? identifier` to `SemanticsUpdateBuilder` (currently it's only available in the temproary `SemanticsUpdateBuilderNew` API.

This is mainly targeted at https://github.com/flutter/flutter/issues/17988

Steps:
part 1: [engine] add `SemanticsUpdateBuilderNew` https://github.com/flutter/engine/pull/47961
part 2: [flutter] use `SemanticsUpdateBuilderNew`  https://github.com/flutter/flutter/pull/138331
**part 3: [engine] update `SemanticsUpdateBuilder` to be the same as `SemanticsUpdateBuilderNew`** <-- we are here
part 4: [flutter] use (now updated) `SemanticsUpdateBuilder` again.
part 5: [engine] remove `SemanticsBuilderNew`
2023-12-11 22:35:07 +00:00
Mouad Debbar
ee266e5318 [web] PointerBinding per view (flutter/engine#48248)
- Move initialization of `PointerBinding`/`KeyboardBinding` out of `FlutterViewEmbedder`.
- `computeEventOffsetToTarget` properly handles events within a given view.
- `PointerBinding` operates on the given Flutter view (it still listens to some `domWindow` events for the implicit view).
    - Stop using globals e.g. `ui.window`, `KeyboardBinding.instance`, `SafariPointerEventWorkaround.instance`, etc.
- `pointer_binding_test.dart` doesn't use globals either.
- `clickDebouncer` is now a static property on `PointerBinding`.

Fixes https://github.com/flutter/flutter/issues/137289
2023-12-11 20:44:58 +00:00
Victoria Ashworth
9622acd973 Fix css changes with macOS 13 and Safari (flutter/engine#48807)
Safari on macOS 13 outputs different styling than before. Adjust tests to accept new changes. 

Fixes https://github.com/flutter/flutter/issues/136274. Fixes https://github.com/flutter/flutter/issues/136279.

Example passing on macOS 12: https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20linux_web_engine/16401/overview
Example passing on macOS 13: https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20linux_web_engine/16396/overview

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-11 19:31:25 +00:00
Victoria Ashworth
31210e4a38 Retry when safaridriver fails (flutter/engine#48791)
Starting `safaridriver` is flakey sometimes on macOS 13. It will occasionally error with "Operation not permitted". As a workaround, if it fails with that message, retry starting `safaridriver`.

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

Example of fix on macOS 13 bot: https://ci.chromium.org/ui/p/flutter/builders/try/Mac%20Engine%20Drone/564967/overview
Note: The test is still failing due to https://github.com/flutter/flutter/issues/136279, but you can see it first has error "Operation not permitted" and retries and connects on second attempt.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-07 21:55:06 +00:00
Jonah Williams
8b54eb6bf5 [Impeller] Store Buffer/Texture bindings in vector instead of map. (flutter/engine#48719)
Places the binding data in a vector, since they key was only meaningful on metal but not used anywhere. I don't think that we need to specificially handle the case where our own contents bind the same contents multiple times, but interested to discuss if folks disagree.
2023-12-06 19:32:41 +00:00
Jonah Williams
8aeac570ad [Impeller] Prefer moving vertex buffer, place on command instead of binding object. (flutter/engine#48630)
Placing the vertex buffer on the binding object meant that we were actually paying 2x the size cost for it (one for vertex bindings, one for fragment bindings). By moving this object onto command itself, we reduce the size and avoid spliting up the command state in a weird way.

Also updates most of the contents to prefer moving the VertexBuffer.
2023-12-05 21:02:52 +00:00
Jonah Williams
7bad7a0150 [Impeller] Delete tessellation control/eval shader support. (flutter/engine#48649)
We have no plans to ever use these for anything.
2023-12-05 17:11:11 +00:00
Tong Mu
673fca77cf Multiview ExternalViewEmbedder (flutter/engine#46169)
This PR adds multiview support for `ExternalViewEmbedder`.

## Nomenclature

The term **view** can be ambiguous in `ExternalViewEmbedder`, and therefore the following terms are used:
* A **native view** refers to the final drawing surface that to composite layers to. It is the "view" used in other places of the engine, such as `Shell::AddView`.
* A **platform view** refers a platform view, a layer that holds content to be embedded.

## Change

The lifecycle of `ExternalViewEmbedder` is changed:

<table>
    <thead>
        <tr>
            <th>Before PR</th>
            <th>After PR</th>
            <th>How it's called</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td rowspan=2>BeginFrame</td>
            <td>BeginFrame</td>
            <td>Once per frame</td>
        </tr>
        <tr>
            <td>PrepareFlutterView</td>
            <td>Once per flutter view</td>
        </tr>
        <tr>
            <td>SubmitFrame</td>
            <td>SubmitFlutterView (renamed)</td>
            <td>Once per flutter view</td>
        </tr>
        <tr>
            <td>EndFrame</td>
            <td>EndFrame (unchanged)</td>
            <td>Once per frame</td>
        </tr>
    </tbody>
</table>

* `BeginFrame` should perform per-frame actions, such as merge-unmerging threads.
* `PrepareView` should perform per-native-view preparations, such as recording the view ID and view size.

This change is necessary because some actions in `PrepareView` needs to be refreshed at the beginning of drawing every native view.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-04 20:29:49 +00:00
Bartek Pacia
79126777a4 Add support for exposing accessibility identifier as resource-id on Android (flutter/engine#47961)
Accompanying framework PR: https://github.com/flutter/flutter/pull/138331

This PR implements support for exposing `SemanticsProperties.identifier` on Android as `resource-id`. Mainly targeted at https://github.com/flutter/flutter/issues/17988. Would also fix https://github.com/flutter/flutter/issues/issues/137735 but it was marked as duplicate. Anyway, there's a lot of context in that issue.

This PR requires changing the `SemanticsUpdateBuilder` interface (defined in engine) that framework depends on, so it requires introducing a temporary API ([see question I asked on Discord](https://discord.com/channels/608014603317936148/608018585025118217/1174845658033819729) to learn more about this approach).

Steps:
**part 1: [engine] add `SemanticsUpdateBuilderNew`** <-- we are here
part 2: [flutter] use `SemanticsUpdateBuilderNew`
part 3: [engine] update `SemanticsUpdateBuilder` to be the same as `SemanticsUpdateBuilderNew`*
part 4: [flutter] use (now updated) `SemanticsUpdateBuilder` again.
part 5: [engine] remove `SemanticsBuilderNew`

I'd like to do these changes first, and only then continue with [the proper framework PR](https://github.com/flutter/flutter/pull/138331).

*More specifically: update `SemanticsUpdateBuilder.updateNode()` to be the same as `SemanticsUpdateBuilderNew.updateNode()`. Number of arguments that function takes is the only change.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-04 19:27:18 +00:00
Yegor
d1ed887379 [web] remove ulimit and add -i to felt (flutter/engine#47414)
The ulimit logic has been failing for me for months now and felt still
ran fine. I think we don't need it any more.

Also add the `-i` option for incremental runs of `felt`. It causes felt
to start faster because it doesn't run `pub get`. In the future, we can
also run felt from the snapshot for even faster start-up.
2023-12-01 21:06:49 -08:00
Yegor
15d0ccaa77 [web] Implement multi-view for semantics (flutter/engine#48251)
Implement multi-view for semantics. Main changes:

- `EngineSemanticsOwner` singleton is split into two classes:
- `EngineSemantics` is a singleton that manages global properties of the
semantics tree, such as whether semantics is currently enabled, and what
gesture mode is used.
- `EngineSemanticsOwner` now supports creating multiple instances of the
class. `EngineFlutterView` now points a `EngineSemanticsOwner` that it
owns.
- Fix a number of issues with disposal logic. Now that views can come in
and out disposal has to be more robust than previously.
`EngineSemanticsOwner` acquired a `reset()` and `SemanticsObject` acquired
 a `dispose()` that clean up the tree and individual nodes respectively.
- In particular, this fixes an issue in Skwasm mode where slight
differences in asynchrony caused the semantics test to fail because old
nodes continued firing events after they were removed from the document
due to improper disposal.
2023-12-01 11:10:05 -08:00
Harry Terkelsen
0bac7851a8 [canvaskit] Add ImageFilter.compose (flutter/engine#48546)
Adds ImageFilter.compose support in CanvasKit. Previously this would
crash.

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

## 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 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
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[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-11-30 16:37:07 -08:00
Harry Terkelsen
9b26cdc88c [canvaskit] Revert to drawImage rendering on Chrome 110 or earlier (flutter/engine#48515)
This updates a fix for Chrome 110 and earlier to always activate, not
just on Windows.

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

## 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 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
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[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-11-30 12:41:23 -08:00
Mouad Debbar
ac83bcf45e [web] No implicit view in multi-view mode (flutter/engine#48505)
- No implicit view in mult-view mode.
- `window.devicePixelRatio` => `EngineFlutterDisplay.instance.devicePixelRatio`.
- `window.physicalSize` => `view.physicalSize`.
- Remove `LayerTree.frameSize`.
- `defaultRouteName` is set to `/` when there's no implicit view.
- All routing operations are noops in multi-view mode.

With these changes, I was able to run all examples in https://github.com/goderbauer/mvp without an implicit view.
2023-11-29 21:11:05 +00:00
Harry Terkelsen
f377fc827e [canvaskit] Disable createImageBitmap support on Chrome 110 or older on Windows. (flutter/engine#48475)
On Chrome 110 or older, there is a bug where an ImageBitmap will be read back upside down if it is stored upside down on the GPU. This only happens on Windows. So if we are on Windows and running on Chrome 110 or older, then fall back to `drawImage` based rendering.

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-11-29 18:06:11 +00:00
Jason Simmons
c0ea0d4a0e Remove use of variable length arrays (flutter/engine#48232)
The variable length array extension will be disabled by default in the next roll of Clang.
2023-11-28 21:28:07 +00:00
Kevin Lubick
92bce6db0e Replace all calls to SkTypeface::Make with SkFontMgr ones (flutter/engine#48319)
Similar to https://github.com/flutter/engine/pull/48179, Flutter needs
to stop depending on the default font manager, which the
`SkTypeface::Make*` calls do implicitly

## 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].
- [ ] 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 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
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[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-11-28 07:08:35 -05:00
Harry Terkelsen
e3d0abe659 [canvaskit] Fall back to drawImage for browsers that don't support createImageBitmap (flutter/engine#48336)
Safari 14 doesn't have the `createImageBitmap` API available. This
change allows us to render into `RenderCanvas` without using
`createImageBitmap` in that case.

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

## 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 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
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[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-11-27 16:23:24 -08:00
Jim Graham
1f0d7cd7ea SurfaceFrame root DisplayLists will no longer prepare an RTree (flutter/engine#48422)
The root slice of a surface frame was requesting the construction of an RTree from its DisplayList when it was built from a layer tree, but since the layer tree already does branch culling, it would not benefit from any further culling during `DisplayList::Dispatch`. Further, if there are platform views present in the layer tree then they will need an RTree to accurately convey "pixel ownership" information to the platform, but the root slice lives below any and all platform views, so it is the only slice that doesn't need an RTree for that case.

The cost of having an RTree in that slice was the accumulation of information and lists of rects that would never prove useful.
2023-11-27 23:27:34 +00:00
Michael Goderbauer
136f4a03c4 Dynamic view sizing [dart:ui] (flutter/engine#48090)
Towards https://github.com/flutter/flutter/issues/134501.

This PR makes the following changes to the public dart:ui API:

* It adds the `FlutterView.pysicalConstraints` property that describes max and min width and height for a view. The framework is allowed to size the `FlutterView` to any `Size` that meets these constraints.
* It adds an optional `size` argument to `FlutterView.render`. The framework provides the chosen `Size` that meets the aforementioned constraints to the `render` method. If the `FlutterView.pysicalConstraints` are tight (minHeight == maxHeight and minWidth == maxWidth) the argument is optional to remain backwards compatible. In all other cases, a `Size` must be provided.
* It adds a `ViewConstraints` class, which is basically the `dart:ui` version of `BoxConstraints` (This is similar to how we have `ViewPadding` in dart:ui to mirror `EdgeInsets` from the framework). It describes the constraints of a `FlutterView`, i.e. it powers the `FlutterView.pysicalConstraints` property.

This change does not wire anything up to the embedders. For now, `FlutterView.pysicalConstraints` just returns tight constraints for the embedder-provided size of the view (`FlutterView.physicalSize`) and the size provided to `FlutterView.render` is ignored (after it is checked that it meets the constrains). 

This PR enables the framework to implement the new dynamic view sizing and embedders to separately expose the new functionality to their clients.

Presubmits will fail until https://github.com/flutter/flutter/pull/138565 is submitted to the framework.

**DO NOT SUBMIT until https://github.com/flutter/flutter/pull/138648 is ready.**
2023-11-27 22:33:59 +00:00
Harry Terkelsen
0e82e66bdd [canvaskit] Enable multiview rendering (flutter/engine#48301)
Allows the CanvasKitRenderer to render into multiple views.

## 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 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
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[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

---------

Co-authored-by: skia-flutter-autoroll <skia-flutter-autoroll@skia.org>
Co-authored-by: Mouad Debbar <mdebbar@google.com>
Co-authored-by: 林洵锋 <linxunfeng@yeah.net>
Co-authored-by: Brandon DeRosier <bdero@google.com>
Co-authored-by: Jonah Williams <jonahwilliams@google.com>
Co-authored-by: Matej Knopp <matej.knopp@gmail.com>
2023-11-27 12:59:26 -08:00
Brandon DeRosier
c49cfdc9a9 [Flutter GPU] Texture binding, index binding, attachments, depth state. (flutter/engine#48386)
Now rendering textured 3D models!

* Combined depth+stencil attachment.
* Allow for multiple color attachments.
* Add blend mode configuration.
* Fix uniform ordering for vertex shaders.
* Texture binding and sampling options.
* Index buffer binding.
* Depth configuration.
2023-11-26 19:47:16 -08:00
Brandon DeRosier
05f43a96aa [Flutter GPU] Raster encoding. First triangle! (flutter/engine#48314)
First triangle, in the framework! 🎉 

Adds shader libraries, pipelines, command buffers, render passes, etc.

* Light pipelines/shader objects. No optimization yet, pipeline warming
to come.
* "Dynamic" command style. Don't re-send bindings if you don't need to.
Essentially: https://github.com/flutter/flutter/issues/133179
* No need to explicitly encode passes.
* Minimal descriptor usage.
* Nothing is async, except for the optional command buffer completion
callback.

It took a bunch of experimenting to get here, but I think things are
starting to look pretty neat. :)

Todo:
* Land the shader bundle format/remove the testing hacks & fixtures that
piggyback off of the runtime effect system.
* Add remaining calls for blend config, clearing bindings, etc.
* Inconsistent error handling patterns that need cleanup.
* Maybe: Surface exceptions for validation errors.
* Handle the texture usage bitmask more elegantly.
2023-11-24 19:02:58 -08:00
Mouad Debbar
4c20a233a8 [web] Hook the new JS API to the FlutterViewManager (flutter/engine#48283)
- Auto-generate view IDs.
- Views don't auto-register/auto-unregister anymore.
- Remove `EnginePlatformDispatcher.registerView/unregisterView` methods.
- Add `FlutterViewManager.createAndRegisterView/disposeAndUnregisterView/dispose` methods.
- Hook the `addView`/`removeView` JS APIs to `FlutterViewManager`.
2023-11-22 21:27:56 +00:00
LongCatIsLooong
59a5579465 Expose a few more glyph apis from ui.Paragraph (flutter/engine#47698)
Add 2 methods for querying glyph-related metrics

```dart
  GlyphInfo? getClosestGlyphInfoForOffset(Offset offset); 
  GlyphInfo? getGlyphInfoAt(int codeUnitOffset);
```

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-11-22 18:04:13 +00:00
Matan Lurey
edb665c82d Make {shell|lib/ui}/... compatible with .clang_tidy. (flutter/engine#48242)
This is mostly just rename `ThreadHost::Type::{IDENTIFIER}` to
`kIdentifier`.

I also ignored some enum violations that are in public APIs.
2023-11-21 12:29:14 -08:00
David Iglesias
b6a14724a8 [web] Add add/removeView JS methods. (flutter/engine#48106)
This PR adds:

* JS-interop types to expose addView/removeView from the running FlutterApp object on JavaScript.
  * Also, the options object that can be passed to `addView`.

### Issues:

* Fixes: https://github.com/flutter/flutter/issues/137377

### Info

Most interesting files:

* `app_bootstrap.dart` -> Adds the implementation for JS add/remove view.
* `js_app.dart` -> Adds the js-interop layer for the FlutterApp object, and the configuration type. (Two options: `hostElement` and `initialData`).
* `flutter_view_manager.dart` -> An abstraction over the `viewData` map that keeps related things together: viewData, js configuration options, register/unregister methods and a Stream<void> of modification events.

The rest of the changes were ""required"" to have a small demo that does anything (currently it lets me "register" views from javascript). I didn't add much in there, because probably it's already being worked on by @mdebbar; just fiddled with the constructor of the EngineFlutterView to create views from JS Config, and added a wrapper around the `viewData` map (`FlutterViewManager`) to prevent direct access to the Map.

## Usage

This is how I'm currently initializing my Flutter App, so I can "leak" the `flutterApp` to window and do things asynchronously after flutter loads:

```html
<script>
  window.addEventListener('load', async function(ev) {
    _flutter.loader.loadEntrypoint({
      onEntrypointLoaded: function(engineInitializer) {
        engineInitializer.initializeEngine({
          multiViewEnabled: true,
        }).then(function(appRunner) {
          return appRunner.runApp();
        }).then(onAppRunning);
      }
    });
    // Leak flutterApp to window so we can do async things...
    function onAppRunning(flutterApp) {
      console.log('Running app', flutterApp);
      window.flutterApp = flutterApp;
    }
  });
</script>
```

This to test:

 * Go on your JS console and use `flutterApp.addView({})` and see how that returns a Promise for the viewId it just added,
 * Now do `flutterApp.removeView(0)` (removes the implicitView), and see how everything starts crashing! (as expected) 
   * Get out of this weird state with a hot reload 🥳

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-11-21 15:30:07 +00:00
Mouad Debbar
5c93379571 [web] EngineFlutterView.dispose() (flutter/engine#48183)
- New `EngineFlutterView.dispose()` to cleanup when the view is removed (and in hot restart).
- `EnginePlatformDispatcher.dispose()` now disposes of all of its registered views.
2023-11-20 17:21:22 +00:00
Kevin Lubick
0d0d4db144 Replace calls to SkFontMgr::RefDefault (flutter/engine#48179)
Skia is removing this API, so clients must track a default FontMgr if
they want one. See https://issues.skia.org/issues/305780908

## 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 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
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[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-11-20 07:57:02 -05:00
Bartek Pacia
2168e305d1 Fix a few typos (flutter/engine#47960)
I found 3 small typos :)

Supersedes #47929

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-11-17 22:46:51 +00:00
Mouad Debbar
3e7fea4e4f [web] Move scene DOM management to DomManager (flutter/engine#47460)
- Move scene insertion logic to `DomManager`.
- Add TODOs in `Renderer` subclasses (cc @harryterkelsen).

Part of https://github.com/flutter/flutter/issues/134443
2023-11-17 18:35:15 +00:00
Mouad Debbar
360c454b63 [web] Move all DOM creation to DomManager (flutter/engine#48123)
- `FlutterViewEmbedder` doesn't create the DOM tree anymore (instead, `DomManager` does).
- `DomManager` only creates the DOM tree (with styles) but doesn't insert it into the document.
- `EngineFlutterView` takes the root element from `DomManager` and inserts it into the document.
- We finally can now create multiple Flutter views, each with its own DOM tree.

cc @yjbanov since I'm making a few changes that probably conflict with your semantics changes.

Part of https://github.com/flutter/flutter/issues/134443
Part of https://github.com/flutter/flutter/issues/137447
2023-11-17 16:45:23 +00:00
Brandon DeRosier
f553fe0023 [Flutter GPU] Add Textures. (flutter/engine#48118) 2023-11-16 22:28:54 -08:00
Matan Lurey
7571e558d4 Make lib/ui/text/... compatible with .clang-tidy. (flutter/engine#48156) 2023-11-16 18:00:09 -08:00
Harry Terkelsen
c2749e93a3 [canvaskit] Size the PictureRecorder when calling Scene.toImage (flutter/engine#48142)
When calling `flatten()` to produce a `Picture` of a `Scene`, size the
`PictureRecorder` to be the same size as the final image.

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

## 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 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
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[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-11-16 15:18:53 -08:00
Matan Lurey
933bd94016 Make flow/... compatible with .clang_tidy. (flutter/engine#47995)
Work towards https://github.com/flutter/flutter/issues/134969.

All changes were made automatically (i.e. with `--fix`).
2023-11-16 08:41:10 -08:00
Matan Lurey
5bb5a50b0a Make lib/ui/painting/... compatible with .clang_tidy. (flutter/engine#47999)
Work towards https://github.com/flutter/flutter/issues/134969.

All changes were made automatically (i.e. with `--fix`).
2023-11-16 08:40:42 -08:00
Matan Lurey
4638f4fc85 Re-land "Make lib/ui/{text|window}/... compatible with .ci.yaml" (flutter/engine#48097)
Reverts https://github.com/flutter/engine/pull/48083.
2023-11-16 08:40:19 -08:00
Matan Lurey
9ce1ec8867 Make lib/ui/compositing/... compatible with .clang_tidy. (flutter/engine#48001)
Work towards https://github.com/flutter/flutter/issues/134969.

All changes were made automatically (i.e. with `--fix`).
2023-11-15 23:09:05 +00:00
Mouad Debbar
9b5f97c730 [web] Apply global styles before inserting the DOM element (flutter/engine#48027)
The current way we are doing global styles (using `CSSStyleSheet`) forces us to insert the DOM element into the document before we attach any styles to the element. That restriction goes away if we append the styles as `TextNode`s into the `<style>` element.

Now with the movement towards `DomManager`, I would like to be able to create the entire DOM tree of the Flutter View (including all styles) before we insert it into the document.

Part of https://github.com/flutter/flutter/issues/134443
2023-11-15 23:02:35 +00:00
auto-submit[bot]
ff90f25a41 Reverts "Make lib/ui/{text|window}/... compatible with .clang_tidy." (flutter/engine#48083)
Reverts flutter/engine#48000
Initiated by: jonahwilliams
This change reverts the following previous change:
Original Description:
I just ... deleted `text_box.h` as it appears unused and unreferenced?

---

Work towards https://github.com/flutter/flutter/issues/134969.

All changes were made automatically (i.e. with `--fix`).
2023-11-15 19:55:17 +00:00
Matan Lurey
2c058e08ff Make lib/ui/{text|window}/... compatible with .clang_tidy. (flutter/engine#48000)
I just ... deleted `text_box.h` as it appears unused and unreferenced?

---

Work towards https://github.com/flutter/flutter/issues/134969.

All changes were made automatically (i.e. with `--fix`).
2023-11-15 11:21:55 -08:00
Mouad Debbar
4bb1a74025 [web] Move EmbeddingStrategy and DimensionsProvider out of FlutterViewEmbedder (flutter/engine#48025)
Part of https://github.com/flutter/flutter/issues/134443
Part of https://github.com/flutter/flutter/issues/117098
2023-11-15 15:37:06 +00:00
David Iglesias
ffcda33b48 [web] JSConfig: Add multiViewEnabled value. (flutter/engine#47939)
This change:

* Adds a boolean to `multiViewEnabled`.
* Removes unused `canvasKitMaximumSurfaces` value.

Part of: https://github.com/flutter/flutter/issues/137377

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-11-15 02:01:17 +00:00
Jackson Gardner
5ea8187703 Use flutter.js in the actual test harness. (flutter/engine#47670)
Run the JS unit tests with flutter.js.

I am going to leave the dart2wasm tests doing the old `window.flutterConfiguration` setup for now, until I actually get dart2wasm/dart2js switching logic built into flutter.js itself.
2023-11-15 00:50:27 +00:00
Mouad Debbar
44cbbf526f [web] Explicit initialization of the implicit view (flutter/engine#47921)
- An explicit API for initializing the implicit view (aka `window`).
- The explicit API is being called during the engine initialization for now, but we could simply remove that or make it conditional.
- Remove direct usages of `window` in tests:
    - Most of the usages were being delegated to `PlatformDispatcher` anyway (e.g. `sendPlatformMessage`).
    - This makes it **_clearer_** which tests depend on the implicit view (there are still hidden/indirect dependencies though).

Part of https://github.com/flutter/flutter/issues/134443
2023-11-14 16:14:50 +00:00
Zachary Anderson
ef11fee4ed Move Skia to //flutter/third_party/skia (flutter/engine#47913)
As part of eliminating the Flutter buildroot
(https://github.com/flutter/flutter/issues/67373), we are moving all
third-party dependencies from //third_party to //flutter/third_party.

Once all third-party dependencies have been migrated, tooling and config
will be moved and the buildroot will be eliminated altogether.

To land this PR, we'll need to:
1. Stop the Skia -> Engine autoroller
1. Update the license goldens in this PR.
1. Update
https://skia.googlesource.com/skia-autoroll-internal-config/+/refs/heads/main/skia-infra-public/skia-flutter.cfg#55
1. Land this PR.
1. Re-start the Skia -> Engine autoroller
2023-11-13 20:04:35 -08:00
Mouad Debbar
a1dc432c9c [web] Cleanup touch and mouse event adapters (flutter/engine#43697)
This PR cleans up a big source of complexity in our pointer handling code. It also drops support for Safari versions prior to 13 ([caniuse](https://caniuse.com/mdn-api_pointerevent)).

Right now, we throw a hard error when running in a browser that doesn't support `PointerEvent`s. Should we turn it into a soft warning, and just disable gesture/pointer handling on those browsers?

For users who need to support older versions of Safari, they can try this polyfill: https://github.com/wessberg/pointer-events (thanks @ditman!)

Fixes https://github.com/flutter/flutter/issues/116141
2023-11-13 22:42:41 +00:00
Hassan Toor
5ae444a017 [web] - fix Safari textfield selection bug (flutter/engine#47917)
In order to fix Safari autofill, we've had to give inactive elements non-zero size because Safari does not respect offscreen or 0-sized inputs, and this leads to broken autofill behavior (see: https://github.com/flutter/engine/pull/43058).

As part of these changes, we needed to disable pointer events for the parent `<form>` element so that we don't have pointer event collisions if users hover over or click into the invisible autofill elements within that form.

This led to an issue where offsets weren't being calculated correctly for "active" inputs because they relied on pointer events bubbling up and being caught by the form.  The fix is to explicitly set pointer events on the active inputs, so that we can correctly discern when our pointer event target is actually the input and correctly calculate the offsets.

Fixes https://github.com/flutter/flutter/issues/136006
2023-11-13 20:00:16 +00:00
Brandon DeRosier
fa96666e03 [Flutter GPU] Add DeviceBuffer. (flutter/engine#47699)
Part of http://flutter.dev/go/impeller-dart

Resolves https://github.com/flutter/flutter/issues/130924.
Resolves https://github.com/flutter/flutter/issues/130925.

Create and upload data to host visible device buffers. Commands should allow for binding either HostBuffers (which eventually resolve to DeviceBuffers) or DeviceBuffers. There's a `Buffer` mixin to allow for expressing this in `BufferView`, but this may end up changing once I actually add Commands and need to solve the puzzle.
2023-11-11 00:56:51 +00:00