1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 10:37:45 +00:00

LibWeb: Make factory method of CSS::StyleSheetList fallible

This commit is contained in:
Kenneth Myhra 2023-02-14 20:30:43 +01:00 committed by Linus Groh
parent 57c34e6325
commit 719839b882
3 changed files with 4 additions and 4 deletions

View file

@ -45,10 +45,10 @@ void StyleSheetList::remove_sheet(CSSStyleSheet& sheet)
m_document.invalidate_style(); m_document.invalidate_style();
} }
StyleSheetList* StyleSheetList::create(DOM::Document& document) WebIDL::ExceptionOr<JS::NonnullGCPtr<StyleSheetList>> StyleSheetList::create(DOM::Document& document)
{ {
auto& realm = document.realm(); auto& realm = document.realm();
return realm.heap().allocate<StyleSheetList>(realm, document).release_allocated_value_but_fixme_should_propagate_errors(); return MUST_OR_THROW_OOM(realm.heap().allocate<StyleSheetList>(realm, document));
} }
StyleSheetList::StyleSheetList(DOM::Document& document) StyleSheetList::StyleSheetList(DOM::Document& document)

View file

@ -15,7 +15,7 @@ class StyleSheetList : public Bindings::LegacyPlatformObject {
WEB_PLATFORM_OBJECT(StyleSheetList, Bindings::LegacyPlatformObject); WEB_PLATFORM_OBJECT(StyleSheetList, Bindings::LegacyPlatformObject);
public: public:
static StyleSheetList* create(DOM::Document& document); static WebIDL::ExceptionOr<JS::NonnullGCPtr<StyleSheetList>> create(DOM::Document& document);
void add_sheet(CSSStyleSheet&); void add_sheet(CSSStyleSheet&);
void remove_sheet(CSSStyleSheet&); void remove_sheet(CSSStyleSheet&);

View file

@ -2046,7 +2046,7 @@ void Document::set_window(Badge<HTML::BrowsingContext>, HTML::Window& window)
CSS::StyleSheetList& Document::style_sheets() CSS::StyleSheetList& Document::style_sheets()
{ {
if (!m_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; return *m_style_sheets;
} }