mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:17:35 +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:
parent
c0eda77928
commit
ad04d7ac9b
107 changed files with 441 additions and 440 deletions
|
@ -16,7 +16,6 @@
|
|||
#include <LibWeb/DOM/DOMTokenList.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
#include <LibWeb/DOM/HTMLCollection.h>
|
||||
#include <LibWeb/DOM/ShadowRoot.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
|
@ -39,6 +38,7 @@
|
|||
#include <LibWeb/Layout/TreeBuilder.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/Painting/PaintableBox.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -82,7 +82,7 @@ String Element::get_attribute(FlyString const& name) const
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-setattribute
|
||||
ExceptionOr<void> Element::set_attribute(FlyString const& name, String const& value)
|
||||
WebIDL::ExceptionOr<void> Element::set_attribute(FlyString const& name, String const& value)
|
||||
{
|
||||
// 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException.
|
||||
// FIXME: Proper name validation
|
||||
|
@ -118,7 +118,7 @@ ExceptionOr<void> Element::set_attribute(FlyString const& name, String const& va
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#validate-and-extract
|
||||
ExceptionOr<QualifiedName> validate_and_extract(JS::Object& global_object, FlyString namespace_, FlyString qualified_name)
|
||||
WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Object& global_object, FlyString namespace_, FlyString qualified_name)
|
||||
{
|
||||
// 1. If namespace is the empty string, then set it to null.
|
||||
if (namespace_.is_empty())
|
||||
|
@ -161,7 +161,7 @@ ExceptionOr<QualifiedName> validate_and_extract(JS::Object& global_object, FlySt
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-setattributens
|
||||
ExceptionOr<void> Element::set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, String const& value)
|
||||
WebIDL::ExceptionOr<void> Element::set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, String const& value)
|
||||
{
|
||||
// 1. Let namespace, prefix, and localName be the result of passing namespace and qualifiedName to validate and extract.
|
||||
auto extracted_qualified_name = TRY(validate_and_extract(global_object(), namespace_, qualified_name));
|
||||
|
@ -190,7 +190,7 @@ bool Element::has_attribute(FlyString const& name) const
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-toggleattribute
|
||||
DOM::ExceptionOr<bool> Element::toggle_attribute(FlyString const& name, Optional<bool> force)
|
||||
WebIDL::ExceptionOr<bool> Element::toggle_attribute(FlyString const& name, Optional<bool> force)
|
||||
{
|
||||
// 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException.
|
||||
// FIXME: Proper name validation
|
||||
|
@ -439,7 +439,7 @@ DOMTokenList* Element::class_list()
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-matches
|
||||
DOM::ExceptionOr<bool> Element::matches(StringView selectors) const
|
||||
WebIDL::ExceptionOr<bool> Element::matches(StringView selectors) const
|
||||
{
|
||||
auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors);
|
||||
if (!maybe_selectors.has_value())
|
||||
|
@ -454,7 +454,7 @@ DOM::ExceptionOr<bool> Element::matches(StringView selectors) const
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-closest
|
||||
DOM::ExceptionOr<DOM::Element const*> Element::closest(StringView selectors) const
|
||||
WebIDL::ExceptionOr<DOM::Element const*> Element::closest(StringView selectors) const
|
||||
{
|
||||
auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors);
|
||||
if (!maybe_selectors.has_value())
|
||||
|
@ -479,7 +479,7 @@ DOM::ExceptionOr<DOM::Element const*> Element::closest(StringView selectors) con
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ExceptionOr<void> Element::set_inner_html(String const& markup)
|
||||
WebIDL::ExceptionOr<void> Element::set_inner_html(String const& markup)
|
||||
{
|
||||
TRY(DOMParsing::inner_html_setter(*this, markup));
|
||||
|
||||
|
@ -729,7 +729,7 @@ void Element::serialize_pseudo_elements_as_json(JsonArraySerializer<StringBuilde
|
|||
}
|
||||
|
||||
// https://w3c.github.io/DOM-Parsing/#dom-element-insertadjacenthtml
|
||||
DOM::ExceptionOr<void> Element::insert_adjacent_html(String position, String text)
|
||||
WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String position, String text)
|
||||
{
|
||||
JS::GCPtr<Node> context;
|
||||
// 1. Use the first matching item from this list:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue