浏览代码

LibWeb: Make factory method of CSS::CSSImportRule fallible

Kenneth Myhra 2 年之前
父节点
当前提交
d53d8cacec

+ 2 - 2
Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp

@@ -18,10 +18,10 @@
 
 
 namespace Web::CSS {
 namespace Web::CSS {
 
 
-CSSImportRule* CSSImportRule::create(AK::URL url, DOM::Document& document)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSImportRule>> CSSImportRule::create(AK::URL url, DOM::Document& document)
 {
 {
     auto& realm = document.realm();
     auto& realm = document.realm();
-    return realm.heap().allocate<CSSImportRule>(realm, move(url), document).release_allocated_value_but_fixme_should_propagate_errors();
+    return MUST_OR_THROW_OOM(realm.heap().allocate<CSSImportRule>(realm, move(url), document));
 }
 }
 
 
 CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document)
 CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document)

+ 1 - 1
Userland/Libraries/LibWeb/CSS/CSSImportRule.h

@@ -21,7 +21,7 @@ class CSSImportRule final
     WEB_PLATFORM_OBJECT(CSSImportRule, CSSRule);
     WEB_PLATFORM_OBJECT(CSSImportRule, CSSRule);
 
 
 public:
 public:
-    static CSSImportRule* create(AK::URL, DOM::Document&);
+    static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSImportRule>> create(AK::URL, DOM::Document&);
 
 
     virtual ~CSSImportRule() = default;
     virtual ~CSSImportRule() = default;
 
 

+ 1 - 1
Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp

@@ -3040,7 +3040,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
             }
             }
 
 
             if (url.has_value())
             if (url.has_value())
-                return CSSImportRule::create(url.value(), const_cast<DOM::Document&>(*m_context.document()));
+                return CSSImportRule::create(url.value(), const_cast<DOM::Document&>(*m_context.document())).release_value_but_fixme_should_propagate_errors();
             dbgln_if(CSS_PARSER_DEBUG, "Unable to parse url from @import rule");
             dbgln_if(CSS_PARSER_DEBUG, "Unable to parse url from @import rule");
             return {};
             return {};
         }
         }