mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibHTML: Use NonnullRefPtrVector in the CSS and HTML parsers.
This commit is contained in:
parent
9ab3718266
commit
e2b8a2315e
Notes:
sideshowbarker
2024-07-19 13:28:30 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e2b8a2315e1
2 changed files with 6 additions and 5 deletions
|
@ -5,7 +5,7 @@
|
|||
|
||||
NonnullRefPtr<StyleSheet> parse_css(const String& css)
|
||||
{
|
||||
Vector<NonnullRefPtr<StyleRule>> rules;
|
||||
NonnullRefPtrVector<StyleRule> rules;
|
||||
|
||||
enum class State {
|
||||
Free,
|
||||
|
@ -16,7 +16,7 @@ NonnullRefPtr<StyleSheet> parse_css(const String& css)
|
|||
|
||||
struct CurrentRule {
|
||||
Vector<Selector> selectors;
|
||||
Vector<NonnullRefPtr<StyleDeclaration>> declarations;
|
||||
NonnullRefPtrVector<StyleDeclaration> declarations;
|
||||
};
|
||||
|
||||
CurrentRule current_rule;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <LibHTML/DOM/Element.h>
|
||||
#include <LibHTML/DOM/Text.h>
|
||||
#include <LibHTML/Parser/HTMLParser.h>
|
||||
|
@ -34,7 +35,7 @@ static bool is_self_closing_tag(const String& tag_name)
|
|||
|
||||
NonnullRefPtr<Document> parse_html(const String& html)
|
||||
{
|
||||
Vector<NonnullRefPtr<ParentNode>> node_stack;
|
||||
NonnullRefPtrVector<ParentNode> node_stack;
|
||||
|
||||
auto doc = adopt(*new Document);
|
||||
node_stack.append(doc);
|
||||
|
@ -76,7 +77,7 @@ NonnullRefPtr<Document> 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<Document> 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();
|
||||
|
|
Loading…
Reference in a new issue