mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:17:44 +00:00
AK: Rename downcast<T> => verify_cast<T>
This makes it much clearer what this cast actually does: it will VERIFY that the thing we're casting is a T (using is<T>()).
This commit is contained in:
parent
6215a9c2cb
commit
ee3a73ddbb
61 changed files with 262 additions and 262 deletions
|
@ -110,7 +110,7 @@ String HTMLElement::inner_text()
|
|||
Function<void(const Layout::Node&)> recurse = [&](auto& node) {
|
||||
for (auto* child = node.first_child(); child; child = child->next_sibling()) {
|
||||
if (is<Layout::TextNode>(child))
|
||||
builder.append(downcast<Layout::TextNode>(*child).text_for_rendering());
|
||||
builder.append(verify_cast<Layout::TextNode>(*child).text_for_rendering());
|
||||
if (is<Layout::BreakNode>(child))
|
||||
builder.append('\n');
|
||||
recurse(*child);
|
||||
|
|
|
@ -98,7 +98,7 @@ void HTMLFormElement::submit_form(RefPtr<HTMLElement> submitter, bool from_submi
|
|||
Vector<URLQueryParam> parameters;
|
||||
|
||||
for_each_in_inclusive_subtree_of_type<HTMLInputElement>([&](auto& node) {
|
||||
auto& input = downcast<HTMLInputElement>(node);
|
||||
auto& input = verify_cast<HTMLInputElement>(node);
|
||||
if (!input.name().is_null() && (input.type() != "submit" || &input == submitter))
|
||||
parameters.append({ input.name(), input.value() });
|
||||
return IterationDecision::Continue;
|
||||
|
|
|
@ -30,7 +30,7 @@ void HTMLStyleElement::children_changed()
|
|||
StringBuilder builder;
|
||||
for_each_child([&](auto& child) {
|
||||
if (is<DOM::Text>(child))
|
||||
builder.append(downcast<DOM::Text>(child).text_content());
|
||||
builder.append(verify_cast<DOM::Text>(child).text_content());
|
||||
});
|
||||
m_css_loader.load_from_text(builder.to_string());
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ RefPtr<HTMLTableSectionElement> HTMLTableElement::t_head()
|
|||
{
|
||||
for (auto* child = first_child(); child; child = child->next_sibling()) {
|
||||
if (is<HTMLTableSectionElement>(*child)) {
|
||||
auto table_section_element = &downcast<HTMLTableSectionElement>(*child);
|
||||
auto table_section_element = &verify_cast<HTMLTableSectionElement>(*child);
|
||||
if (table_section_element->tag_name() == TagNames::thead)
|
||||
return table_section_element;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ DOM::ExceptionOr<void> HTMLTableElement::set_t_head(HTMLTableSectionElement& the
|
|||
if (is<HTMLTableCaptionElement>(*child))
|
||||
continue;
|
||||
if (is<HTMLTableColElement>(*child)) {
|
||||
auto table_col_element = &downcast<HTMLTableColElement>(*child);
|
||||
auto table_col_element = &verify_cast<HTMLTableColElement>(*child);
|
||||
if (table_col_element->tag_name() == TagNames::colgroup)
|
||||
continue;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ NonnullRefPtr<HTMLTableSectionElement> HTMLTableElement::create_t_head()
|
|||
if (is<HTMLTableCaptionElement>(*child))
|
||||
continue;
|
||||
if (is<HTMLTableColElement>(*child)) {
|
||||
auto table_col_element = &downcast<HTMLTableColElement>(*child);
|
||||
auto table_col_element = &verify_cast<HTMLTableColElement>(*child);
|
||||
if (table_col_element->tag_name() == TagNames::colgroup)
|
||||
continue;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ RefPtr<HTMLTableSectionElement> HTMLTableElement::t_foot()
|
|||
{
|
||||
for (auto* child = first_child(); child; child = child->next_sibling()) {
|
||||
if (is<HTMLTableSectionElement>(*child)) {
|
||||
auto table_section_element = &downcast<HTMLTableSectionElement>(*child);
|
||||
auto table_section_element = &verify_cast<HTMLTableSectionElement>(*child);
|
||||
if (table_section_element->tag_name() == TagNames::tfoot)
|
||||
return table_section_element;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ NonnullRefPtr<HTMLTableSectionElement> HTMLTableElement::create_t_body()
|
|||
if (!is<HTMLElement>(*child))
|
||||
continue;
|
||||
if (is<HTMLTableSectionElement>(*child)) {
|
||||
auto table_section_element = &downcast<HTMLTableSectionElement>(*child);
|
||||
auto table_section_element = &verify_cast<HTMLTableSectionElement>(*child);
|
||||
if (table_section_element->tag_name() == TagNames::tbody) {
|
||||
// We have found an element which is a <tbody> we'll insert after this
|
||||
child_to_append_after = child->next_sibling();
|
||||
|
|
|
@ -411,7 +411,7 @@ HTMLDocumentParser::AdjustedInsertionLocation HTMLDocumentParser::find_appropria
|
|||
auto last_table = m_stack_of_open_elements.last_element_with_tag_name(HTML::TagNames::table);
|
||||
if (last_template.element && (!last_table.element || last_template.index > last_table.index)) {
|
||||
// This returns the template content, so no need to check the parent is a template.
|
||||
return { downcast<HTMLTemplateElement>(last_template.element)->content(), nullptr };
|
||||
return { verify_cast<HTMLTemplateElement>(last_template.element)->content(), nullptr };
|
||||
}
|
||||
if (!last_table.element) {
|
||||
VERIFY(m_parsing_fragment);
|
||||
|
@ -428,7 +428,7 @@ HTMLDocumentParser::AdjustedInsertionLocation HTMLDocumentParser::find_appropria
|
|||
}
|
||||
|
||||
if (is<HTMLTemplateElement>(*adjusted_insertion_location.parent))
|
||||
return { downcast<HTMLTemplateElement>(*adjusted_insertion_location.parent).content(), nullptr };
|
||||
return { verify_cast<HTMLTemplateElement>(*adjusted_insertion_location.parent).content(), nullptr };
|
||||
|
||||
return adjusted_insertion_location;
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ void HTMLDocumentParser::handle_before_head(HTMLToken& token)
|
|||
|
||||
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::head) {
|
||||
auto element = insert_html_element(token);
|
||||
m_head_element = downcast<HTMLHeadElement>(*element);
|
||||
m_head_element = verify_cast<HTMLHeadElement>(*element);
|
||||
m_insertion_mode = InsertionMode::InHead;
|
||||
return;
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ void HTMLDocumentParser::handle_before_head(HTMLToken& token)
|
|||
}
|
||||
|
||||
AnythingElse:
|
||||
m_head_element = downcast<HTMLHeadElement>(*insert_html_element(HTMLToken::make_start_tag(HTML::TagNames::head)));
|
||||
m_head_element = verify_cast<HTMLHeadElement>(*insert_html_element(HTMLToken::make_start_tag(HTML::TagNames::head)));
|
||||
m_insertion_mode = InsertionMode::InHead;
|
||||
process_using_the_rules_for(InsertionMode::InHead, token);
|
||||
return;
|
||||
|
@ -583,7 +583,7 @@ void HTMLDocumentParser::handle_in_head(HTMLToken& token)
|
|||
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::script) {
|
||||
auto adjusted_insertion_location = find_appropriate_place_for_inserting_node();
|
||||
auto element = create_element_for(token, Namespace::HTML);
|
||||
auto& script_element = downcast<HTMLScriptElement>(*element);
|
||||
auto& script_element = verify_cast<HTMLScriptElement>(*element);
|
||||
script_element.set_parser_document({}, document());
|
||||
script_element.set_non_blocking({}, false);
|
||||
|
||||
|
@ -706,7 +706,7 @@ DOM::Text* HTMLDocumentParser::find_character_insertion_node()
|
|||
if (adjusted_insertion_location.parent->is_document())
|
||||
return nullptr;
|
||||
if (adjusted_insertion_location.parent->last_child() && adjusted_insertion_location.parent->last_child()->is_text())
|
||||
return downcast<DOM::Text>(adjusted_insertion_location.parent->last_child());
|
||||
return verify_cast<DOM::Text>(adjusted_insertion_location.parent->last_child());
|
||||
auto new_text_node = adopt_ref(*new DOM::Text(document(), ""));
|
||||
adjusted_insertion_location.parent->append_child(new_text_node);
|
||||
return new_text_node;
|
||||
|
@ -1268,7 +1268,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
|
|||
close_a_p_element();
|
||||
auto element = insert_html_element(token);
|
||||
if (!m_stack_of_open_elements.contains(HTML::TagNames::template_))
|
||||
m_form_element = downcast<HTMLFormElement>(*element);
|
||||
m_form_element = verify_cast<HTMLFormElement>(*element);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1877,7 +1877,7 @@ void HTMLDocumentParser::handle_text(HTMLToken& token)
|
|||
if (token.is_end_of_file()) {
|
||||
log_parse_error();
|
||||
if (current_node().local_name() == HTML::TagNames::script)
|
||||
downcast<HTMLScriptElement>(current_node()).set_already_started({}, true);
|
||||
verify_cast<HTMLScriptElement>(current_node()).set_already_started({}, true);
|
||||
m_stack_of_open_elements.pop();
|
||||
m_insertion_mode = m_original_insertion_mode;
|
||||
process_using_the_rules_for(m_insertion_mode, token);
|
||||
|
@ -1887,7 +1887,7 @@ void HTMLDocumentParser::handle_text(HTMLToken& token)
|
|||
// Make sure the <script> element has up-to-date text content before preparing the script.
|
||||
flush_character_insertions();
|
||||
|
||||
NonnullRefPtr<HTMLScriptElement> script = downcast<HTMLScriptElement>(current_node());
|
||||
NonnullRefPtr<HTMLScriptElement> script = verify_cast<HTMLScriptElement>(current_node());
|
||||
m_stack_of_open_elements.pop();
|
||||
m_insertion_mode = m_original_insertion_mode;
|
||||
// FIXME: Handle tokenizer insertion point stuff here.
|
||||
|
@ -2289,7 +2289,7 @@ void HTMLDocumentParser::handle_in_table(HTMLToken& token)
|
|||
return;
|
||||
}
|
||||
|
||||
m_form_element = downcast<HTMLFormElement>(*insert_html_element(token));
|
||||
m_form_element = verify_cast<HTMLFormElement>(*insert_html_element(token));
|
||||
|
||||
// FIXME: See previous FIXME, as this is the same situation but for form.
|
||||
m_stack_of_open_elements.pop();
|
||||
|
@ -3025,7 +3025,7 @@ NonnullRefPtrVector<DOM::Node> HTMLDocumentParser::parse_html_fragment(DOM::Elem
|
|||
|
||||
for (auto* form_candidate = &context_element; form_candidate; form_candidate = form_candidate->parent_element()) {
|
||||
if (is<HTMLFormElement>(*form_candidate)) {
|
||||
parser.m_form_element = downcast<HTMLFormElement>(*form_candidate);
|
||||
parser.m_form_element = verify_cast<HTMLFormElement>(*form_candidate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue