Skip to content

Commit

Permalink
refactor!: Clean up table roles and properties (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcampbell authored Apr 30, 2024
1 parent a8398b8 commit e34dad9
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 87 deletions.
23 changes: 10 additions & 13 deletions bindings/c/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,7 @@ node_id_property_methods! {
(member_of, set_member_of, clear_member_of),
(next_on_line, set_next_on_line, clear_next_on_line),
(previous_on_line, set_previous_on_line, clear_previous_on_line),
(popup_for, set_popup_for, clear_popup_for),
(table_header, set_table_header, clear_table_header),
(table_row_header, set_table_row_header, clear_table_row_header),
(table_column_header, set_table_column_header, clear_table_column_header)
(popup_for, set_popup_for, clear_popup_for)
}

/// Only call this function with a string that originated from AccessKit.
Expand All @@ -579,7 +576,9 @@ string_property_methods! {
(role_description, set_role_description, clear_role_description),
(state_description, set_state_description, clear_state_description),
(tooltip, set_tooltip, clear_tooltip),
(url, set_url, clear_url)
(url, set_url, clear_url),
(row_index_text, set_row_index_text, clear_row_index_text),
(column_index_text, set_column_index_text, clear_column_index_text)
}

f64_property_methods! {
Expand All @@ -599,14 +598,12 @@ f64_property_methods! {
}

usize_property_methods! {
(table_row_count, set_table_row_count, clear_table_row_count),
(table_column_count, set_table_column_count, clear_table_column_count),
(table_row_index, set_table_row_index, clear_table_row_index),
(table_column_index, set_table_column_index, clear_table_column_index),
(table_cell_column_index, set_table_cell_column_index, clear_table_cell_column_index),
(table_cell_column_span, set_table_cell_column_span, clear_table_cell_column_span),
(table_cell_row_index, set_table_cell_row_index, clear_table_cell_row_index),
(table_cell_row_span, set_table_cell_row_span, clear_table_cell_row_span),
(row_count, set_row_count, clear_row_count),
(column_count, set_column_count, clear_column_count),
(row_index, set_row_index, clear_row_index),
(column_index, set_column_index, clear_column_index),
(row_span, set_row_span, clear_row_span),
(column_span, set_column_span, clear_column_span),
(level, set_level, clear_level),
(size_of_set, set_size_of_set, clear_size_of_set),
(position_in_set, set_position_in_set, clear_position_in_set)
Expand Down
23 changes: 10 additions & 13 deletions bindings/python/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,7 @@ node_id_property_methods! {
(member_of, set_member_of, clear_member_of),
(next_on_line, set_next_on_line, clear_next_on_line),
(previous_on_line, set_previous_on_line, clear_previous_on_line),
(popup_for, set_popup_for, clear_popup_for),
(table_header, set_table_header, clear_table_header),
(table_row_header, set_table_row_header, clear_table_row_header),
(table_column_header, set_table_column_header, clear_table_column_header)
(popup_for, set_popup_for, clear_popup_for)
}

string_property_methods! {
Expand All @@ -500,7 +497,9 @@ string_property_methods! {
(role_description, set_role_description, clear_role_description),
(state_description, set_state_description, clear_state_description),
(tooltip, set_tooltip, clear_tooltip),
(url, set_url, clear_url)
(url, set_url, clear_url),
(row_index_text, set_row_index_text, clear_row_index_text),
(column_index_text, set_column_index_text, clear_column_index_text)
}

f64_property_methods! {
Expand All @@ -520,14 +519,12 @@ f64_property_methods! {
}

usize_property_methods! {
(table_row_count, set_table_row_count, clear_table_row_count),
(table_column_count, set_table_column_count, clear_table_column_count),
(table_row_index, set_table_row_index, clear_table_row_index),
(table_column_index, set_table_column_index, clear_table_column_index),
(table_cell_column_index, set_table_cell_column_index, clear_table_cell_column_index),
(table_cell_column_span, set_table_cell_column_span, clear_table_cell_column_span),
(table_cell_row_index, set_table_cell_row_index, clear_table_cell_row_index),
(table_cell_row_span, set_table_cell_row_span, clear_table_cell_row_span),
(row_count, set_row_count, clear_row_count),
(column_count, set_column_count, clear_column_count),
(row_index, set_row_index, clear_row_index),
(column_index, set_column_index, clear_column_index),
(row_span, set_row_span, clear_row_span),
(column_span, set_column_span, clear_column_span),
(level, set_level, clear_level),
(size_of_set, set_size_of_set, clear_size_of_set),
(position_in_set, set_position_in_set, clear_position_in_set)
Expand Down
90 changes: 38 additions & 52 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ pub enum Role {
Pane,
RowHeader,
ColumnHeader,
Column,
RowGroup,
List,
Table,
TableHeaderContainer,
LayoutTableCell,
LayoutTableRow,
LayoutTable,
Expand Down Expand Up @@ -855,9 +853,6 @@ enum PropertyId {
NextOnLine,
PreviousOnLine,
PopupFor,
TableHeader,
TableRowHeader,
TableColumnHeader,

// String
Name,
Expand All @@ -875,6 +870,8 @@ enum PropertyId {
StateDescription,
Tooltip,
Url,
RowIndexText,
ColumnIndexText,

// f64
ScrollX,
Expand All @@ -892,14 +889,12 @@ enum PropertyId {
FontWeight,

// usize
TableRowCount,
TableColumnCount,
TableRowIndex,
TableColumnIndex,
TableCellColumnIndex,
TableCellColumnSpan,
TableCellRowIndex,
TableCellRowSpan,
RowCount,
ColumnCount,
RowIndex,
ColumnIndex,
RowSpan,
ColumnSpan,
Level,
SizeOfSet,
PositionInSet,
Expand Down Expand Up @@ -1480,10 +1475,7 @@ node_id_property_methods! {
(MemberOf, member_of, set_member_of, clear_member_of),
(NextOnLine, next_on_line, set_next_on_line, clear_next_on_line),
(PreviousOnLine, previous_on_line, set_previous_on_line, clear_previous_on_line),
(PopupFor, popup_for, set_popup_for, clear_popup_for),
(TableHeader, table_header, set_table_header, clear_table_header),
(TableRowHeader, table_row_header, set_table_row_header, clear_table_row_header),
(TableColumnHeader, table_column_header, set_table_column_header, clear_table_column_header)
(PopupFor, popup_for, set_popup_for, clear_popup_for)
}

string_property_methods! {
Expand Down Expand Up @@ -1530,7 +1522,9 @@ string_property_methods! {
///
/// [`name`]: Node::name
(Tooltip, tooltip, set_tooltip, clear_tooltip),
(Url, url, set_url, clear_url)
(Url, url, set_url, clear_url),
(RowIndexText, row_index_text, set_row_index_text, clear_row_index_text),
(ColumnIndexText, column_index_text, set_column_index_text, clear_column_index_text)
}

f64_property_methods! {
Expand All @@ -1553,14 +1547,12 @@ f64_property_methods! {
}

usize_property_methods! {
(TableRowCount, table_row_count, set_table_row_count, clear_table_row_count),
(TableColumnCount, table_column_count, set_table_column_count, clear_table_column_count),
(TableRowIndex, table_row_index, set_table_row_index, clear_table_row_index),
(TableColumnIndex, table_column_index, set_table_column_index, clear_table_column_index),
(TableCellColumnIndex, table_cell_column_index, set_table_cell_column_index, clear_table_cell_column_index),
(TableCellColumnSpan, table_cell_column_span, set_table_cell_column_span, clear_table_cell_column_span),
(TableCellRowIndex, table_cell_row_index, set_table_cell_row_index, clear_table_cell_row_index),
(TableCellRowSpan, table_cell_row_span, set_table_cell_row_span, clear_table_cell_row_span),
(RowCount, row_count, set_row_count, clear_row_count),
(ColumnCount, column_count, set_column_count, clear_column_count),
(RowIndex, row_index, set_row_index, clear_row_index),
(ColumnIndex, column_index, set_column_index, clear_column_index),
(RowSpan, row_span, set_row_span, clear_row_span),
(ColumnSpan, column_span, set_column_span, clear_column_span),
(Level, level, set_level, clear_level),
(SizeOfSet, size_of_set, set_size_of_set, clear_size_of_set),
(PositionInSet, position_in_set, set_position_in_set, clear_position_in_set)
Expand Down Expand Up @@ -1910,10 +1902,7 @@ impl<'de> Visitor<'de> for NodeVisitor {
MemberOf,
NextOnLine,
PreviousOnLine,
PopupFor,
TableHeader,
TableRowHeader,
TableColumnHeader
PopupFor
},
String {
Name,
Expand All @@ -1930,7 +1919,9 @@ impl<'de> Visitor<'de> for NodeVisitor {
RoleDescription,
StateDescription,
Tooltip,
Url
Url,
RowIndexText,
ColumnIndexText
},
F64 {
ScrollX,
Expand All @@ -1948,14 +1939,12 @@ impl<'de> Visitor<'de> for NodeVisitor {
FontWeight
},
Usize {
TableRowCount,
TableColumnCount,
TableRowIndex,
TableColumnIndex,
TableCellColumnIndex,
TableCellColumnSpan,
TableCellRowIndex,
TableCellRowSpan,
RowCount,
ColumnCount,
RowIndex,
ColumnIndex,
RowSpan,
ColumnSpan,
Level,
SizeOfSet,
PositionInSet
Expand Down Expand Up @@ -2096,10 +2085,7 @@ impl JsonSchema for Node {
MemberOf,
NextOnLine,
PreviousOnLine,
PopupFor,
TableHeader,
TableRowHeader,
TableColumnHeader
PopupFor
},
Box<str> {
Name,
Expand All @@ -2116,7 +2102,9 @@ impl JsonSchema for Node {
RoleDescription,
StateDescription,
Tooltip,
Url
Url,
RowIndexText,
ColumnIndexText
},
f64 {
ScrollX,
Expand All @@ -2134,14 +2122,12 @@ impl JsonSchema for Node {
FontWeight
},
usize {
TableRowCount,
TableColumnCount,
TableRowIndex,
TableColumnIndex,
TableCellColumnIndex,
TableCellColumnSpan,
TableCellRowIndex,
TableCellRowSpan,
RowCount,
ColumnCount,
RowIndex,
ColumnIndex,
RowSpan,
ColumnSpan,
Level,
SizeOfSet,
PositionInSet
Expand Down
5 changes: 0 additions & 5 deletions platforms/atspi-common/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ impl<'a> NodeWrapper<'a> {
Role::CheckBox => AtspiRole::CheckBox,
Role::Switch => AtspiRole::ToggleButton,
Role::ColorWell => AtspiRole::PushButton,
Role::Column => AtspiRole::Unknown,
Role::ColumnHeader => AtspiRole::ColumnHeader,
Role::ComboBox | Role::EditableComboBox => AtspiRole::ComboBox,
Role::Complementary => AtspiRole::Landmark,
Expand Down Expand Up @@ -259,10 +258,6 @@ impl<'a> NodeWrapper<'a> {
Role::SvgRoot => AtspiRole::DocumentFrame,
Role::Tab => AtspiRole::PageTab,
Role::Table => AtspiRole::Table,
// TODO: This mapping is correct, but it doesn't seem to be
// used. We don't necessarily want to always expose these containers, but
// we must do so if they are focusable.
Role::TableHeaderContainer => AtspiRole::Panel,
Role::TabList => AtspiRole::PageTabList,
Role::TabPanel => AtspiRole::ScrollPane,
// TODO: This mapping should also be applied to the dfn
Expand Down
2 changes: 0 additions & 2 deletions platforms/macos/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ fn ns_role(node_state: &NodeState) -> &'static NSAccessibilityRole {
Role::Pane => NSAccessibilityUnknownRole,
Role::RowHeader => NSAccessibilityCellRole,
Role::ColumnHeader => NSAccessibilityCellRole,
Role::Column => NSAccessibilityColumnRole,
Role::RowGroup => NSAccessibilityGroupRole,
Role::List => NSAccessibilityListRole,
Role::Table => NSAccessibilityTableRole,
Role::TableHeaderContainer => NSAccessibilityGroupRole,
Role::LayoutTableCell => NSAccessibilityGroupRole,
Role::LayoutTableRow => NSAccessibilityGroupRole,
Role::LayoutTable => NSAccessibilityGroupRole,
Expand Down
2 changes: 0 additions & 2 deletions platforms/windows/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,9 @@ impl<'a> NodeWrapper<'a> {
Role::Pane => UIA_PaneControlTypeId,
Role::RowHeader => UIA_DataItemControlTypeId,
Role::ColumnHeader => UIA_DataItemControlTypeId,
Role::Column => UIA_GroupControlTypeId,
Role::RowGroup => UIA_GroupControlTypeId,
Role::List => UIA_ListControlTypeId,
Role::Table => UIA_TableControlTypeId,
Role::TableHeaderContainer => UIA_GroupControlTypeId,
Role::LayoutTableCell => UIA_DataItemControlTypeId,
Role::LayoutTableRow => UIA_DataItemControlTypeId,
Role::LayoutTable => UIA_TableControlTypeId,
Expand Down

0 comments on commit e34dad9

Please sign in to comment.