mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-04-01 02:06:11 +00:00
Global object initialization is tightly coupled to realm creation, so simply pass it to the function instead of relying on the non-standard 'associated realm' concept, which I'd like to remove later. This works essentially the same way as regular Object::initialize() now. Additionally this allows us to forward the realm to GlobalObject's add_constructor() / initialize_constructor() helpers, so they set the correct realm on the allocated constructor function object.
50 lines
2.0 KiB
C++
50 lines
2.0 KiB
C++
/*
|
|
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibJS/Forward.h>
|
|
#include <LibJS/Runtime/Completion.h>
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
|
|
namespace Web::Bindings {
|
|
class WindowObject;
|
|
}
|
|
|
|
namespace WebContent {
|
|
|
|
class ConsoleGlobalObject final : public JS::GlobalObject {
|
|
JS_OBJECT(ConsoleGlobalObject, JS::GlobalObject);
|
|
|
|
public:
|
|
ConsoleGlobalObject(JS::Realm&, Web::Bindings::WindowObject&);
|
|
virtual ~ConsoleGlobalObject() override = default;
|
|
|
|
virtual JS::ThrowCompletionOr<Object*> internal_get_prototype_of() const override;
|
|
virtual JS::ThrowCompletionOr<bool> internal_set_prototype_of(Object* prototype) override;
|
|
virtual JS::ThrowCompletionOr<bool> internal_is_extensible() const override;
|
|
virtual JS::ThrowCompletionOr<bool> internal_prevent_extensions() override;
|
|
virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyKey const& name) const override;
|
|
virtual JS::ThrowCompletionOr<bool> internal_define_own_property(JS::PropertyKey const& name, JS::PropertyDescriptor const& descriptor) override;
|
|
virtual JS::ThrowCompletionOr<bool> internal_has_property(JS::PropertyKey const& name) const override;
|
|
virtual JS::ThrowCompletionOr<JS::Value> internal_get(JS::PropertyKey const&, JS::Value) const override;
|
|
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override;
|
|
virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const& name) override;
|
|
virtual JS::ThrowCompletionOr<JS::MarkedVector<JS::Value>> internal_own_property_keys() const override;
|
|
|
|
virtual void initialize_global_object(JS::Realm&) override;
|
|
|
|
private:
|
|
virtual void visit_edges(Visitor&) override;
|
|
|
|
// Because $0 is not a nice C++ function name
|
|
JS_DECLARE_NATIVE_FUNCTION(inspected_node_getter);
|
|
|
|
Web::Bindings::WindowObject* m_window_object;
|
|
};
|
|
|
|
}
|