Pārlūkot izejas kodu

LibWeb: Make factory method of CSS::ResolvedCSSStyleDeclaration fallible

Kenneth Myhra 2 gadi atpakaļ
vecāks
revīzija
8fbd43cb27

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

@@ -20,9 +20,9 @@
 
 namespace Web::CSS {
 
-ResolvedCSSStyleDeclaration* ResolvedCSSStyleDeclaration::create(DOM::Element& element)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<ResolvedCSSStyleDeclaration>> ResolvedCSSStyleDeclaration::create(DOM::Element& element)
 {
-    return element.realm().heap().allocate<ResolvedCSSStyleDeclaration>(element.realm(), element).release_allocated_value_but_fixme_should_propagate_errors();
+    return MUST_OR_THROW_OOM(element.realm().heap().allocate<ResolvedCSSStyleDeclaration>(element.realm(), element));
 }
 
 ResolvedCSSStyleDeclaration::ResolvedCSSStyleDeclaration(DOM::Element& element)

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

@@ -14,7 +14,7 @@ class ResolvedCSSStyleDeclaration final : public CSSStyleDeclaration {
     WEB_PLATFORM_OBJECT(ResolvedCSSStyleDeclaration, CSSStyleDeclaration);
 
 public:
-    static ResolvedCSSStyleDeclaration* create(DOM::Element& element);
+    static WebIDL::ExceptionOr<JS::NonnullGCPtr<ResolvedCSSStyleDeclaration>> create(DOM::Element& element);
 
     virtual ~ResolvedCSSStyleDeclaration() override = default;
 

+ 1 - 1
Userland/Libraries/LibWeb/DOM/Element.cpp

@@ -438,7 +438,7 @@ Element::NeedsRelayout Element::recompute_style()
 
 NonnullRefPtr<CSS::StyleProperties> Element::resolved_css_values()
 {
-    auto element_computed_style = CSS::ResolvedCSSStyleDeclaration::create(*this);
+    auto element_computed_style = CSS::ResolvedCSSStyleDeclaration::create(*this).release_value_but_fixme_should_propagate_errors();
     auto properties = CSS::StyleProperties::create();
 
     for (auto i = to_underlying(CSS::first_property_id); i <= to_underlying(CSS::last_property_id); ++i) {

+ 1 - 1
Userland/Libraries/LibWeb/HTML/Window.cpp

@@ -644,7 +644,7 @@ Page const* Window::page() const
 
 CSS::CSSStyleDeclaration* Window::get_computed_style_impl(DOM::Element& element) const
 {
-    return CSS::ResolvedCSSStyleDeclaration::create(element);
+    return CSS::ResolvedCSSStyleDeclaration::create(element).release_value_but_fixme_should_propagate_errors().ptr();
 }
 
 JS::NonnullGCPtr<CSS::MediaQueryList> Window::match_media_impl(DeprecatedString media)