From e2b8a2315e1405fddfd687d478e58447f156eeac Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 27 Jun 2019 13:23:22 +0200 Subject: [PATCH] LibHTML: Use NonnullRefPtrVector in the CSS and HTML parsers. --- LibHTML/Parser/CSSParser.cpp | 4 ++-- LibHTML/Parser/HTMLParser.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/LibHTML/Parser/CSSParser.cpp b/LibHTML/Parser/CSSParser.cpp index 2e544043e6..314895f581 100644 --- a/LibHTML/Parser/CSSParser.cpp +++ b/LibHTML/Parser/CSSParser.cpp @@ -5,7 +5,7 @@ NonnullRefPtr parse_css(const String& css) { - Vector> rules; + NonnullRefPtrVector rules; enum class State { Free, @@ -16,7 +16,7 @@ NonnullRefPtr parse_css(const String& css) struct CurrentRule { Vector selectors; - Vector> declarations; + NonnullRefPtrVector declarations; }; CurrentRule current_rule; diff --git a/LibHTML/Parser/HTMLParser.cpp b/LibHTML/Parser/HTMLParser.cpp index 1f8faaf37c..ef10c4057d 100644 --- a/LibHTML/Parser/HTMLParser.cpp +++ b/LibHTML/Parser/HTMLParser.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -34,7 +35,7 @@ static bool is_self_closing_tag(const String& tag_name) NonnullRefPtr parse_html(const String& html) { - Vector> node_stack; + NonnullRefPtrVector node_stack; auto doc = adopt(*new Document); node_stack.append(doc); @@ -76,7 +77,7 @@ NonnullRefPtr parse_html(const String& html) if (state == State::Free && !text_buffer.is_empty()) { auto text_node = adopt(*new Text(String::copy(text_buffer))); text_buffer.clear(); - node_stack.last()->append_child(text_node); + node_stack.last().append_child(text_node); } state = new_state; text_buffer.clear(); @@ -93,7 +94,7 @@ NonnullRefPtr parse_html(const String& html) new_element->set_attributes(move(attributes)); node_stack.append(new_element); if (node_stack.size() != 1) - node_stack[node_stack.size() - 2]->append_child(new_element); + node_stack[node_stack.size() - 2].append_child(new_element); if (is_self_closing_tag(new_element->tag_name())) close_tag();