本文整理汇总了C++中RenderTable::node方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderTable::node方法的具体用法?C++ RenderTable::node怎么用?C++ RenderTable::node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderTable
的用法示例。
在下文中一共展示了RenderTable::node方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isDataTable
bool AXTable::isDataTable() const
{
if (!m_renderer)
return false;
// Do not consider it a data table is it has an ARIA role.
if (hasARIARole())
return false;
// When a section of the document is contentEditable, all tables should be
// treated as data tables, otherwise users may not be able to work with rich
// text editors that allow creating and editing tables.
if (node() && node()->rendererIsEditable())
return true;
// This employs a heuristic to determine if this table should appear.
// Only "data" tables should be exposed as tables.
// Unfortunately, there is no good way to determine the difference
// between a "layout" table and a "data" table.
RenderTable* table = toRenderTable(m_renderer);
Node* tableNode = table->node();
if (!tableNode || !isHTMLTableElement(tableNode))
return false;
// if there is a caption element, summary, THEAD, or TFOOT section, it's most certainly a data table
HTMLTableElement* tableElement = toHTMLTableElement(tableNode);
if (!tableElement->summary().isEmpty() || tableElement->tHead() || tableElement->tFoot() || tableElement->caption())
return true;
// if someone used "rules" attribute than the table should appear
if (!tableElement->rules().isEmpty())
return true;
// if there's a colgroup or col element, it's probably a data table.
for (Node* child = tableElement->firstChild(); child; child = child->nextSibling()) {
if (child->hasTagName(colTag) || child->hasTagName(colgroupTag))
return true;
}
// go through the cell's and check for tell-tale signs of "data" table status
// cells have borders, or use attributes like headers, abbr, scope or axis
table->recalcSectionsIfNeeded();
RenderTableSection* firstBody = table->firstBody();
if (!firstBody)
return false;
int numCols = firstBody->numColumns();
int numRows = firstBody->numRows();
// If there's only one cell, it's not a good AXTable candidate.
if (numRows == 1 && numCols == 1)
return false;
// If there are at least 20 rows, we'll call it a data table.
if (numRows >= 20)
return true;
// Store the background color of the table to check against cell's background colors.
RenderStyle* tableStyle = table->style();
if (!tableStyle)
return false;
Color tableBGColor = tableStyle->visitedDependentColor(CSSPropertyBackgroundColor);
// check enough of the cells to find if the table matches our criteria
// Criteria:
// 1) must have at least one valid cell (and)
// 2) at least half of cells have borders (or)
// 3) at least half of cells have different bg colors than the table, and there is cell spacing
unsigned validCellCount = 0;
unsigned borderedCellCount = 0;
unsigned backgroundDifferenceCellCount = 0;
unsigned cellsWithTopBorder = 0;
unsigned cellsWithBottomBorder = 0;
unsigned cellsWithLeftBorder = 0;
unsigned cellsWithRightBorder = 0;
Color alternatingRowColors[5];
int alternatingRowColorCount = 0;
int headersInFirstColumnCount = 0;
for (int row = 0; row < numRows; ++row) {
int headersInFirstRowCount = 0;
for (int col = 0; col < numCols; ++col) {
RenderTableCell* cell = firstBody->primaryCellAt(row, col);
if (!cell)
continue;
Node* cellNode = cell->node();
if (!cellNode)
continue;
if (cell->width() < 1 || cell->height() < 1)
continue;
validCellCount++;
bool isTHCell = cellNode->hasTagName(thTag);
// If the first row is comprised of all <th> tags, assume it is a data table.
if (!row && isTHCell)
//.........这里部分代码省略.........