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) { ...@@ -58,7 +58,7 @@ static bool IsTableCellEmpty(Node* cell) {
} }
static bool IsTableRowEmpty(Node* row) { static bool IsTableRowEmpty(Node* row) {
if (!IsHTMLTableRowElement(row)) if (!IsA<HTMLTableRowElement>(row))
return false; return false;
row->GetDocument().UpdateStyleAndLayout(); row->GetDocument().UpdateStyleAndLayout();
...@@ -252,10 +252,10 @@ void DeleteSelectionCommand::InitializePositionData( ...@@ -252,10 +252,10 @@ void DeleteSelectionCommand::InitializePositionData(
start_root_ = RootEditableElementOf(start); start_root_ = RootEditableElementOf(start);
end_root_ = RootEditableElementOf(end); end_root_ = RootEditableElementOf(end);
start_table_row_ = start_table_row_ = To<HTMLTableRowElement>(
ToHTMLTableRowElement(EnclosingNodeOfType(start, &IsHTMLTableRowElement)); EnclosingNodeOfType(start, &IsA<HTMLTableRowElement>));
end_table_row_ = end_table_row_ = To<HTMLTableRowElement>(
ToHTMLTableRowElement(EnclosingNodeOfType(end, &IsHTMLTableRowElement)); EnclosingNodeOfType(end, &IsA<HTMLTableRowElement>));
// Don't move content out of a table cell. // Don't move content out of a table cell.
// If the cell is non-editable, enclosingNodeOfType won't return it by // If the cell is non-editable, enclosingNodeOfType won't return it by
......
...@@ -130,7 +130,7 @@ static HTMLElement* AncestorToRetainStructureAndAppearanceForBlock( ...@@ -130,7 +130,7 @@ static HTMLElement* AncestorToRetainStructureAndAppearanceForBlock(
return nullptr; return nullptr;
if (common_ancestor_block->HasTagName(html_names::kTbodyTag) || if (common_ancestor_block->HasTagName(html_names::kTbodyTag) ||
IsHTMLTableRowElement(*common_ancestor_block)) IsA<HTMLTableRowElement>(*common_ancestor_block))
return Traversal<HTMLTableElement>::FirstAncestor(*common_ancestor_block); return Traversal<HTMLTableElement>::FirstAncestor(*common_ancestor_block);
if (IsNonTableCellHTMLBlockElement(common_ancestor_block)) if (IsNonTableCellHTMLBlockElement(common_ancestor_block))
......
...@@ -72,7 +72,7 @@ unsigned HTMLTableCellElement::rowSpan() const { ...@@ -72,7 +72,7 @@ unsigned HTMLTableCellElement::rowSpan() const {
} }
int HTMLTableCellElement::cellIndex() const { int HTMLTableCellElement::cellIndex() const {
if (!IsHTMLTableRowElement(parentElement())) if (!IsA<HTMLTableRowElement>(parentElement()))
return -1; return -1;
int index = 0; int index = 0;
......
...@@ -78,7 +78,7 @@ HTMLTableRowElement* HTMLTableRowsCollection::RowAfter( ...@@ -78,7 +78,7 @@ HTMLTableRowElement* HTMLTableRowsCollection::RowAfter(
else if (IsInSection(*previous, html_names::kTbodyTag)) else if (IsInSection(*previous, html_names::kTbodyTag))
child = Traversal<HTMLElement>::NextSibling(*previous->parentNode()); child = Traversal<HTMLElement>::NextSibling(*previous->parentNode());
for (; child; child = Traversal<HTMLElement>::NextSibling(*child)) { for (; child; child = Traversal<HTMLElement>::NextSibling(*child)) {
if (auto* row = ToHTMLTableRowElementOrNull(child)) if (auto* row = DynamicTo<HTMLTableRowElement>(child))
return row; return row;
if (child->HasTagName(html_names::kTbodyTag)) { if (child->HasTagName(html_names::kTbodyTag)) {
if (HTMLTableRowElement* row = if (HTMLTableRowElement* row =
...@@ -115,7 +115,7 @@ HTMLTableRowElement* HTMLTableRowsCollection::LastRow(HTMLTableElement& table) { ...@@ -115,7 +115,7 @@ HTMLTableRowElement* HTMLTableRowsCollection::LastRow(HTMLTableElement& table) {
for (HTMLElement* child = Traversal<HTMLElement>::LastChild(table); child; for (HTMLElement* child = Traversal<HTMLElement>::LastChild(table); child;
child = Traversal<HTMLElement>::PreviousSibling(*child)) { child = Traversal<HTMLElement>::PreviousSibling(*child)) {
if (auto* row = ToHTMLTableRowElementOrNull(child)) if (auto* row = DynamicTo<HTMLTableRowElement>(child))
return row; return row;
if (child->HasTagName(html_names::kTbodyTag)) { if (child->HasTagName(html_names::kTbodyTag)) {
if (HTMLTableRowElement* last_row = if (HTMLTableRowElement* last_row =
...@@ -152,7 +152,7 @@ HTMLTableRowsCollection::HTMLTableRowsCollection(ContainerNode& table, ...@@ -152,7 +152,7 @@ HTMLTableRowsCollection::HTMLTableRowsCollection(ContainerNode& table,
Element* HTMLTableRowsCollection::VirtualItemAfter(Element* previous) const { Element* HTMLTableRowsCollection::VirtualItemAfter(Element* previous) const {
return RowAfter(To<HTMLTableElement>(ownerNode()), return RowAfter(To<HTMLTableElement>(ownerNode()),
ToHTMLTableRowElement(previous)); To<HTMLTableRowElement>(previous));
} }
} // namespace blink } // namespace blink
...@@ -43,7 +43,7 @@ class HTMLTableRowsCollection final : public HTMLCollection { ...@@ -43,7 +43,7 @@ class HTMLTableRowsCollection final : public HTMLCollection {
HTMLTableRowsCollection(ContainerNode&, CollectionType); HTMLTableRowsCollection(ContainerNode&, CollectionType);
HTMLTableRowElement* Item(unsigned offset) const { HTMLTableRowElement* Item(unsigned offset) const {
return ToHTMLTableRowElement(HTMLCollection::item(offset)); return To<HTMLTableRowElement>(HTMLCollection::item(offset));
} }
static HTMLTableRowElement* RowAfter(HTMLTableElement&, HTMLTableRowElement*); static HTMLTableRowElement* RowAfter(HTMLTableElement&, HTMLTableRowElement*);
......
...@@ -421,8 +421,8 @@ static bool IsRequiredOwnedElement(AXObject* parent, ...@@ -421,8 +421,8 @@ static bool IsRequiredOwnedElement(AXObject* parent,
if (!current_element) if (!current_element)
return false; return false;
if (IsHTMLTableCellElement(*current_element)) if (IsHTMLTableCellElement(*current_element))
return IsHTMLTableRowElement(*parent_node); return IsA<HTMLTableRowElement>(*parent_node);
if (IsHTMLTableRowElement(*current_element)) if (IsA<HTMLTableRowElement>(*current_element))
return IsHTMLTableSectionElement(parent_html_element); return IsHTMLTableSectionElement(parent_html_element);
// In case of ListboxRole and its child, ListBoxOptionRole, inheritance of // In case of ListboxRole and its child, ListBoxOptionRole, inheritance of
...@@ -637,7 +637,7 @@ ax::mojom::Role AXNodeObject::NativeRoleIgnoringAria() const { ...@@ -637,7 +637,7 @@ ax::mojom::Role AXNodeObject::NativeRoleIgnoringAria() const {
return IsDataTable() ? ax::mojom::Role::kTable return IsDataTable() ? ax::mojom::Role::kTable
: ax::mojom::Role::kLayoutTable; : ax::mojom::Role::kLayoutTable;
} }
if (IsHTMLTableRowElement(*GetNode())) if (IsA<HTMLTableRowElement>(*GetNode()))
return DetermineTableRowRole(); return DetermineTableRowRole();
if (IsHTMLTableCellElement(*GetNode())) if (IsHTMLTableCellElement(*GetNode()))
return DetermineTableCellRole(); return DetermineTableCellRole();
......
...@@ -615,7 +615,7 @@ void AXObjectCacheImpl::ContainingTableRowsOrColsMaybeChanged(Node* node) { ...@@ -615,7 +615,7 @@ void AXObjectCacheImpl::ContainingTableRowsOrColsMaybeChanged(Node* node) {
// removal of a <tr> or <td>. // removal of a <tr> or <td>.
// Get parent table from DOM, because AXObject/layout tree are incomplete. // Get parent table from DOM, because AXObject/layout tree are incomplete.
ContainerNode* containing_table = nullptr; ContainerNode* containing_table = nullptr;
if (IsHTMLTableCellElement(node) || IsHTMLTableRowElement(node)) if (IsHTMLTableCellElement(node) || IsA<HTMLTableRowElement>(node))
containing_table = FindParentTable(node); containing_table = FindParentTable(node);
if (containing_table) { 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