Repository navigation
[linux] Read heading text through the AtkText interface - #188005
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements the AtkText interface for FlAccessibleNode to expose accessibility names as text content to screen readers, and updates the header role to ATK_ROLE_HEADING. Feedback suggests aligning the AtkText implementation with ATK specifications by returning -1 when caret is unsupported, returning nullptr for invalid selections, and properly handling offset and boundary_type in fl_accessible_node_get_text_at_offset to support character-by-character navigation. Additionally, expanding test coverage to verify these behaviors is recommended.
Expose a semantics node's name as text content via the AtkText interface so screen readers announce the text of headings. Orca reads the text content of a heading exclusively through AtkText, not the AtkObject name, so a node with `Semantics(header: true)` was announced as just "header" while its text was skipped (flutter#187925). Also map the `is_header` flag to ATK_ROLE_HEADING (the content-heading role, matching HTML h1-h6 and `Semantics(header: true)`) instead of ATK_ROLE_HEADER (the document masthead/banner role). FlAccessibleTextField already implements a richer AtkText and continues to override the base implementation. Fixes flutter#187925
25b4f44 to
aae0d05
Compare
robert-ancell
left a comment
There was a problem hiding this comment.
Looks good, thanks!
Head branch was pushed to by a user without write access
|
autosubmit label was removed for flutter/flutter/188005, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/188005, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
This is failing in formatting: @sawirricardo can you fix this in your branch? |
Head branch was pushed to by a user without write access
05d2cfb
Fixes #187925
Problem
On Linux, a node with
Semantics(header: true)is announced by Orca as just "header" — the node's text is never read. Withheader: falsethe same text is read correctly.Root cause
Two issues in the Linux embedder's accessibility code (
engine/src/flutter/shell/platform/linux/):The node's label is exposed only via the
AtkObjectname property, not theAtkTextinterface. Orca reads the text content of a heading exclusively throughAtkText(see_generate_headingin Orca'sspeech_generator.py, which calls_generate_text_content→AXText.get_substring→atk_text_get_text). It never falls back to the name for the heading/header roles. So Orca finds no text and announces only the role.This matches the ATK contract used by GTK:
GtkLabelexposes its text throughAtkText. Flutter's label is its text content, so it should be exposed the same way. (FlAccessibleTextFieldalready does this for editable text.)The wrong ATK role.
is_headermaps toATK_ROLE_HEADER, which is the document masthead/banner role.ATK_ROLE_HEADINGis the content-heading role (the HTML<h1>–<h6>analogue) and is whatSemantics(header: true)means (matching iOSheadertrait and Android heading class).Fix
AtkTextinterface onFlAccessibleNode, backed by the node's existing accessibility name (get_character_count,get_text,get_character_at_offset,get_caret_offset,get_n_selections,get_selection,get_text_at_offset). This is safe for other roles: Orca's default presentation for buttons/panels/images reads theAtkObjectname via_generate_accessible_label_and_name, notAtkText, so their announcement is unchanged.FlAccessibleTextFieldalready declares a richerAtkTextand continues to override the base implementation.is_headerflag toATK_ROLE_HEADING.Result
For the repro in #187925, Orca now announces "Section One, heading" instead of just "header".
Test plan
ExposesTextViaAtkTexttest verifyingatk_text_get_character_count/atk_text_get_text/atk_text_get_character_at_offsetreturn the node's label.is_header→ATK_ROLE_HEADING.Linux linux_unit_tests(cannot run locally — Linux GTK/ATK build; developed/analyzed on macOS). Reviewers, please confirm CI is green.