Skip to content
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

Add the focus state related methods to the platform dispatcher #49841

Merged
merged 1 commit into from
Feb 1, 2024
Merged

Add the focus state related methods to the platform dispatcher #49841

merged 1 commit into from
Feb 1, 2024

Conversation

tugorez
Copy link
Contributor

@tugorez tugorez commented Jan 17, 2024

This change augments the platform dispatcher to allow the engine <===> framework to communicate flutter and platform focus changes.

Relevant Issues are:

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.

@tugorez tugorez marked this pull request as ready for review January 18, 2024 21:56
@tugorez tugorez changed the title Add the focus view change and focus state change classes Add the focus state related methods to the platform dispatcher Jan 18, 2024
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
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 like the structure of this API now. I mostly have suggestions for improving the docs.

@gspencergoog Should also take a look at this in case he ends up implementing the framework side that will consume this API.

lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Show resolved Hide resolved
@github-actions github-actions bot added the platform-web Code specifically for the web engine label Jan 29, 2024
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/web_ui/lib/src/engine/platform_dispatcher.dart Outdated Show resolved Hide resolved
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.

API LGTM

lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved
lib/ui/platform_dispatcher.dart Outdated Show resolved Hide resolved

/// Represents the focus state of a given [FlutterView].
///
/// This enum will be associated with a [FlutterView] by instantiating a [ViewFocusEvent].

This comment was marked as resolved.

@tugorez tugorez merged commit 1312954 into flutter:main Feb 1, 2024
26 checks passed
@tugorez tugorez deleted the focus-management branch February 1, 2024 21:20
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 2, 2024
@zanderso zanderso added the revert Label used to revert changes in a closed and merged pull request. label Feb 2, 2024
@zanderso
Copy link
Member

zanderso commented Feb 2, 2024

This PR is causing analysis to fail in snippet code on rolling to the framework: https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20analyze/73029/overview. I added the revert tag.

@zanderso
Copy link
Member

zanderso commented Feb 2, 2024

RUNNING: cd .; bin/cache/dart-sdk/bin/dart --enable-asserts /b/s/w/ir/x/w/flutter/dev/bots/analyze_snippet_code.dart --verbose
workingDirectory: /b/s/w/ir/x/w/flutter, executable: /b/s/w/ir/x/w/flutter/bin/cache/dart-sdk/bin/dart, arguments: [--enable-asserts, /b/s/w/ir/x/w/flutter/dev/bots/analyze_snippet_code.dart, --verbose]
bin/cache/pkg/sky_engine/lib/ui/platform_dispatcher.dart:320:7: The function 'ViewFocusEvent' isn't defined (expression) (undefined_function)
bin/cache/pkg/sky_engine/lib/ui/platform_dispatcher.dart:322:16: Undefined name 'ViewFocusState' (expression) (undefined_identifier)
bin/cache/pkg/sky_engine/lib/ui/platform_dispatcher.dart:323:20: Undefined name 'ViewFocusDirection' (expression) (undefined_identifier)
bin/cache/pkg/sky_engine/lib/ui/platform_dispatcher.dart:338:7: The function 'ViewFocusEvent' isn't defined (expression) (undefined_function)
bin/cache/pkg/sky_engine/lib/ui/platform_dispatcher.dart:340:16: Undefined name 'ViewFocusState' (expression) (undefined_identifier)
bin/cache/pkg/sky_engine/lib/ui/platform_dispatcher.dart:341:20: Undefined name 'ViewFocusDirection' (expression) (undefined_identifier)
bin/cache/pkg/sky_engine/lib/ui/platform_dispatcher.dart:376:16: Undefined name 'ViewFocusSate' (statement) (undefined_identifier)
bin/cache/pkg/sky_engine/lib/ui/platform_dispatcher.dart:377:20: Undefined name 'ViewFocusDirection' (statement) (undefined_identifier)
Found 8 snippet code errors.
See the documentation at the top of dev/bots/analyze_snippet_code.dart for details.

auto-submit bot pushed a commit that referenced this pull request Feb 2, 2024
@auto-submit auto-submit bot removed the revert Label used to revert changes in a closed and merged pull request. label Feb 2, 2024
auto-submit bot added a commit that referenced this pull request Feb 2, 2024
…er" (#50268)

Reverts #49841
Initiated by: zanderso
This change reverts the following previous change:
Original Description:
This change augments the platform dispatcher to allow the engine <===> framework to communicate flutter and platform focus changes.

Relevant Issues are:
* Design doc link: https://github.com/flutter/website/actions/runs/7560898849/job/20588395967
* Design doc: flutter/flutter#141711
* Focus in web multiview: flutter/flutter#137443

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 2, 2024
@tugorez
Copy link
Contributor Author

tugorez commented Feb 2, 2024

This PR is causing analysis to fail in snippet code on rolling to the framework: https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20analyze/73029/overview. I added the revert tag.

Oops, thanks for catching this. @zanderso is there any reason we don't have those linter checks enabled as part of the engine commit process?

auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Feb 2, 2024
…142783)

flutter/engine@dd4c79a...b35153d

2024-02-02 skia-flutter-autoroll@skia.org Manual roll Dart SDK from 82936dcdaf4f to 5a5d4c262200 (2 revisions) (flutter/engine#50264)
2024-02-01 dkwingsmt@users.noreply.github.com Remove number of arguments from defining Dart FFI (flutter/engine#50153)
2024-02-01 32242716+ricardoamador@users.noreply.github.com Refactor the linux_android targets to make use of recent changes to android virtual device params (flutter/engine#50099)
2024-02-01 goderbauer@google.com Re-add tests deleted on accident (flutter/engine#50223)
2024-02-01 30870216+gaaclarke@users.noreply.github.com [Impeller] updated todos from opengles golden work (flutter/engine#50218)
2024-02-01 flar@google.com Get bounds from RTree in DLBuilder::Build() (flutter/engine#50253)
2024-02-01 chinmaygarde@google.com [Impeller] Remove unused define. (flutter/engine#50250)
2024-02-01 tugorez@users.noreply.github.com Add the focus state related methods to the platform dispatcher (flutter/engine#49841)
2024-02-01 jason-simmons@users.noreply.github.com Fix the output paths of the Web esbuild GN template (flutter/engine#50188)
2024-02-01 chinmaygarde@google.com [Impeller] Delete unnecessary special casing for Vulkan in framebuffer fetch. (flutter/engine#50251)

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
@tugorez
Copy link
Contributor Author

tugorez commented Feb 2, 2024

This PR is causing analysis to fail in snippet code on rolling to the framework: https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20analyze/73029/overview. I added the revert tag.

Oops, thanks for catching this. @zanderso is there any reason we don't have those linter checks enabled as part of the engine commit process?

Also is there an easy way to verify these things locally?

@zanderso
Copy link
Member

zanderso commented Feb 2, 2024

I'm not familiar with how the snippet analysis is implemented. I vaguely recall that @gspencergoog might know more about this.

tugorez added a commit that referenced this pull request Feb 2, 2024
These changes were originally landed on
#49841 but reverted in
0eb7b10.
I fixed the offending dart snippets and (think) they now will work
without issues (I think I was able to verify them locally by manually
patching my bin/cache/... copy of these files with these changes).

Relevant Issues are:
* Design doc link:
https://github.com/flutter/website/actions/runs/7560898849/job/20588395967
* Design doc: flutter/flutter#141711
* Focus in web multiview:
flutter/flutter#137443

## 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
@gspencergoog
Copy link
Contributor

Snippet analysis happens in dev/bots/analyze_snippet_code.dart in the flutter repo. You can run it locally, but you'd have to (manually?) put the engine artifacts into the cache directory of your local flutter repo for it to catch these.

Perhaps that script should be added as part of the presumbits that the engine runs on the Flutter repo?

auto-submit bot pushed a commit that referenced this pull request Feb 9, 2024
…0177)

Make the flutter web engine publish view focus events.

Relevant Issues are:
* Design doc link: https://github.com/flutter/website/actions/runs/7560898849/job/20588395967
* Design doc: flutter/flutter#141711
* Focus in web multiview: flutter/flutter#137443
* Platform dispatcher changes: #49841

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
auto-submit bot pushed a commit that referenced this pull request Feb 12, 2024
#50533)

Rename [ViewFocusDirection.backwards] to [ViewFocusDirection.backward]

Relevant Issues are:

Design doc link: https://github.com/flutter/website/actions/runs/7560898849/job/20588395967
Design doc: flutter/flutter#141711
Focus in web multiview: flutter/flutter#137443
Platform dispatcher changes: #49841

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
auto-submit bot pushed a commit that referenced this pull request Feb 15, 2024
Move the accesibility placeholder to the platform dispatcher.

This change makes the platform dispatcher append a single accesibility placeholder, per app, to the `<body />`. Previous behavior was to insert a placeholder inside each `<flutter-view />`

Relevant Issues are:

* Design doc: https://flutter.dev/go/focus-management 
* Focus in web multiview: flutter/flutter#137443
* Platform dispatcher changes: #49841

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
auto-submit bot pushed a commit that referenced this pull request Feb 21, 2024
…#50610)

Make the view focus binding report focus transitions across elements.

Previously the web engine reported all the focusin/focusout events as if the elements were first blurred before moving the focus.

Relevant Issues are:

* Design doc: https://flutter.dev/go/focus-management 
* Focus in web multiview: flutter/flutter#137443
* Platform dispatcher changes: #49841

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
auto-submit bot pushed a commit that referenced this pull request Feb 22, 2024
Add view focus direction detection to flutter web.

Relevant Issues are:

* Design doc: https://flutter.dev/go/focus-management 
* Focus in web multiview: flutter/flutter#137443
* Platform dispatcher changes: #49841

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
auto-submit bot pushed a commit that referenced this pull request Mar 7, 2024
Prepends the accesibility placeholder. Previously it was being appended (last child) to the body. 

Relevant Issues are:

* Design doc: https://flutter.dev/go/focus-management 
* Focus in web multiview: flutter/flutter#137443
* Platform dispatcher changes: #49841

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
auto-submit bot pushed a commit that referenced this pull request Mar 8, 2024
)

Mark the Flutter View as focusable by setting a tabindex value.

* When a given flutter view is focused its tabindex will be `-1`
* When a given flutter view is not focused its tabindex will be `0`
* When semantics are enabled no tabindex will be set.

Relevant Issues are:

* Design doc: https://flutter.dev/go/focus-management 
* Focus in web multiview: flutter/flutter#137443
* Platform dispatcher changes: #49841

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
auto-submit bot pushed a commit that referenced this pull request Mar 13, 2024
Implement PlatformDispatcher.requestViewFocusChange on web. 

Relevant Issues are:

* Design doc: https://flutter.dev/go/focus-management 
* Focus in web multiview: flutter/flutter#137443
* Platform dispatcher changes: #49841

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-web Code specifically for the web engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants