From 719839b8822bcfb6fac3ea21ad427f1e7ae0da5e Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Tue, 14 Feb 2023 20:30:43 +0100 Subject: [PATCH] LibWeb: Make factory method of CSS::StyleSheetList fallible --- Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp | 4 ++-- Userland/Libraries/LibWeb/CSS/StyleSheetList.h | 2 +- Userland/Libraries/LibWeb/DOM/Document.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp b/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp index a770b76307..b73ae1cc93 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp @@ -45,10 +45,10 @@ void StyleSheetList::remove_sheet(CSSStyleSheet& sheet) m_document.invalidate_style(); } -StyleSheetList* StyleSheetList::create(DOM::Document& document) +WebIDL::ExceptionOr> StyleSheetList::create(DOM::Document& document) { auto& realm = document.realm(); - return realm.heap().allocate(realm, document).release_allocated_value_but_fixme_should_propagate_errors(); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document)); } StyleSheetList::StyleSheetList(DOM::Document& document) diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h index b80226af15..05d661249e 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h +++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h @@ -15,7 +15,7 @@ class StyleSheetList : public Bindings::LegacyPlatformObject { WEB_PLATFORM_OBJECT(StyleSheetList, Bindings::LegacyPlatformObject); public: - static StyleSheetList* create(DOM::Document& document); + static WebIDL::ExceptionOr> create(DOM::Document& document); void add_sheet(CSSStyleSheet&); void remove_sheet(CSSStyleSheet&); diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 2484426c2a..0a76876b07 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -2046,7 +2046,7 @@ void Document::set_window(Badge, HTML::Window& window) CSS::StyleSheetList& Document::style_sheets() { if (!m_style_sheets) - m_style_sheets = CSS::StyleSheetList::create(*this); + m_style_sheets = CSS::StyleSheetList::create(*this).release_value_but_fixme_should_propagate_errors(); return *m_style_sheets; }