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

LibWeb: Move ExceptionOr from DOM/ to WebIDL/

This is a concept fully defined in the Web IDL spec and doesn't belong
in the DOM directory/namespace - not even DOMException, despite the name
:^)
This commit is contained in:
Linus Groh 2022-09-25 17:03:42 +01:00
parent c0eda77928
commit ad04d7ac9b
107 changed files with 441 additions and 440 deletions

View file

@ -27,7 +27,7 @@ void CSSGroupingRule::visit_edges(Cell::Visitor& visitor)
visitor.visit(&m_rules);
}
DOM::ExceptionOr<u32> CSSGroupingRule::insert_rule(StringView rule, u32 index)
WebIDL::ExceptionOr<u32> CSSGroupingRule::insert_rule(StringView rule, u32 index)
{
TRY(m_rules.insert_a_css_rule(rule, index));
// NOTE: The spec doesn't say where to set the parent rule, so we'll do it here.
@ -35,7 +35,7 @@ DOM::ExceptionOr<u32> CSSGroupingRule::insert_rule(StringView rule, u32 index)
return index;
}
DOM::ExceptionOr<void> CSSGroupingRule::delete_rule(u32 index)
WebIDL::ExceptionOr<void> CSSGroupingRule::delete_rule(u32 index)
{
return m_rules.remove_a_css_rule(index);
}

View file

@ -23,8 +23,8 @@ public:
CSSRuleList const& css_rules() const { return m_rules; }
CSSRuleList& css_rules() { return m_rules; }
CSSRuleList* css_rules_for_bindings() { return &m_rules; }
DOM::ExceptionOr<u32> insert_rule(StringView rule, u32 index = 0);
DOM::ExceptionOr<void> delete_rule(u32 index);
WebIDL::ExceptionOr<u32> insert_rule(StringView rule, u32 index = 0);
WebIDL::ExceptionOr<void> delete_rule(u32 index);
virtual void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const;

View file

@ -48,7 +48,7 @@ bool CSSRuleList::is_supported_property_index(u32 index) const
}
// https://www.w3.org/TR/cssom/#insert-a-css-rule
DOM::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView, CSSRule*> rule, u32 index)
WebIDL::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView, CSSRule*> rule, u32 index)
{
// 1. Set length to the number of items in list.
auto length = m_rules.size();
@ -86,7 +86,7 @@ DOM::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView, CS
}
// https://www.w3.org/TR/cssom/#remove-a-css-rule
DOM::ExceptionOr<void> CSSRuleList::remove_a_css_rule(u32 index)
WebIDL::ExceptionOr<void> CSSRuleList::remove_a_css_rule(u32 index)
{
// 1. Set length to the number of items in list.
auto length = m_rules.size();

View file

@ -13,8 +13,8 @@
#include <AK/RefPtr.h>
#include <LibWeb/Bindings/LegacyPlatformObject.h>
#include <LibWeb/CSS/CSSRule.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/Forward.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::CSS {
@ -57,8 +57,8 @@ public:
virtual bool is_supported_property_index(u32 index) const override;
virtual JS::Value item_value(size_t index) const override;
DOM::ExceptionOr<void> remove_a_css_rule(u32 index);
DOM::ExceptionOr<unsigned> insert_a_css_rule(Variant<StringView, CSSRule*>, u32 index);
WebIDL::ExceptionOr<void> remove_a_css_rule(u32 index);
WebIDL::ExceptionOr<unsigned> insert_a_css_rule(Variant<StringView, CSSRule*>, u32 index);
void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const;
// Returns whether the match state of any media queries changed after evaluation.

View file

@ -69,7 +69,7 @@ Optional<StyleProperty> PropertyOwningCSSStyleDeclaration::property(PropertyID p
}
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty
DOM::ExceptionOr<void> PropertyOwningCSSStyleDeclaration::set_property(PropertyID property_id, StringView value, StringView priority)
WebIDL::ExceptionOr<void> PropertyOwningCSSStyleDeclaration::set_property(PropertyID property_id, StringView value, StringView priority)
{
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
// NOTE: This is handled by the virtual override in ResolvedCSSStyleDeclaration.
@ -117,7 +117,7 @@ DOM::ExceptionOr<void> PropertyOwningCSSStyleDeclaration::set_property(PropertyI
}
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty
DOM::ExceptionOr<String> PropertyOwningCSSStyleDeclaration::remove_property(PropertyID property_id)
WebIDL::ExceptionOr<String> PropertyOwningCSSStyleDeclaration::remove_property(PropertyID property_id)
{
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
// NOTE: This is handled by the virtual override in ResolvedCSSStyleDeclaration.
@ -214,7 +214,7 @@ String CSSStyleDeclaration::get_property_priority(StringView property_name) cons
return maybe_property->important == Important::Yes ? "important" : "";
}
DOM::ExceptionOr<void> CSSStyleDeclaration::set_property(StringView property_name, StringView css_text, StringView priority)
WebIDL::ExceptionOr<void> CSSStyleDeclaration::set_property(StringView property_name, StringView css_text, StringView priority)
{
auto property_id = property_id_from_string(property_name);
if (property_id == CSS::PropertyID::Invalid)
@ -222,7 +222,7 @@ DOM::ExceptionOr<void> CSSStyleDeclaration::set_property(StringView property_nam
return set_property(property_id, css_text, priority);
}
DOM::ExceptionOr<String> CSSStyleDeclaration::remove_property(StringView property_name)
WebIDL::ExceptionOr<String> CSSStyleDeclaration::remove_property(StringView property_name)
{
auto property_id = property_id_from_string(property_name);
if (property_id == CSS::PropertyID::Invalid)

View file

@ -36,11 +36,11 @@ public:
virtual Optional<StyleProperty> property(PropertyID) const = 0;
virtual DOM::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority = ""sv) = 0;
virtual DOM::ExceptionOr<String> remove_property(PropertyID) = 0;
virtual WebIDL::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority = ""sv) = 0;
virtual WebIDL::ExceptionOr<String> remove_property(PropertyID) = 0;
DOM::ExceptionOr<void> set_property(StringView property_name, StringView css_text, StringView priority);
DOM::ExceptionOr<String> remove_property(StringView property_name);
WebIDL::ExceptionOr<void> set_property(StringView property_name, StringView css_text, StringView priority);
WebIDL::ExceptionOr<String> remove_property(StringView property_name);
String get_property_value(StringView property) const;
String get_property_priority(StringView property) const;
@ -72,8 +72,8 @@ public:
virtual Optional<StyleProperty> property(PropertyID) const override;
virtual DOM::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority) override;
virtual DOM::ExceptionOr<String> remove_property(PropertyID) override;
virtual WebIDL::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority) override;
virtual WebIDL::ExceptionOr<String> remove_property(PropertyID) override;
Vector<StyleProperty> const& properties() const { return m_properties; }
HashMap<String, StyleProperty> const& custom_properties() const { return m_custom_properties; }

View file

@ -8,7 +8,7 @@
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleSheetList.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::CSS {
@ -39,7 +39,7 @@ void CSSStyleSheet::visit_edges(Cell::Visitor& visitor)
}
// https://www.w3.org/TR/cssom/#dom-cssstylesheet-insertrule
DOM::ExceptionOr<unsigned> CSSStyleSheet::insert_rule(StringView rule, unsigned index)
WebIDL::ExceptionOr<unsigned> CSSStyleSheet::insert_rule(StringView rule, unsigned index)
{
// FIXME: 1. If the origin-clean flag is unset, throw a SecurityError exception.
@ -71,7 +71,7 @@ DOM::ExceptionOr<unsigned> CSSStyleSheet::insert_rule(StringView rule, unsigned
}
// https://www.w3.org/TR/cssom/#dom-cssstylesheet-deleterule
DOM::ExceptionOr<void> CSSStyleSheet::delete_rule(unsigned index)
WebIDL::ExceptionOr<void> CSSStyleSheet::delete_rule(unsigned index)
{
// FIXME: 1. If the origin-clean flag is unset, throw a SecurityError exception.
@ -89,7 +89,7 @@ DOM::ExceptionOr<void> CSSStyleSheet::delete_rule(unsigned index)
}
// https://www.w3.org/TR/cssom/#dom-cssstylesheet-removerule
DOM::ExceptionOr<void> CSSStyleSheet::remove_rule(unsigned index)
WebIDL::ExceptionOr<void> CSSStyleSheet::remove_rule(unsigned index)
{
// The removeRule(index) method must run the same steps as deleteRule().
return delete_rule(index);

View file

@ -40,9 +40,9 @@ public:
CSSRuleList* css_rules() { return m_rules; }
CSSRuleList const* css_rules() const { return m_rules; }
DOM::ExceptionOr<unsigned> insert_rule(StringView rule, unsigned index);
DOM::ExceptionOr<void> remove_rule(unsigned index);
DOM::ExceptionOr<void> delete_rule(unsigned index);
WebIDL::ExceptionOr<unsigned> insert_rule(StringView rule, unsigned index);
WebIDL::ExceptionOr<void> remove_rule(unsigned index);
WebIDL::ExceptionOr<void> delete_rule(unsigned index);
void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const;
// Returns whether the match state of any media queries changed after evaluation.

View file

@ -535,14 +535,14 @@ Optional<StyleProperty> ResolvedCSSStyleDeclaration::property(PropertyID propert
}
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty
DOM::ExceptionOr<void> ResolvedCSSStyleDeclaration::set_property(PropertyID, StringView, StringView)
WebIDL::ExceptionOr<void> ResolvedCSSStyleDeclaration::set_property(PropertyID, StringView, StringView)
{
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
return DOM::NoModificationAllowedError::create(global_object(), "Cannot modify properties in result of getComputedStyle()");
}
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty
DOM::ExceptionOr<String> ResolvedCSSStyleDeclaration::remove_property(PropertyID)
WebIDL::ExceptionOr<String> ResolvedCSSStyleDeclaration::remove_property(PropertyID)
{
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
return DOM::NoModificationAllowedError::create(global_object(), "Cannot remove properties from result of getComputedStyle()");

View file

@ -22,8 +22,8 @@ public:
virtual size_t length() const override;
virtual String item(size_t index) const override;
virtual Optional<StyleProperty> property(PropertyID) const override;
virtual DOM::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority) override;
virtual DOM::ExceptionOr<String> remove_property(PropertyID) override;
virtual WebIDL::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority) override;
virtual WebIDL::ExceptionOr<String> remove_property(PropertyID) override;
virtual String serialized() const override;