1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 07:44:58 +00:00

LibWeb: Delete LegacyPlatformObject and move behavior to PlatformObject

We have two known PlatformObjects that need to implement some of the
behavior of LegacyPlatformObjects to date: Window, and HTMLFormElement.

To make this not require double (or virtual) inheritance of
PlatformObject, move the behavior of LegacyPlatformObject into
PlatformObject. The selection of LegacyPlatformObject behavior is done
with a new bitfield of feature flags instead of a dozen virtual
functions that return bool. This change simplifies every class involved
in the diff with the notable exception of Window, which now needs some
ugly const casts to implement named property access.
This commit is contained in:
Andrew Kaster 2024-01-09 16:05:03 -07:00 committed by Andreas Kling
parent 6047f1adcb
commit 521ed0e911
41 changed files with 684 additions and 801 deletions

View file

@ -21,9 +21,15 @@ JS::NonnullGCPtr<DOMStringMap> DOMStringMap::create(DOM::Element& element)
}
DOMStringMap::DOMStringMap(DOM::Element& element)
: LegacyPlatformObject(element.realm())
: PlatformObject(element.realm())
, m_associated_element(element)
{
m_legacy_platform_object_flags = LegacyPlatformObjectFlags {
.supports_named_properties = true,
.has_named_property_setter = true,
.has_named_property_deleter = true,
.has_legacy_override_built_ins_interface_extended_attribute = true,
};
}
DOMStringMap::~DOMStringMap() = default;
@ -121,7 +127,7 @@ String DOMStringMap::determine_value_of_named_property(FlyString const& name) co
// https://html.spec.whatwg.org/multipage/dom.html#dom-domstringmap-setitem
WebIDL::ExceptionOr<void> DOMStringMap::set_value_of_new_named_property(String const& name, JS::Value unconverted_value)
{
// NOTE: Since LegacyPlatformObject does not know the type of value, we must convert it ourselves.
// NOTE: Since PlatformObject does not know the type of value, we must convert it ourselves.
// The type of `value` is `DOMString`.
auto value = TRY(unconverted_value.to_string(vm()));
@ -170,7 +176,7 @@ WebIDL::ExceptionOr<void> DOMStringMap::set_value_of_existing_named_property(Str
}
// https://html.spec.whatwg.org/multipage/dom.html#dom-domstringmap-removeitem
WebIDL::ExceptionOr<Bindings::LegacyPlatformObject::DidDeletionFail> DOMStringMap::delete_value(String const& name)
WebIDL::ExceptionOr<Bindings::PlatformObject::DidDeletionFail> DOMStringMap::delete_value(String const& name)
{
StringBuilder builder;