Skip to content

Commit f8c0d0a

Browse files
authored
refactor!: Drop FrozenNode (#496)
1 parent 6338e45 commit f8c0d0a

File tree

3 files changed

+3
-173
lines changed

3 files changed

+3
-173
lines changed

common/src/lib.rs

Lines changed: 0 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -884,23 +884,6 @@ impl Default for PropertyIndices {
884884
}
885885
}
886886

887-
#[derive(Clone, Debug, PartialEq)]
888-
struct FrozenProperties {
889-
indices: PropertyIndices,
890-
values: Box<[PropertyValue]>,
891-
}
892-
893-
/// An accessibility node snapshot that can't be modified. This is not used by
894-
/// toolkits or applications, but only by code that retains an AccessKit tree
895-
/// in memory, such as the `accesskit_consumer` crate.
896-
#[derive(Clone, PartialEq)]
897-
pub struct FrozenNode {
898-
role: Role,
899-
actions: u32,
900-
flags: u32,
901-
properties: FrozenProperties,
902-
}
903-
904887
#[derive(Clone, Debug, Default, PartialEq)]
905888
struct Properties {
906889
indices: PropertyIndices,
@@ -974,31 +957,8 @@ impl Properties {
974957
}
975958
}
976959

977-
impl From<Properties> for FrozenProperties {
978-
fn from(props: Properties) -> Self {
979-
Self {
980-
indices: props.indices,
981-
values: props.values.into_boxed_slice(),
982-
}
983-
}
984-
}
985-
986960
macro_rules! flag_methods {
987961
($($(#[$doc:meta])* ($id:ident, $getter:ident, $setter:ident, $clearer:ident)),+) => {
988-
impl FrozenNode {
989-
$($(#[$doc])*
990-
#[inline]
991-
pub fn $getter(&self) -> bool {
992-
(self.flags & (Flag::$id).mask()) != 0
993-
})*
994-
fn debug_flag_properties(&self, fmt: &mut fmt::DebugStruct) {
995-
$(
996-
if self.$getter() {
997-
fmt.field(stringify!($getter), &true);
998-
}
999-
)*
1000-
}
1001-
}
1002962
impl Node {
1003963
$($(#[$doc])*
1004964
#[inline]
@@ -1109,13 +1069,6 @@ macro_rules! vec_type_methods {
11091069

11101070
macro_rules! property_methods {
11111071
($($(#[$doc:meta])* ($id:ident, $getter:ident, $type_getter:ident, $getter_result:ty, $setter:ident, $type_setter:ident, $setter_param:ty, $clearer:ident)),+) => {
1112-
impl FrozenNode {
1113-
$($(#[$doc])*
1114-
#[inline]
1115-
pub fn $getter(&self) -> $getter_result {
1116-
self.properties.indices.$type_getter(&self.properties.values, PropertyId::$id)
1117-
})*
1118-
}
11191072
impl Node {
11201073
$($(#[$doc])*
11211074
#[inline]
@@ -1168,9 +1121,6 @@ macro_rules! node_id_vec_property_methods {
11681121
$(#[$doc])*
11691122
($id, NodeId, $getter, get_node_id_vec, $setter, set_node_id_vec, $pusher, push_to_node_id_vec, $clearer)
11701123
})*
1171-
impl FrozenNode {
1172-
slice_properties_debug_method! { debug_node_id_vec_properties, [$($getter,)*] }
1173-
}
11741124
impl Node {
11751125
slice_properties_debug_method! { debug_node_id_vec_properties, [$($getter,)*] }
11761126
}
@@ -1195,9 +1145,6 @@ macro_rules! node_id_property_methods {
11951145
$(#[$doc])*
11961146
($id, $getter, get_node_id_property, Option<NodeId>, $setter, set_node_id_property, NodeId, $clearer)
11971147
})*
1198-
impl FrozenNode {
1199-
option_properties_debug_method! { debug_node_id_properties, [$($getter,)*] }
1200-
}
12011148
impl Node {
12021149
option_properties_debug_method! { debug_node_id_properties, [$($getter,)*] }
12031150
}
@@ -1210,9 +1157,6 @@ macro_rules! string_property_methods {
12101157
$(#[$doc])*
12111158
($id, $getter, get_string_property, Option<&str>, $setter, set_string_property, impl Into<Box<str>>, $clearer)
12121159
})*
1213-
impl FrozenNode {
1214-
option_properties_debug_method! { debug_string_properties, [$($getter,)*] }
1215-
}
12161160
impl Node {
12171161
option_properties_debug_method! { debug_string_properties, [$($getter,)*] }
12181162
}
@@ -1225,9 +1169,6 @@ macro_rules! f64_property_methods {
12251169
$(#[$doc])*
12261170
($id, $getter, get_f64_property, Option<f64>, $setter, set_f64_property, f64, $clearer)
12271171
})*
1228-
impl FrozenNode {
1229-
option_properties_debug_method! { debug_f64_properties, [$($getter,)*] }
1230-
}
12311172
impl Node {
12321173
option_properties_debug_method! { debug_f64_properties, [$($getter,)*] }
12331174
}
@@ -1240,9 +1181,6 @@ macro_rules! usize_property_methods {
12401181
$(#[$doc])*
12411182
($id, $getter, get_usize_property, Option<usize>, $setter, set_usize_property, usize, $clearer)
12421183
})*
1243-
impl FrozenNode {
1244-
option_properties_debug_method! { debug_usize_properties, [$($getter,)*] }
1245-
}
12461184
impl Node {
12471185
option_properties_debug_method! { debug_usize_properties, [$($getter,)*] }
12481186
}
@@ -1255,9 +1193,6 @@ macro_rules! color_property_methods {
12551193
$(#[$doc])*
12561194
($id, $getter, get_color_property, Option<u32>, $setter, set_color_property, u32, $clearer)
12571195
})*
1258-
impl FrozenNode {
1259-
option_properties_debug_method! { debug_color_properties, [$($getter,)*] }
1260-
}
12611196
impl Node {
12621197
option_properties_debug_method! { debug_color_properties, [$($getter,)*] }
12631198
}
@@ -1270,9 +1205,6 @@ macro_rules! text_decoration_property_methods {
12701205
$(#[$doc])*
12711206
($id, $getter, get_text_decoration_property, Option<TextDecoration>, $setter, set_text_decoration_property, TextDecoration, $clearer)
12721207
})*
1273-
impl FrozenNode {
1274-
option_properties_debug_method! { debug_text_decoration_properties, [$($getter,)*] }
1275-
}
12761208
impl Node {
12771209
option_properties_debug_method! { debug_text_decoration_properties, [$($getter,)*] }
12781210
}
@@ -1285,9 +1217,6 @@ macro_rules! length_slice_property_methods {
12851217
$(#[$doc])*
12861218
($id, $getter, get_length_slice_property, &[u8], $setter, set_length_slice_property, impl Into<Box<[u8]>>, $clearer)
12871219
})*
1288-
impl FrozenNode {
1289-
slice_properties_debug_method! { debug_length_slice_properties, [$($getter,)*] }
1290-
}
12911220
impl Node {
12921221
slice_properties_debug_method! { debug_length_slice_properties, [$($getter,)*] }
12931222
}
@@ -1300,9 +1229,6 @@ macro_rules! coord_slice_property_methods {
13001229
$(#[$doc])*
13011230
($id, $getter, get_coord_slice_property, Option<&[f32]>, $setter, set_coord_slice_property, impl Into<Box<[f32]>>, $clearer)
13021231
})*
1303-
impl FrozenNode {
1304-
option_properties_debug_method! { debug_coord_slice_properties, [$($getter,)*] }
1305-
}
13061232
impl Node {
13071233
option_properties_debug_method! { debug_coord_slice_properties, [$($getter,)*] }
13081234
}
@@ -1315,9 +1241,6 @@ macro_rules! bool_property_methods {
13151241
$(#[$doc])*
13161242
($id, $getter, get_bool_property, Option<bool>, $setter, set_bool_property, bool, $clearer)
13171243
})*
1318-
impl FrozenNode {
1319-
option_properties_debug_method! { debug_bool_properties, [$($getter,)*] }
1320-
}
13211244
impl Node {
13221245
option_properties_debug_method! { debug_bool_properties, [$($getter,)*] }
13231246
}
@@ -1326,18 +1249,6 @@ macro_rules! bool_property_methods {
13261249

13271250
macro_rules! unique_enum_property_methods {
13281251
($($(#[$doc:meta])* ($id:ident, $getter:ident, $setter:ident, $clearer:ident)),+) => {
1329-
impl FrozenNode {
1330-
$($(#[$doc])*
1331-
#[inline]
1332-
pub fn $getter(&self) -> Option<$id> {
1333-
match self.properties.indices.get(&self.properties.values, PropertyId::$id) {
1334-
PropertyValue::None => None,
1335-
PropertyValue::$id(value) => Some(*value),
1336-
_ => unexpected_property_type(),
1337-
}
1338-
})*
1339-
option_properties_debug_method! { debug_unique_enum_properties, [$($getter,)*] }
1340-
}
13411252
impl Node {
13421253
$($(#[$doc])*
13431254
#[inline]
@@ -1371,38 +1282,6 @@ impl Node {
13711282
}
13721283
}
13731284

1374-
impl From<Node> for FrozenNode {
1375-
fn from(node: Node) -> Self {
1376-
Self {
1377-
role: node.role,
1378-
actions: node.actions,
1379-
flags: node.flags,
1380-
properties: node.properties.into(),
1381-
}
1382-
}
1383-
}
1384-
1385-
impl From<&FrozenNode> for Node {
1386-
fn from(node: &FrozenNode) -> Self {
1387-
Self {
1388-
role: node.role,
1389-
actions: node.actions,
1390-
flags: node.flags,
1391-
properties: Properties {
1392-
indices: node.properties.indices,
1393-
values: node.properties.values.to_vec(),
1394-
},
1395-
}
1396-
}
1397-
}
1398-
1399-
impl FrozenNode {
1400-
#[inline]
1401-
pub fn role(&self) -> Role {
1402-
self.role
1403-
}
1404-
}
1405-
14061285
impl Node {
14071286
#[inline]
14081287
pub fn role(&self) -> Role {
@@ -1412,16 +1291,7 @@ impl Node {
14121291
pub fn set_role(&mut self, value: Role) {
14131292
self.role = value;
14141293
}
1415-
}
14161294

1417-
impl FrozenNode {
1418-
#[inline]
1419-
pub fn supports_action(&self, action: Action) -> bool {
1420-
(self.actions & action.mask()) != 0
1421-
}
1422-
}
1423-
1424-
impl Node {
14251295
#[inline]
14261296
pub fn supports_action(&self, action: Action) -> bool {
14271297
(self.actions & action.mask()) != 0
@@ -1806,10 +1676,6 @@ property_methods! {
18061676
(TextSelection, text_selection, get_text_selection_property, Option<&TextSelection>, set_text_selection, set_text_selection_property, impl Into<Box<TextSelection>>, clear_text_selection)
18071677
}
18081678

1809-
impl FrozenNode {
1810-
option_properties_debug_method! { debug_option_properties, [transform, bounds, text_selection,] }
1811-
}
1812-
18131679
impl Node {
18141680
option_properties_debug_method! { debug_option_properties, [transform, bounds, text_selection,] }
18151681
}
@@ -1818,40 +1684,6 @@ vec_property_methods! {
18181684
(CustomActions, CustomAction, custom_actions, get_custom_action_vec, set_custom_actions, set_custom_action_vec, push_custom_action, push_to_custom_action_vec, clear_custom_actions)
18191685
}
18201686

1821-
impl fmt::Debug for FrozenNode {
1822-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1823-
let mut fmt = f.debug_struct("FrozenNode");
1824-
1825-
fmt.field("role", &self.role());
1826-
1827-
let supported_actions = action_mask_to_action_vec(self.actions);
1828-
if !supported_actions.is_empty() {
1829-
fmt.field("actions", &supported_actions);
1830-
}
1831-
1832-
self.debug_flag_properties(&mut fmt);
1833-
self.debug_node_id_vec_properties(&mut fmt);
1834-
self.debug_node_id_properties(&mut fmt);
1835-
self.debug_string_properties(&mut fmt);
1836-
self.debug_f64_properties(&mut fmt);
1837-
self.debug_usize_properties(&mut fmt);
1838-
self.debug_color_properties(&mut fmt);
1839-
self.debug_text_decoration_properties(&mut fmt);
1840-
self.debug_length_slice_properties(&mut fmt);
1841-
self.debug_coord_slice_properties(&mut fmt);
1842-
self.debug_bool_properties(&mut fmt);
1843-
self.debug_unique_enum_properties(&mut fmt);
1844-
self.debug_option_properties(&mut fmt);
1845-
1846-
let custom_actions = self.custom_actions();
1847-
if !custom_actions.is_empty() {
1848-
fmt.field("custom_actions", &custom_actions);
1849-
}
1850-
1851-
fmt.finish()
1852-
}
1853-
}
1854-
18551687
impl fmt::Debug for Node {
18561688
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18571689
let mut fmt = f.debug_struct("Node");

consumer/src/node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// found in the LICENSE.chromium file.
1010

1111
use accesskit::{
12-
Action, Affine, FrozenNode as NodeData, Live, NodeId, Orientation, Point, Rect, Role,
13-
TextSelection, Toggled,
12+
Action, Affine, Live, Node as NodeData, NodeId, Orientation, Point, Rect, Role, TextSelection,
13+
Toggled,
1414
};
1515
use alloc::{
1616
string::{String, ToString},

consumer/src/tree.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// the LICENSE-APACHE file) or the MIT license (found in
44
// the LICENSE-MIT file), at your option.
55

6-
use accesskit::{FrozenNode as NodeData, NodeId, Tree as TreeData, TreeUpdate};
6+
use accesskit::{Node as NodeData, NodeId, Tree as TreeData, TreeUpdate};
77
use alloc::vec;
88
use core::fmt;
99
use hashbrown::{HashMap, HashSet};
@@ -72,8 +72,6 @@ impl State {
7272
}
7373

7474
for (node_id, node_data) in update.nodes {
75-
let node_data = NodeData::from(node_data);
76-
7775
unreachable.remove(&node_id);
7876

7977
let mut seen_child_ids = HashSet::with_capacity(node_data.children().len());

0 commit comments

Comments
 (0)