@@ -311,42 +311,43 @@ void AccessibilityBridge::ConvertFlutterUpdate(const SemanticsNode& node,
311311
312312void AccessibilityBridge::SetRoleFromFlutterUpdate (ui::AXNodeData& node_data,
313313 const SemanticsNode& node) {
314- const FlutterSemanticsFlags* flags = node.flags ;
315- FML_DCHECK (flags) << " SemanticsNode::flags must not be null" ;
316- if (flags->is_button ) {
314+ FlutterSemanticsFlag flags = node.flags ;
315+ if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsButton ) {
317316 node_data.role = ax::mojom::Role::kButton ;
318317 return ;
319318 }
320- if (flags->is_text_field && !flags->is_read_only ) {
319+ if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
320+ !(flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly )) {
321321 node_data.role = ax::mojom::Role::kTextField ;
322322 return ;
323323 }
324- if (flags-> is_header ) {
324+ if (flags & FlutterSemanticsFlag:: kFlutterSemanticsFlagIsHeader ) {
325325 node_data.role = ax::mojom::Role::kHeader ;
326326 return ;
327327 }
328- if (flags-> is_image ) {
328+ if (flags & FlutterSemanticsFlag:: kFlutterSemanticsFlagIsImage ) {
329329 node_data.role = ax::mojom::Role::kImage ;
330330 return ;
331331 }
332- if (flags-> is_link ) {
332+ if (flags & FlutterSemanticsFlag:: kFlutterSemanticsFlagIsLink ) {
333333 node_data.role = ax::mojom::Role::kLink ;
334334 return ;
335335 }
336336
337- if (flags->is_in_mutually_exclusive_group && flags->has_checked_state ) {
337+ if (flags & kFlutterSemanticsFlagIsInMutuallyExclusiveGroup &&
338+ flags & kFlutterSemanticsFlagHasCheckedState ) {
338339 node_data.role = ax::mojom::Role::kRadioButton ;
339340 return ;
340341 }
341- if (flags-> has_checked_state ) {
342+ if (flags & kFlutterSemanticsFlagHasCheckedState ) {
342343 node_data.role = ax::mojom::Role::kCheckBox ;
343344 return ;
344345 }
345- if (flags-> has_toggled_state ) {
346+ if (flags & kFlutterSemanticsFlagHasToggledState ) {
346347 node_data.role = ax::mojom::Role::kSwitch ;
347348 return ;
348349 }
349- if (flags-> is_slider ) {
350+ if (flags & kFlutterSemanticsFlagIsSlider ) {
350351 node_data.role = ax::mojom::Role::kSlider ;
351352 return ;
352353 }
@@ -361,14 +362,17 @@ void AccessibilityBridge::SetRoleFromFlutterUpdate(ui::AXNodeData& node_data,
361362
362363void AccessibilityBridge::SetStateFromFlutterUpdate (ui::AXNodeData& node_data,
363364 const SemanticsNode& node) {
364- const FlutterSemanticsFlags* flags = node.flags ;
365+ FlutterSemanticsFlag flags = node.flags ;
365366 FlutterSemanticsAction actions = node.actions ;
366- if (flags->has_expanded_state && flags->is_expanded ) {
367+ if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagHasExpandedState &&
368+ flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsExpanded ) {
367369 node_data.AddState (ax::mojom::State::kExpanded );
368- } else if (flags->has_expanded_state ) {
370+ } else if (flags &
371+ FlutterSemanticsFlag::kFlutterSemanticsFlagHasExpandedState ) {
369372 node_data.AddState (ax::mojom::State::kCollapsed );
370373 }
371- if (flags->is_text_field && !flags->is_read_only ) {
374+ if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
375+ (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly ) == 0 ) {
372376 node_data.AddState (ax::mojom::State::kEditable );
373377 }
374378 if (node_data.role == ax::mojom::Role::kStaticText &&
@@ -431,7 +435,7 @@ void AccessibilityBridge::SetBooleanAttributesFromFlutterUpdate(
431435 ui::AXNodeData& node_data,
432436 const SemanticsNode& node) {
433437 FlutterSemanticsAction actions = node.actions ;
434- const FlutterSemanticsFlags* flags = node.flags ;
438+ FlutterSemanticsFlag flags = node.flags ;
435439 node_data.AddBoolAttribute (ax::mojom::BoolAttribute::kScrollable ,
436440 actions & kHasScrollingAction );
437441 node_data.AddBoolAttribute (
@@ -440,10 +444,13 @@ void AccessibilityBridge::SetBooleanAttributesFromFlutterUpdate(
440444 // TODO(chunhtai): figure out if there is a node that does not clip overflow.
441445 node_data.AddBoolAttribute (ax::mojom::BoolAttribute::kClipsChildren ,
442446 !node.children_in_traversal_order .empty ());
443- node_data.AddBoolAttribute (ax::mojom::BoolAttribute::kSelected ,
444- flags->is_selected );
445- node_data.AddBoolAttribute (ax::mojom::BoolAttribute::kEditableRoot ,
446- flags->is_text_field && !flags->is_read_only );
447+ node_data.AddBoolAttribute (
448+ ax::mojom::BoolAttribute::kSelected ,
449+ flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsSelected );
450+ node_data.AddBoolAttribute (
451+ ax::mojom::BoolAttribute::kEditableRoot ,
452+ flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
453+ (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly ) == 0 );
447454 // Mark nodes as line breaking so that screen readers don't
448455 // merge all consecutive objects into one.
449456 // TODO(schectman): When should a node have this attribute set?
@@ -455,13 +462,15 @@ void AccessibilityBridge::SetBooleanAttributesFromFlutterUpdate(
455462void AccessibilityBridge::SetIntAttributesFromFlutterUpdate (
456463 ui::AXNodeData& node_data,
457464 const SemanticsNode& node) {
458- const FlutterSemanticsFlags* flags = node.flags ;
465+ FlutterSemanticsFlag flags = node.flags ;
459466 node_data.AddIntAttribute (ax::mojom::IntAttribute::kTextDirection ,
460467 node.text_direction );
461468
462469 int sel_start = node.text_selection_base ;
463470 int sel_end = node.text_selection_extent ;
464- if (flags->is_text_field && !flags->is_read_only && !node.value .empty ()) {
471+ if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
472+ (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly ) == 0 &&
473+ !node.value .empty ()) {
465474 // By default the text field selection should be at the end.
466475 sel_start = sel_start == -1 ? node.value .length () : sel_start;
467476 sel_end = sel_end == -1 ? node.value .length () : sel_end;
@@ -474,15 +483,18 @@ void AccessibilityBridge::SetIntAttributesFromFlutterUpdate(
474483 node_data.AddIntAttribute (
475484 ax::mojom::IntAttribute::kCheckedState ,
476485 static_cast <int32_t >(
477- flags->is_check_state_mixed ? ax::mojom::CheckedState::kMixed
478- : flags->is_checked ? ax::mojom::CheckedState::kTrue
479- : ax::mojom::CheckedState::kFalse ));
486+ flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsCheckStateMixed
487+ ? ax::mojom::CheckedState::kMixed
488+ : flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsChecked
489+ ? ax::mojom::CheckedState::kTrue
490+ : ax::mojom::CheckedState::kFalse ));
480491 } else if (node_data.role == ax::mojom::Role::kSwitch ) {
481492 node_data.AddIntAttribute (
482493 ax::mojom::IntAttribute::kCheckedState ,
483- static_cast <int32_t >(flags->is_toggled
484- ? ax::mojom::CheckedState::kTrue
485- : ax::mojom::CheckedState::kFalse ));
494+ static_cast <int32_t >(
495+ flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsToggled
496+ ? ax::mojom::CheckedState::kTrue
497+ : ax::mojom::CheckedState::kFalse ));
486498 }
487499}
488500
@@ -536,12 +548,13 @@ void AccessibilityBridge::SetTooltipFromFlutterUpdate(
536548
537549void AccessibilityBridge::SetTreeData (const SemanticsNode& node,
538550 ui::AXTreeUpdate& tree_update) {
539- const FlutterSemanticsFlags* flags = node.flags ;
540- // Set selection of the focused node if:
541- // 1. this text field has a valid selection
542- // 2. this text field doesn't have a valid selection but had selection stored
543- // in the tree.
544- if (flags->is_text_field && flags->is_focused ) {
551+ FlutterSemanticsFlag flags = node.flags ;
552+ // Set selection of the focused node if:
553+ // 1. this text field has a valid selection
554+ // 2. this text field doesn't have a valid selection but had selection stored
555+ // in the tree.
556+ if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
557+ flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsFocused ) {
545558 if (node.text_selection_base != -1 ) {
546559 tree_update.tree_data .sel_anchor_object_id = node.id ;
547560 tree_update.tree_data .sel_anchor_offset = node.text_selection_base ;
@@ -557,10 +570,13 @@ void AccessibilityBridge::SetTreeData(const SemanticsNode& node,
557570 }
558571 }
559572
560- if (flags->is_focused && tree_update.tree_data .focus_id != node.id ) {
573+ if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsFocused &&
574+ tree_update.tree_data .focus_id != node.id ) {
561575 tree_update.tree_data .focus_id = node.id ;
562576 tree_update.has_tree_data = true ;
563- } else if (!flags->is_focused && tree_update.tree_data .focus_id == node.id ) {
577+ } else if ((flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsFocused ) ==
578+ 0 &&
579+ tree_update.tree_data .focus_id == node.id ) {
564580 tree_update.tree_data .focus_id = ui::AXNode::kInvalidAXID ;
565581 tree_update.has_tree_data = true ;
566582 }
@@ -571,10 +587,7 @@ AccessibilityBridge::FromFlutterSemanticsNode(
571587 const FlutterSemanticsNode2& flutter_node) {
572588 SemanticsNode result;
573589 result.id = flutter_node.id ;
574- FML_DCHECK (flutter_node.flags2 )
575- << " FlutterSemanticsNode2::flags2 must not be null" ;
576-
577- result.flags = flutter_node.flags2 ;
590+ result.flags = flutter_node.flags ;
578591 result.actions = flutter_node.actions ;
579592 result.text_selection_base = flutter_node.text_selection_base ;
580593 result.text_selection_extent = flutter_node.text_selection_extent ;
0 commit comments