diff --git a/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp b/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp index f6ac28a08e..a86b86c1ac 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp @@ -17,9 +17,9 @@ namespace Web::CSS { -CSSRuleList* CSSRuleList::create(JS::Realm& realm, JS::MarkedVector const& rules) +WebIDL::ExceptionOr> CSSRuleList::create(JS::Realm& realm, JS::MarkedVector const& rules) { - auto rule_list = realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + auto rule_list = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); for (auto* rule : rules) rule_list->m_rules.append(*rule); return rule_list; @@ -30,9 +30,9 @@ CSSRuleList::CSSRuleList(JS::Realm& realm) { } -CSSRuleList* CSSRuleList::create_empty(JS::Realm& realm) +WebIDL::ExceptionOr> CSSRuleList::create_empty(JS::Realm& realm) { - return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); } JS::ThrowCompletionOr CSSRuleList::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/CSS/CSSRuleList.h b/Userland/Libraries/LibWeb/CSS/CSSRuleList.h index 726a7c5f9e..76f56f4a30 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRuleList.h +++ b/Userland/Libraries/LibWeb/CSS/CSSRuleList.h @@ -23,8 +23,8 @@ class CSSRuleList : public Bindings::LegacyPlatformObject { WEB_PLATFORM_OBJECT(CSSRuleList, Bindings::LegacyPlatformObject); public: - static CSSRuleList* create(JS::Realm&, JS::MarkedVector const&); - static CSSRuleList* create_empty(JS::Realm&); + static WebIDL::ExceptionOr> create(JS::Realm&, JS::MarkedVector const&); + static WebIDL::ExceptionOr> create_empty(JS::Realm&); ~CSSRuleList() = default; diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index f02b6dc81a..402dd17b45 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -127,8 +127,8 @@ CSSStyleSheet* Parser::parse_as_css_stylesheet(Optional location) rules.append(rule); } - auto* rule_list = CSSRuleList::create(m_context.realm(), rules); - return CSSStyleSheet::create(m_context.realm(), *rule_list, *MediaList::create(m_context.realm(), {}), move(location)); + auto rule_list = CSSRuleList::create(m_context.realm(), rules).release_value_but_fixme_should_propagate_errors(); + return CSSStyleSheet::create(m_context.realm(), rule_list, *MediaList::create(m_context.realm(), {}), move(location)); } Optional Parser::parse_as_selector(SelectorParsingMode parsing_mode) @@ -3057,8 +3057,8 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr rule) if (auto* child_rule = convert_to_rule(raw_rule)) child_rules.append(child_rule); } - auto* rule_list = CSSRuleList::create(m_context.realm(), child_rules); - return CSSMediaRule::create(m_context.realm(), *MediaList::create(m_context.realm(), move(media_query_list)), *rule_list).release_value_but_fixme_should_propagate_errors(); + auto rule_list = CSSRuleList::create(m_context.realm(), child_rules).release_value_but_fixme_should_propagate_errors(); + return CSSMediaRule::create(m_context.realm(), *MediaList::create(m_context.realm(), move(media_query_list)), rule_list).release_value_but_fixme_should_propagate_errors(); } if (rule->at_rule_name().equals_ignoring_case("supports"sv)) { auto supports_tokens = TokenStream { rule->prelude() }; @@ -3081,8 +3081,8 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr rule) child_rules.append(child_rule); } - auto* rule_list = CSSRuleList::create(m_context.realm(), child_rules); - return CSSSupportsRule::create(m_context.realm(), supports.release_nonnull(), *rule_list); + auto rule_list = CSSRuleList::create(m_context.realm(), child_rules).release_value_but_fixme_should_propagate_errors(); + return CSSSupportsRule::create(m_context.realm(), supports.release_nonnull(), rule_list); } // FIXME: More at rules! @@ -7396,8 +7396,10 @@ namespace Web { CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const& context, StringView css, Optional location) { - if (css.is_empty()) - return CSS::CSSStyleSheet::create(context.realm(), *CSS::CSSRuleList::create_empty(context.realm()), *CSS::MediaList::create(context.realm(), {}), location); + if (css.is_empty()) { + auto rule_list = CSS::CSSRuleList::create_empty(context.realm()).release_value_but_fixme_should_propagate_errors(); + return CSS::CSSStyleSheet::create(context.realm(), rule_list, *CSS::MediaList::create(context.realm(), {}), location); + } CSS::Parser::Parser parser(context, css); return parser.parse_as_css_stylesheet(location); }