accessibilitytable.cpp
来自「linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自Web」· C++ 代码 · 共 490 行 · 第 1/2 页
CPP
490 行
continue; AccessibilityTableRow* row = static_cast<AccessibilityTableRow*>(rowObject); // we need to check every cell for a new row, because cell spans // can cause us to mess rows if we just check the first column if (appendedRows.contains(row)) continue; row->setRowIndex((int)m_rows.size()); m_rows.append(row); m_children.append(row); appendedRows.add(row); } } tableSection = table->sectionBelow(tableSection, true); } // make the columns based on the number of columns in the first body unsigned length = initialTableSection->numColumns(); for (unsigned i = 0; i < length; ++i) { AccessibilityTableColumn* column = static_cast<AccessibilityTableColumn*>(axCache->getOrCreate(ColumnRole)); column->setColumnIndex((int)i); column->setParentTable(this); m_columns.append(column); m_children.append(column); } AccessibilityObject* headerContainerObject = headerContainer(); if (headerContainerObject) m_children.append(headerContainerObject);} AccessibilityObject* AccessibilityTable::headerContainer(){ if (m_headerContainer) return m_headerContainer; m_headerContainer = static_cast<AccessibilityTableHeaderContainer*>(axObjectCache()->getOrCreate(TableHeaderContainerRole)); m_headerContainer->setParentTable(this); return m_headerContainer;}AccessibilityObject::AccessibilityChildrenVector& AccessibilityTable::columns(){ if (!hasChildren()) addChildren(); return m_columns;}AccessibilityObject::AccessibilityChildrenVector& AccessibilityTable::rows(){ if (!hasChildren()) addChildren(); return m_rows;} void AccessibilityTable::rowHeaders(AccessibilityChildrenVector& headers){ if (!m_renderer) return; if (!hasChildren()) addChildren(); unsigned rowCount = m_rows.size(); for (unsigned k = 0; k < rowCount; ++k) { AccessibilityObject* header = static_cast<AccessibilityTableRow*>(m_rows[k].get())->headerObject(); if (!header) continue; headers.append(header); }}void AccessibilityTable::columnHeaders(AccessibilityChildrenVector& headers){ if (!m_renderer) return; if (!hasChildren()) addChildren(); unsigned colCount = m_columns.size(); for (unsigned k = 0; k < colCount; ++k) { AccessibilityObject* header = static_cast<AccessibilityTableColumn*>(m_columns[k].get())->headerObject(); if (!header) continue; headers.append(header); }} void AccessibilityTable::cells(AccessibilityObject::AccessibilityChildrenVector& cells){ if (!m_renderer) return; if (!hasChildren()) addChildren(); int numRows = m_rows.size(); for (int row = 0; row < numRows; ++row) { AccessibilityChildrenVector rowChildren = m_rows[row]->children(); cells.append(rowChildren); }} const unsigned AccessibilityTable::columnCount(){ if (!hasChildren()) addChildren(); return m_columns.size(); } const unsigned AccessibilityTable::rowCount(){ if (!hasChildren()) addChildren(); return m_rows.size();} AccessibilityTableCell* AccessibilityTable::cellForColumnAndRow(unsigned column, unsigned row){ if (!m_renderer) return 0; if (!hasChildren()) addChildren(); RenderTable* table = static_cast<RenderTable*>(m_renderer); RenderTableSection* tableSection = table->header(); if (!tableSection) tableSection = table->firstBody(); RenderTableCell* cell = 0; unsigned rowCount = 0; unsigned rowOffset = 0; while (tableSection) { rowCount += tableSection->numRows(); unsigned numCols = tableSection->numColumns(); if (row < rowCount && column < numCols) { int sectionSpecificRow = row - rowOffset; cell = tableSection->cellAt(sectionSpecificRow, column).cell; // we didn't find the cell, which means there's spanning happening // search backwards to find the spanning cell if (!cell) { // first try rows for (int testRow = sectionSpecificRow-1; testRow >= 0; --testRow) { cell = tableSection->cellAt(testRow, column).cell; // cell overlapped. use this one if (cell && ((cell->row() + (cell->rowSpan()-1)) >= (int)sectionSpecificRow)) break; cell = 0; } if (!cell) { // try cols for (int testCol = column-1; testCol >= 0; --testCol) { cell = tableSection->cellAt(sectionSpecificRow, testCol).cell; // cell overlapped. use this one if (cell && ((cell->col() + (cell->colSpan()-1)) >= (int)column)) break; cell = 0; } } } } if (cell) break; rowOffset += rowCount; // we didn't find anything between the rows we should have if (row < rowOffset) break; tableSection = table->sectionBelow(tableSection, true); } if (!cell) return 0; AccessibilityObject* cellObject = axObjectCache()->getOrCreate(cell); ASSERT(cellObject->isTableCell()); return static_cast<AccessibilityTableCell*>(cellObject);}AccessibilityRole AccessibilityTable::roleValue() const{ if (!isDataTable()) return AccessibilityRenderObject::roleValue(); return TableRole;} bool AccessibilityTable::accessibilityIsIgnored() const{ if (!isDataTable()) return AccessibilityRenderObject::accessibilityIsIgnored(); return false;} String AccessibilityTable::title() const{ if (!isDataTable()) return AccessibilityRenderObject::title(); String title; if (!m_renderer) return title; // see if there is a caption Node* tableElement = m_renderer->node(); if (tableElement) { HTMLTableCaptionElement* caption = static_cast<HTMLTableElement*>(tableElement)->caption(); if (caption) title = caption->innerText(); } // try the standard if (title.isEmpty()) title = AccessibilityRenderObject::title(); return title;}bool AccessibilityTable::isDataTable() const{ if (!m_renderer) return false; return m_isAccessibilityTable;}} // namespace WebCore
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?