Commit 7fb7aa56 authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Use new downcast helper for blink::HTMLHeadElement

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

Bug: 891908
Change-Id: I80ca40f08a7afd742be2b3321f9c9b4f27efd5a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1748968Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#686311}
parent 3ae2445b
...@@ -523,7 +523,8 @@ void TidyUpHTMLStructure(Document& document) { ...@@ -523,7 +523,8 @@ void TidyUpHTMLStructure(Document& document) {
if (current_root && IsHTMLHtmlElement(current_root)) if (current_root && IsHTMLHtmlElement(current_root))
return; return;
Element* const existing_head = Element* const existing_head =
current_root && IsHTMLHeadElement(current_root) ? current_root : nullptr; current_root && IsA<HTMLHeadElement>(current_root) ? current_root
: nullptr;
Element* const existing_body = Element* const existing_body =
current_root && (IsA<HTMLBodyElement>(current_root) || current_root && (IsA<HTMLBodyElement>(current_root) ||
IsA<HTMLFrameSetElement>(current_root)) IsA<HTMLFrameSetElement>(current_root))
......
...@@ -695,7 +695,7 @@ DocumentFragment* CreateContextualFragment( ...@@ -695,7 +695,7 @@ DocumentFragment* CreateContextualFragment(
Node* next_node = nullptr; Node* next_node = nullptr;
for (Node* node = fragment->firstChild(); node; node = next_node) { for (Node* node = fragment->firstChild(); node; node = next_node) {
next_node = node->nextSibling(); next_node = node->nextSibling();
if (IsHTMLHtmlElement(*node) || IsHTMLHeadElement(*node) || if (IsHTMLHtmlElement(*node) || IsA<HTMLHeadElement>(*node) ||
IsA<HTMLBodyElement>(*node)) { IsA<HTMLBodyElement>(*node)) {
auto* element = To<HTMLElement>(node); auto* element = To<HTMLElement>(node);
if (Node* first_child = element->firstChild()) if (Node* first_child = element->firstChild())
......
...@@ -163,7 +163,7 @@ AtomicString SerializerMarkupAccumulator::AppendElement( ...@@ -163,7 +163,7 @@ AtomicString SerializerMarkupAccumulator::AppendElement(
const Element& element) { const Element& element) {
AtomicString prefix = MarkupAccumulator::AppendElement(element); AtomicString prefix = MarkupAccumulator::AppendElement(element);
if (IsHTMLHeadElement(element)) if (IsA<HTMLHeadElement>(element))
AppendExtraForHeadElement(element); AppendExtraForHeadElement(element);
resource_delegate_.AddResourceForElement(*document_, element); resource_delegate_.AddResourceForElement(*document_, element);
...@@ -176,7 +176,7 @@ AtomicString SerializerMarkupAccumulator::AppendElement( ...@@ -176,7 +176,7 @@ AtomicString SerializerMarkupAccumulator::AppendElement(
void SerializerMarkupAccumulator::AppendExtraForHeadElement( void SerializerMarkupAccumulator::AppendExtraForHeadElement(
const Element& element) { const Element& element) {
DCHECK(IsHTMLHeadElement(element)); DCHECK(IsA<HTMLHeadElement>(element));
// TODO(tiger): Refactor MarkupAccumulator so it is easier to append an // TODO(tiger): Refactor MarkupAccumulator so it is easier to append an
// element like this, without special cases for XHTML // element like this, without special cases for XHTML
......
...@@ -200,7 +200,8 @@ String WebFrameSerializerImpl::PostActionAfterSerializeOpenTag( ...@@ -200,7 +200,8 @@ String WebFrameSerializerImpl::PostActionAfterSerializeOpenTag(
if (!param->is_html_document) if (!param->is_html_document)
return result.ToString(); return result.ToString();
// Check after processing the open tag of HEAD element // Check after processing the open tag of HEAD element
if (!param->have_added_charset_declaration && IsHTMLHeadElement(*element)) { if (!param->have_added_charset_declaration &&
IsA<HTMLHeadElement>(*element)) {
param->have_added_charset_declaration = true; param->have_added_charset_declaration = true;
// Check meta element. WebKit only pre-parse the first 512 bytes of the // Check meta element. WebKit only pre-parse the first 512 bytes of the
// document. If the whole <HEAD> is larger and meta is the end of head // document. If the whole <HEAD> is larger and meta is the end of head
......
...@@ -353,7 +353,7 @@ void HTMLElementStack::RemoveHTMLHeadElement(Element* element) { ...@@ -353,7 +353,7 @@ void HTMLElementStack::RemoveHTMLHeadElement(Element* element) {
} }
void HTMLElementStack::Remove(Element* element) { void HTMLElementStack::Remove(Element* element) {
DCHECK(!IsHTMLHeadElement(element)); DCHECK(!IsA<HTMLHeadElement>(element));
if (top_->GetElement() == element) { if (top_->GetElement() == element) {
Pop(); Pop();
return; return;
......
...@@ -139,7 +139,7 @@ Node* DOMPatchSupport::PatchNode(Node* node, ...@@ -139,7 +139,7 @@ Node* DOMPatchSupport::PatchNode(Node* node,
new_list.push_back(CreateDigest(child, nullptr)); new_list.push_back(CreateDigest(child, nullptr));
for (Node* child = fragment->firstChild(); child; for (Node* child = fragment->firstChild(); child;
child = child->nextSibling()) { child = child->nextSibling()) {
if (IsHTMLHeadElement(*child) && !child->hasChildren() && if (IsA<HTMLHeadElement>(*child) && !child->hasChildren() &&
markup_copy.Find("</head>") == kNotFound) { markup_copy.Find("</head>") == kNotFound) {
// HTML5 parser inserts empty <head> tag whenever it parses <body> // HTML5 parser inserts empty <head> tag whenever it parses <body>
continue; continue;
...@@ -335,7 +335,7 @@ bool DOMPatchSupport::InnerPatchChildren( ...@@ -335,7 +335,7 @@ bool DOMPatchSupport::InnerPatchChildren(
// Always match <head> and <body> tags with each other - we can't remove // Always match <head> and <body> tags with each other - we can't remove
// them from the DOM upon patching. // them from the DOM upon patching.
if (IsHTMLHeadElement(*old_list[i]->node_)) { if (IsA<HTMLHeadElement>(*old_list[i]->node_)) {
old_head = old_list[i].Get(); old_head = old_list[i].Get();
continue; continue;
} }
...@@ -387,7 +387,7 @@ bool DOMPatchSupport::InnerPatchChildren( ...@@ -387,7 +387,7 @@ bool DOMPatchSupport::InnerPatchChildren(
// Mark <head> and <body> nodes for merge. // Mark <head> and <body> nodes for merge.
if (old_head || old_body) { if (old_head || old_body) {
for (wtf_size_t i = 0; i < new_list.size(); ++i) { for (wtf_size_t i = 0; i < new_list.size(); ++i) {
if (old_head && IsHTMLHeadElement(*new_list[i]->node_)) if (old_head && IsA<HTMLHeadElement>(*new_list[i]->node_))
merges.Set(new_list[i].Get(), old_head); merges.Set(new_list[i].Get(), old_head);
if (old_body && IsA<HTMLBodyElement>(*new_list[i]->node_)) if (old_body && IsA<HTMLBodyElement>(*new_list[i]->node_))
merges.Set(new_list[i].Get(), old_body); merges.Set(new_list[i].Get(), old_body);
...@@ -418,7 +418,7 @@ bool DOMPatchSupport::InnerPatchChildren( ...@@ -418,7 +418,7 @@ bool DOMPatchSupport::InnerPatchChildren(
Node* anchor_node = NodeTraversal::ChildAt(*parent_node, old_map[i].second); Node* anchor_node = NodeTraversal::ChildAt(*parent_node, old_map[i].second);
if (node == anchor_node) if (node == anchor_node)
continue; continue;
if (IsA<HTMLBodyElement>(*node) || IsHTMLHeadElement(*node)) { if (IsA<HTMLBodyElement>(*node) || IsA<HTMLHeadElement>(*node)) {
// Never move head or body, move the rest of the nodes around them. // Never move head or body, move the rest of the nodes around them.
continue; continue;
} }
......
...@@ -454,7 +454,7 @@ AXObject* AXObjectCacheImpl::GetOrCreate(Node* node) { ...@@ -454,7 +454,7 @@ AXObject* AXObjectCacheImpl::GetOrCreate(Node* node) {
if (!LayoutTreeBuilderTraversal::Parent(*node)) if (!LayoutTreeBuilderTraversal::Parent(*node))
return nullptr; return nullptr;
if (IsHTMLHeadElement(node)) if (IsA<HTMLHeadElement>(node))
return nullptr; return nullptr;
AXObject* new_obj = CreateFromNode(node); AXObject* new_obj = CreateFromNode(node);
......
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