mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:57:46 +00:00
LibWeb: Remove unecessary dependence on Window from DOM and WebIDL
These classes only needed Window to get at its realm. Pass a realm directly to construct DOM and WebIDL classes. This change importantly removes the guarantee that a Document will always have a non-null Window object. Only Documents created by a BrowsingContext will have a non-null Window object. Documents created by for example, DocumentFragment, will not have a Window (soon). This incremental commit leaves some workarounds in place to keep other parts of the code building.
This commit is contained in:
parent
8407bf60c5
commit
8de7e49a56
56 changed files with 364 additions and 326 deletions
|
@ -61,7 +61,7 @@ DOMTokenList* DOMTokenList::create(Element const& associated_element, FlyString
|
|||
|
||||
// https://dom.spec.whatwg.org/#ref-for-domtokenlist%E2%91%A0%E2%91%A2
|
||||
DOMTokenList::DOMTokenList(Element const& associated_element, FlyString associated_attribute)
|
||||
: Bindings::LegacyPlatformObject(associated_element.window().cached_web_prototype("DOMTokenList"))
|
||||
: Bindings::LegacyPlatformObject(Bindings::cached_web_prototype(associated_element.realm(), "DOMTokenList"))
|
||||
, m_associated_element(associated_element)
|
||||
, m_associated_attribute(move(associated_attribute))
|
||||
{
|
||||
|
@ -234,9 +234,9 @@ void DOMTokenList::set_value(String value)
|
|||
WebIDL::ExceptionOr<void> DOMTokenList::validate_token(StringView token) const
|
||||
{
|
||||
if (token.is_empty())
|
||||
return WebIDL::SyntaxError::create(global_object(), "Non-empty DOM tokens are not allowed");
|
||||
return WebIDL::SyntaxError::create(realm(), "Non-empty DOM tokens are not allowed");
|
||||
if (any_of(token, is_ascii_space))
|
||||
return WebIDL::InvalidCharacterError::create(global_object(), "DOM tokens containing ASCII whitespace are not allowed");
|
||||
return WebIDL::InvalidCharacterError::create(realm(), "DOM tokens containing ASCII whitespace are not allowed");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue