mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 20:07:34 +00:00
LibWeb: Make factory methods of CSS::CSSStyleDeclaration fallible
This commit is contained in:
parent
48872cd190
commit
c950d1904a
4 changed files with 10 additions and 10 deletions
|
@ -19,9 +19,9 @@ CSSStyleDeclaration::CSSStyleDeclaration(JS::Realm& realm)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyOwningCSSStyleDeclaration* PropertyOwningCSSStyleDeclaration::create(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration>> PropertyOwningCSSStyleDeclaration::create(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||||
{
|
{
|
||||||
return realm.heap().allocate<PropertyOwningCSSStyleDeclaration>(realm, realm, move(properties), move(custom_properties)).release_allocated_value_but_fixme_should_propagate_errors();
|
return MUST_OR_THROW_OOM(realm.heap().allocate<PropertyOwningCSSStyleDeclaration>(realm, realm, move(properties), move(custom_properties)));
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||||
|
@ -38,10 +38,10 @@ DeprecatedString PropertyOwningCSSStyleDeclaration::item(size_t index) const
|
||||||
return CSS::string_from_property_id(m_properties[index].property_id);
|
return CSS::string_from_property_id(m_properties[index].property_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementInlineCSSStyleDeclaration* ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<ElementInlineCSSStyleDeclaration>> ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||||
{
|
{
|
||||||
auto& realm = element.realm();
|
auto& realm = element.realm();
|
||||||
return realm.heap().allocate<ElementInlineCSSStyleDeclaration>(realm, element, move(properties), move(custom_properties)).release_allocated_value_but_fixme_should_propagate_errors();
|
return MUST_OR_THROW_OOM(realm.heap().allocate<ElementInlineCSSStyleDeclaration>(realm, element, move(properties), move(custom_properties)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||||
|
|
|
@ -63,7 +63,7 @@ class PropertyOwningCSSStyleDeclaration : public CSSStyleDeclaration {
|
||||||
friend class ElementInlineCSSStyleDeclaration;
|
friend class ElementInlineCSSStyleDeclaration;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static PropertyOwningCSSStyleDeclaration* create(JS::Realm&, Vector<StyleProperty>, HashMap<DeprecatedString, StyleProperty> custom_properties);
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration>> create(JS::Realm&, Vector<StyleProperty>, HashMap<DeprecatedString, StyleProperty> custom_properties);
|
||||||
|
|
||||||
virtual ~PropertyOwningCSSStyleDeclaration() override = default;
|
virtual ~PropertyOwningCSSStyleDeclaration() override = default;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ class ElementInlineCSSStyleDeclaration final : public PropertyOwningCSSStyleDecl
|
||||||
WEB_PLATFORM_OBJECT(ElementInlineCSSStyleDeclaration, PropertyOwningCSSStyleDeclaration);
|
WEB_PLATFORM_OBJECT(ElementInlineCSSStyleDeclaration, PropertyOwningCSSStyleDeclaration);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ElementInlineCSSStyleDeclaration* create(DOM::Element&, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties);
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ElementInlineCSSStyleDeclaration>> create(DOM::Element&, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties);
|
||||||
|
|
||||||
virtual ~ElementInlineCSSStyleDeclaration() override = default;
|
virtual ~ElementInlineCSSStyleDeclaration() override = default;
|
||||||
|
|
||||||
|
|
|
@ -2242,7 +2242,7 @@ ElementInlineCSSStyleDeclaration* Parser::parse_as_style_attribute(DOM::Element&
|
||||||
{
|
{
|
||||||
auto declarations_and_at_rules = parse_a_list_of_declarations(m_token_stream);
|
auto declarations_and_at_rules = parse_a_list_of_declarations(m_token_stream);
|
||||||
auto [properties, custom_properties] = extract_properties(declarations_and_at_rules);
|
auto [properties, custom_properties] = extract_properties(declarations_and_at_rules);
|
||||||
return ElementInlineCSSStyleDeclaration::create(element, move(properties), move(custom_properties));
|
return ElementInlineCSSStyleDeclaration::create(element, move(properties), move(custom_properties)).release_value_but_fixme_should_propagate_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<AK::URL> Parser::parse_url_function(ComponentValue const& component_value, AllowedDataUrlType allowed_data_url_type)
|
Optional<AK::URL> Parser::parse_url_function(ComponentValue const& component_value, AllowedDataUrlType allowed_data_url_type)
|
||||||
|
@ -3149,7 +3149,7 @@ auto Parser::extract_properties(Vector<DeclarationOrAtRule> const& declarations_
|
||||||
PropertyOwningCSSStyleDeclaration* Parser::convert_to_style_declaration(Vector<DeclarationOrAtRule> const& declarations_and_at_rules)
|
PropertyOwningCSSStyleDeclaration* Parser::convert_to_style_declaration(Vector<DeclarationOrAtRule> const& declarations_and_at_rules)
|
||||||
{
|
{
|
||||||
auto [properties, custom_properties] = extract_properties(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));
|
return PropertyOwningCSSStyleDeclaration::create(m_context.realm(), move(properties), move(custom_properties)).release_value_but_fixme_should_propagate_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& declaration)
|
Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& declaration)
|
||||||
|
@ -7407,7 +7407,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)
|
CSS::ElementInlineCSSStyleDeclaration* parse_css_style_attribute(CSS::Parser::ParsingContext const& context, StringView css, DOM::Element& element)
|
||||||
{
|
{
|
||||||
if (css.is_empty())
|
if (css.is_empty())
|
||||||
return CSS::ElementInlineCSSStyleDeclaration::create(element, {}, {});
|
return CSS::ElementInlineCSSStyleDeclaration::create(element, {}, {}).release_value_but_fixme_should_propagate_errors();
|
||||||
CSS::Parser::Parser parser(context, css);
|
CSS::Parser::Parser parser(context, css);
|
||||||
return parser.parse_as_style_attribute(element);
|
return parser.parse_as_style_attribute(element);
|
||||||
}
|
}
|
||||||
|
|
|
@ -611,7 +611,7 @@ void Element::set_shadow_root(JS::GCPtr<ShadowRoot> shadow_root)
|
||||||
CSS::CSSStyleDeclaration* Element::style_for_bindings()
|
CSS::CSSStyleDeclaration* Element::style_for_bindings()
|
||||||
{
|
{
|
||||||
if (!m_inline_style)
|
if (!m_inline_style)
|
||||||
m_inline_style = CSS::ElementInlineCSSStyleDeclaration::create(*this, {}, {});
|
m_inline_style = CSS::ElementInlineCSSStyleDeclaration::create(*this, {}, {}).release_value_but_fixme_should_propagate_errors();
|
||||||
return m_inline_style;
|
return m_inline_style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue