@@ -311,43 +311,43 @@ void AccessibilityBridge::ConvertFlutterUpdate(const SemanticsNode& node,
311
311
312
312
void AccessibilityBridge::SetRoleFromFlutterUpdate (ui::AXNodeData& node_data,
313
313
const SemanticsNode& node) {
314
- FlutterSemanticsFlag flags = node.flags ;
315
- if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsButton ) {
314
+ const FlutterSemanticsFlags* flags = node.flags ;
315
+ FML_DCHECK (flags) << " SemanticsNode::flags must not be null" ;
316
+ if (flags->is_button ) {
316
317
node_data.role = ax::mojom::Role::kButton ;
317
318
return ;
318
319
}
319
- if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
320
- !(flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly )) {
320
+ if (flags->is_text_field && !flags->is_read_only ) {
321
321
node_data.role = ax::mojom::Role::kTextField ;
322
322
return ;
323
323
}
324
- if (flags & FlutterSemanticsFlag:: kFlutterSemanticsFlagIsHeader ) {
324
+ if (flags-> is_header ) {
325
325
node_data.role = ax::mojom::Role::kHeader ;
326
326
return ;
327
327
}
328
- if (flags & FlutterSemanticsFlag:: kFlutterSemanticsFlagIsImage ) {
328
+ if (flags-> is_image ) {
329
329
node_data.role = ax::mojom::Role::kImage ;
330
330
return ;
331
331
}
332
- if (flags & FlutterSemanticsFlag:: kFlutterSemanticsFlagIsLink ) {
332
+ if (flags-> is_link ) {
333
333
node_data.role = ax::mojom::Role::kLink ;
334
334
return ;
335
335
}
336
336
337
- if (flags & kFlutterSemanticsFlagIsInMutuallyExclusiveGroup &&
338
- flags & kFlutterSemanticsFlagHasCheckedState ) {
337
+ if (flags-> is_in_mutually_exclusive_group &&
338
+ flags-> is_checked != FlutterCheckState:: kFlutterCheckStateNone ) {
339
339
node_data.role = ax::mojom::Role::kRadioButton ;
340
340
return ;
341
341
}
342
- if (flags & kFlutterSemanticsFlagHasCheckedState ) {
342
+ if (flags-> is_checked != FlutterCheckState:: kFlutterCheckStateNone ) {
343
343
node_data.role = ax::mojom::Role::kCheckBox ;
344
344
return ;
345
345
}
346
- if (flags & kFlutterSemanticsFlagHasToggledState ) {
346
+ if (flags-> is_toggled != FlutterTristate:: kFlutterTristateNone ) {
347
347
node_data.role = ax::mojom::Role::kSwitch ;
348
348
return ;
349
349
}
350
- if (flags & kFlutterSemanticsFlagIsSlider ) {
350
+ if (flags-> is_slider ) {
351
351
node_data.role = ax::mojom::Role::kSlider ;
352
352
return ;
353
353
}
@@ -362,17 +362,14 @@ void AccessibilityBridge::SetRoleFromFlutterUpdate(ui::AXNodeData& node_data,
362
362
363
363
void AccessibilityBridge::SetStateFromFlutterUpdate (ui::AXNodeData& node_data,
364
364
const SemanticsNode& node) {
365
- FlutterSemanticsFlag flags = node.flags ;
365
+ const FlutterSemanticsFlags* flags = node.flags ;
366
366
FlutterSemanticsAction actions = node.actions ;
367
- if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagHasExpandedState &&
368
- flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsExpanded ) {
367
+ if (flags->is_expanded == FlutterTristate::kFlutterTristateTrue ) {
369
368
node_data.AddState (ax::mojom::State::kExpanded );
370
- } else if (flags &
371
- FlutterSemanticsFlag::kFlutterSemanticsFlagHasExpandedState ) {
369
+ } else if (flags->is_expanded == FlutterTristate::kFlutterTristateFalse ) {
372
370
node_data.AddState (ax::mojom::State::kCollapsed );
373
371
}
374
- if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
375
- (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly ) == 0 ) {
372
+ if (flags->is_text_field && !flags->is_read_only ) {
376
373
node_data.AddState (ax::mojom::State::kEditable );
377
374
}
378
375
if (node_data.role == ax::mojom::Role::kStaticText &&
@@ -435,7 +432,7 @@ void AccessibilityBridge::SetBooleanAttributesFromFlutterUpdate(
435
432
ui::AXNodeData& node_data,
436
433
const SemanticsNode& node) {
437
434
FlutterSemanticsAction actions = node.actions ;
438
- FlutterSemanticsFlag flags = node.flags ;
435
+ const FlutterSemanticsFlags* flags = node.flags ;
439
436
node_data.AddBoolAttribute (ax::mojom::BoolAttribute::kScrollable ,
440
437
actions & kHasScrollingAction );
441
438
node_data.AddBoolAttribute (
@@ -444,13 +441,10 @@ void AccessibilityBridge::SetBooleanAttributesFromFlutterUpdate(
444
441
// TODO(chunhtai): figure out if there is a node that does not clip overflow.
445
442
node_data.AddBoolAttribute (ax::mojom::BoolAttribute::kClipsChildren ,
446
443
!node.children_in_traversal_order .empty ());
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 );
444
+ node_data.AddBoolAttribute (ax::mojom::BoolAttribute::kSelected ,
445
+ flags->is_selected );
446
+ node_data.AddBoolAttribute (ax::mojom::BoolAttribute::kEditableRoot ,
447
+ flags->is_text_field && !flags->is_read_only );
454
448
// Mark nodes as line breaking so that screen readers don't
455
449
// merge all consecutive objects into one.
456
450
// TODO(schectman): When should a node have this attribute set?
@@ -462,15 +456,13 @@ void AccessibilityBridge::SetBooleanAttributesFromFlutterUpdate(
462
456
void AccessibilityBridge::SetIntAttributesFromFlutterUpdate (
463
457
ui::AXNodeData& node_data,
464
458
const SemanticsNode& node) {
465
- FlutterSemanticsFlag flags = node.flags ;
459
+ const FlutterSemanticsFlags* flags = node.flags ;
466
460
node_data.AddIntAttribute (ax::mojom::IntAttribute::kTextDirection ,
467
461
node.text_direction );
468
462
469
463
int sel_start = node.text_selection_base ;
470
464
int sel_end = node.text_selection_extent ;
471
- if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
472
- (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly ) == 0 &&
473
- !node.value .empty ()) {
465
+ if (flags->is_text_field && !flags->is_read_only && !node.value .empty ()) {
474
466
// By default the text field selection should be at the end.
475
467
sel_start = sel_start == -1 ? node.value .length () : sel_start;
476
468
sel_end = sel_end == -1 ? node.value .length () : sel_end;
@@ -483,16 +475,16 @@ void AccessibilityBridge::SetIntAttributesFromFlutterUpdate(
483
475
node_data.AddIntAttribute (
484
476
ax::mojom::IntAttribute::kCheckedState ,
485
477
static_cast <int32_t >(
486
- flags & FlutterSemanticsFlag:: kFlutterSemanticsFlagIsCheckStateMixed
478
+ ( flags-> is_checked == FlutterCheckState:: kFlutterCheckStateMixed )
487
479
? ax::mojom::CheckedState::kMixed
488
- : flags & FlutterSemanticsFlag:: kFlutterSemanticsFlagIsChecked
480
+ : ( flags-> is_checked == FlutterCheckState:: kFlutterCheckStateTrue )
489
481
? ax::mojom::CheckedState::kTrue
490
482
: ax::mojom::CheckedState::kFalse ));
491
483
} else if (node_data.role == ax::mojom::Role::kSwitch ) {
492
484
node_data.AddIntAttribute (
493
485
ax::mojom::IntAttribute::kCheckedState ,
494
486
static_cast <int32_t >(
495
- flags & FlutterSemanticsFlag:: kFlutterSemanticsFlagIsToggled
487
+ ( flags-> is_toggled == FlutterTristate:: kFlutterTristateTrue )
496
488
? ax::mojom::CheckedState::kTrue
497
489
: ax::mojom::CheckedState::kFalse ));
498
490
}
@@ -548,13 +540,13 @@ void AccessibilityBridge::SetTooltipFromFlutterUpdate(
548
540
549
541
void AccessibilityBridge::SetTreeData (const SemanticsNode& node,
550
542
ui::AXTreeUpdate& tree_update) {
551
- FlutterSemanticsFlag flags = node.flags ;
543
+ const FlutterSemanticsFlags* flags = node.flags ;
552
544
// Set selection of the focused node if:
553
545
// 1. this text field has a valid selection
554
546
// 2. this text field doesn't have a valid selection but had selection stored
555
547
// in the tree.
556
- if (flags & FlutterSemanticsFlag:: kFlutterSemanticsFlagIsTextField &&
557
- flags & FlutterSemanticsFlag:: kFlutterSemanticsFlagIsFocused ) {
548
+ if (flags-> is_text_field &&
549
+ flags-> is_focused == FlutterTristate:: kFlutterTristateTrue ) {
558
550
if (node.text_selection_base != -1 ) {
559
551
tree_update.tree_data .sel_anchor_object_id = node.id ;
560
552
tree_update.tree_data .sel_anchor_offset = node.text_selection_base ;
@@ -570,12 +562,11 @@ void AccessibilityBridge::SetTreeData(const SemanticsNode& node,
570
562
}
571
563
}
572
564
573
- if (flags & FlutterSemanticsFlag:: kFlutterSemanticsFlagIsFocused &&
565
+ if (flags-> is_focused == FlutterTristate:: kFlutterTristateTrue &&
574
566
tree_update.tree_data .focus_id != node.id ) {
575
567
tree_update.tree_data .focus_id = node.id ;
576
568
tree_update.has_tree_data = true ;
577
- } else if ((flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsFocused ) ==
578
- 0 &&
569
+ } else if (flags->is_focused != FlutterTristate::kFlutterTristateTrue &&
579
570
tree_update.tree_data .focus_id == node.id ) {
580
571
tree_update.tree_data .focus_id = ui::AXNode::kInvalidAXID ;
581
572
tree_update.has_tree_data = true ;
@@ -587,7 +578,10 @@ AccessibilityBridge::FromFlutterSemanticsNode(
587
578
const FlutterSemanticsNode2& flutter_node) {
588
579
SemanticsNode result;
589
580
result.id = flutter_node.id ;
590
- result.flags = flutter_node.flags ;
581
+ FML_DCHECK (flutter_node.flags2 )
582
+ << " FlutterSemanticsNode2::flags2 must not be null" ;
583
+
584
+ result.flags = flutter_node.flags2 ;
591
585
result.actions = flutter_node.actions ;
592
586
result.text_selection_base = flutter_node.text_selection_base ;
593
587
result.text_selection_extent = flutter_node.text_selection_extent ;
@@ -596,8 +590,6 @@ AccessibilityBridge::FromFlutterSemanticsNode(
596
590
result.scroll_position = flutter_node.scroll_position ;
597
591
result.scroll_extent_max = flutter_node.scroll_extent_max ;
598
592
result.scroll_extent_min = flutter_node.scroll_extent_min ;
599
- result.elevation = flutter_node.elevation ;
600
- result.thickness = flutter_node.thickness ;
601
593
if (flutter_node.label ) {
602
594
result.label = std::string (flutter_node.label );
603
595
}
0 commit comments