Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ui::AXTableInfo Class Reference

#include <ax_table_info.h>

Classes

struct  CellData
 

Public Member Functions

 ~AXTableInfo ()
 
bool Update ()
 
bool valid () const
 
void Invalidate ()
 
std::string ToString () const
 

Static Public Member Functions

static AXTableInfoCreate (AXTree *tree, AXNode *table_node)
 

Public Attributes

size_t row_count = 0
 
size_t col_count = 0
 
std::vector< std::vector< int32_t > > col_headers
 
std::vector< std::vector< int32_t > > row_headers
 
std::vector< int32_t > all_headers
 
int32_t caption_id
 
std::vector< std::vector< int32_t > > cell_ids
 
std::vector< CellDatacell_data_vector
 
std::vector< int32_t > unique_cell_ids
 
std::vector< AXNode * > extra_mac_nodes
 
std::unordered_map< int32_t, size_t > cell_id_to_index
 
std::unordered_map< int32_t, size_t > row_id_to_index
 
std::vector< AXNode * > row_nodes
 
int aria_row_count = 0
 
int aria_col_count = 0
 

Detailed Description

Definition at line 22 of file ax_table_info.h.

Constructor & Destructor Documentation

◆ ~AXTableInfo()

ui::AXTableInfo::~AXTableInfo ( )

Definition at line 547 of file ax_table_info.cc.

547 {
548 if (!extra_mac_nodes.empty()) {
549 ClearExtraMacNodes();
550 for (AXTreeObserver* observer : tree_->observers()) {
551 observer->OnAtomicUpdateFinished(
552 tree_, false,
553 {{table_node_, AXTreeObserver::ChangeType::NODE_CHANGED}});
554 }
555 }
556}
std::vector< AXNode * > extra_mac_nodes
Definition: ax_table_info.h:85
std::vector< AXTreeObserver * > & observers()
Definition: ax_tree.h:55

Member Function Documentation

◆ Create()

AXTableInfo * ui::AXTableInfo::Create ( AXTree tree,
AXNode table_node 
)
static

Definition at line 75 of file ax_table_info.cc.

75 {
76 BASE_DCHECK(tree);
77 BASE_DCHECK(table_node);
78
79#ifndef NDEBUG
80 // Sanity check, make sure the node is in the tree.
81 AXNode* node = table_node;
82 while (node && node != tree->root())
83 node = node->parent();
84 BASE_DCHECK(node == tree->root());
85#endif
86
87 if (!IsTableLike(table_node->data().role))
88 return nullptr;
89
90 AXTableInfo* info = new AXTableInfo(tree, table_node);
91 bool success = info->Update();
92 BASE_DCHECK(success);
93
94 return info;
95}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
bool IsTableLike(const ax::mojom::Role role)
#define BASE_DCHECK(condition)
Definition: logging.h:63

◆ Invalidate()

void ui::AXTableInfo::Invalidate ( )

Definition at line 146 of file ax_table_info.cc.

146 {
147 valid_ = false;
148}

◆ ToString()

std::string ui::AXTableInfo::ToString ( ) const

Definition at line 518 of file ax_table_info.cc.

518 {
519 // First, scan through to get the length of the largest id.
520 int padding = 0;
521 for (size_t r = 0; r < row_count; r++) {
522 for (size_t c = 0; c < col_count; c++) {
523 // Extract the length of the id for padding purposes.
524 padding = std::max(padding, static_cast<int>(log10(cell_ids[r][c])));
525 }
526 }
527
528 std::string result;
529 for (size_t r = 0; r < row_count; r++) {
530 result += "|";
531 for (size_t c = 0; c < col_count; c++) {
532 int cell_id = cell_ids[r][c];
533 result += base::NumberToString(cell_id);
534 int cell_padding = padding;
535 if (cell_id != 0)
536 cell_padding = padding - static_cast<int>(log10(cell_id));
537 result += std::string(cell_padding, ' ') + '|';
538 }
539 result += "\n";
540 }
541 return result;
542}
std::vector< std::vector< int32_t > > cell_ids
Definition: ax_table_info.h:74
GAsyncResult * result
static float max(float r, float g, float b)
Definition: hsl.cpp:49
std::string NumberToString(int32_t number)
Definition: string_utils.cc:91

◆ Update()

bool ui::AXTableInfo::Update ( )

Definition at line 97 of file ax_table_info.cc.

97 {
98 if (!table_node_->IsTable())
99 return false;
100
101 ClearVectors();
102
103 std::vector<std::vector<AXNode*>> cell_nodes_per_row;
104 caption_id = 0;
105 FindRowsAndThenCells(table_node_, &row_nodes, &cell_nodes_per_row,
106 caption_id);
107 BASE_DCHECK(cell_nodes_per_row.size() == row_nodes.size());
108
109 // Get the optional row and column count from the table. If we encounter
110 // a cell with an index or span larger than this, we'll update the
111 // table row and column count to be large enough to fit all cells.
112 row_count = GetSizeTAttribute(*table_node_, IntAttribute::kTableRowCount);
113 col_count = GetSizeTAttribute(*table_node_, IntAttribute::kTableColumnCount);
114
115 // Note - GetIntAttribute returns 0 if no value has been specified for the
116 // attribute.
117 aria_row_count = static_cast<int>(
118 table_node_->GetIntAttribute(IntAttribute::kAriaRowCount));
119 aria_col_count = static_cast<int>(
120 table_node_->GetIntAttribute(IntAttribute::kAriaColumnCount));
121
122 // Iterate over the cells and build up an array of CellData
123 // entries, one for each cell. Compute the actual row and column
124 BuildCellDataVectorFromRowAndCellNodes(row_nodes, cell_nodes_per_row);
125
126 // At this point we have computed valid row and column indices for
127 // every cell in the table, and an accurate row and column count for the
128 // whole table that fits every cell and its spans. The final step is to
129 // fill in a 2-dimensional array that lets us look up an individual cell
130 // by its (row, column) coordinates, plus arrays to hold row and column
131 // headers.
132 BuildCellAndHeaderVectorsFromCellData();
133
134 // On Mac, we add a few extra nodes to the table - see comment
135 // at the top of UpdateExtraMacNodes for details.
136 if (tree_->enable_extra_mac_nodes())
137 UpdateExtraMacNodes();
138
139 // The table metadata is now valid, any table queries will now be
140 // fast. Any time a node in the table is updated, we'll have to
141 // recompute all of this.
142 valid_ = true;
143 return true;
144}
bool IsTable() const
Definition: ax_node.cc:540
int GetIntAttribute(ax::mojom::IntAttribute attribute) const
Definition: ax_node.h:232
std::vector< AXNode * > row_nodes
Definition: ax_table_info.h:94
int32_t caption_id
Definition: ax_table_info.h:68
bool enable_extra_mac_nodes() const
Definition: ax_tree.h:141

◆ valid()

bool ui::AXTableInfo::valid ( ) const
inline

Definition at line 47 of file ax_table_info.h.

47{ return valid_; }

Member Data Documentation

◆ all_headers

std::vector<int32_t> ui::AXTableInfo::all_headers

Definition at line 65 of file ax_table_info.h.

◆ aria_col_count

int ui::AXTableInfo::aria_col_count = 0

Definition at line 99 of file ax_table_info.h.

◆ aria_row_count

int ui::AXTableInfo::aria_row_count = 0

Definition at line 98 of file ax_table_info.h.

◆ caption_id

int32_t ui::AXTableInfo::caption_id

Definition at line 68 of file ax_table_info.h.

◆ cell_data_vector

std::vector<CellData> ui::AXTableInfo::cell_data_vector

Definition at line 77 of file ax_table_info.h.

◆ cell_id_to_index

std::unordered_map<int32_t, size_t> ui::AXTableInfo::cell_id_to_index

Definition at line 88 of file ax_table_info.h.

◆ cell_ids

std::vector<std::vector<int32_t> > ui::AXTableInfo::cell_ids

Definition at line 74 of file ax_table_info.h.

◆ col_count

size_t ui::AXTableInfo::col_count = 0

Definition at line 56 of file ax_table_info.h.

◆ col_headers

std::vector<std::vector<int32_t> > ui::AXTableInfo::col_headers

Definition at line 59 of file ax_table_info.h.

◆ extra_mac_nodes

std::vector<AXNode*> ui::AXTableInfo::extra_mac_nodes

Definition at line 85 of file ax_table_info.h.

◆ row_count

size_t ui::AXTableInfo::row_count = 0

Definition at line 52 of file ax_table_info.h.

◆ row_headers

std::vector<std::vector<int32_t> > ui::AXTableInfo::row_headers

Definition at line 62 of file ax_table_info.h.

◆ row_id_to_index

std::unordered_map<int32_t, size_t> ui::AXTableInfo::row_id_to_index

Definition at line 91 of file ax_table_info.h.

◆ row_nodes

std::vector<AXNode*> ui::AXTableInfo::row_nodes

Definition at line 94 of file ax_table_info.h.

◆ unique_cell_ids

std::vector<int32_t> ui::AXTableInfo::unique_cell_ids

Definition at line 80 of file ax_table_info.h.


The documentation for this class was generated from the following files: