mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:17:35 +00:00
LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated PlatformObjects. Their C++ wrapper classes are removed, and the LibJS garbage collector is now responsible for their lifetimes. There's a fair amount of hacks and band-aids in this patch, and we'll have a lot of cleanup to do after this.
This commit is contained in:
parent
bb547ce1c4
commit
6f433c8656
445 changed files with 4797 additions and 4268 deletions
|
@ -12,7 +12,6 @@
|
|||
#include <LibJS/Runtime/PropertyKey.h>
|
||||
#include <LibWeb/Bindings/CrossOriginAbstractOperations.h>
|
||||
#include <LibWeb/Bindings/DOMExceptionWrapper.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/Bindings/WindowProxy.h>
|
||||
#include <LibWeb/DOM/DOMException.h>
|
||||
#include <LibWeb/HTML/CrossOrigin/Reporting.h>
|
||||
|
@ -22,9 +21,9 @@
|
|||
namespace Web::Bindings {
|
||||
|
||||
// 7.4 The WindowProxy exotic object, https://html.spec.whatwg.org/multipage/window-object.html#the-windowproxy-exotic-object
|
||||
WindowProxy::WindowProxy(JS::Realm& realm, WindowObject& window)
|
||||
WindowProxy::WindowProxy(JS::Realm& realm, HTML::Window& window)
|
||||
: JS::Object(realm, nullptr)
|
||||
, m_window(&window)
|
||||
, m_window(window)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -105,7 +104,7 @@ JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> WindowProxy::internal_ge
|
|||
return m_window->internal_get_own_property(property_key);
|
||||
|
||||
// 4. Let property be CrossOriginGetOwnPropertyHelper(W, P).
|
||||
auto property = cross_origin_get_own_property_helper(m_window, property_key);
|
||||
auto property = cross_origin_get_own_property_helper(const_cast<HTML::Window*>(m_window.ptr()), property_key);
|
||||
|
||||
// 5. If property is not undefined, then return property.
|
||||
if (property.has_value())
|
||||
|
@ -155,7 +154,7 @@ JS::ThrowCompletionOr<JS::Value> WindowProxy::internal_get(JS::PropertyKey const
|
|||
// 1. Let W be the value of the [[Window]] internal slot of this.
|
||||
|
||||
// 2. Check if an access between two browsing contexts should be reported, given the current global object's browsing context, W's browsing context, P, and the current settings object.
|
||||
HTML::check_if_access_between_two_browsing_contexts_should_be_reported(*static_cast<WindowObject&>(HTML::current_global_object()).impl().browsing_context(), *m_window->impl().browsing_context(), property_key, HTML::current_settings_object());
|
||||
HTML::check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast<HTML::Window>(HTML::current_global_object()).impl().browsing_context(), *m_window->browsing_context(), property_key, HTML::current_settings_object());
|
||||
|
||||
// 3. If IsPlatformObjectSameOrigin(W) is true, then return ? OrdinaryGet(this, P, Receiver).
|
||||
// NOTE: this is passed rather than W as OrdinaryGet and CrossOriginGet will invoke the [[GetOwnProperty]] internal method.
|
||||
|
@ -175,7 +174,7 @@ JS::ThrowCompletionOr<bool> WindowProxy::internal_set(JS::PropertyKey const& pro
|
|||
// 1. Let W be the value of the [[Window]] internal slot of this.
|
||||
|
||||
// 2. Check if an access between two browsing contexts should be reported, given the current global object's browsing context, W's browsing context, P, and the current settings object.
|
||||
HTML::check_if_access_between_two_browsing_contexts_should_be_reported(*static_cast<WindowObject&>(HTML::current_global_object()).impl().browsing_context(), *m_window->impl().browsing_context(), property_key, HTML::current_settings_object());
|
||||
HTML::check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast<HTML::Window>(HTML::current_global_object()).browsing_context(), *m_window->impl().browsing_context(), property_key, HTML::current_settings_object());
|
||||
|
||||
// 3. If IsPlatformObjectSameOrigin(W) is true, then:
|
||||
if (is_platform_object_same_origin(*m_window)) {
|
||||
|
@ -252,13 +251,14 @@ JS::ThrowCompletionOr<JS::MarkedVector<JS::Value>> WindowProxy::internal_own_pro
|
|||
}
|
||||
|
||||
// 7. Return the concatenation of keys and ! CrossOriginOwnPropertyKeys(W).
|
||||
keys.extend(cross_origin_own_property_keys(m_window));
|
||||
keys.extend(cross_origin_own_property_keys(m_window.ptr()));
|
||||
return keys;
|
||||
}
|
||||
|
||||
void WindowProxy::visit_edges(JS::Cell::Visitor& visitor)
|
||||
{
|
||||
visitor.visit(m_window);
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_window.ptr());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue