Commit bcefca5b authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Use new downcast helper for blink::HTMLTableRowElement

This CL has two goals,
1. Use To<HTMLTableRowElement> and DynamicTo<HTMLTableRowElement> as new
   downcast helper
2. Use IsA<HTMLTableRowElement>(element) in place of
   IsHTMLTableRowElement(element)

Bug: 891908
Change-Id: I4095c5486fbdf63c3c692b295f23b18d626ab48d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1899640Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#713505}
parent b12c1747
......@@ -58,7 +58,7 @@ static bool IsTableCellEmpty(Node* cell) {
}
static bool IsTableRowEmpty(Node* row) {
if (!IsHTMLTableRowElement(row))
if (!IsA<HTMLTableRowElement>(row))
return false;
row->GetDocument().UpdateStyleAndLayout();
......@@ -252,10 +252,10 @@ void DeleteSelectionCommand::InitializePositionData(
start_root_ = RootEditableElementOf(start);
end_root_ = RootEditableElementOf(end);
start_table_row_ =
ToHTMLTableRowElement(EnclosingNodeOfType(start, &IsHTMLTableRowElement));
end_table_row_ =
ToHTMLTableRowElement(EnclosingNodeOfType(end, &IsHTMLTableRowElement));
start_table_row_ = To<HTMLTableRowElement>(
EnclosingNodeOfType(start, &IsA<HTMLTableRowElement>));
end_table_row_ = To<HTMLTableRowElement>(
EnclosingNodeOfType(end, &IsA<HTMLTableRowElement>));
// Don't move content out of a table cell.
// If the cell is non-editable, enclosingNodeOfType won't return it by
......
......@@ -130,7 +130,7 @@ static HTMLElement* AncestorToRetainStructureAndAppearanceForBlock(
return nullptr;
if (common_ancestor_block->HasTagName(html_names::kTbodyTag) ||
IsHTMLTableRowElement(*common_ancestor_block))
IsA<HTMLTableRowElement>(*common_ancestor_block))
return Traversal<HTMLTableElement>::FirstAncestor(*common_ancestor_block);
if (IsNonTableCellHTMLBlockElement(common_ancestor_block))
......
......@@ -72,7 +72,7 @@ unsigned HTMLTableCellElement::rowSpan() const {
}
int HTMLTableCellElement::cellIndex() const {
if (!IsHTMLTableRowElement(parentElement()))
if (!IsA<HTMLTableRowElement>(parentElement()))
return -1;
int index = 0;
......
......@@ -78,7 +78,7 @@ HTMLTableRowElement* HTMLTableRowsCollection::RowAfter(
else if (IsInSection(*previous, html_names::kTbodyTag))
child = Traversal<HTMLElement>::NextSibling(*previous->parentNode());
for (; child; child = Traversal<HTMLElement>::NextSibling(*child)) {
if (auto* row = ToHTMLTableRowElementOrNull(child))
if (auto* row = DynamicTo<HTMLTableRowElement>(child))
return row;
if (child->HasTagName(html_names::kTbodyTag)) {
if (HTMLTableRowElement* row =
......@@ -115,7 +115,7 @@ HTMLTableRowElement* HTMLTableRowsCollection::LastRow(HTMLTableElement& table) {
for (HTMLElement* child = Traversal<HTMLElement>::LastChild(table); child;
child = Traversal<HTMLElement>::PreviousSibling(*child)) {
if (auto* row = ToHTMLTableRowElementOrNull(child))
if (auto* row = DynamicTo<HTMLTableRowElement>(child))
return row;
if (child->HasTagName(html_names::kTbodyTag)) {
if (HTMLTableRowElement* last_row =
......@@ -152,7 +152,7 @@ HTMLTableRowsCollection::HTMLTableRowsCollection(ContainerNode& table,
Element* HTMLTableRowsCollection::VirtualItemAfter(Element* previous) const {
return RowAfter(To<HTMLTableElement>(ownerNode()),
ToHTMLTableRowElement(previous));
To<HTMLTableRowElement>(previous));
}
} // namespace blink
......@@ -43,7 +43,7 @@ class HTMLTableRowsCollection final : public HTMLCollection {
HTMLTableRowsCollection(ContainerNode&, CollectionType);
HTMLTableRowElement* Item(unsigned offset) const {
return ToHTMLTableRowElement(HTMLCollection::item(offset));
return To<HTMLTableRowElement>(HTMLCollection::item(offset));
}
static HTMLTableRowElement* RowAfter(HTMLTableElement&, HTMLTableRowElement*);
......
......@@ -421,8 +421,8 @@ static bool IsRequiredOwnedElement(AXObject* parent,
if (!current_element)
return false;
if (IsHTMLTableCellElement(*current_element))
return IsHTMLTableRowElement(*parent_node);
if (IsHTMLTableRowElement(*current_element))
return IsA<HTMLTableRowElement>(*parent_node);
if (IsA<HTMLTableRowElement>(*current_element))
return IsHTMLTableSectionElement(parent_html_element);
// In case of ListboxRole and its child, ListBoxOptionRole, inheritance of
......@@ -637,7 +637,7 @@ ax::mojom::Role AXNodeObject::NativeRoleIgnoringAria() const {
return IsDataTable() ? ax::mojom::Role::kTable
: ax::mojom::Role::kLayoutTable;
}
if (IsHTMLTableRowElement(*GetNode()))
if (IsA<HTMLTableRowElement>(*GetNode()))
return DetermineTableRowRole();
if (IsHTMLTableCellElement(*GetNode()))
return DetermineTableCellRole();
......
......@@ -615,7 +615,7 @@ void AXObjectCacheImpl::ContainingTableRowsOrColsMaybeChanged(Node* node) {
// removal of a <tr> or <td>.
// Get parent table from DOM, because AXObject/layout tree are incomplete.
ContainerNode* containing_table = nullptr;
if (IsHTMLTableCellElement(node) || IsHTMLTableRowElement(node))
if (IsHTMLTableCellElement(node) || IsA<HTMLTableRowElement>(node))
containing_table = FindParentTable(node);
if (containing_table) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment