mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-09 02:47:32 +00:00
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. :^)
This commit is contained in:
parent
6a8695e759
commit
b88ff97537
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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&);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user