本文整理汇总了C++中HTMLTableElement类的典型用法代码示例。如果您正苦于以下问题:C++ HTMLTableElement类的具体用法?C++ HTMLTableElement怎么用?C++ HTMLTableElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTMLTableElement类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jsHTMLTableElementPrototypeFunctionDeleteCaption
JSValue* jsHTMLTableElementPrototypeFunctionDeleteCaption(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
if (!thisValue->isObject(&JSHTMLTableElement::s_info))
return throwError(exec, TypeError);
JSHTMLTableElement* castedThisObj = static_cast<JSHTMLTableElement*>(thisValue);
HTMLTableElement* imp = static_cast<HTMLTableElement*>(castedThisObj->impl());
imp->deleteCaption();
return jsUndefined();
}
示例2: jsHTMLTableElementPrototypeFunctionCreateCaption
JSValue* jsHTMLTableElementPrototypeFunctionCreateCaption(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
if (!thisValue->isObject(&JSHTMLTableElement::s_info))
return throwError(exec, TypeError);
JSHTMLTableElement* castedThisObj = static_cast<JSHTMLTableElement*>(thisValue);
HTMLTableElement* imp = static_cast<HTMLTableElement*>(castedThisObj->impl());
KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createCaption()));
return result;
}
示例3: jsHTMLTableElementPrototypeFunctionDeleteRow
JSValue* jsHTMLTableElementPrototypeFunctionDeleteRow(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
if (!thisValue->isObject(&JSHTMLTableElement::s_info))
return throwError(exec, TypeError);
JSHTMLTableElement* castedThisObj = static_cast<JSHTMLTableElement*>(thisValue);
HTMLTableElement* imp = static_cast<HTMLTableElement*>(castedThisObj->impl());
ExceptionCode ec = 0;
int index = args[0]->toInt32(exec);
imp->deleteRow(index, ec);
setDOMException(exec, ec);
return jsUndefined();
}
示例4: jsHTMLTableElementPrototypeFunctionInsertRow
JSValue* jsHTMLTableElementPrototypeFunctionInsertRow(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
if (!thisValue->isObject(&JSHTMLTableElement::s_info))
return throwError(exec, TypeError);
JSHTMLTableElement* castedThisObj = static_cast<JSHTMLTableElement*>(thisValue);
HTMLTableElement* imp = static_cast<HTMLTableElement*>(castedThisObj->impl());
ExceptionCode ec = 0;
int index = args[0]->toInt32(exec);
KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->insertRow(index, ec)));
setDOMException(exec, ec);
return result;
}
示例5: GetTable
int32_t
HTMLTableRowElement::RowIndex() const
{
HTMLTableElement* table = GetTable();
if (!table) {
return -1;
}
nsIHTMLCollection* rows = table->Rows();
uint32_t numRows = rows->Length();
for (uint32_t i = 0; i < numRows; i++) {
if (rows->GetElementAt(i) == this) {
return i;
}
}
return -1;
}
示例6: parentNode
int HTMLTableRowElement::rowIndex() const
{
auto* parent = parentNode();
if (!parent)
return -1;
HTMLTableElement* table;
if (is<HTMLTableElement>(*parent))
table = downcast<HTMLTableElement>(parent);
else {
if (!is<HTMLTableSectionElement>(*parent) || !is<HTMLTableElement>(parent->parentNode()))
return -1;
table = downcast<HTMLTableElement>(parent->parentNode());
}
auto rows = table->rows();
unsigned length = rows->length();
for (unsigned i = 0; i < length; ++i) {
if (rows->item(i) == this)
return i;
}
return -1;
}
示例7: toRenderTable
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++;
//.........这里部分代码省略.........
示例8: switch
void JSHTMLTableElement::putValueProperty(ExecState* exec, int token, JSValue* value)
{
switch (token) {
case CaptionAttrNum: {
HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl());
ExceptionCode ec = 0;
imp->setCaption(toHTMLTableCaptionElement(value), ec);
setDOMException(exec, ec);
break;
}
case THeadAttrNum: {
HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl());
ExceptionCode ec = 0;
imp->setTHead(toHTMLTableSectionElement(value), ec);
setDOMException(exec, ec);
break;
}
case TFootAttrNum: {
HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl());
ExceptionCode ec = 0;
imp->setTFoot(toHTMLTableSectionElement(value), ec);
setDOMException(exec, ec);
break;
}
case AlignAttrNum: {
HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl());
imp->setAlign(valueToStringWithNullCheck(exec, value));
break;
}
case BgColorAttrNum: {
HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl());
imp->setBgColor(valueToStringWithNullCheck(exec, value));
break;
}
case BorderAttrNum: {
HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl());
imp->setBorder(valueToStringWithNullCheck(exec, value));
break;
}
case CellPaddingAttrNum: {
HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl());
imp->setCellPadding(valueToStringWithNullCheck(exec, value));
break;
}
case CellSpacingAttrNum: {
HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl());
imp->setCellSpacing(valueToStringWithNullCheck(exec, value));
break;
}
case FrameAttrNum: {
HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl());
imp->setFrame(valueToStringWithNullCheck(exec, value));
break;
}
case RulesAttrNum: {
HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl());
imp->setRules(valueToStringWithNullCheck(exec, value));
break;
}
case SummaryAttrNum: {
HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl());
imp->setSummary(valueToStringWithNullCheck(exec, value));
break;
}
case WidthAttrNum: {
HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl());
imp->setWidth(valueToStringWithNullCheck(exec, value));
break;
}
}
}
示例9: ariaRoleAttribute
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)
//.........这里部分代码省略.........
示例10: toRenderTable
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++;
//.........这里部分代码省略.........
示例11: throwError
JSValue* JSHTMLTableElementPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
if (!thisObj->inherits(&JSHTMLTableElement::info))
return throwError(exec, TypeError);
JSHTMLTableElement* castedThisObj = static_cast<JSHTMLTableElement*>(thisObj);
HTMLTableElement* imp = static_cast<HTMLTableElement*>(castedThisObj->impl());
switch (id) {
case JSHTMLTableElement::CreateTHeadFuncNum: {
KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createTHead()));
return result;
}
case JSHTMLTableElement::DeleteTHeadFuncNum: {
imp->deleteTHead();
return jsUndefined();
}
case JSHTMLTableElement::CreateTFootFuncNum: {
KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createTFoot()));
return result;
}
case JSHTMLTableElement::DeleteTFootFuncNum: {
imp->deleteTFoot();
return jsUndefined();
}
case JSHTMLTableElement::CreateCaptionFuncNum: {
KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createCaption()));
return result;
}
case JSHTMLTableElement::DeleteCaptionFuncNum: {
imp->deleteCaption();
return jsUndefined();
}
case JSHTMLTableElement::InsertRowFuncNum: {
ExceptionCode ec = 0;
bool indexOk;
int index = args[0]->toInt32(exec, indexOk);
if (!indexOk) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return jsUndefined();
}
KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->insertRow(index, ec)));
setDOMException(exec, ec);
return result;
}
case JSHTMLTableElement::DeleteRowFuncNum: {
ExceptionCode ec = 0;
bool indexOk;
int index = args[0]->toInt32(exec, indexOk);
if (!indexOk) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return jsUndefined();
}
imp->deleteRow(index, ec);
setDOMException(exec, ec);
return jsUndefined();
}
}
return 0;
}