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 window.h5vcc.accessibility #5154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

haozheng-cobalt
Copy link
Contributor

@haozheng-cobalt haozheng-cobalt commented Mar 24, 2025

This PR adds window.h5vcc.accessibility APIs.
There are 2 exposed attributes textToSpeech which is readonly, and ontexttospeechchange which would trigger register callback only from C++ backend when a11y settings are changed.

b/391708407

@haozheng-cobalt haozheng-cobalt requested a review from a team as a code owner March 24, 2025 01:05
@haozheng-cobalt haozheng-cobalt force-pushed the h5vcc-a11y branch 2 times, most recently from 264dff8 to 576ce28 Compare March 24, 2025 16:41
@haozheng-cobalt haozheng-cobalt self-assigned this Mar 24, 2025
// This callback is invoked when text-to-speech settings have changed. It
// may also be invoked if other accessibility settings (ones not related to
// text-to-speech) have changed.
attribute EventHandler ontexttospeechchange;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this correspond to a c25 web api? The name is not very similar to a c25 one, so it's unclear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this does not match C25 web API exactly. I'm following the blink syntax standard for creating EventHandler, I think our other new h5vcc web APIs are following this syntax too, e.g. in h5vcc_metrics.idl and h5vcc_runtime.idl

Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to keep the old name for now, otherwise you will need to make a custom Kabuki change and use a loader to test screen reader. Because Kabuki won't recognize this new event.

Copy link
Contributor

Choose a reason for hiding this comment

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

Our other h5vcc APIs that used events instead of callbacks change the names of web APIs but all correspond to c25 APIs and so have very similar names to them. If this is a similar case, it should change the name as you did but be similar to the c25 name. Or, if you think the name is inaccurate now that we use events (i.e. if it's addTextToSpeechListener), you should explicitly call out in the comment what this API corresponds to from c25.

Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally, you added the API in the IDL but you did not add an implementation for it (even a stub) in the source as far as I can tell

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the API will be auto-generated by DEFINE_ATTRIBUTE_EVENT_LISTENER. If not, I'll add to this in follow-up CLs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comments to explain how to map the APIs to C25.

@haozheng-cobalt haozheng-cobalt force-pushed the h5vcc-a11y branch 2 times, most recently from 7a82a93 to b086396 Compare March 24, 2025 20:39
@hlwarriner
Copy link
Contributor

Can you please do the following before merging?

  1. Run cobalt just to make sure it doesn't crash on startup.
  2. Build the following targets using the new linux-x64x11-no-starboard platform:
$ cobalt/build/gn.py -p linux-x64x11-no-starboard -C devel
$ autoninja -C out/linux-x64x11-no-starboard_devel blink_wpt_tests dump_syms minidump_stackwalk content_shell

This build config uses some strict compiler flags in blink that aren't used for existing CI builds. So it would be good to manually verify the build works until b/405988705 is fixed.

Copy link
Contributor

@hlwarriner hlwarriner left a comment

Choose a reason for hiding this comment

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

Left a few small comments but otherwise looks good!

@haozheng-cobalt
Copy link
Contributor Author

Can you please do the following before merging?

  1. Run cobalt just to make sure it doesn't crash on startup.
  2. Build the following targets using the new linux-x64x11-no-starboard platform:
$ cobalt/build/gn.py -p linux-x64x11-no-starboard -C devel
$ autoninja -C out/linux-x64x11-no-starboard_devel blink_wpt_tests dump_syms minidump_stackwalk content_shell

This build config uses some strict compiler flags in blink that aren't used for existing CI builds. So it would be good to manually verify the build works until b/405988705 is fixed.

You are right!
the linux build does capture a few issues normal ATV build doesn't.
including below that I have addressed:

../../third_party/blink/renderer/modules/cobalt/h_5_vcc.cc:42:7: error: field 'accessibility_' will be initialized after field 'crash_log_' [-Werror,-Wreorder-ctor]
../../third_party/blink/renderer/modules/cobalt/h5vcc_accessibility/h_5_vcc_accessibility.cc:42:1: error: [blink-gc] Base class 'EventTargetWithInlineData' of derived class 'H5vccAccessibility' requires tracing.
void H5vccAccessibility::Trace(Visitor* visitor) const {
^
../../third_party/blink/renderer/modules/cobalt/h5vcc_accessibility/h_5_vcc_accessibility.cc:42:1: error: [blink-gc] Base class 'ExecutionContextLifecycleObserver' of derived class 'H5vccAccessibility' requires tracing.
2 errors generated.

// This callback is invoked when text-to-speech settings have changed. It
// may also be invoked if other accessibility settings (ones not related to
// text-to-speech) have changed.
attribute EventHandler ontexttospeechchange;
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to keep the old name for now, otherwise you will need to make a custom Kabuki change and use a loader to test screen reader. Because Kabuki won't recognize this new event.

@haozheng-cobalt haozheng-cobalt force-pushed the h5vcc-a11y branch 3 times, most recently from c60c07c to 5e588a8 Compare March 25, 2025 04:08
@hlwarriner
Copy link
Contributor

Can you please do the following before merging?

  1. Run cobalt just to make sure it doesn't crash on startup.
  2. Build the following targets using the new linux-x64x11-no-starboard platform:
$ cobalt/build/gn.py -p linux-x64x11-no-starboard -C devel
$ autoninja -C out/linux-x64x11-no-starboard_devel blink_wpt_tests dump_syms minidump_stackwalk content_shell

This build config uses some strict compiler flags in blink that aren't used for existing CI builds. So it would be good to manually verify the build works until b/405988705 is fixed.

You are right! the linux build does capture a few issues normal ATV build doesn't. including below that I have addressed:

../../third_party/blink/renderer/modules/cobalt/h_5_vcc.cc:42:7: error: field 'accessibility_' will be initialized after field 'crash_log_' [-Werror,-Wreorder-ctor]
../../third_party/blink/renderer/modules/cobalt/h5vcc_accessibility/h_5_vcc_accessibility.cc:42:1: error: [blink-gc] Base class 'EventTargetWithInlineData' of derived class 'H5vccAccessibility' requires tracing.
void H5vccAccessibility::Trace(Visitor* visitor) const {
^
../../third_party/blink/renderer/modules/cobalt/h5vcc_accessibility/h_5_vcc_accessibility.cc:42:1: error: [blink-gc] Base class 'ExecutionContextLifecycleObserver' of derived class 'H5vccAccessibility' requires tracing.
2 errors generated.

Yup - thanks for fixing them!

new H5vccAccessibilityImpl(*render_frame_host, std::move(receiver));
}

void H5vccAccessibilityImpl::GetTextToSpeech(GetTextToSpeechCallback callback) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If there are different implementations for 1P-ATV and 3P then I'd recommend, instead of branching here on preprocessor conditionals, providing different Mojo implementations.

See the CrashAnnotator Mojo interface as an example:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Holden, I'll focus on ATV implementation first, in next PR.

@haozheng-cobalt haozheng-cobalt force-pushed the h5vcc-a11y branch 3 times, most recently from 4cab11e to e378f46 Compare March 25, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants