forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[web:a11y] add platform view role (flutter#44188)
Add `PlatformViewRoleManager`, the primary role manager for platform views. Currently, all it does is manager the `aria-owns` attribute that determines the screen reader traversal order of the platform view w.r.t. surrounding content. This is a partial fix for flutter/flutter#124765. While it does not address literally using the TAB key as a means for traversing widgets, it does address traversal via screen reader shortcuts.
- Loading branch information
Showing
11 changed files
with
116 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import '../dom.dart'; | ||
import '../platform_views/slots.dart'; | ||
import 'semantics.dart'; | ||
|
||
/// Manages the semantic element corresponding to a platform view. | ||
/// | ||
/// The element in the semantics tree exists only to supply the ARIA traversal | ||
/// order. The actual content of the platform view is managed by | ||
/// [PlatformViewManager]. | ||
/// | ||
/// The traversal order is established using "aria-owns", by pointing to the | ||
/// element that hosts the view contents. As of this writing, Safari on macOS | ||
/// and on iOS does not support "aria-owns". All other browsers on all operating | ||
/// systems support it. | ||
/// | ||
/// See also: | ||
/// * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-owns | ||
/// * https://bugs.webkit.org/show_bug.cgi?id=223798 | ||
class PlatformViewRoleManager extends PrimaryRoleManager { | ||
PlatformViewRoleManager(SemanticsObject semanticsObject) | ||
: super.withBasics(PrimaryRole.platformView, semanticsObject); | ||
|
||
@override | ||
void update() { | ||
super.update(); | ||
|
||
if (semanticsObject.isPlatformView) { | ||
if (semanticsObject.isPlatformViewIdDirty) { | ||
semanticsObject.element.setAttribute( | ||
'aria-owns', | ||
getPlatformViewDomId(semanticsObject.platformViewId), | ||
); | ||
} | ||
} else { | ||
semanticsObject.element.removeAttribute('aria-owns'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters