summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-07 17:58:54 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-07 17:58:54 +0100
commitb88ff975371a6d251f93b22596366c07007bacf3 (patch)
treeb2272bc5a3864f29a6f57373225f7e2d6885bc3a
parent6a8695e7592177b9c952d9db3dfdeccb2a4dd973 (diff)
downloadserenity-b88ff975371a6d251f93b22596366c07007bacf3.zip
LibHTML: Make the CSS parser return RefPtr's
It should be possible for the CSS parser to fail, and we'll know it failed if it returns nullptr. Returning RefPtr's makes it actually possible to return nullptr. :^)
-rw-r--r--Libraries/LibHTML/CSS/StyleResolver.cpp2
-rw-r--r--Libraries/LibHTML/Parser/CSSParser.cpp8
-rw-r--r--Libraries/LibHTML/Parser/CSSParser.h4
3 files changed, 7 insertions, 7 deletions
diff --git a/Libraries/LibHTML/CSS/StyleResolver.cpp b/Libraries/LibHTML/CSS/StyleResolver.cpp
index 76c4a34ae0..9377943ca5 100644
--- a/Libraries/LibHTML/CSS/StyleResolver.cpp
+++ b/Libraries/LibHTML/CSS/StyleResolver.cpp
@@ -22,7 +22,7 @@ static StyleSheet& default_stylesheet()
if (!sheet) {
extern const char default_stylesheet_source[];
String css = default_stylesheet_source;
- sheet = &parse_css(css).leak_ref();
+ sheet = parse_css(css).leak_ref();
}
return *sheet;
}
diff --git a/Libraries/LibHTML/Parser/CSSParser.cpp b/Libraries/LibHTML/Parser/CSSParser.cpp
index 5ce42df1cb..5c562389bb 100644
--- a/Libraries/LibHTML/Parser/CSSParser.cpp
+++ b/Libraries/LibHTML/Parser/CSSParser.cpp
@@ -376,7 +376,7 @@ public:
consume_whitespace_or_comments();
}
- NonnullRefPtr<StyleSheet> parse_sheet()
+ RefPtr<StyleSheet> parse_sheet()
{
while (index < css.length()) {
parse_rule();
@@ -385,7 +385,7 @@ public:
return StyleSheet::create(move(rules));
}
- NonnullRefPtr<StyleDeclaration> parse_standalone_declaration()
+ RefPtr<StyleDeclaration> parse_standalone_declaration()
{
consume_whitespace_or_comments();
for (;;) {
@@ -415,13 +415,13 @@ private:
StringView css;
};
-NonnullRefPtr<StyleSheet> parse_css(const StringView& css)
+RefPtr<StyleSheet> parse_css(const StringView& css)
{
CSSParser parser(css);
return parser.parse_sheet();
}
-NonnullRefPtr<StyleDeclaration> parse_css_declaration(const StringView& css)
+RefPtr<StyleDeclaration> parse_css_declaration(const StringView& css)
{
CSSParser parser(css);
return parser.parse_standalone_declaration();
diff --git a/Libraries/LibHTML/Parser/CSSParser.h b/Libraries/LibHTML/Parser/CSSParser.h
index 44e57f5dd5..050b0dd8c7 100644
--- a/Libraries/LibHTML/Parser/CSSParser.h
+++ b/Libraries/LibHTML/Parser/CSSParser.h
@@ -3,6 +3,6 @@
#include <AK/NonnullRefPtr.h>
#include <LibHTML/CSS/StyleSheet.h>
-NonnullRefPtr<StyleSheet> parse_css(const StringView&);
-NonnullRefPtr<StyleDeclaration> parse_css_declaration(const StringView&);
+RefPtr<StyleSheet> parse_css(const StringView&);
+RefPtr<StyleDeclaration> parse_css_declaration(const StringView&);