mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb: Replace GlobalObject with Realm in wrapper functions
Similar to create() in LibJS, wrap() et al. are on a low enough level to warrant passing a Realm directly instead of relying on the current realm from the VM, as a wrapper may need to be allocated while no JS is being executed.
This commit is contained in:
parent
56b2ae5ac0
commit
40a70461a0
Notes:
sideshowbarker
2024-07-17 07:53:19 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/40a70461a0 Pull-request: https://github.com/SerenityOS/serenity/pull/14973 Reviewed-by: https://github.com/davidot ✅
60 changed files with 261 additions and 235 deletions
|
@ -913,7 +913,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
// The lambda must take the JS::Value to convert as a parameter instead of capturing it in order to support union types being variadic.
|
||||
|
||||
StringBuilder to_variant_captures;
|
||||
to_variant_captures.append("&global_object, &vm"sv);
|
||||
to_variant_captures.append("&global_object, &vm, &realm"sv);
|
||||
|
||||
if (dictionary_type)
|
||||
to_variant_captures.append(String::formatted(", &{}{}_to_dictionary", js_name, js_suffix));
|
||||
|
@ -925,6 +925,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
// These might be unused.
|
||||
(void)global_object;
|
||||
(void)vm;
|
||||
(void)realm;
|
||||
)~~~");
|
||||
|
||||
// 1. If the union type includes undefined and V is undefined, then return the unique undefined value.
|
||||
|
@ -1507,10 +1508,11 @@ static void generate_wrap_statement(SourceGenerator& generator, String const& va
|
|||
auto cpp_type = IDL::idl_type_name_to_cpp_type(current_union_type, interface);
|
||||
union_generator.set("current_type", cpp_type.name);
|
||||
union_generator.append(R"~~~(
|
||||
[&vm, &global_object](@current_type@ const& visited_union_value@recursion_depth@) -> JS::Value {
|
||||
[&vm, &global_object, &realm](@current_type@ const& visited_union_value@recursion_depth@) -> JS::Value {
|
||||
// These may be unused.
|
||||
(void)vm;
|
||||
(void)global_object;
|
||||
(void) realm;
|
||||
)~~~");
|
||||
|
||||
// NOTE: While we are using const&, the underlying type for wrappable types in unions is (Nonnull)RefPtr, which are not references.
|
||||
|
@ -1609,11 +1611,11 @@ static void generate_wrap_statement(SourceGenerator& generator, String const& va
|
|||
} else {
|
||||
if (wrapping_reference == WrappingReference::No) {
|
||||
scoped_generator.append(R"~~~(
|
||||
@result_expression@ wrap(global_object, const_cast<@type@&>(*@value@));
|
||||
@result_expression@ wrap(realm, const_cast<@type@&>(*@value@));
|
||||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
@result_expression@ wrap(global_object, const_cast<@type@&>(@value@));
|
||||
@result_expression@ wrap(realm, const_cast<@type@&>(@value@));
|
||||
)~~~");
|
||||
}
|
||||
}
|
||||
|
@ -1948,7 +1950,7 @@ inline String idl_enum_to_string(@enum.type.name@ value) {
|
|||
|
||||
if (should_emit_wrapper_factory(interface)) {
|
||||
generator.append(R"~~~(
|
||||
@wrapper_class@* wrap(JS::GlobalObject&, @fully_qualified_name@&);
|
||||
@wrapper_class@* wrap(JS::Realm&, @fully_qualified_name@&);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -2045,9 +2047,9 @@ void @wrapper_class@::initialize(JS::Realm& realm)
|
|||
|
||||
if (should_emit_wrapper_factory(interface)) {
|
||||
generator.append(R"~~~(
|
||||
@wrapper_class@* wrap(JS::GlobalObject& global_object, @fully_qualified_name@& impl)
|
||||
@wrapper_class@* wrap(JS::Realm& realm, @fully_qualified_name@& impl)
|
||||
{
|
||||
return static_cast<@wrapper_class@*>(wrap_impl(global_object, impl));
|
||||
return static_cast<@wrapper_class@*>(wrap_impl(realm, impl));
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
@ -2072,6 +2074,7 @@ void @wrapper_class@::visit_edges(JS::Cell::Visitor& visitor)
|
|||
static JS::Value wrap_for_legacy_platform_object_get_own_property(JS::GlobalObject& global_object, [[maybe_unused]] auto& retval)
|
||||
{
|
||||
[[maybe_unused]] auto& vm = global_object.vm();
|
||||
[[maybe_unused]] auto& realm = *vm.current_realm();
|
||||
)~~~");
|
||||
|
||||
if (interface.named_property_getter.has_value()) {
|
||||
|
@ -2989,7 +2992,7 @@ JS::ThrowCompletionOr<JS::Object*> @constructor_class@::construct(FunctionObject
|
|||
)~~~");
|
||||
}
|
||||
generator.append(R"~~~(
|
||||
return wrap(global_object, *impl);
|
||||
return wrap(realm, *impl);
|
||||
)~~~");
|
||||
} else {
|
||||
// Multiple constructor overloads - can't do that yet.
|
||||
|
@ -3528,9 +3531,10 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::to_string)
|
|||
iterator_generator.append(R"~~~(
|
||||
JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::entries)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
|
||||
return wrap(global_object, @iterator_name@::create(*impl, Object::PropertyKind::KeyAndValue));
|
||||
return wrap(realm, @iterator_name@::create(*impl, Object::PropertyKind::KeyAndValue));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::for_each)
|
||||
|
@ -3557,16 +3561,18 @@ JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::for_each)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::keys)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
|
||||
return wrap(global_object, @iterator_name@::create(*impl, Object::PropertyKind::Key));
|
||||
return wrap(realm, @iterator_name@::create(*impl, Object::PropertyKind::Key));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::values)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
|
||||
return wrap(global_object, @iterator_name@::create(*impl, Object::PropertyKind::Value));
|
||||
return wrap(realm, @iterator_name@::create(*impl, Object::PropertyKind::Value));
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
@ -3613,7 +3619,7 @@ private:
|
|||
NonnullRefPtr<@fully_qualified_name@> m_impl;
|
||||
};
|
||||
|
||||
@wrapper_class@* wrap(JS::GlobalObject&, @fully_qualified_name@&);
|
||||
@wrapper_class@* wrap(JS::Realm&, @fully_qualified_name@&);
|
||||
|
||||
} // namespace Web::Bindings
|
||||
)~~~");
|
||||
|
@ -3696,9 +3702,9 @@ void @wrapper_class@::visit_edges(Cell::Visitor& visitor)
|
|||
impl().visit_edges(visitor);
|
||||
}
|
||||
|
||||
@wrapper_class@* wrap(JS::GlobalObject& global_object, @fully_qualified_name@& impl)
|
||||
@wrapper_class@* wrap(JS::Realm& realm, @fully_qualified_name@& impl)
|
||||
{
|
||||
return static_cast<@wrapper_class@*>(wrap_impl(global_object, impl));
|
||||
return static_cast<@wrapper_class@*>(wrap_impl(realm, impl));
|
||||
}
|
||||
|
||||
} // namespace Web::Bindings
|
||||
|
|
|
@ -38,6 +38,7 @@ JS::ThrowCompletionOr<JS::Value> AudioConstructor::call()
|
|||
JS::ThrowCompletionOr<JS::Object*> AudioConstructor::construct(FunctionObject&)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. Let document be the current global object's associated Document.
|
||||
auto& window = static_cast<WindowObject&>(HTML::current_global_object());
|
||||
|
@ -59,7 +60,7 @@ JS::ThrowCompletionOr<JS::Object*> AudioConstructor::construct(FunctionObject&)
|
|||
}
|
||||
|
||||
// 5. Return audio.
|
||||
return wrap(global_object(), audio);
|
||||
return wrap(realm, audio);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,22 +20,22 @@
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
CSSRuleWrapper* wrap(JS::GlobalObject& global_object, CSS::CSSRule& rule)
|
||||
CSSRuleWrapper* wrap(JS::Realm& realm, CSS::CSSRule& rule)
|
||||
{
|
||||
if (rule.wrapper())
|
||||
return static_cast<CSSRuleWrapper*>(rule.wrapper());
|
||||
|
||||
if (is<CSS::CSSStyleRule>(rule))
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, verify_cast<CSS::CSSStyleRule>(rule)));
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(realm, verify_cast<CSS::CSSStyleRule>(rule)));
|
||||
if (is<CSS::CSSImportRule>(rule))
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, verify_cast<CSS::CSSImportRule>(rule)));
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(realm, verify_cast<CSS::CSSImportRule>(rule)));
|
||||
if (is<CSS::CSSMediaRule>(rule))
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, verify_cast<CSS::CSSMediaRule>(rule)));
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(realm, verify_cast<CSS::CSSMediaRule>(rule)));
|
||||
if (is<CSS::CSSFontFaceRule>(rule))
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, verify_cast<CSS::CSSFontFaceRule>(rule)));
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(realm, verify_cast<CSS::CSSFontFaceRule>(rule)));
|
||||
if (is<CSS::CSSSupportsRule>(rule))
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, verify_cast<CSS::CSSSupportsRule>(rule)));
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, rule));
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(realm, verify_cast<CSS::CSSSupportsRule>(rule)));
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(realm, rule));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
CSSRuleWrapper* wrap(JS::GlobalObject&, CSS::CSSRule&);
|
||||
CSSRuleWrapper* wrap(JS::Realm&, CSS::CSSRule&);
|
||||
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
JS::Object* wrap(JS::GlobalObject& global_object, DOM::EventTarget& target)
|
||||
JS::Object* wrap(JS::Realm& realm, DOM::EventTarget& target)
|
||||
{
|
||||
return target.create_wrapper(global_object);
|
||||
return target.create_wrapper(realm);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
JS::Object* wrap(JS::GlobalObject&, DOM::EventTarget&);
|
||||
JS::Object* wrap(JS::Realm&, DOM::EventTarget&);
|
||||
|
||||
}
|
||||
|
|
|
@ -21,36 +21,36 @@
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
EventWrapper* wrap(JS::GlobalObject& global_object, DOM::Event& event)
|
||||
EventWrapper* wrap(JS::Realm& realm, DOM::Event& event)
|
||||
{
|
||||
if (event.wrapper())
|
||||
return static_cast<EventWrapper*>(event.wrapper());
|
||||
|
||||
if (is<DOM::CustomEvent>(event))
|
||||
return static_cast<CustomEventWrapper*>(wrap_impl(global_object, static_cast<DOM::CustomEvent&>(event)));
|
||||
return static_cast<CustomEventWrapper*>(wrap_impl(realm, static_cast<DOM::CustomEvent&>(event)));
|
||||
if (is<CSS::MediaQueryListEvent>(event))
|
||||
return static_cast<MediaQueryListEventWrapper*>(wrap_impl(global_object, static_cast<CSS::MediaQueryListEvent&>(event)));
|
||||
return static_cast<MediaQueryListEventWrapper*>(wrap_impl(realm, static_cast<CSS::MediaQueryListEvent&>(event)));
|
||||
if (is<HTML::CloseEvent>(event))
|
||||
return static_cast<CloseEventWrapper*>(wrap_impl(global_object, static_cast<HTML::CloseEvent&>(event)));
|
||||
return static_cast<CloseEventWrapper*>(wrap_impl(realm, static_cast<HTML::CloseEvent&>(event)));
|
||||
if (is<HTML::MessageEvent>(event))
|
||||
return static_cast<MessageEventWrapper*>(wrap_impl(global_object, static_cast<HTML::MessageEvent&>(event)));
|
||||
return static_cast<MessageEventWrapper*>(wrap_impl(realm, static_cast<HTML::MessageEvent&>(event)));
|
||||
if (is<HTML::PageTransitionEvent>(event))
|
||||
return static_cast<PageTransitionEventWrapper*>(wrap_impl(global_object, static_cast<HTML::PageTransitionEvent&>(event)));
|
||||
return static_cast<PageTransitionEventWrapper*>(wrap_impl(realm, static_cast<HTML::PageTransitionEvent&>(event)));
|
||||
if (is<HTML::PromiseRejectionEvent>(event))
|
||||
return static_cast<PromiseRejectionEventWrapper*>(wrap_impl(global_object, static_cast<HTML::PromiseRejectionEvent&>(event)));
|
||||
return static_cast<PromiseRejectionEventWrapper*>(wrap_impl(realm, static_cast<HTML::PromiseRejectionEvent&>(event)));
|
||||
if (is<HTML::SubmitEvent>(event))
|
||||
return static_cast<SubmitEventWrapper*>(wrap_impl(global_object, static_cast<HTML::SubmitEvent&>(event)));
|
||||
return static_cast<SubmitEventWrapper*>(wrap_impl(realm, static_cast<HTML::SubmitEvent&>(event)));
|
||||
if (is<UIEvents::KeyboardEvent>(event))
|
||||
return static_cast<KeyboardEventWrapper*>(wrap_impl(global_object, static_cast<UIEvents::KeyboardEvent&>(event)));
|
||||
return static_cast<KeyboardEventWrapper*>(wrap_impl(realm, static_cast<UIEvents::KeyboardEvent&>(event)));
|
||||
if (is<UIEvents::MouseEvent>(event))
|
||||
return static_cast<MouseEventWrapper*>(wrap_impl(global_object, static_cast<UIEvents::MouseEvent&>(event)));
|
||||
return static_cast<MouseEventWrapper*>(wrap_impl(realm, static_cast<UIEvents::MouseEvent&>(event)));
|
||||
if (is<XHR::ProgressEvent>(event))
|
||||
return static_cast<ProgressEventWrapper*>(wrap_impl(global_object, static_cast<XHR::ProgressEvent&>(event)));
|
||||
return static_cast<ProgressEventWrapper*>(wrap_impl(realm, static_cast<XHR::ProgressEvent&>(event)));
|
||||
if (is<UIEvents::UIEvent>(event))
|
||||
return static_cast<UIEventWrapper*>(wrap_impl(global_object, static_cast<UIEvents::UIEvent&>(event)));
|
||||
return static_cast<UIEventWrapper*>(wrap_impl(realm, static_cast<UIEvents::UIEvent&>(event)));
|
||||
if (is<WebGL::WebGLContextEvent>(event))
|
||||
return static_cast<WebGLContextEventWrapper*>(wrap_impl(global_object, static_cast<WebGL::WebGLContextEvent&>(event)));
|
||||
return static_cast<EventWrapper*>(wrap_impl(global_object, event));
|
||||
return static_cast<WebGLContextEventWrapper*>(wrap_impl(realm, static_cast<WebGL::WebGLContextEvent&>(event)));
|
||||
return static_cast<EventWrapper*>(wrap_impl(realm, event));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
EventWrapper* wrap(JS::GlobalObject&, DOM::Event&);
|
||||
EventWrapper* wrap(JS::Realm&, DOM::Event&);
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ JS::ThrowCompletionOr<JS::Value> ImageConstructor::call()
|
|||
JS::ThrowCompletionOr<JS::Object*> ImageConstructor::construct(FunctionObject&)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. Let document be the current global object's associated Document.
|
||||
auto& window = static_cast<WindowObject&>(HTML::current_global_object());
|
||||
|
@ -59,7 +60,7 @@ JS::ThrowCompletionOr<JS::Object*> ImageConstructor::construct(FunctionObject&)
|
|||
}
|
||||
|
||||
// 5. Return img.
|
||||
return wrap(global_object(), image_element);
|
||||
return wrap(realm, image_element);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -343,18 +343,17 @@ void queue_mutation_observer_microtask(DOM::Document& document)
|
|||
// 4. If records is not empty, then invoke mo’s callback with « records, mo », and mo. If this throws an exception, catch it, and report the exception.
|
||||
if (!records.is_empty()) {
|
||||
auto& callback = mutation_observer.callback();
|
||||
auto& global_object = callback.callback_context.global_object();
|
||||
auto& realm = callback.callback_context.realm();
|
||||
|
||||
auto* wrapped_records = MUST(JS::Array::create(realm, 0));
|
||||
for (size_t i = 0; i < records.size(); ++i) {
|
||||
auto& record = records.at(i);
|
||||
auto* wrapped_record = Bindings::wrap(global_object, record);
|
||||
auto* wrapped_record = Bindings::wrap(realm, record);
|
||||
auto property_index = JS::PropertyKey { i };
|
||||
MUST(wrapped_records->create_data_property(property_index, wrapped_record));
|
||||
}
|
||||
|
||||
auto* wrapped_mutation_observer = Bindings::wrap(global_object, mutation_observer);
|
||||
auto* wrapped_mutation_observer = Bindings::wrap(realm, mutation_observer);
|
||||
|
||||
auto result = IDL::invoke_callback(callback, wrapped_mutation_observer, wrapped_records, wrapped_mutation_observer);
|
||||
if (result.is_abrupt())
|
||||
|
|
|
@ -175,186 +175,186 @@
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& node)
|
||||
NodeWrapper* wrap(JS::Realm& realm, DOM::Node& node)
|
||||
{
|
||||
if (node.wrapper())
|
||||
return static_cast<NodeWrapper*>(node.wrapper());
|
||||
|
||||
if (is<DOM::Document>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::Document>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::Document>(node)));
|
||||
if (is<DOM::DocumentType>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::DocumentType>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::DocumentType>(node)));
|
||||
if (is<HTML::HTMLAnchorElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLAnchorElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLAnchorElement>(node)));
|
||||
if (is<HTML::HTMLAreaElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLAreaElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLAreaElement>(node)));
|
||||
if (is<HTML::HTMLAudioElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLAudioElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLAudioElement>(node)));
|
||||
if (is<HTML::HTMLBaseElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLBaseElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLBaseElement>(node)));
|
||||
if (is<HTML::HTMLBodyElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLBodyElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLBodyElement>(node)));
|
||||
if (is<HTML::HTMLBRElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLBRElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLBRElement>(node)));
|
||||
if (is<HTML::HTMLButtonElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLButtonElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLButtonElement>(node)));
|
||||
if (is<HTML::HTMLCanvasElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLCanvasElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLCanvasElement>(node)));
|
||||
if (is<HTML::HTMLDataElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDataElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDataElement>(node)));
|
||||
if (is<HTML::HTMLDataListElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDataListElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDataListElement>(node)));
|
||||
if (is<HTML::HTMLDetailsElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDetailsElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDetailsElement>(node)));
|
||||
if (is<HTML::HTMLDialogElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDialogElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDialogElement>(node)));
|
||||
if (is<HTML::HTMLDirectoryElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDirectoryElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDirectoryElement>(node)));
|
||||
if (is<HTML::HTMLDivElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDivElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDivElement>(node)));
|
||||
if (is<HTML::HTMLDListElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDListElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDListElement>(node)));
|
||||
if (is<HTML::HTMLEmbedElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLEmbedElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLEmbedElement>(node)));
|
||||
if (is<HTML::HTMLFieldSetElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLFieldSetElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLFieldSetElement>(node)));
|
||||
if (is<HTML::HTMLFontElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLFontElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLFontElement>(node)));
|
||||
if (is<HTML::HTMLFormElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLFormElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLFormElement>(node)));
|
||||
if (is<HTML::HTMLFrameElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLFrameElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLFrameElement>(node)));
|
||||
if (is<HTML::HTMLFrameSetElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLFrameSetElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLFrameSetElement>(node)));
|
||||
if (is<HTML::HTMLHeadElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLHeadElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLHeadElement>(node)));
|
||||
if (is<HTML::HTMLHeadingElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLHeadingElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLHeadingElement>(node)));
|
||||
if (is<HTML::HTMLHRElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLHRElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLHRElement>(node)));
|
||||
if (is<HTML::HTMLHtmlElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLHtmlElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLHtmlElement>(node)));
|
||||
if (is<HTML::HTMLIFrameElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLIFrameElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLIFrameElement>(node)));
|
||||
if (is<HTML::HTMLImageElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLImageElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLImageElement>(node)));
|
||||
if (is<HTML::HTMLInputElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLInputElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLInputElement>(node)));
|
||||
if (is<HTML::HTMLLabelElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLLabelElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLLabelElement>(node)));
|
||||
if (is<HTML::HTMLLegendElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLLegendElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLLegendElement>(node)));
|
||||
if (is<HTML::HTMLLIElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLLIElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLLIElement>(node)));
|
||||
if (is<HTML::HTMLLinkElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLLinkElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLLinkElement>(node)));
|
||||
if (is<HTML::HTMLMapElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLMapElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLMapElement>(node)));
|
||||
if (is<HTML::HTMLMarqueeElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLMarqueeElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLMarqueeElement>(node)));
|
||||
if (is<HTML::HTMLMenuElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLMenuElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLMenuElement>(node)));
|
||||
if (is<HTML::HTMLMetaElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLMetaElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLMetaElement>(node)));
|
||||
if (is<HTML::HTMLMeterElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLMeterElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLMeterElement>(node)));
|
||||
if (is<HTML::HTMLModElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLModElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLModElement>(node)));
|
||||
if (is<HTML::HTMLObjectElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLObjectElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLObjectElement>(node)));
|
||||
if (is<HTML::HTMLOListElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLOListElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLOListElement>(node)));
|
||||
if (is<HTML::HTMLOptGroupElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLOptGroupElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLOptGroupElement>(node)));
|
||||
if (is<HTML::HTMLOptionElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLOptionElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLOptionElement>(node)));
|
||||
if (is<HTML::HTMLOutputElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLOutputElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLOutputElement>(node)));
|
||||
if (is<HTML::HTMLParagraphElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLParagraphElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLParagraphElement>(node)));
|
||||
if (is<HTML::HTMLParamElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLParamElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLParamElement>(node)));
|
||||
if (is<HTML::HTMLPictureElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLPictureElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLPictureElement>(node)));
|
||||
if (is<HTML::HTMLPreElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLPreElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLPreElement>(node)));
|
||||
if (is<HTML::HTMLProgressElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLProgressElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLProgressElement>(node)));
|
||||
if (is<HTML::HTMLQuoteElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLQuoteElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLQuoteElement>(node)));
|
||||
if (is<HTML::HTMLScriptElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLScriptElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLScriptElement>(node)));
|
||||
if (is<HTML::HTMLSelectElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLSelectElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLSelectElement>(node)));
|
||||
if (is<HTML::HTMLSlotElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLSlotElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLSlotElement>(node)));
|
||||
if (is<HTML::HTMLSourceElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLSourceElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLSourceElement>(node)));
|
||||
if (is<HTML::HTMLSpanElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLSpanElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLSpanElement>(node)));
|
||||
if (is<HTML::HTMLStyleElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLStyleElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLStyleElement>(node)));
|
||||
if (is<HTML::HTMLTableCaptionElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTableCaptionElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTableCaptionElement>(node)));
|
||||
if (is<HTML::HTMLTableCellElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTableCellElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTableCellElement>(node)));
|
||||
if (is<HTML::HTMLTableColElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTableColElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTableColElement>(node)));
|
||||
if (is<HTML::HTMLTableElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTableElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTableElement>(node)));
|
||||
if (is<HTML::HTMLTableRowElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTableRowElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTableRowElement>(node)));
|
||||
if (is<HTML::HTMLTableSectionElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTableSectionElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTableSectionElement>(node)));
|
||||
if (is<HTML::HTMLTemplateElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTemplateElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTemplateElement>(node)));
|
||||
if (is<HTML::HTMLTextAreaElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTextAreaElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTextAreaElement>(node)));
|
||||
if (is<HTML::HTMLTimeElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTimeElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTimeElement>(node)));
|
||||
if (is<HTML::HTMLTitleElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTitleElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTitleElement>(node)));
|
||||
if (is<HTML::HTMLTrackElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTrackElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTrackElement>(node)));
|
||||
if (is<HTML::HTMLUListElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLUListElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLUListElement>(node)));
|
||||
if (is<HTML::HTMLUnknownElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLUnknownElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLUnknownElement>(node)));
|
||||
if (is<HTML::HTMLVideoElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLVideoElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLVideoElement>(node)));
|
||||
if (is<HTML::HTMLElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLElement>(node)));
|
||||
if (is<SVG::SVGSVGElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGSVGElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGSVGElement>(node)));
|
||||
if (is<SVG::SVGCircleElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGCircleElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGCircleElement>(node)));
|
||||
if (is<SVG::SVGEllipseElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGEllipseElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGEllipseElement>(node)));
|
||||
if (is<SVG::SVGLineElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGLineElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGLineElement>(node)));
|
||||
if (is<SVG::SVGPolygonElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGPolygonElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGPolygonElement>(node)));
|
||||
if (is<SVG::SVGPolylineElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGPolylineElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGPolylineElement>(node)));
|
||||
if (is<SVG::SVGPathElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGPathElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGPathElement>(node)));
|
||||
if (is<SVG::SVGRectElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGRectElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGRectElement>(node)));
|
||||
if (is<SVG::SVGTextContentElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGTextContentElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGTextContentElement>(node)));
|
||||
if (is<DOM::Element>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::Element>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::Element>(node)));
|
||||
if (is<DOM::DocumentFragment>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::DocumentFragment>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::DocumentFragment>(node)));
|
||||
if (is<DOM::Comment>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::Comment>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::Comment>(node)));
|
||||
if (is<DOM::Text>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::Text>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::Text>(node)));
|
||||
if (is<DOM::CharacterData>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::CharacterData>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::CharacterData>(node)));
|
||||
if (is<DOM::Attribute>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::Attribute>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, node));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::Attribute>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(realm, node));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
namespace Web {
|
||||
namespace Bindings {
|
||||
|
||||
NodeWrapper* wrap(JS::GlobalObject&, DOM::Node&);
|
||||
NodeWrapper* wrap(JS::Realm&, DOM::Node&);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ JS::ThrowCompletionOr<JS::Value> OptionConstructor::call()
|
|||
JS::ThrowCompletionOr<JS::Object*> OptionConstructor::construct(FunctionObject&)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. Let document be the current global object's associated Document.
|
||||
auto& window = static_cast<WindowObject&>(HTML::current_global_object());
|
||||
|
@ -74,7 +75,7 @@ JS::ThrowCompletionOr<JS::Object*> OptionConstructor::construct(FunctionObject&)
|
|||
option_element->m_selected = vm.argument(3).to_boolean();
|
||||
|
||||
// 7. Return option.
|
||||
return wrap(global_object(), option_element);
|
||||
return wrap(realm, option_element);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -427,14 +427,16 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::parent_getter)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::document_getter)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
return wrap(global_object, impl->associated_document());
|
||||
return wrap(realm, impl->associated_document());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::performance_getter)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
return wrap(global_object, impl->performance());
|
||||
return wrap(realm, impl->performance());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::performance_setter)
|
||||
|
@ -457,16 +459,18 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::performance_setter)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::screen_getter)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
return wrap(global_object, impl->screen());
|
||||
return wrap(realm, impl->screen());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::event_getter)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
if (!impl->current_event())
|
||||
return JS::js_undefined();
|
||||
return wrap(global_object, const_cast<DOM::Event&>(*impl->current_event()));
|
||||
return wrap(realm, const_cast<DOM::Event&>(*impl->current_event()));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::event_setter)
|
||||
|
@ -491,8 +495,9 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::location_setter)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::crypto_getter)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
return wrap(global_object, impl->crypto());
|
||||
return wrap(realm, impl->crypto());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::inner_width_getter)
|
||||
|
@ -515,28 +520,31 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::device_pixel_ratio_getter)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::get_computed_style)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
auto* object = TRY(vm.argument(0).to_object(vm));
|
||||
if (!is<ElementWrapper>(object))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "DOM element");
|
||||
|
||||
return wrap(global_object, impl->get_computed_style(static_cast<ElementWrapper*>(object)->impl()));
|
||||
return wrap(realm, impl->get_computed_style(static_cast<ElementWrapper*>(object)->impl()));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::get_selection)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
auto* selection = impl->get_selection();
|
||||
if (!selection)
|
||||
return JS::js_null();
|
||||
return wrap(global_object, *selection);
|
||||
return wrap(realm, *selection);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::match_media)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
auto media = TRY(vm.argument(0).to_string(vm));
|
||||
return wrap(global_object, impl->match_media(move(media)));
|
||||
return wrap(realm, impl->match_media(move(media)));
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-view/#dom-window-scrollx
|
||||
|
@ -668,8 +676,9 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::scroll_by)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::history_getter)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
return wrap(global_object, impl->associated_document().history());
|
||||
return wrap(realm, impl->associated_document().history());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::screen_left_getter)
|
||||
|
@ -713,16 +722,18 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::origin_getter)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::local_storage_getter)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
// FIXME: localStorage may throw. We have to deal with that here.
|
||||
return wrap(global_object, *impl->local_storage());
|
||||
return wrap(realm, *impl->local_storage());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::session_storage_getter)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
// FIXME: sessionStorage may throw. We have to deal with that here.
|
||||
return wrap(global_object, *impl->session_storage());
|
||||
return wrap(realm, *impl->session_storage());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::name_getter)
|
||||
|
|
|
@ -26,9 +26,8 @@ private:
|
|||
};
|
||||
|
||||
template<class NativeObject>
|
||||
inline Wrapper* wrap_impl(JS::GlobalObject& global_object, NativeObject& native_object)
|
||||
inline Wrapper* wrap_impl(JS::Realm& realm, NativeObject& native_object)
|
||||
{
|
||||
auto& realm = *global_object.associated_realm();
|
||||
if (!native_object.wrapper()) {
|
||||
native_object.set_wrapper(*realm.heap().allocate<typename NativeObject::WrapperType>(realm, realm, native_object));
|
||||
}
|
||||
|
|
|
@ -119,6 +119,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
CSSStyleDeclarationWrapper* wrap(JS::GlobalObject&, CSS::CSSStyleDeclaration&);
|
||||
CSSStyleDeclarationWrapper* wrap(JS::Realm&, CSS::CSSStyleDeclaration&);
|
||||
|
||||
}
|
||||
|
|
|
@ -66,6 +66,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
CSSStyleSheetWrapper* wrap(JS::GlobalObject&, CSS::CSSStyleSheet&);
|
||||
CSSStyleSheetWrapper* wrap(JS::Realm&, CSS::CSSStyleSheet&);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -51,9 +51,9 @@ bool MediaQueryList::evaluate()
|
|||
return now_matches;
|
||||
}
|
||||
|
||||
JS::Object* MediaQueryList::create_wrapper(JS::GlobalObject& global_object)
|
||||
JS::Object* MediaQueryList::create_wrapper(JS::Realm& realm)
|
||||
{
|
||||
return wrap(global_object, *this);
|
||||
return wrap(realm, *this);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-view/#dom-mediaquerylist-addlistener
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
// ^EventTarget
|
||||
virtual void ref_event_target() override { ref(); }
|
||||
virtual void unref_event_target() override { unref(); }
|
||||
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
||||
virtual JS::Object* create_wrapper(JS::Realm&) override;
|
||||
|
||||
void add_listener(RefPtr<DOM::IDLEventListener> listener);
|
||||
void remove_listener(RefPtr<DOM::IDLEventListener> listener);
|
||||
|
@ -62,6 +62,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
MediaQueryListWrapper* wrap(JS::GlobalObject&, CSS::MediaQueryList&);
|
||||
MediaQueryListWrapper* wrap(JS::Realm&, CSS::MediaQueryList&);
|
||||
|
||||
}
|
||||
|
|
|
@ -57,6 +57,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
StyleSheetListWrapper* wrap(JS::GlobalObject&, CSS::StyleSheetList&);
|
||||
StyleSheetListWrapper* wrap(JS::Realm&, CSS::StyleSheetList&);
|
||||
|
||||
}
|
||||
|
|
|
@ -39,6 +39,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
CryptoWrapper* wrap(JS::GlobalObject&, Crypto::Crypto&);
|
||||
CryptoWrapper* wrap(JS::Realm&, Crypto::Crypto&);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -9,6 +9,7 @@
|
|||
#include <LibJS/Runtime/Promise.h>
|
||||
#include <LibWeb/Bindings/DOMExceptionWrapper.h>
|
||||
#include <LibWeb/Bindings/IDLAbstractOperations.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/Bindings/Wrapper.h>
|
||||
#include <LibWeb/Crypto/SubtleCrypto.h>
|
||||
#include <LibWeb/DOM/DOMException.h>
|
||||
|
@ -17,15 +18,15 @@ namespace Web::Crypto {
|
|||
|
||||
JS::Promise* SubtleCrypto::digest(String const& algorithm, JS::Handle<JS::Object> const& data)
|
||||
{
|
||||
auto& global_object = wrapper()->global_object();
|
||||
auto& realm = *global_object.associated_realm();
|
||||
auto& vm = Bindings::main_thread_vm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. Let algorithm be the algorithm parameter passed to the digest() method.
|
||||
|
||||
// 2. Let data be the result of getting a copy of the bytes held by the data parameter passed to the digest() method.
|
||||
auto data_buffer_or_error = Bindings::IDL::get_buffer_source_copy(*data.cell());
|
||||
if (data_buffer_or_error.is_error()) {
|
||||
auto* error = wrap(wrapper()->global_object(), DOM::OperationError::create("Failed to copy bytes from ArrayBuffer"));
|
||||
auto* error = wrap(realm, DOM::OperationError::create("Failed to copy bytes from ArrayBuffer"));
|
||||
auto* promise = JS::Promise::create(realm);
|
||||
promise->reject(error);
|
||||
return promise;
|
||||
|
@ -46,7 +47,7 @@ JS::Promise* SubtleCrypto::digest(String const& algorithm, JS::Handle<JS::Object
|
|||
}
|
||||
// 4. If an error occurred, return a Promise rejected with normalizedAlgorithm.
|
||||
else {
|
||||
auto* error = wrap(wrapper()->global_object(), DOM::NotSupportedError::create(String::formatted("Invalid hash function '{}'", algorithm)));
|
||||
auto* error = wrap(realm, DOM::NotSupportedError::create(String::formatted("Invalid hash function '{}'", algorithm)));
|
||||
auto* promise = JS::Promise::create(realm);
|
||||
promise->reject(error);
|
||||
return promise;
|
||||
|
@ -67,7 +68,7 @@ JS::Promise* SubtleCrypto::digest(String const& algorithm, JS::Handle<JS::Object
|
|||
auto digest = hash.digest();
|
||||
auto result_buffer = ByteBuffer::copy(digest.immutable_data(), hash.digest_size());
|
||||
if (result_buffer.is_error()) {
|
||||
auto* error = wrap(wrapper()->global_object(), DOM::OperationError::create("Failed to create result buffer"));
|
||||
auto* error = wrap(realm, DOM::OperationError::create("Failed to create result buffer"));
|
||||
promise->reject(error);
|
||||
return promise;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -32,6 +32,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
SubtleCryptoWrapper* wrap(JS::GlobalObject&, Crypto::SubtleCrypto&);
|
||||
SubtleCryptoWrapper* wrap(JS::Realm&, Crypto::SubtleCrypto&);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ AbortSignal::AbortSignal()
|
|||
{
|
||||
}
|
||||
|
||||
JS::Object* AbortSignal::create_wrapper(JS::GlobalObject& global_object)
|
||||
JS::Object* AbortSignal::create_wrapper(JS::Realm& realm)
|
||||
{
|
||||
return wrap(global_object, *this);
|
||||
return wrap(realm, *this);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#abortsignal-add
|
||||
|
@ -38,6 +38,10 @@ void AbortSignal::add_abort_algorithm(Function<void()> abort_algorithm)
|
|||
// https://dom.spec.whatwg.org/#abortsignal-signal-abort
|
||||
void AbortSignal::signal_abort(JS::Value reason)
|
||||
{
|
||||
VERIFY(wrapper());
|
||||
auto& vm = wrapper()->vm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. If signal is aborted, then return.
|
||||
if (aborted())
|
||||
return;
|
||||
|
@ -46,7 +50,7 @@ void AbortSignal::signal_abort(JS::Value reason)
|
|||
if (!reason.is_undefined())
|
||||
m_abort_reason = reason;
|
||||
else
|
||||
m_abort_reason = wrap(wrapper()->global_object(), AbortError::create("Aborted without reason"));
|
||||
m_abort_reason = wrap(realm, AbortError::create("Aborted without reason"));
|
||||
|
||||
// 3. For each algorithm in signal’s abort algorithms: run algorithm.
|
||||
for (auto& algorithm : m_abort_algorithms)
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
// ^EventTarget
|
||||
virtual void ref_event_target() override { ref(); }
|
||||
virtual void unref_event_target() override { unref(); }
|
||||
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
||||
virtual JS::Object* create_wrapper(JS::Realm&) override;
|
||||
|
||||
private:
|
||||
AbortSignal();
|
||||
|
|
|
@ -58,6 +58,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
DOMTokenListWrapper* wrap(JS::GlobalObject&, DOM::DOMTokenList&);
|
||||
DOMTokenListWrapper* wrap(JS::Realm&, DOM::DOMTokenList&);
|
||||
|
||||
}
|
||||
|
|
|
@ -88,7 +88,8 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<NonnullRefPtr<DOM::DOMEv
|
|||
|
||||
// 6. Let global be listener callback’s associated Realm’s global object.
|
||||
auto& callback = listener->callback->callback();
|
||||
auto& global = callback.callback.cell()->global_object();
|
||||
auto& realm = callback.callback->shape().realm();
|
||||
auto& global = realm.global_object();
|
||||
|
||||
// 7. Let currentEvent be undefined.
|
||||
RefPtr<Event> current_event;
|
||||
|
@ -112,8 +113,8 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<NonnullRefPtr<DOM::DOMEv
|
|||
|
||||
// 10. Call a user object’s operation with listener’s callback, "handleEvent", « event », and event’s currentTarget attribute value. If this throws an exception, then:
|
||||
// FIXME: These should be wrapped for us in call_user_object_operation, but it currently doesn't do that.
|
||||
auto* this_value = Bindings::wrap(global, *event.current_target());
|
||||
auto* wrapped_event = Bindings::wrap(global, event);
|
||||
auto* this_value = Bindings::wrap(realm, *event.current_target());
|
||||
auto* wrapped_event = Bindings::wrap(realm, event);
|
||||
auto result = Bindings::IDL::call_user_object_operation(callback, "handleEvent", this_value, wrapped_event);
|
||||
|
||||
// If this throws an exception, then:
|
||||
|
|
|
@ -384,10 +384,10 @@ Bindings::CallbackType* EventTarget::get_current_value_of_event_handler(FlyStrin
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
auto& global_object = settings_object.global_object();
|
||||
auto& vm = Bindings::main_thread_vm();
|
||||
|
||||
// 8. Push settings object's realm execution context onto the JavaScript execution context stack; it is now the running JavaScript execution context.
|
||||
global_object.vm().push_execution_context(settings_object.realm_execution_context());
|
||||
vm.push_execution_context(settings_object.realm_execution_context());
|
||||
|
||||
// 9. Let function be the result of calling OrdinaryFunctionCreate, with arguments:
|
||||
// functionPrototype
|
||||
|
@ -419,19 +419,19 @@ Bindings::CallbackType* EventTarget::get_current_value_of_event_handler(FlyStrin
|
|||
// 3. If eventHandler is an element's event handler, then set scope to NewObjectEnvironment(document, true, scope).
|
||||
// (Otherwise, eventHandler is a Window object's event handler.)
|
||||
if (is<Element>(this)) {
|
||||
auto* wrapped_document = Bindings::wrap(global_object, *document);
|
||||
auto* wrapped_document = Bindings::wrap(realm, *document);
|
||||
scope = JS::new_object_environment(*wrapped_document, true, scope);
|
||||
}
|
||||
|
||||
// 4. If form owner is not null, then set scope to NewObjectEnvironment(form owner, true, scope).
|
||||
if (form_owner) {
|
||||
auto* wrapped_form_owner = Bindings::wrap(global_object, *form_owner);
|
||||
auto* wrapped_form_owner = Bindings::wrap(realm, *form_owner);
|
||||
scope = JS::new_object_environment(*wrapped_form_owner, true, scope);
|
||||
}
|
||||
|
||||
// 5. If element is not null, then set scope to NewObjectEnvironment(element, true, scope).
|
||||
if (element) {
|
||||
auto* wrapped_element = Bindings::wrap(global_object, *element);
|
||||
auto* wrapped_element = Bindings::wrap(realm, *element);
|
||||
scope = JS::new_object_environment(*wrapped_element, true, scope);
|
||||
}
|
||||
|
||||
|
@ -441,8 +441,8 @@ Bindings::CallbackType* EventTarget::get_current_value_of_event_handler(FlyStrin
|
|||
VERIFY(function);
|
||||
|
||||
// 10. Remove settings object's realm execution context from the JavaScript execution context stack.
|
||||
VERIFY(global_object.vm().execution_context_stack().last() == &settings_object.realm_execution_context());
|
||||
global_object.vm().pop_execution_context();
|
||||
VERIFY(vm.execution_context_stack().last() == &settings_object.realm_execution_context());
|
||||
vm.pop_execution_context();
|
||||
|
||||
// 11. Set function.[[ScriptOrModule]] to null.
|
||||
function->set_script_or_module({});
|
||||
|
@ -602,6 +602,7 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri
|
|||
|
||||
// Needed for wrapping.
|
||||
auto* callback_object = callback->callback.cell();
|
||||
auto& realm = callback_object->shape().realm();
|
||||
|
||||
if (special_error_event_handling) {
|
||||
// -> If special error event handling is true
|
||||
|
@ -619,7 +620,7 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri
|
|||
// NOTE: current_target is always non-null here, as the event dispatcher takes care to make sure it's non-null (and uses it as the this value for the callback!)
|
||||
// FIXME: This is rewrapping the this value of the callback defined in activate_event_handler. While I don't think this is observable as the event dispatcher
|
||||
// calls directly into the callback without considering things such as proxies, it is a waste. However, if it observable, then we must reuse the this_value that was given to the callback.
|
||||
auto* this_value = Bindings::wrap(callback_object->global_object(), *error_event.current_target());
|
||||
auto* this_value = Bindings::wrap(realm, *error_event.current_target());
|
||||
|
||||
return_value_or_error = Bindings::IDL::invoke_callback(*callback, this_value, wrapped_message, wrapped_filename, wrapped_lineno, wrapped_colno, error_event.error());
|
||||
} else {
|
||||
|
@ -627,10 +628,10 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri
|
|||
// Invoke callback with one argument, the value of which is the Event object event, with the callback this value set to event's currentTarget. Let return value be the callback's return value. [WEBIDL]
|
||||
|
||||
// FIXME: This has the same rewrapping issue as this_value.
|
||||
auto* wrapped_event = Bindings::wrap(callback_object->global_object(), event);
|
||||
auto* wrapped_event = Bindings::wrap(realm, event);
|
||||
|
||||
// FIXME: The comments about this in the special_error_event_handling path also apply here.
|
||||
auto* this_value = Bindings::wrap(callback_object->global_object(), *event.current_target());
|
||||
auto* this_value = Bindings::wrap(realm, *event.current_target());
|
||||
|
||||
return_value_or_error = Bindings::IDL::invoke_callback(*callback, this_value, wrapped_event);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
virtual bool dispatch_event(NonnullRefPtr<Event>);
|
||||
ExceptionOr<bool> dispatch_event_binding(NonnullRefPtr<Event>);
|
||||
|
||||
virtual JS::Object* create_wrapper(JS::GlobalObject&) = 0;
|
||||
virtual JS::Object* create_wrapper(JS::Realm&) = 0;
|
||||
|
||||
virtual EventTarget* get_parent(Event const&) { return nullptr; }
|
||||
|
||||
|
|
|
@ -64,6 +64,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
HTMLCollectionWrapper* wrap(JS::GlobalObject&, DOM::HTMLCollection&);
|
||||
HTMLCollectionWrapper* wrap(JS::Realm&, DOM::HTMLCollection&);
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
NamedNodeMapWrapper* wrap(JS::GlobalObject&, DOM::NamedNodeMap&);
|
||||
NamedNodeMapWrapper* wrap(JS::Realm&, DOM::NamedNodeMap&);
|
||||
|
||||
}
|
||||
|
|
|
@ -806,9 +806,9 @@ bool Node::is_editable() const
|
|||
return parent() && parent()->is_editable();
|
||||
}
|
||||
|
||||
JS::Object* Node::create_wrapper(JS::GlobalObject& global_object)
|
||||
JS::Object* Node::create_wrapper(JS::Realm& realm)
|
||||
{
|
||||
return wrap(global_object, *this);
|
||||
return wrap(realm, *this);
|
||||
}
|
||||
|
||||
void Node::removed_last_ref()
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
// ^EventTarget
|
||||
virtual void ref_event_target() final { ref(); }
|
||||
virtual void unref_event_target() final { unref(); }
|
||||
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
||||
virtual JS::Object* create_wrapper(JS::Realm&) override;
|
||||
|
||||
virtual ~Node();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ private:
|
|||
Bindings::CallbackType m_callback;
|
||||
};
|
||||
|
||||
inline JS::Object* wrap(JS::GlobalObject&, Web::DOM::NodeFilter& filter)
|
||||
inline JS::Object* wrap(JS::Realm&, Web::DOM::NodeFilter& filter)
|
||||
{
|
||||
return filter.callback().callback.cell();
|
||||
}
|
||||
|
|
|
@ -118,12 +118,12 @@ JS::ThrowCompletionOr<RefPtr<Node>> NodeIterator::traverse(Direction direction)
|
|||
JS::ThrowCompletionOr<NodeFilter::Result> NodeIterator::filter(Node& node)
|
||||
{
|
||||
VERIFY(wrapper());
|
||||
auto& global_object = wrapper()->global_object();
|
||||
auto& vm = wrapper()->vm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. If traverser’s active flag is set, then throw an "InvalidStateError" DOMException.
|
||||
if (m_active)
|
||||
return JS::throw_completion(wrap(global_object, InvalidStateError::create("NodeIterator is already active")));
|
||||
return JS::throw_completion(wrap(realm, InvalidStateError::create("NodeIterator is already active")));
|
||||
|
||||
// 2. Let n be node’s nodeType attribute value − 1.
|
||||
auto n = node.node_type() - 1;
|
||||
|
@ -141,7 +141,7 @@ JS::ThrowCompletionOr<NodeFilter::Result> NodeIterator::filter(Node& node)
|
|||
|
||||
// 6. Let result be the return value of call a user object’s operation with traverser’s filter, "acceptNode", and « node ».
|
||||
// If this throws an exception, then unset traverser’s active flag and rethrow the exception.
|
||||
auto result = Bindings::IDL::call_user_object_operation(m_filter->callback(), "acceptNode", {}, wrap(global_object, node));
|
||||
auto result = Bindings::IDL::call_user_object_operation(m_filter->callback(), "acceptNode", {}, wrap(realm, node));
|
||||
if (result.is_abrupt()) {
|
||||
m_active = false;
|
||||
return result;
|
||||
|
|
|
@ -221,12 +221,12 @@ JS::ThrowCompletionOr<RefPtr<Node>> TreeWalker::next_node()
|
|||
JS::ThrowCompletionOr<NodeFilter::Result> TreeWalker::filter(Node& node)
|
||||
{
|
||||
VERIFY(wrapper());
|
||||
auto& global_object = wrapper()->global_object();
|
||||
auto& vm = wrapper()->vm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. If traverser’s active flag is set, then throw an "InvalidStateError" DOMException.
|
||||
if (m_active)
|
||||
return JS::throw_completion(wrap(global_object, InvalidStateError::create("NodeIterator is already active")));
|
||||
return JS::throw_completion(wrap(realm, InvalidStateError::create("NodeIterator is already active")));
|
||||
|
||||
// 2. Let n be node’s nodeType attribute value − 1.
|
||||
auto n = node.node_type() - 1;
|
||||
|
@ -244,7 +244,7 @@ JS::ThrowCompletionOr<NodeFilter::Result> TreeWalker::filter(Node& node)
|
|||
|
||||
// 6. Let result be the return value of call a user object’s operation with traverser’s filter, "acceptNode", and « node ».
|
||||
// If this throws an exception, then unset traverser’s active flag and rethrow the exception.
|
||||
auto result = Bindings::IDL::call_user_object_operation(m_filter->callback(), "acceptNode", {}, wrap(global_object, node));
|
||||
auto result = Bindings::IDL::call_user_object_operation(m_filter->callback(), "acceptNode", {}, wrap(realm, node));
|
||||
if (result.is_abrupt()) {
|
||||
m_active = false;
|
||||
return result;
|
||||
|
|
|
@ -72,6 +72,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
HeadersWrapper* wrap(JS::GlobalObject&, Fetch::Headers&);
|
||||
HeadersWrapper* wrap(JS::Realm&, Fetch::Headers&);
|
||||
|
||||
}
|
||||
|
|
|
@ -42,6 +42,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
HeadersIteratorWrapper* wrap(JS::GlobalObject&, Fetch::HeadersIterator&);
|
||||
HeadersIteratorWrapper* wrap(JS::Realm&, Fetch::HeadersIterator&);
|
||||
|
||||
}
|
||||
|
|
|
@ -262,9 +262,9 @@ JS::Promise* Blob::array_buffer()
|
|||
return promise;
|
||||
}
|
||||
|
||||
JS::Object* Blob::create_wrapper(JS::GlobalObject& global_object)
|
||||
JS::Object* Blob::create_wrapper(JS::Realm& realm)
|
||||
{
|
||||
return wrap(global_object, *this);
|
||||
return wrap(realm, *this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
JS::Promise* text();
|
||||
JS::Promise* array_buffer();
|
||||
|
||||
virtual JS::Object* create_wrapper(JS::GlobalObject&);
|
||||
virtual JS::Object* create_wrapper(JS::Realm&);
|
||||
|
||||
ReadonlyBytes bytes() const { return m_byte_buffer.bytes(); }
|
||||
|
||||
|
|
|
@ -34,6 +34,6 @@ protected:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
HTMLOptionsCollectionWrapper* wrap(JS::GlobalObject&, HTML::HTMLOptionsCollection&);
|
||||
HTMLOptionsCollectionWrapper* wrap(JS::Realm&, HTML::HTMLOptionsCollection&);
|
||||
|
||||
}
|
||||
|
|
|
@ -84,9 +84,9 @@ void MessagePort::post_message(JS::Value message)
|
|||
}));
|
||||
}
|
||||
|
||||
JS::Object* MessagePort::create_wrapper(JS::GlobalObject& global_object)
|
||||
JS::Object* MessagePort::create_wrapper(JS::Realm& realm)
|
||||
{
|
||||
return wrap(global_object, *this);
|
||||
return wrap(realm, *this);
|
||||
}
|
||||
|
||||
void MessagePort::start()
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
// ^EventTarget
|
||||
virtual void ref_event_target() override { ref(); }
|
||||
virtual void unref_event_target() override { unref(); }
|
||||
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
||||
virtual JS::Object* create_wrapper(JS::Realm&) override;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/web-messaging.html#entangle
|
||||
void entangle_with(MessagePort&);
|
||||
|
|
|
@ -49,6 +49,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
StorageWrapper* wrap(JS::GlobalObject&, HTML::Storage&);
|
||||
StorageWrapper* wrap(JS::Realm&, HTML::Storage&);
|
||||
|
||||
}
|
||||
|
|
|
@ -284,9 +284,9 @@ bool Window::dispatch_event(NonnullRefPtr<DOM::Event> event)
|
|||
return DOM::EventDispatcher::dispatch(*this, event, true);
|
||||
}
|
||||
|
||||
JS::Object* Window::create_wrapper(JS::GlobalObject& global_object)
|
||||
JS::Object* Window::create_wrapper(JS::Realm& realm)
|
||||
{
|
||||
return &global_object;
|
||||
return &realm.global_object();
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-view-1/#dom-window-innerwidth
|
||||
|
@ -653,8 +653,8 @@ u32 Window::request_idle_callback(NonnullOwnPtr<Bindings::CallbackType> callback
|
|||
auto handle = window.m_idle_callback_identifier;
|
||||
// 4. Push callback to the end of window's list of idle request callbacks, associated with handle.
|
||||
auto handler = [callback = move(callback)](NonnullRefPtr<RequestIdleCallback::IdleDeadline> deadline) -> JS::Completion {
|
||||
auto& global_object = callback->callback.cell()->global_object();
|
||||
auto* wrapped_deadline = Bindings::wrap(global_object, *deadline);
|
||||
auto& realm = callback->callback.cell()->shape().realm();
|
||||
auto* wrapped_deadline = Bindings::wrap(realm, *deadline);
|
||||
return Bindings::IDL::invoke_callback(const_cast<Bindings::CallbackType&>(*callback), {}, JS::Value(wrapped_deadline));
|
||||
};
|
||||
window.m_idle_request_callbacks.append(adopt_ref(*new IdleCallback(move(handler), handle)));
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
virtual void ref_event_target() override { RefCounted::ref(); }
|
||||
virtual void unref_event_target() override { RefCounted::unref(); }
|
||||
virtual bool dispatch_event(NonnullRefPtr<DOM::Event>) override;
|
||||
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
||||
virtual JS::Object* create_wrapper(JS::Realm&) override;
|
||||
|
||||
Page* page();
|
||||
Page const* page() const;
|
||||
|
|
|
@ -314,9 +314,9 @@ void Worker::post_message(JS::Value message, JS::Value)
|
|||
target_port->post_message(message);
|
||||
}
|
||||
|
||||
JS::Object* Worker::create_wrapper(JS::GlobalObject& global_object)
|
||||
JS::Object* Worker::create_wrapper(JS::Realm& realm)
|
||||
{
|
||||
return wrap(global_object, *this);
|
||||
return wrap(realm, *this);
|
||||
}
|
||||
|
||||
#undef __ENUMERATE
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
// ^EventTarget
|
||||
virtual void ref_event_target() override { ref(); }
|
||||
virtual void unref_event_target() override { unref(); }
|
||||
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
||||
virtual JS::Object* create_wrapper(JS::Realm&) override;
|
||||
|
||||
MessagePort* implicit_message_port() { return m_implicit_port; }
|
||||
RefPtr<MessagePort> outside_message_port() { return m_outside_port; }
|
||||
|
@ -102,6 +102,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
WorkerWrapper* wrap(JS::GlobalObject&, HTML::Worker&);
|
||||
WorkerWrapper* wrap(JS::Realm&, HTML::Worker&);
|
||||
|
||||
}
|
||||
|
|
|
@ -54,9 +54,9 @@ DOM::ExceptionOr<void> WorkerGlobalScope::import_scripts(Vector<String> urls)
|
|||
return {};
|
||||
}
|
||||
|
||||
JS::Object* WorkerGlobalScope::create_wrapper(JS::GlobalObject& global_object)
|
||||
JS::Object* WorkerGlobalScope::create_wrapper(JS::Realm& realm)
|
||||
{
|
||||
return wrap(global_object, *this);
|
||||
return wrap(realm, *this);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-location
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
// ^EventTarget
|
||||
virtual void ref_event_target() override { ref(); }
|
||||
virtual void unref_event_target() override { unref(); }
|
||||
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
||||
virtual JS::Object* create_wrapper(JS::Realm&) override;
|
||||
|
||||
// Following methods are from the WorkerGlobalScope IDL definition
|
||||
// https://html.spec.whatwg.org/multipage/workers.html#the-workerglobalscope-common-interface
|
||||
|
|
|
@ -39,9 +39,9 @@ void Performance::unref_event_target()
|
|||
m_window.unref();
|
||||
}
|
||||
|
||||
JS::Object* Performance::create_wrapper(JS::GlobalObject& global_object)
|
||||
JS::Object* Performance::create_wrapper(JS::Realm& realm)
|
||||
{
|
||||
return Bindings::wrap(global_object, *this);
|
||||
return Bindings::wrap(realm, *this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
virtual void ref_event_target() override;
|
||||
virtual void unref_event_target() override;
|
||||
|
||||
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
||||
virtual JS::Object* create_wrapper(JS::Realm&) override;
|
||||
|
||||
private:
|
||||
HTML::Window& m_window;
|
||||
|
|
|
@ -63,6 +63,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
URLSearchParamsWrapper* wrap(JS::GlobalObject&, URL::URLSearchParams&);
|
||||
URLSearchParamsWrapper* wrap(JS::Realm&, URL::URLSearchParams&);
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
URLSearchParamsIteratorWrapper* wrap(JS::GlobalObject&, URL::URLSearchParamsIterator&);
|
||||
URLSearchParamsIteratorWrapper* wrap(JS::Realm&, URL::URLSearchParamsIterator&);
|
||||
|
||||
}
|
||||
|
|
|
@ -226,9 +226,9 @@ void WebSocket::on_message(ByteBuffer message, bool is_text)
|
|||
TODO();
|
||||
}
|
||||
|
||||
JS::Object* WebSocket::create_wrapper(JS::GlobalObject& global_object)
|
||||
JS::Object* WebSocket::create_wrapper(JS::Realm& realm)
|
||||
{
|
||||
return wrap(global_object, *this);
|
||||
return wrap(realm, *this);
|
||||
}
|
||||
|
||||
#undef __ENUMERATE
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
private:
|
||||
virtual void ref_event_target() override { ref(); }
|
||||
virtual void unref_event_target() override { unref(); }
|
||||
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
||||
virtual JS::Object* create_wrapper(JS::Realm&) override;
|
||||
|
||||
void on_open();
|
||||
void on_message(ByteBuffer message, bool is_text);
|
||||
|
|
|
@ -124,7 +124,7 @@ DOM::ExceptionOr<JS::Value> XMLHttpRequest::response()
|
|||
else if (m_response_type == Bindings::XMLHttpRequestResponseType::Blob) {
|
||||
auto blob_part = TRY_OR_RETURN_OOM(try_make_ref_counted<FileAPI::Blob>(m_received_bytes, get_final_mime_type().type()));
|
||||
auto blob = TRY(FileAPI::Blob::create(Vector<FileAPI::BlobPart> { move(blob_part) }));
|
||||
m_response_object = JS::make_handle(JS::Value(blob->create_wrapper(global_object)));
|
||||
m_response_object = JS::make_handle(JS::Value(blob->create_wrapper(realm)));
|
||||
}
|
||||
// 7. Otherwise, if this’s response type is "document", set a document response for this.
|
||||
else if (m_response_type == Bindings::XMLHttpRequestResponseType::Document) {
|
||||
|
@ -568,9 +568,9 @@ DOM::ExceptionOr<void> XMLHttpRequest::send(Optional<XMLHttpRequestBodyInit> bod
|
|||
return {};
|
||||
}
|
||||
|
||||
JS::Object* XMLHttpRequest::create_wrapper(JS::GlobalObject& global_object)
|
||||
JS::Object* XMLHttpRequest::create_wrapper(JS::Realm& realm)
|
||||
{
|
||||
return wrap(global_object, *this);
|
||||
return wrap(realm, *this);
|
||||
}
|
||||
|
||||
Bindings::CallbackType* XMLHttpRequest::onreadystatechange()
|
||||
|
|
|
@ -82,7 +82,7 @@ public:
|
|||
private:
|
||||
virtual void ref_event_target() override { ref(); }
|
||||
virtual void unref_event_target() override { unref(); }
|
||||
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
||||
virtual JS::Object* create_wrapper(JS::Realm&) override;
|
||||
|
||||
void set_ready_state(ReadyState);
|
||||
void set_status(Fetch::Infrastructure::Status status) { m_status = status; }
|
||||
|
|
|
@ -43,9 +43,9 @@ protected:
|
|||
}
|
||||
|
||||
private:
|
||||
virtual JS::Object* create_wrapper(JS::GlobalObject& global_object) override
|
||||
virtual JS::Object* create_wrapper(JS::Realm& realm) override
|
||||
{
|
||||
return wrap(global_object, *this);
|
||||
return wrap(realm, *this);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -97,6 +97,7 @@ JS::ThrowCompletionOr<JS::MarkedVector<JS::Value>> ConsoleGlobalObject::internal
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(ConsoleGlobalObject::inspected_node_getter)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* this_object = TRY(vm.this_value().to_object(vm));
|
||||
|
||||
if (!is<ConsoleGlobalObject>(this_object))
|
||||
|
@ -108,7 +109,7 @@ JS_DEFINE_NATIVE_FUNCTION(ConsoleGlobalObject::inspected_node_getter)
|
|||
if (!inspected_node)
|
||||
return JS::js_undefined();
|
||||
|
||||
return Web::Bindings::wrap(global_object, *inspected_node);
|
||||
return Web::Bindings::wrap(realm, *inspected_node);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue