From ff8495de35df26b03a8be40c45d069ce56bdd5b3 Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Sun, 12 Feb 2023 22:44:04 +0100 Subject: [PATCH] LibWeb: Make factory method of CSS::CSSFontFaceRule fallible --- Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp | 5 +++-- Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h | 2 +- Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp index 7890656ccb..34895f99bd 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp @@ -9,12 +9,13 @@ #include #include #include +#include namespace Web::CSS { -CSSFontFaceRule* CSSFontFaceRule::create(JS::Realm& realm, FontFace&& font_face) +WebIDL::ExceptionOr> CSSFontFaceRule::create(JS::Realm& realm, FontFace&& font_face) { - return realm.heap().allocate(realm, realm, move(font_face)).release_allocated_value_but_fixme_should_propagate_errors(); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(font_face))); } CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, FontFace&& font_face) diff --git a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h index fe08427d46..ab6263bdfb 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h @@ -16,7 +16,7 @@ class CSSFontFaceRule final : public CSSRule { WEB_PLATFORM_OBJECT(CSSFontFaceRule, CSSRule); public: - static CSSFontFaceRule* create(JS::Realm&, FontFace&&); + static WebIDL::ExceptionOr> create(JS::Realm&, FontFace&&); virtual ~CSSFontFaceRule() override = default; diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 9e43248edf..a0e6514595 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -5394,7 +5394,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream& tokens) unicode_range.empend(0x0u, 0x10FFFFu); } - return CSSFontFaceRule::create(m_context.realm(), FontFace { font_family.release_value(), move(src), move(unicode_range) }); + return CSSFontFaceRule::create(m_context.realm(), FontFace { font_family.release_value(), move(src), move(unicode_range) }).release_value_but_fixme_should_propagate_errors(); } Vector Parser::parse_font_face_src(TokenStream& component_values)