mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:27:43 +00:00
LibJS: Make Heap::allocate<T>() infallible
Stop worrying about tiny OOMs. Work towards #20449. While going through these, I also changed the function signature in many places where returning ThrowCompletionOr<T> is no longer necessary.
This commit is contained in:
parent
980e7164fe
commit
72c9f56c66
337 changed files with 1229 additions and 1251 deletions
|
@ -14,9 +14,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSFontFaceRule>> CSSFontFaceRule::create(JS::Realm& realm, FontFace&& font_face)
|
||||
JS::NonnullGCPtr<CSSFontFaceRule> CSSFontFaceRule::create(JS::Realm& realm, FontFace&& font_face)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<CSSFontFaceRule>(realm, realm, move(font_face)));
|
||||
return realm.heap().allocate<CSSFontFaceRule>(realm, realm, move(font_face));
|
||||
}
|
||||
|
||||
CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, FontFace&& font_face)
|
||||
|
|
|
@ -16,7 +16,7 @@ class CSSFontFaceRule final : public CSSRule {
|
|||
WEB_PLATFORM_OBJECT(CSSFontFaceRule, CSSRule);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSFontFaceRule>> create(JS::Realm&, FontFace&&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSFontFaceRule> create(JS::Realm&, FontFace&&);
|
||||
|
||||
virtual ~CSSFontFaceRule() override = default;
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSImportRule>> CSSImportRule::create(AK::URL url, DOM::Document& document)
|
||||
JS::NonnullGCPtr<CSSImportRule> CSSImportRule::create(AK::URL url, DOM::Document& document)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<CSSImportRule>(realm, move(url), document));
|
||||
return realm.heap().allocate<CSSImportRule>(realm, move(url), document);
|
||||
}
|
||||
|
||||
CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document)
|
||||
|
|
|
@ -22,7 +22,7 @@ class CSSImportRule final
|
|||
WEB_PLATFORM_OBJECT(CSSImportRule, CSSRule);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSImportRule>> create(AK::URL, DOM::Document&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSImportRule> create(AK::URL, DOM::Document&);
|
||||
|
||||
virtual ~CSSImportRule() = default;
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSKeyframeRule>> CSSKeyframeRule::create(JS::Realm& realm, CSS::Percentage key, Web::CSS::CSSStyleDeclaration& declarations)
|
||||
JS::NonnullGCPtr<CSSKeyframeRule> CSSKeyframeRule::create(JS::Realm& realm, CSS::Percentage key, Web::CSS::CSSStyleDeclaration& declarations)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<CSSKeyframeRule>(realm, realm, key, declarations));
|
||||
return realm.heap().allocate<CSSKeyframeRule>(realm, realm, key, declarations);
|
||||
}
|
||||
|
||||
void CSSKeyframeRule::visit_edges(Visitor& visitor)
|
||||
|
|
|
@ -20,7 +20,7 @@ class CSSKeyframeRule final : public CSSRule {
|
|||
WEB_PLATFORM_OBJECT(CSSKeyframeRule, CSSRule);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSKeyframeRule>> create(JS::Realm& realm, CSS::Percentage key, CSSStyleDeclaration& declarations);
|
||||
static JS::NonnullGCPtr<CSSKeyframeRule> create(JS::Realm&, CSS::Percentage key, CSSStyleDeclaration&);
|
||||
|
||||
virtual ~CSSKeyframeRule() = default;
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSKeyframesRule>> CSSKeyframesRule::create(JS::Realm& realm, AK::FlyString name, Vector<JS::NonnullGCPtr<CSSKeyframeRule>> keyframes)
|
||||
JS::NonnullGCPtr<CSSKeyframesRule> CSSKeyframesRule::create(JS::Realm& realm, AK::FlyString name, Vector<JS::NonnullGCPtr<CSSKeyframeRule>> keyframes)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<CSSKeyframesRule>(realm, realm, move(name), move(keyframes)));
|
||||
return realm.heap().allocate<CSSKeyframesRule>(realm, realm, move(name), move(keyframes));
|
||||
}
|
||||
|
||||
void CSSKeyframesRule::visit_edges(Visitor& visitor)
|
||||
|
|
|
@ -21,7 +21,7 @@ class CSSKeyframesRule final : public CSSRule {
|
|||
WEB_PLATFORM_OBJECT(CSSKeyframesRule, CSSRule);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSKeyframesRule>> create(JS::Realm& realm, FlyString name, Vector<JS::NonnullGCPtr<CSSKeyframeRule>> keyframes);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSKeyframesRule> create(JS::Realm&, FlyString name, Vector<JS::NonnullGCPtr<CSSKeyframeRule>>);
|
||||
|
||||
virtual ~CSSKeyframesRule() = default;
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSMediaRule>> CSSMediaRule::create(JS::Realm& realm, MediaList& media_queries, CSSRuleList& rules)
|
||||
JS::NonnullGCPtr<CSSMediaRule> CSSMediaRule::create(JS::Realm& realm, MediaList& media_queries, CSSRuleList& rules)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<CSSMediaRule>(realm, realm, media_queries, rules));
|
||||
return realm.heap().allocate<CSSMediaRule>(realm, realm, media_queries, rules);
|
||||
}
|
||||
|
||||
CSSMediaRule::CSSMediaRule(JS::Realm& realm, MediaList& media, CSSRuleList& rules)
|
||||
|
|
|
@ -18,7 +18,7 @@ class CSSMediaRule final : public CSSConditionRule {
|
|||
WEB_PLATFORM_OBJECT(CSSMediaRule, CSSConditionRule);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSMediaRule>> create(JS::Realm&, MediaList& media_queries, CSSRuleList&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSMediaRule> create(JS::Realm&, MediaList& media_queries, CSSRuleList&);
|
||||
|
||||
virtual ~CSSMediaRule() = default;
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ CSSNamespaceRule::CSSNamespaceRule(JS::Realm& realm, Optional<DeprecatedString>
|
|||
{
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSNamespaceRule>> CSSNamespaceRule::create(JS::Realm& realm, Optional<DeprecatedString> prefix, AK::StringView namespace_uri)
|
||||
JS::NonnullGCPtr<CSSNamespaceRule> CSSNamespaceRule::create(JS::Realm& realm, Optional<DeprecatedString> prefix, AK::StringView namespace_uri)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<CSSNamespaceRule>(realm, realm, prefix, namespace_uri));
|
||||
return realm.heap().allocate<CSSNamespaceRule>(realm, realm, prefix, namespace_uri);
|
||||
}
|
||||
|
||||
void CSSNamespaceRule::initialize(JS::Realm& realm)
|
||||
|
|
|
@ -14,7 +14,7 @@ class CSSNamespaceRule final : public CSSRule {
|
|||
WEB_PLATFORM_OBJECT(CSSNamespaceRule, CSSRule);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSNamespaceRule>> create(JS::Realm&, Optional<DeprecatedString> prefix, StringView namespace_uri);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSNamespaceRule> create(JS::Realm&, Optional<DeprecatedString> prefix, StringView namespace_uri);
|
||||
|
||||
virtual ~CSSNamespaceRule() = default;
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSRuleList>> CSSRuleList::create(JS::Realm& realm, JS::MarkedVector<CSSRule*> const& rules)
|
||||
JS::NonnullGCPtr<CSSRuleList> CSSRuleList::create(JS::Realm& realm, JS::MarkedVector<CSSRule*> const& rules)
|
||||
{
|
||||
auto rule_list = MUST_OR_THROW_OOM(realm.heap().allocate<CSSRuleList>(realm, realm));
|
||||
auto rule_list = realm.heap().allocate<CSSRuleList>(realm, realm);
|
||||
for (auto* rule : rules)
|
||||
rule_list->m_rules.append(*rule);
|
||||
return rule_list;
|
||||
|
@ -31,9 +31,9 @@ CSSRuleList::CSSRuleList(JS::Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSRuleList>> CSSRuleList::create_empty(JS::Realm& realm)
|
||||
JS::NonnullGCPtr<CSSRuleList> CSSRuleList::create_empty(JS::Realm& realm)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<CSSRuleList>(realm, realm));
|
||||
return realm.heap().allocate<CSSRuleList>(realm, realm);
|
||||
}
|
||||
|
||||
void CSSRuleList::initialize(JS::Realm& realm)
|
||||
|
|
|
@ -23,8 +23,8 @@ class CSSRuleList : public Bindings::LegacyPlatformObject {
|
|||
WEB_PLATFORM_OBJECT(CSSRuleList, Bindings::LegacyPlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSRuleList>> create(JS::Realm&, JS::MarkedVector<CSSRule*> const&);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSRuleList>> create_empty(JS::Realm&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSRuleList> create(JS::Realm&, JS::MarkedVector<CSSRule*> const&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSRuleList> create_empty(JS::Realm&);
|
||||
|
||||
~CSSRuleList() = default;
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ void CSSStyleDeclaration::initialize(JS::Realm& realm)
|
|||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSStyleDeclarationPrototype>(realm, "CSSStyleDeclaration"));
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration>> PropertyOwningCSSStyleDeclaration::create(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||
JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration> PropertyOwningCSSStyleDeclaration::create(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<PropertyOwningCSSStyleDeclaration>(realm, realm, move(properties), move(custom_properties)));
|
||||
return realm.heap().allocate<PropertyOwningCSSStyleDeclaration>(realm, realm, move(properties), move(custom_properties));
|
||||
}
|
||||
|
||||
PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||
|
@ -45,10 +45,10 @@ DeprecatedString PropertyOwningCSSStyleDeclaration::item(size_t index) const
|
|||
return CSS::string_from_property_id(m_properties[index].property_id);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<ElementInlineCSSStyleDeclaration>> ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||
JS::NonnullGCPtr<ElementInlineCSSStyleDeclaration> ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||
{
|
||||
auto& realm = element.realm();
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<ElementInlineCSSStyleDeclaration>(realm, element, move(properties), move(custom_properties)));
|
||||
return realm.heap().allocate<ElementInlineCSSStyleDeclaration>(realm, element, move(properties), move(custom_properties));
|
||||
}
|
||||
|
||||
ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||
|
|
|
@ -53,7 +53,7 @@ class PropertyOwningCSSStyleDeclaration : public CSSStyleDeclaration {
|
|||
friend class ElementInlineCSSStyleDeclaration;
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration>>
|
||||
[[nodiscard]] static JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration>
|
||||
create(JS::Realm&, Vector<StyleProperty>, HashMap<DeprecatedString, StyleProperty> custom_properties);
|
||||
|
||||
virtual ~PropertyOwningCSSStyleDeclaration() override = default;
|
||||
|
@ -93,7 +93,7 @@ class ElementInlineCSSStyleDeclaration final : public PropertyOwningCSSStyleDecl
|
|||
WEB_PLATFORM_OBJECT(ElementInlineCSSStyleDeclaration, PropertyOwningCSSStyleDeclaration);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ElementInlineCSSStyleDeclaration>> create(DOM::Element&, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<ElementInlineCSSStyleDeclaration> create(DOM::Element&, Vector<StyleProperty>, HashMap<DeprecatedString, StyleProperty> custom_properties);
|
||||
|
||||
virtual ~ElementInlineCSSStyleDeclaration() override = default;
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleRule>> CSSStyleRule::create(JS::Realm& realm, Vector<NonnullRefPtr<Web::CSS::Selector>>&& selectors, CSSStyleDeclaration& declaration)
|
||||
JS::NonnullGCPtr<CSSStyleRule> CSSStyleRule::create(JS::Realm& realm, Vector<NonnullRefPtr<Web::CSS::Selector>>&& selectors, CSSStyleDeclaration& declaration)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<CSSStyleRule>(realm, realm, move(selectors), declaration));
|
||||
return realm.heap().allocate<CSSStyleRule>(realm, realm, move(selectors), declaration);
|
||||
}
|
||||
|
||||
CSSStyleRule::CSSStyleRule(JS::Realm& realm, Vector<NonnullRefPtr<Selector>>&& selectors, CSSStyleDeclaration& declaration)
|
||||
|
|
|
@ -18,7 +18,7 @@ class CSSStyleRule final : public CSSRule {
|
|||
WEB_PLATFORM_OBJECT(CSSStyleRule, CSSRule);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleRule>> create(JS::Realm&, Vector<NonnullRefPtr<Selector>>&&, CSSStyleDeclaration&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSStyleRule> create(JS::Realm&, Vector<NonnullRefPtr<Selector>>&&, CSSStyleDeclaration&);
|
||||
|
||||
virtual ~CSSStyleRule() override = default;
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleSheet>> CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<AK::URL> location)
|
||||
JS::NonnullGCPtr<CSSStyleSheet> CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<AK::URL> location)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<CSSStyleSheet>(realm, realm, rules, media, move(location)));
|
||||
return realm.heap().allocate<CSSStyleSheet>(realm, realm, rules, media, move(location));
|
||||
}
|
||||
|
||||
CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<AK::URL> location)
|
||||
|
|
|
@ -23,7 +23,7 @@ class CSSStyleSheet final
|
|||
WEB_PLATFORM_OBJECT(CSSStyleSheet, StyleSheet);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleSheet>> create(JS::Realm&, CSSRuleList& rules, MediaList& media, Optional<AK::URL> location);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSStyleSheet> create(JS::Realm&, CSSRuleList&, MediaList&, Optional<AK::URL> location);
|
||||
|
||||
virtual ~CSSStyleSheet() override = default;
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSSupportsRule>> CSSSupportsRule::create(JS::Realm& realm, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||
JS::NonnullGCPtr<CSSSupportsRule> CSSSupportsRule::create(JS::Realm& realm, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<CSSSupportsRule>(realm, realm, move(supports), rules));
|
||||
return realm.heap().allocate<CSSSupportsRule>(realm, realm, move(supports), rules);
|
||||
}
|
||||
|
||||
CSSSupportsRule::CSSSupportsRule(JS::Realm& realm, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||
|
|
|
@ -19,7 +19,7 @@ class CSSSupportsRule final : public CSSConditionRule {
|
|||
WEB_PLATFORM_OBJECT(CSSSupportsRule, CSSConditionRule);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSSupportsRule>> create(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
||||
static JS::NonnullGCPtr<CSSSupportsRule> create(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
||||
|
||||
virtual ~CSSSupportsRule() = default;
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaList>> MediaList::create(JS::Realm& realm, Vector<NonnullRefPtr<MediaQuery>>&& media)
|
||||
JS::NonnullGCPtr<MediaList> MediaList::create(JS::Realm& realm, Vector<NonnullRefPtr<MediaQuery>>&& media)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<MediaList>(realm, realm, move(media)));
|
||||
return realm.heap().allocate<MediaList>(realm, realm, move(media));
|
||||
}
|
||||
|
||||
MediaList::MediaList(JS::Realm& realm, Vector<NonnullRefPtr<MediaQuery>>&& media)
|
||||
|
|
|
@ -20,7 +20,7 @@ class MediaList final : public Bindings::LegacyPlatformObject {
|
|||
WEB_PLATFORM_OBJECT(MediaList, Bindings::LegacyPlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaList>> create(JS::Realm&, Vector<NonnullRefPtr<MediaQuery>>&& media);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<MediaList> create(JS::Realm&, Vector<NonnullRefPtr<MediaQuery>>&&);
|
||||
~MediaList() = default;
|
||||
|
||||
DeprecatedString media_text() const;
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryList>> MediaQueryList::create(DOM::Document& document, Vector<NonnullRefPtr<MediaQuery>>&& media)
|
||||
JS::NonnullGCPtr<MediaQueryList> MediaQueryList::create(DOM::Document& document, Vector<NonnullRefPtr<MediaQuery>>&& media)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(document.heap().allocate<MediaQueryList>(document.realm(), document, move(media)));
|
||||
return document.heap().allocate<MediaQueryList>(document.realm(), document, move(media));
|
||||
}
|
||||
|
||||
MediaQueryList::MediaQueryList(DOM::Document& document, Vector<NonnullRefPtr<MediaQuery>>&& media)
|
||||
|
|
|
@ -17,7 +17,7 @@ class MediaQueryList final : public DOM::EventTarget {
|
|||
WEB_PLATFORM_OBJECT(MediaQueryList, DOM::EventTarget);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryList>> create(DOM::Document&, Vector<NonnullRefPtr<MediaQuery>>&&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<MediaQueryList> create(DOM::Document&, Vector<NonnullRefPtr<MediaQuery>>&&);
|
||||
|
||||
virtual ~MediaQueryList() override = default;
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryListEvent>> MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
JS::NonnullGCPtr<MediaQueryListEvent> MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<MediaQueryListEvent>(realm, realm, event_name, event_init));
|
||||
return realm.heap().allocate<MediaQueryListEvent>(realm, realm, event_name, event_init);
|
||||
}
|
||||
|
||||
MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
|
|
|
@ -20,7 +20,7 @@ class MediaQueryListEvent final : public DOM::Event {
|
|||
WEB_PLATFORM_OBJECT(MediaQueryListEvent, DOM::Event);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryListEvent>> construct_impl(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& event_init = {});
|
||||
[[nodiscard]] static JS::NonnullGCPtr<MediaQueryListEvent> construct_impl(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& = {});
|
||||
|
||||
virtual ~MediaQueryListEvent() override;
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@ namespace Web {
|
|||
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const& context, StringView css, Optional<AK::URL> location)
|
||||
{
|
||||
if (css.is_empty()) {
|
||||
auto rule_list = CSS::CSSRuleList::create_empty(context.realm()).release_value_but_fixme_should_propagate_errors();
|
||||
auto media_list = CSS::MediaList::create(context.realm(), {}).release_value_but_fixme_should_propagate_errors();
|
||||
return CSS::CSSStyleSheet::create(context.realm(), rule_list, media_list, location).release_value_but_fixme_should_propagate_errors();
|
||||
auto rule_list = CSS::CSSRuleList::create_empty(context.realm());
|
||||
auto media_list = CSS::MediaList::create(context.realm(), {});
|
||||
return CSS::CSSStyleSheet::create(context.realm(), rule_list, media_list, location);
|
||||
}
|
||||
auto parser = CSS::Parser::Parser::create(context, css).release_value_but_fixme_should_propagate_errors();
|
||||
return parser.parse_as_css_stylesheet(location);
|
||||
|
@ -29,7 +29,7 @@ CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const& cont
|
|||
CSS::ElementInlineCSSStyleDeclaration* parse_css_style_attribute(CSS::Parser::ParsingContext const& context, StringView css, DOM::Element& element)
|
||||
{
|
||||
if (css.is_empty())
|
||||
return CSS::ElementInlineCSSStyleDeclaration::create(element, {}, {}).release_value_but_fixme_should_propagate_errors();
|
||||
return CSS::ElementInlineCSSStyleDeclaration::create(element, {}, {});
|
||||
auto parser = CSS::Parser::Parser::create(context, css).release_value_but_fixme_should_propagate_errors();
|
||||
return parser.parse_as_style_attribute(element);
|
||||
}
|
||||
|
|
|
@ -161,9 +161,9 @@ CSSStyleSheet* Parser::parse_as_css_stylesheet(Optional<AK::URL> location)
|
|||
rules.append(rule);
|
||||
}
|
||||
|
||||
auto rule_list = CSSRuleList::create(m_context.realm(), rules).release_value_but_fixme_should_propagate_errors();
|
||||
auto media_list = MediaList::create(m_context.realm(), {}).release_value_but_fixme_should_propagate_errors();
|
||||
return CSSStyleSheet::create(m_context.realm(), rule_list, media_list, move(location)).release_value_but_fixme_should_propagate_errors();
|
||||
auto rule_list = CSSRuleList::create(m_context.realm(), rules);
|
||||
auto media_list = MediaList::create(m_context.realm(), {});
|
||||
return CSSStyleSheet::create(m_context.realm(), rule_list, media_list, move(location));
|
||||
}
|
||||
|
||||
Optional<SelectorList> Parser::parse_as_selector(SelectorParsingMode parsing_mode)
|
||||
|
@ -2360,7 +2360,7 @@ ElementInlineCSSStyleDeclaration* Parser::parse_as_style_attribute(DOM::Element&
|
|||
{
|
||||
auto declarations_and_at_rules = parse_a_list_of_declarations(m_token_stream);
|
||||
auto [properties, custom_properties] = extract_properties(declarations_and_at_rules);
|
||||
return ElementInlineCSSStyleDeclaration::create(element, move(properties), move(custom_properties)).release_value_but_fixme_should_propagate_errors();
|
||||
return ElementInlineCSSStyleDeclaration::create(element, move(properties), move(custom_properties));
|
||||
}
|
||||
|
||||
Optional<AK::URL> Parser::parse_url_function(ComponentValue const& component_value)
|
||||
|
@ -3149,7 +3149,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
|
|||
}
|
||||
|
||||
if (url.has_value())
|
||||
return CSSImportRule::create(url.value(), const_cast<DOM::Document&>(*m_context.document())).release_value_but_fixme_should_propagate_errors();
|
||||
return CSSImportRule::create(url.value(), const_cast<DOM::Document&>(*m_context.document()));
|
||||
dbgln_if(CSS_PARSER_DEBUG, "Unable to parse url from @import rule");
|
||||
return {};
|
||||
}
|
||||
|
@ -3166,9 +3166,9 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
|
|||
if (auto* child_rule = convert_to_rule(raw_rule))
|
||||
child_rules.append(child_rule);
|
||||
}
|
||||
auto media_list = MediaList::create(m_context.realm(), move(media_query_list)).release_value_but_fixme_should_propagate_errors();
|
||||
auto rule_list = CSSRuleList::create(m_context.realm(), child_rules).release_value_but_fixme_should_propagate_errors();
|
||||
return CSSMediaRule::create(m_context.realm(), media_list, rule_list).release_value_but_fixme_should_propagate_errors();
|
||||
auto media_list = MediaList::create(m_context.realm(), move(media_query_list));
|
||||
auto rule_list = CSSRuleList::create(m_context.realm(), child_rules);
|
||||
return CSSMediaRule::create(m_context.realm(), media_list, rule_list);
|
||||
}
|
||||
if (rule->at_rule_name().equals_ignoring_ascii_case("supports"sv)) {
|
||||
auto supports_tokens = TokenStream { rule->prelude() };
|
||||
|
@ -3191,8 +3191,8 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
|
|||
child_rules.append(child_rule);
|
||||
}
|
||||
|
||||
auto rule_list = CSSRuleList::create(m_context.realm(), child_rules).release_value_but_fixme_should_propagate_errors();
|
||||
return CSSSupportsRule::create(m_context.realm(), supports.release_nonnull(), rule_list).release_value_but_fixme_should_propagate_errors();
|
||||
auto rule_list = CSSRuleList::create(m_context.realm(), child_rules);
|
||||
return CSSSupportsRule::create(m_context.realm(), supports.release_nonnull(), rule_list);
|
||||
}
|
||||
if (rule->at_rule_name().equals_ignoring_ascii_case("keyframes"sv)) {
|
||||
auto prelude_stream = TokenStream { rule->prelude() };
|
||||
|
@ -3286,7 +3286,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
|
|||
auto block_declarations = parse_a_list_of_declarations(block_stream);
|
||||
auto style = convert_to_style_declaration(block_declarations);
|
||||
for (auto& selector : selectors) {
|
||||
auto keyframe_rule = CSSKeyframeRule::create(m_context.realm(), selector, *style).release_value_but_fixme_should_propagate_errors();
|
||||
auto keyframe_rule = CSSKeyframeRule::create(m_context.realm(), selector, *style);
|
||||
keyframes.append(keyframe_rule);
|
||||
}
|
||||
} else {
|
||||
|
@ -3294,7 +3294,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
|
|||
}
|
||||
}
|
||||
|
||||
return CSSKeyframesRule::create(m_context.realm(), name, move(keyframes)).release_value_but_fixme_should_propagate_errors();
|
||||
return CSSKeyframesRule::create(m_context.realm(), name, move(keyframes));
|
||||
}
|
||||
if (rule->at_rule_name().equals_ignoring_ascii_case("namespace"sv)) {
|
||||
// https://drafts.csswg.org/css-namespaces/#syntax
|
||||
|
@ -3325,7 +3325,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
|
|||
return {};
|
||||
}
|
||||
|
||||
return CSSNamespaceRule::create(m_context.realm(), prefix, namespace_uri).release_value_but_fixme_should_propagate_errors();
|
||||
return CSSNamespaceRule::create(m_context.realm(), prefix, namespace_uri);
|
||||
}
|
||||
|
||||
// FIXME: More at rules!
|
||||
|
@ -3363,7 +3363,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
|
|||
return {};
|
||||
}
|
||||
|
||||
return CSSStyleRule::create(m_context.realm(), move(selectors.value()), *declaration).release_value_but_fixme_should_propagate_errors();
|
||||
return CSSStyleRule::create(m_context.realm(), move(selectors.value()), *declaration);
|
||||
}
|
||||
|
||||
auto Parser::extract_properties(Vector<DeclarationOrAtRule> const& declarations_and_at_rules) -> PropertiesAndCustomProperties
|
||||
|
@ -3392,7 +3392,7 @@ auto Parser::extract_properties(Vector<DeclarationOrAtRule> const& declarations_
|
|||
PropertyOwningCSSStyleDeclaration* Parser::convert_to_style_declaration(Vector<DeclarationOrAtRule> const& declarations_and_at_rules)
|
||||
{
|
||||
auto [properties, custom_properties] = extract_properties(declarations_and_at_rules);
|
||||
return PropertyOwningCSSStyleDeclaration::create(m_context.realm(), move(properties), move(custom_properties)).release_value_but_fixme_should_propagate_errors();
|
||||
return PropertyOwningCSSStyleDeclaration::create(m_context.realm(), move(properties), move(custom_properties));
|
||||
}
|
||||
|
||||
Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& declaration)
|
||||
|
@ -6133,7 +6133,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream<ComponentValue>& tokens)
|
|||
unicode_range.empend(0x0u, 0x10FFFFu);
|
||||
}
|
||||
|
||||
return CSSFontFaceRule::create(m_context.realm(), FontFace { font_family.release_value(), weight, slope, move(src), move(unicode_range) }).release_value_but_fixme_should_propagate_errors();
|
||||
return CSSFontFaceRule::create(m_context.realm(), FontFace { font_family.release_value(), weight, slope, move(src), move(unicode_range) });
|
||||
}
|
||||
|
||||
Vector<FontFace::Source> Parser::parse_font_face_src(TokenStream<ComponentValue>& component_values)
|
||||
|
|
|
@ -48,9 +48,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<ResolvedCSSStyleDeclaration>> ResolvedCSSStyleDeclaration::create(DOM::Element& element)
|
||||
JS::NonnullGCPtr<ResolvedCSSStyleDeclaration> ResolvedCSSStyleDeclaration::create(DOM::Element& element)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(element.realm().heap().allocate<ResolvedCSSStyleDeclaration>(element.realm(), element));
|
||||
return element.realm().heap().allocate<ResolvedCSSStyleDeclaration>(element.realm(), element);
|
||||
}
|
||||
|
||||
ResolvedCSSStyleDeclaration::ResolvedCSSStyleDeclaration(DOM::Element& element)
|
||||
|
|
|
@ -14,7 +14,7 @@ class ResolvedCSSStyleDeclaration final : public CSSStyleDeclaration {
|
|||
WEB_PLATFORM_OBJECT(ResolvedCSSStyleDeclaration, CSSStyleDeclaration);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ResolvedCSSStyleDeclaration>> create(DOM::Element& element);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<ResolvedCSSStyleDeclaration> create(DOM::Element&);
|
||||
|
||||
virtual ~ResolvedCSSStyleDeclaration() override = default;
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Screen>> Screen::create(HTML::Window& window)
|
||||
JS::NonnullGCPtr<Screen> Screen::create(HTML::Window& window)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(window.heap().allocate<Screen>(window.realm(), window));
|
||||
return window.heap().allocate<Screen>(window.realm(), window);
|
||||
}
|
||||
|
||||
Screen::Screen(HTML::Window& window)
|
||||
|
|
|
@ -17,7 +17,7 @@ class Screen final : public Bindings::PlatformObject {
|
|||
WEB_PLATFORM_OBJECT(Screen, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Screen>> create(HTML::Window&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Screen> create(HTML::Window&);
|
||||
|
||||
i32 width() const { return screen_rect().width(); }
|
||||
i32 height() const { return screen_rect().height(); }
|
||||
|
|
|
@ -62,10 +62,10 @@ void StyleSheetList::remove_sheet(CSSStyleSheet& sheet)
|
|||
m_document->invalidate_style();
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<StyleSheetList>> StyleSheetList::create(DOM::Document& document)
|
||||
JS::NonnullGCPtr<StyleSheetList> StyleSheetList::create(DOM::Document& document)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<StyleSheetList>(realm, document));
|
||||
return realm.heap().allocate<StyleSheetList>(realm, document);
|
||||
}
|
||||
|
||||
StyleSheetList::StyleSheetList(DOM::Document& document)
|
||||
|
|
|
@ -16,7 +16,7 @@ class StyleSheetList : public Bindings::LegacyPlatformObject {
|
|||
WEB_PLATFORM_OBJECT(StyleSheetList, Bindings::LegacyPlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<StyleSheetList>> create(DOM::Document& document);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<StyleSheetList> create(DOM::Document&);
|
||||
|
||||
void add_sheet(CSSStyleSheet&);
|
||||
void remove_sheet(CSSStyleSheet&);
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<VisualViewport>> VisualViewport::create(DOM::Document& document)
|
||||
JS::NonnullGCPtr<VisualViewport> VisualViewport::create(DOM::Document& document)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(document.heap().allocate<VisualViewport>(document.realm(), document));
|
||||
return document.heap().allocate<VisualViewport>(document.realm(), document);
|
||||
}
|
||||
|
||||
VisualViewport::VisualViewport(DOM::Document& document)
|
||||
|
|
|
@ -15,7 +15,7 @@ class VisualViewport final : public DOM::EventTarget {
|
|||
WEB_PLATFORM_OBJECT(VisualViewport, DOM::EventTarget);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<VisualViewport>> create(DOM::Document&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<VisualViewport> create(DOM::Document&);
|
||||
|
||||
virtual ~VisualViewport() override = default;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue