Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@ditman
Copy link
Member

@ditman ditman commented Mar 20, 2024

Adds a function to each 'wheel' DataPacket sent to the framework so it can signal whether to allowPlatformDefault or not.

The current default is to always preventDefault on browser events that get sent to the framework.

This PR enables the framework to call a method on the DataPackets to allowPlatformDefault: true, if the framework won't handle the Signal (signals are handled synchronously on the framework).

This lets the engine "wait" for the framework to decide whether to preventDefault on a wheel event or not.

Issues

Tests

  • Added unit tests for the feature in the engine repo, veryfing whether the event has had its defaultPrevented or not.
  • Manually tested in a demo app (see below)

Demo

Previous approaches

  1. Add a handled bool property to PointerDataPacket that the framework can write to (brittle)
  2. Modifications to the PlatformDispatcher so the framework can acknowledgePointerData with a PointerDataResponse (fffffatttt change)
  3. acknowledge function in PointerDataPacket

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 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.

@ditman ditman force-pushed the mutable-pointer-data-packet branch from 69f2aa3 to bb1c9bf Compare April 11, 2024 00:20
@ditman ditman changed the title [web] RFC - Allow PointerDataPacket to be marked as "not handled". [web] RFC - Allow event default in some 'wheel' events. Apr 11, 2024
@ditman
Copy link
Member Author

ditman commented Apr 11, 2024

I changed this so it doesn't exposea a mutable property, instead it allows the framework to call a new PlatformDispatcher method. PTAL @yjbanov @goderbauer

@ditman ditman requested a review from mdebbar April 11, 2024 21:30
@mdebbar
Copy link
Contributor

mdebbar commented Apr 12, 2024

Here's a slightly different approach that I tried a few months ago: mdebbar@51ec1ee

It basically adds a handledCallback method to PointerData, and the framework can directly invoke the callback to indicate that it has handled the pointer event. The callback is a closure that has access to the browser event and can call preventDefault (or any other methods) on it.

This avoids adding a new method to the PlatformDispatcher singleton.

@ditman
Copy link
Member Author

ditman commented Apr 12, 2024

I like not having to add new methods to the Platform Dispatcher, not going to lie :)

@ditman ditman force-pushed the mutable-pointer-data-packet branch 2 times, most recently from 5dcc6ce to 05067ef Compare May 10, 2024 20:26
Copy link
Member Author

@ditman ditman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the simplest I can come up with that could be removed/noop'd without much drama.

@ditman
Copy link
Member Author

ditman commented May 11, 2024

(PTAL @yjbanov @goderbauer @mdebbar)

@ditman ditman force-pushed the mutable-pointer-data-packet branch 2 times, most recently from 5feb42a to 9f280d3 Compare May 24, 2024 00:57
@ditman
Copy link
Member Author

ditman commented May 29, 2024

Adding tests.

@ditman ditman force-pushed the mutable-pointer-data-packet branch from 1368ca4 to e715552 Compare May 29, 2024 04:02
@ditman ditman changed the title [web] RFC - Allow event default in some 'wheel' events. [web] Adds allowPlatformDefault for 'wheel' signals. May 29, 2024
@ditman ditman changed the title [web] Adds allowPlatformDefault for 'wheel' signals. [web] Adds allowPlatformDefault for wheel signals. May 29, 2024
@ditman ditman marked this pull request as ready for review May 29, 2024 04:13
@ditman
Copy link
Member Author

ditman commented May 29, 2024

This is finally ready to go, PTAL @mdebbar @goderbauer (optionally, @yjbanov)!

@ditman ditman requested review from goderbauer and yjbanov May 29, 2024 04:13
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can live with this dart:ui API. :)

Leaving reviewing the web implementation to others.

@ditman ditman requested a review from goderbauer May 29, 2024 20:12
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for lib/ui


// An optional function that allows the framework to respond to the event
// that triggered this PointerData instance.
final PointerDataRespondCallback? _onRespond;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can inline a function type here without creating a one-off typedef. Is this a guideline or something?

Copy link
Member Author

@ditman ditman May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can inline a function type here without creating a one-off typedef. Is this a guideline or something?

@kevmoo I went back and forth on this (I originally had this as an inline function type). The Style guide for Flutter repo that @goderbauer linked says this:

Prefer using typedefs to declare callbacks. Typedefs benefit from having documentation on the type itself and make it easier to read and find common callsites for the signature.

I don't have strong feelings about it (but when we were bikeshedding in parameter name, it was a chore to rename it in several, unconnected parts, and that's when I ended up adding the typedef... it's also nice to be able to add some dartdoc to the typedef).

@ditman ditman force-pushed the mutable-pointer-data-packet branch from 290ec95 to 663dafa Compare June 5, 2024 22:41
@ditman ditman added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 5, 2024
@auto-submit auto-submit bot merged commit 7ab0cf4 into flutter:main Jun 5, 2024
@ditman ditman deleted the mutable-pointer-data-packet branch June 5, 2024 23:27
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 6, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 6, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jun 6, 2024
…149785)

flutter/engine@f51e0ad...0edca2e

2024-06-06 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] Use Skia software renderer to draw stroked text. (#53198)" (flutter/engine#53237)
2024-06-05 jonahwilliams@google.com [Impeller] Use Skia software renderer to draw stroked text. (flutter/engine#53198)
2024-06-05 chinmaygarde@google.com Remove the DBC interpreter flag. (flutter/engine#53204)
2024-06-05 ditman@gmail.com [web] Adds allowPlatformDefault for wheel signals. (flutter/engine#51566)
2024-06-05 jonahwilliams@google.com [Impeller] fix emojis with non-solid color sources. (flutter/engine#53229)
2024-06-05 skia-flutter-autoroll@skia.org Roll Skia from 8448abc95867 to 89570a0a171e (1 revision) (flutter/engine#53236)
2024-06-05 skia-flutter-autoroll@skia.org Roll Dart SDK from f838a9a8d45f to 86b8aacb2609 (1 revision) (flutter/engine#53234)
2024-06-05 flar@google.com [DisplayList] remove legacy DisplayListMatrixClipTracker (flutter/engine#53232)

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

To file a bug in Flutter: 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants