本文整理汇总了C++中RenderTable::firstBody方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderTable::firstBody方法的具体用法?C++ RenderTable::firstBody怎么用?C++ RenderTable::firstBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderTable
的用法示例。
在下文中一共展示了RenderTable::firstBody方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rowIndexRange
void AccessibilityTableCell::rowIndexRange(pair<int, int>& rowRange)
{
if (!m_renderer || !m_renderer->isTableCell())
return;
RenderTableCell* renderCell = toRenderTableCell(m_renderer);
rowRange.first = renderCell->rowIndex();
rowRange.second = renderCell->rowSpan();
// since our table might have multiple sections, we have to offset our row appropriately
RenderTableSection* section = renderCell->section();
RenderTable* table = renderCell->table();
if (!table || !section)
return;
// FIXME: This will skip a table with just a tfoot. Should fix by using RenderTable::topSection.
RenderTableSection* tableSection = table->header();
if (!tableSection)
tableSection = table->firstBody();
unsigned rowOffset = 0;
while (tableSection) {
if (tableSection == section)
break;
rowOffset += tableSection->numRows();
tableSection = table->sectionBelow(tableSection, SkipEmptySections);
}
rowRange.first += rowOffset;
}
示例2: rowIndexRange
void AccessibilityTableCell::rowIndexRange(pair<int, int>& rowRange)
{
if (!m_renderer)
return;
RenderTableCell* renderCell = static_cast<RenderTableCell*>(m_renderer);
rowRange.first = renderCell->row();
rowRange.second = renderCell->rowSpan();
// since our table might have multiple sections, we have to offset our row appropriately
RenderTableSection* section = renderCell->section();
RenderTable* table = renderCell->table();
if (!table || !section)
return;
RenderTableSection* tableSection = table->header();
if (!tableSection)
tableSection = table->firstBody();
unsigned rowOffset = 0;
while (tableSection) {
if (tableSection == section)
break;
rowOffset += tableSection->numRows();
tableSection = table->sectionBelow(tableSection, true);
}
rowRange.first += rowOffset;
}
示例3: headerObject
AccessibilityObject* AccessibilityTableColumn::headerObject()
{
if (!m_parent)
return 0;
RenderObject* renderer = m_parent->renderer();
if (!renderer)
return 0;
if (!m_parent->isAccessibilityTable())
return 0;
AccessibilityTable* parentTable = toAccessibilityTable(m_parent);
if (parentTable->isAriaTable()) {
AccessibilityChildrenVector rowChildren = children();
unsigned childrenCount = rowChildren.size();
for (unsigned i = 0; i < childrenCount; ++i) {
AccessibilityObject* cell = rowChildren[i].get();
if (cell->ariaRoleAttribute() == ColumnHeaderRole)
return cell;
}
return 0;
}
if (!renderer->isTable())
return 0;
RenderTable* table = toRenderTable(renderer);
AccessibilityObject* headerObject = 0;
// try the <thead> section first. this doesn't require th tags
headerObject = headerObjectForSection(table->header(), false);
if (headerObject)
return headerObject;
// now try for <th> tags in the first body
headerObject = headerObjectForSection(table->firstBody(), true);
return headerObject;
}
示例4: tableElement
HTMLTableElement* AccessibilityTable::tableElement() const
{
if (!m_renderer->isTable())
return nullptr;
RenderTable* table = toRenderTable(m_renderer);
if (table->element() && isHTMLTableElement(table->element()))
return toHTMLTableElement(table->element());
// If the table has a display:table-row-group, then the RenderTable does not have a pointer to it's HTMLTableElement.
// We can instead find it by asking the firstSection for its parent.
RenderTableSection* firstBody = table->firstBody();
if (!firstBody || !firstBody->element())
return nullptr;
Element* actualTable = firstBody->element()->parentElement();
if (!actualTable || !isHTMLTableElement(actualTable))
return nullptr;
return toHTMLTableElement(actualTable);
}
示例5: isDataTable
bool AccessibilityTable::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()->hasEditableStyle())
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);
if (!table->element() || !isHTMLTableElement(table->element()))
return false;
// if there is a caption element, summary, THEAD, or TFOOT section, it's most certainly a data table
HTMLTableElement* tableElement = toHTMLTableElement(table->element());
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 (const auto& child : childrenOfType<Element>(*tableElement)) {
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.
const RenderStyle& tableStyle = table->style();
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;
Element* cellElement = cell->element();
if (!cellElement)
continue;
if (cell->width() < 1 || cell->height() < 1)
continue;
validCellCount++;
bool isTHCell = cellElement->hasTagName(thTag);
// If the first row is comprised of all <th> tags, assume it is a data table.
if (!row && isTHCell)
headersInFirstRowCount++;
//.........这里部分代码省略.........
示例6: isTableExposableThroughAccessibility
bool AccessibilityTable::isTableExposableThroughAccessibility()
{
// the following is a heuristic used to determine if a
// <table> should be exposed as an AXTable. The goal
// is to only show "data" tables
if (!m_renderer || !m_renderer->isTable())
return false;
// if the developer assigned an aria role to this, then we shouldn't
// expose it as a table, unless, of course, the aria role is a table
AccessibilityRole ariaRole = ariaRoleAttribute();
if (ariaRole == TableRole)
return true;
if (ariaRole != UnknownRole)
return false;
RenderTable* table = static_cast<RenderTable*>(m_renderer);
// 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
Node* tableNode = table->element();
if (!tableNode || !tableNode->hasTagName(tableTag))
return false;
// if there is a caption element, summary, THEAD, or TFOOT section, it's most certainly a data table
HTMLTableElement* tableElement = static_cast<HTMLTableElement*>(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;
// 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
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;
// 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->backgroundColor();
// 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;
for (int row = 0; row < numRows; ++row) {
for (int col = 0; col < numCols; ++col) {
RenderTableCell* cell = firstBody->cellAt(row, col).cell;
if (!cell)
continue;
Node* cellNode = cell->element();
if (!cellNode)
continue;
if (cell->width() < 1 || cell->height() < 1)
continue;
validCellCount++;
HTMLTableCellElement* cellElement = static_cast<HTMLTableCellElement*>(cellNode);
// in this case, the developer explicitly assigned a "data" table attribute
if (!cellElement->headers().isEmpty() || !cellElement->abbr().isEmpty() ||
!cellElement->axis().isEmpty() || !cellElement->scope().isEmpty())
return true;
RenderStyle* renderStyle = cell->style();
if (!renderStyle)
continue;
// a cell needs to have matching bordered sides, before it can be considered a bordered cell.
if ((cell->borderTop() > 0 && cell->borderBottom() > 0) ||
(cell->borderLeft() > 0 && cell->borderRight() > 0))
borderedCellCount++;
// if the cell has a different color from the table and there is cell spacing,
// then it is probably a data table cell (spacing and colors take the place of borders)
Color cellColor = renderStyle->backgroundColor();
if (table->hBorderSpacing() > 0 && table->vBorderSpacing() > 0 &&
tableBGColor != cellColor && cellColor.alpha() != 1)
//.........这里部分代码省略.........
示例7: cellForColumnAndRow
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()->get(cell);
ASSERT(cellObject->isTableCell());
return static_cast<AccessibilityTableCell*>(cellObject);
}
示例8: addChildren
void AccessibilityTable::addChildren()
{
if (!isDataTable()) {
AccessibilityRenderObject::addChildren();
return;
}
ASSERT(!m_haveChildren);
m_haveChildren = true;
if (!m_renderer)
return;
RenderTable* table = static_cast<RenderTable*>(m_renderer);
AXObjectCache* axCache = m_renderer->document()->axObjectCache();
// go through all the available sections to pull out the rows
// and add them as children
RenderTableSection* tableSection = table->header();
if (!tableSection)
tableSection = table->firstBody();
if (!tableSection)
return;
RenderTableSection* initialTableSection = tableSection;
while (tableSection) {
HashSet<AccessibilityObject*> appendedRows;
unsigned numRows = tableSection->numRows();
unsigned numCols = tableSection->numColumns();
for (unsigned rowIndex = 0; rowIndex < numRows; ++rowIndex) {
for (unsigned colIndex = 0; colIndex < numCols; ++colIndex) {
RenderTableCell* cell = tableSection->cellAt(rowIndex, colIndex).cell;
if (!cell)
continue;
AccessibilityObject* rowObject = axCache->get(cell->parent());
if (!rowObject->isTableRow())
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->get(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);
}
示例9: isDataTable
bool AccessibilityTable::isDataTable() const
{
if (!m_renderer)
return false;
// Do not consider it a data table is it has an ARIA role.
if (hasARIARole())
return false;
// 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 || !tableNode->hasTagName(tableTag))
return false;
// if there is a caption element, summary, THEAD, or TFOOT section, it's most certainly a data table
HTMLTableElement* tableElement = static_cast<HTMLTableElement*>(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;
// 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
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;
// 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;
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++;
HTMLTableCellElement* cellElement = static_cast<HTMLTableCellElement*>(cellNode);
bool isTHCell = cellElement->hasTagName(thTag);
// If the first row is comprised of all <th> tags, assume it is a data table.
if (!row && isTHCell)
headersInFirstRowCount++;
// If the first column is comprised of all <th> tags, assume it is a data table.
if (!col && isTHCell)
headersInFirstColumnCount++;
// in this case, the developer explicitly assigned a "data" table attribute
if (!cellElement->headers().isEmpty() || !cellElement->abbr().isEmpty()
|| !cellElement->axis().isEmpty() || !cellElement->scope().isEmpty())
return true;
RenderStyle* renderStyle = cell->style();
if (!renderStyle)
continue;
// a cell needs to have matching bordered sides, before it can be considered a bordered cell.
if ((cell->borderTop() > 0 && cell->borderBottom() > 0)
|| (cell->borderLeft() > 0 && cell->borderRight() > 0))
borderedCellCount++;
//.........这里部分代码省略.........
示例10: cellForColumnAndRow
AccessibilityTableCell* AccessibilityTable::cellForColumnAndRow(unsigned column, unsigned row)
{
if (!m_renderer || !m_renderer->isTable())
return 0;
updateChildrenIfNecessary();
RenderTable* table = toRenderTable(m_renderer);
// FIXME: This will skip a table with just a tfoot. Should fix by using RenderTable::topSection.
RenderTableSection* tableSection = table->header();
if (!tableSection)
tableSection = table->firstBody();
RenderTableCell* cell = 0;
unsigned rowCount = 0;
unsigned rowOffset = 0;
while (tableSection) {
unsigned numRows = tableSection->numRows();
unsigned numCols = tableSection->numColumns();
rowCount += numRows;
unsigned sectionSpecificRow = row - rowOffset;
if (row < rowCount && column < numCols && sectionSpecificRow < numRows) {
cell = tableSection->primaryCellAt(sectionSpecificRow, column);
// 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->primaryCellAt(testRow, column);
// cell overlapped. use this one
ASSERT(cell->rowSpan() >= 1);
if (cell && ((cell->rowIndex() + (cell->rowSpan() - 1)) >= sectionSpecificRow))
break;
cell = 0;
}
if (!cell) {
// try cols
for (int testCol = column - 1; testCol >= 0; --testCol) {
cell = tableSection->primaryCellAt(sectionSpecificRow, testCol);
// cell overlapped. use this one
ASSERT(cell->rowSpan() >= 1);
if (cell && ((cell->col() + (cell->colSpan() - 1)) >= column))
break;
cell = 0;
}
}
}
}
if (cell)
break;
rowOffset += numRows;
// we didn't find anything between the rows we should have
if (row < rowCount)
break;
tableSection = table->sectionBelow(tableSection, SkipEmptySections);
}
if (!cell)
return 0;
AccessibilityObject* cellObject = axObjectCache()->getOrCreate(cell);
ASSERT(cellObject->isTableCell());
return static_cast<AccessibilityTableCell*>(cellObject);
}
示例11: addChildren
void AccessibilityTable::addChildren()
{
if (!isAccessibilityTable()) {
AccessibilityRenderObject::addChildren();
return;
}
ASSERT(!m_haveChildren);
m_haveChildren = true;
if (!m_renderer || !m_renderer->isTable())
return;
RenderTable* table = toRenderTable(m_renderer);
AXObjectCache* axCache = m_renderer->document()->axObjectCache();
// go through all the available sections to pull out the rows
// and add them as children
// FIXME: This will skip a table with just a tfoot. Should fix by using RenderTable::topSection.
RenderTableSection* tableSection = table->header();
if (!tableSection)
tableSection = table->firstBody();
if (!tableSection)
return;
RenderTableSection* initialTableSection = tableSection;
while (tableSection) {
HashSet<AccessibilityObject*> appendedRows;
unsigned numRows = tableSection->numRows();
unsigned numCols = tableSection->numColumns();
for (unsigned rowIndex = 0; rowIndex < numRows; ++rowIndex) {
for (unsigned colIndex = 0; colIndex < numCols; ++colIndex) {
RenderTableCell* cell = tableSection->primaryCellAt(rowIndex, colIndex);
if (!cell)
continue;
AccessibilityObject* rowObject = axCache->getOrCreate(cell->parent());
if (!rowObject->isTableRow())
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);
if (!row->accessibilityIsIgnored())
m_children.append(row);
#if PLATFORM(GTK)
else
m_children.append(row->children());
#endif
appendedRows.add(row);
}
}
tableSection = table->sectionBelow(tableSection, SkipEmptySections);
}
// 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->setParent(this);
m_columns.append(column);
if (!column->accessibilityIsIgnored())
m_children.append(column);
}
AccessibilityObject* headerContainerObject = headerContainer();
if (headerContainerObject && !headerContainerObject->accessibilityIsIgnored())
m_children.append(headerContainerObject);
}