-
Notifications
You must be signed in to change notification settings - Fork 6k
Add support for setting the heading level for web semantics (#97894) #41435
Changes from 1 commit
a341b26
eff0206
7f8ef2c
9029d63
260d4bd
baea4c1
bf0fe7f
b773f81
90de9fc
c9ac350
c8ccd31
0241f07
6298a5f
36c5fd6
30153e0
5460388
a526070
dceef3c
3a6e45d
b9bfb88
664c1e4
e6a8c6a
470f67f
a56c398
b31bd9f
8305e4b
d860f21
a16a8f7
70efe89
ddeaefc
bcd3205
9d25b32
268e31c
a7bb630
0f72806
79e4728
4b69d9f
c83039b
b351c1e
5705912
89ef536
e60c0a7
bb787e0
7199da1
76b65f6
ee38434
41f77aa
e38e3f3
1e570fb
ac1ec5e
0b9efa6
4a54812
6d8d511
2586dbc
fc0a3a5
ca2d289
5e05f24
9231840
c52b545
33a246c
1b0e241
e918e20
4383464
5186055
af5e70a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -786,6 +786,11 @@ abstract class SemanticsUpdateBuilder { | |
| /// z-direction starting at `elevation`. Basically, in the z-direction the | ||
| /// node starts at `elevation` above the parent and ends at `elevation` + | ||
| /// `thickness` above the parent. | ||
| /// | ||
| /// The `headingLevel` describes that this node is a heading, additionally | ||
| /// indicates the hierarchy level this node represents as a heading. A value | ||
| /// of -1 indicates that this node is not a heading. A value of 1 or greater | ||
| /// indicates that this node is a heading at the specified level. | ||
|
||
| void updateNode({ | ||
| required int id, | ||
| required int flags, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,15 +9,26 @@ import 'semantics.dart'; | |
| /// level (h1 ... h6). | ||
| class Heading extends PrimaryRoleManager { | ||
| Heading(SemanticsObject semanticsObject) | ||
| : super.withBasics(PrimaryRole.heading, semanticsObject); | ||
| : super.withBasics(PrimaryRole.heading, semanticsObject) { | ||
| addHeadingRole(); | ||
| } | ||
|
|
||
| @override | ||
| void update() { | ||
| super.update(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can return early if the heading level field is not dirty.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I added it. |
||
|
|
||
| if (semanticsObject.headingLevel != -1) { | ||
| semanticsObject.setAriaRole('heading'); | ||
| semanticsObject.element.setAttribute('aria-level', semanticsObject.headingLevel); | ||
| } | ||
| if (semanticsObject.headingLevel != -1) { | ||
| addHeadingLevel(semanticsObject.headingLevel); | ||
| } else { | ||
| addHeadingLevel(1); | ||
| } | ||
| } | ||
|
|
||
| void addHeadingRole() { | ||
| semanticsObject.setAriaRole('heading'); | ||
| } | ||
|
|
||
| void addHeadingLevel(int headingLevel) { | ||
| semanticsObject.element.setAttribute('aria-level', headingLevel); | ||
| } | ||
| } | ||
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.
nit: I'd replace "additionally indicates" with just "and"