-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Correctly implement PlatformViews' cursors on Web #174300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correctly implement PlatformViews' cursors on Web #174300
Conversation
79adc8e to
14d3ade
Compare
|
This new behavior makes sense for the specific platform view used by |
|
I've tested the cursor behavior. The following app is a Screen.Recording.2025-09-15.at.4.40.34.PM.mp4Code```dart import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart';const kStartUrl = 'https://example.com'; void main() { class CenteredWebViewApp extends StatelessWidget { @OverRide class CenteredWebViewPage extends StatefulWidget { @OverRide class _CenteredWebViewPageState extends State { @OverRide @OverRide } |
MouseCursor.uncontrolled on Web|
I talked with @mdebbar offline. For the record, Mouad was curious it would work even though the webview region of the Flutter view was assigned with a different cursor (such as the Mouad then pointed out that changing |
mdebbar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
autosubmit label was removed for flutter/flutter/174300, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
Manual roll requested by bmparr@google.com flutter/flutter@9ff2767...4a04204 2025-09-23 mohellebiabdessalem@gmail.com Simplify asserts in `FlutterMutatorTest` (flutter/flutter#175730) 2025-09-23 mohellebiabdessalem@gmail.com Improve code quality in `AccessibilityBridgeTest.java` (flutter/flutter#175718) 2025-09-23 mohellebiabdessalem@gmail.com Fix linter issues in `VsyncWaiterTest` Capital L for long values (flutter/flutter#175780) 2025-09-23 mohellebiabdessalem@gmail.com Fix wrong order of asserts arguments (flutter/flutter#175726) 2025-09-23 mohellebiabdessalem@gmail.com Simplify test asserts and use lambdas (flutter/flutter#175727) 2025-09-23 mohellebiabdessalem@gmail.com Remove unused imports, fix assertion order, add non null annotations to `ImageReaderPlatformViewRenderTargetTest.java` (flutter/flutter#175723) 2025-09-23 mohellebiabdessalem@gmail.com Remove unnecessary `String.valueOf` in `KeyboardManager.java` (flutter/flutter#175502) 2025-09-23 mohellebiabdessalem@gmail.com Fix outdated link of `intl` package to point to the correct new location (flutter/flutter#174498) 2025-09-23 engine-flutter-autoroll@skia.org Roll Packages from 45c9a84 to 3413b65 (4 revisions) (flutter/flutter#175854) 2025-09-23 mohellebiabdessalem@gmail.com Fix typo in tests `README` (flutter/flutter#175788) 2025-09-23 byoungchan.lee@gmx.com Update maximum known Gradle version to 9.1.0 (flutter/flutter#175543) 2025-09-23 engine-flutter-autoroll@skia.org Roll Dart SDK from 9e943fe076c8 to 14b4ced3022a (5 revisions) (flutter/flutter#175843) 2025-09-23 bruno.leroux@gmail.com Document how to hide counter in TextField.maxLength (flutter/flutter#175797) 2025-09-23 bruno.leroux@gmail.com [a11y-app] Fix Autocomplete semantics label (flutter/flutter#175409) 2025-09-23 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from CcCe3HpQtBYhTZscb... to naeytagBIBEpKgZNZ... (flutter/flutter#175824) 2025-09-23 engine-flutter-autoroll@skia.org Roll Skia from a38a531dec1d to cabeab8cb22c (16 revisions) (flutter/flutter#175822) 2025-09-23 jiahaog@users.noreply.github.com Load fonts in the order addFont is called (flutter/flutter#174253) 2025-09-22 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#175545) 2025-09-22 mohellebiabdessalem@gmail.com Remove `name` field form `SupportedPlatform` enum (flutter/flutter#175611) 2025-09-22 mdebbar@google.com [web] Cleanup opportunities post renderer unification (flutter/flutter#174659) 2025-09-22 mohellebiabdessalem@gmail.com Update `KeyChannelResponder.java` to use method reference (flutter/flutter#175510) 2025-09-22 dominik@roszkowski.dev Update docs/engine/contributing/Compiling-the-engine.md with macOS build steps (flutter/flutter#175716) 2025-09-22 bkonyi@google.com [ Widget Preview ] Allow for custom `Preview` annotations, add support for runtime transformations (flutter/flutter#175535) 2025-09-22 mohellebiabdessalem@gmail.com Remove unnecessary public modifier in `KeyboardManager.java` (flutter/flutter#175500) 2025-09-22 muhatashim@google.com bump robolectric and java to 21 (flutter/flutter#175550) 2025-09-22 dixita0607@users.noreply.github.com Fix: Update docs tool tag to sample in ImageProvider (flutter/flutter#175256) 2025-09-22 stuartmorgan@google.com Roll Packages from 3d5c419 to 45c9a84 (flutter/flutter#175794) 2025-09-21 dkwingsmt@users.noreply.github.com Correctly implement PlatformViews' cursors on Web (flutter/flutter#174300) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
Fix flutter#174246 Before: https://github.com/user-attachments/assets/33d2a476-d9c4-46e1-a5c5-ea8e602060d6 After: https://github.com/user-attachments/assets/383e4a01-4b8e-4c0e-a5a4-fa0d1fc28b67 This PR is not a result of a thorough fix for mouse cursors on all platforms, but simply matching the behavior of `SelectionArea` on Web to that on non-Web. A central question lies how a platform view widget should control the mouse cursor. On the surface, the answer is simple: it doesn't, and let the view content to control (hence the `MouseCursor.uncontrolled` constant). But what if the empty region of the view content doesn't control the cursor at all? This would be a problem even on non-Web, because if neither the view content nor the view controls the cursor on non-Web, then the user will find the cursor remaining the one used by the last region, which would be different when entering and when leaving, the same bug as flutter#174246 . On the other hand, what is it supposed to fall back to if the view content doesn't define a cursor? Is the default cursor the logically correct option? ... I decided that I did not want to dig too much into the details, and instead focus on this specific issue. I tried the repro app on macOS and found that the empty region of `SelectionArea` falls back to the widget behind it, the same behavior as `MouseCursor.defer`. Therefore in this PR I made `MouseCursor.uncontrolled` essentially the same as `.defer` on Web, matching the behavior across platforms. ## 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], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Fix flutter#174246 Before: https://github.com/user-attachments/assets/33d2a476-d9c4-46e1-a5c5-ea8e602060d6 After: https://github.com/user-attachments/assets/383e4a01-4b8e-4c0e-a5a4-fa0d1fc28b67 This PR is not a result of a thorough fix for mouse cursors on all platforms, but simply matching the behavior of `SelectionArea` on Web to that on non-Web. A central question lies how a platform view widget should control the mouse cursor. On the surface, the answer is simple: it doesn't, and let the view content to control (hence the `MouseCursor.uncontrolled` constant). But what if the empty region of the view content doesn't control the cursor at all? This would be a problem even on non-Web, because if neither the view content nor the view controls the cursor on non-Web, then the user will find the cursor remaining the one used by the last region, which would be different when entering and when leaving, the same bug as flutter#174246 . On the other hand, what is it supposed to fall back to if the view content doesn't define a cursor? Is the default cursor the logically correct option? ... I decided that I did not want to dig too much into the details, and instead focus on this specific issue. I tried the repro app on macOS and found that the empty region of `SelectionArea` falls back to the widget behind it, the same behavior as `MouseCursor.defer`. Therefore in this PR I made `MouseCursor.uncontrolled` essentially the same as `.defer` on Web, matching the behavior across platforms. ## 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], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Fix flutter#174246 Before: https://github.com/user-attachments/assets/33d2a476-d9c4-46e1-a5c5-ea8e602060d6 After: https://github.com/user-attachments/assets/383e4a01-4b8e-4c0e-a5a4-fa0d1fc28b67 This PR is not a result of a thorough fix for mouse cursors on all platforms, but simply matching the behavior of `SelectionArea` on Web to that on non-Web. A central question lies how a platform view widget should control the mouse cursor. On the surface, the answer is simple: it doesn't, and let the view content to control (hence the `MouseCursor.uncontrolled` constant). But what if the empty region of the view content doesn't control the cursor at all? This would be a problem even on non-Web, because if neither the view content nor the view controls the cursor on non-Web, then the user will find the cursor remaining the one used by the last region, which would be different when entering and when leaving, the same bug as flutter#174246 . On the other hand, what is it supposed to fall back to if the view content doesn't define a cursor? Is the default cursor the logically correct option? ... I decided that I did not want to dig too much into the details, and instead focus on this specific issue. I tried the repro app on macOS and found that the empty region of `SelectionArea` falls back to the widget behind it, the same behavior as `MouseCursor.defer`. Therefore in this PR I made `MouseCursor.uncontrolled` essentially the same as `.defer` on Web, matching the behavior across platforms. ## 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], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

Fix #174246
Before:
Screen.Recording.2025-08-29.at.3.46.47.PM.mp4
After:
Screen.Recording.2025-08-29.at.3.48.29.PM.mp4
This PR is not a result of a thorough fix for mouse cursors on all platforms, but simply matching the behavior of
SelectionAreaon Web to that on non-Web.A central question lies how a platform view widget should control the mouse cursor. On the surface, the answer is simple: it doesn't, and let the view content to control (hence the
MouseCursor.uncontrolledconstant). But what if the empty region of the view content doesn't control the cursor at all? This would be a problem even on non-Web, because if neither the view content nor the view controls the cursor on non-Web, then the user will find the cursor remaining the one used by the last region, which would be different when entering and when leaving, the same bug as #174246 . On the other hand, what is it supposed to fall back to if the view content doesn't define a cursor? Is the default cursor the logically correct option? ...I decided that I did not want to dig too much into the details, and instead focus on this specific issue. I tried the repro app on macOS and found that the empty region of
SelectionAreafalls back to the widget behind it, the same behavior asMouseCursor.defer. Therefore in this PR I madeMouseCursor.uncontrolledessentially the same as.deferon Web, matching the behavior across platforms.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.