mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibJS: Move builtin prototypes to the global object
This moves us towards being able to run JavaScript in different global objects without allocating a separate GC heap.
This commit is contained in:
parent
cbcf317e76
commit
fca08bd000
40 changed files with 131 additions and 101 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <AK/Function.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/PrimitiveString.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
#include <LibWeb/Bindings/CanvasRenderingContext2DWrapper.h>
|
||||
|
@ -44,7 +45,7 @@ CanvasRenderingContext2DWrapper* wrap(JS::Heap& heap, CanvasRenderingContext2D&
|
|||
}
|
||||
|
||||
CanvasRenderingContext2DWrapper::CanvasRenderingContext2DWrapper(CanvasRenderingContext2D& impl)
|
||||
: Wrapper(*interpreter().object_prototype())
|
||||
: Wrapper(*interpreter().global_object().object_prototype())
|
||||
, m_impl(impl)
|
||||
{
|
||||
put_native_property("fillStyle", fill_style_getter, fill_style_setter);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibWeb/Bindings/EventListenerWrapper.h>
|
||||
#include <LibWeb/DOM/EventListener.h>
|
||||
|
||||
|
@ -33,7 +34,7 @@ namespace Web {
|
|||
namespace Bindings {
|
||||
|
||||
EventListenerWrapper::EventListenerWrapper(EventListener& impl)
|
||||
: Wrapper(*interpreter().object_prototype())
|
||||
: Wrapper(*interpreter().global_object().object_prototype())
|
||||
, m_impl(impl)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <AK/Function.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibWeb/Bindings/EventListenerWrapper.h>
|
||||
#include <LibWeb/Bindings/EventTargetWrapper.h>
|
||||
#include <LibWeb/DOM/EventListener.h>
|
||||
|
@ -37,7 +38,7 @@ namespace Web {
|
|||
namespace Bindings {
|
||||
|
||||
EventTargetWrapper::EventTargetWrapper(EventTarget& impl)
|
||||
: Wrapper(*interpreter().object_prototype())
|
||||
: Wrapper(*interpreter().global_object().object_prototype())
|
||||
, m_impl(impl)
|
||||
{
|
||||
put_native_function("addEventListener", add_event_listener, 2);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibWeb/Bindings/EventWrapper.h>
|
||||
#include <LibWeb/Bindings/MouseEventWrapper.h>
|
||||
#include <LibWeb/DOM/MouseEvent.h>
|
||||
|
@ -40,7 +41,7 @@ EventWrapper* wrap(JS::Heap& heap, Event& event)
|
|||
}
|
||||
|
||||
EventWrapper::EventWrapper(Event& event)
|
||||
: Wrapper(*interpreter().object_prototype())
|
||||
: Wrapper(*interpreter().global_object().object_prototype())
|
||||
, m_event(event)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -26,13 +26,14 @@
|
|||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibWeb/Bindings/NavigatorObject.h>
|
||||
|
||||
namespace Web {
|
||||
namespace Bindings {
|
||||
|
||||
NavigatorObject::NavigatorObject()
|
||||
: Object(interpreter().object_prototype())
|
||||
: Object(interpreter().global_object().object_prototype())
|
||||
{
|
||||
put("appCodeName", js_string(heap(), "Mozilla"));
|
||||
put("appName", js_string(heap(), "Netscape"));
|
||||
|
|
|
@ -43,6 +43,12 @@ namespace Bindings {
|
|||
WindowObject::WindowObject(Window& impl)
|
||||
: m_impl(impl)
|
||||
{
|
||||
}
|
||||
|
||||
void WindowObject::initialize()
|
||||
{
|
||||
GlobalObject::initialize();
|
||||
|
||||
put("window", this);
|
||||
put_native_property("document", document_getter, document_setter);
|
||||
put_native_function("alert", alert);
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace Bindings {
|
|||
class WindowObject final : public JS::GlobalObject {
|
||||
public:
|
||||
explicit WindowObject(Window&);
|
||||
virtual void initialize() override;
|
||||
virtual ~WindowObject() override;
|
||||
|
||||
Window& impl() { return *m_impl; }
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/Bindings/XMLHttpRequestConstructor.h>
|
||||
#include <LibWeb/Bindings/XMLHttpRequestWrapper.h>
|
||||
|
@ -35,7 +36,7 @@ namespace Web {
|
|||
namespace Bindings {
|
||||
|
||||
XMLHttpRequestConstructor::XMLHttpRequestConstructor()
|
||||
: NativeFunction(*interpreter().function_prototype())
|
||||
: NativeFunction(*interpreter().global_object().function_prototype())
|
||||
{
|
||||
put("length", JS::Value(1));
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <AK/Function.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibWeb/Bindings/XMLHttpRequestPrototype.h>
|
||||
#include <LibWeb/Bindings/XMLHttpRequestWrapper.h>
|
||||
#include <LibWeb/DOM/XMLHttpRequest.h>
|
||||
|
@ -35,7 +36,7 @@ namespace Web {
|
|||
namespace Bindings {
|
||||
|
||||
XMLHttpRequestPrototype::XMLHttpRequestPrototype()
|
||||
: Object(interpreter().object_prototype())
|
||||
: Object(interpreter().global_object().object_prototype())
|
||||
{
|
||||
put_native_function("open", open, 2);
|
||||
put_native_function("send", send, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue