diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp index b7e760ec6ce..72ec204d97d 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp @@ -89,12 +89,6 @@ class @legacy_constructor_class@;)~~~"); add_interface(gen, interface.prototype_class, interface.constructor_class, lookup_legacy_constructor(interface)); } - // FIXME: Special case window. We should convert Window to use IDL. - { - auto gen = generator.fork(); - add_interface(gen, "WindowPrototype"sv, "WindowConstructor"sv, {}); - } - // FIXME: Special case WebAssembly. We should convert WASM to use IDL. { auto gen = generator.fork(); @@ -142,11 +136,6 @@ static ErrorOr generate_intrinsic_definitions(StringView output_path, Vect } } - // FIXME: Special case window. We should convert Window to use IDL. - generator.append(R"~~~( -#include -#include )~~~"); - // FIXME: Special case WebAssembly. We should convert WASM to use IDL. generator.append(R"~~~( #include @@ -204,12 +193,6 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea add_interface(gen, interface.name, interface.prototype_class, interface.constructor_class, lookup_legacy_constructor(interface)); } - // FIXME: Special case window. We should convert Window to use IDL - { - auto gen = generator.fork(); - add_interface(gen, "Window"sv, "WindowPrototype"sv, "WindowConstructor"sv, {}); - } - // FIXME: Special case WebAssembly. We should convert WASM to use IDL. { auto gen = generator.fork(); @@ -285,13 +268,6 @@ static ErrorOr generate_exposed_interface_implementation(StringView class_ } } - // FIXME: Special case window. We should convert Window to use IDL - if (class_name == "Window"sv) { - generator.append(R"~~~(#include -#include -)~~~"); - } - generator.append(R"~~~( namespace Web::Bindings { @@ -319,12 +295,6 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global) add_interface(gen, interface.name, interface.prototype_class, lookup_legacy_constructor(interface)); } - // FIXME: Special case window. We should convert Window to use IDL - if (class_name == "Window"sv) { - auto gen = generator.fork(); - add_interface(gen, "Window"sv, "WindowPrototype"sv, {}); - } - generator.append(R"~~~( } diff --git a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp deleted file mode 100644 index 95935409d0c..00000000000 --- a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022, the SerenityOS developers. - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include -#include -#include - -namespace Web::Bindings { - -WindowConstructor::WindowConstructor(JS::Realm& realm) - : NativeFunction(*realm.intrinsics().function_prototype()) -{ -} - -WindowConstructor::~WindowConstructor() = default; - -JS::ThrowCompletionOr WindowConstructor::call() -{ - return vm().throw_completion(JS::ErrorType::ConstructorWithoutNew, "Window"); -} - -JS::ThrowCompletionOr> WindowConstructor::construct(FunctionObject&) -{ - return vm().throw_completion(JS::ErrorType::NotAConstructor, "Window"); -} - -JS::ThrowCompletionOr WindowConstructor::initialize(JS::Realm& realm) -{ - auto& vm = this->vm(); - - MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); - define_direct_property(vm.names.prototype, &ensure_web_prototype(realm, "Window"), 0); - define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable); - - return {}; -} - -} diff --git a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h deleted file mode 100644 index 07f39ebf076..00000000000 --- a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2022, the SerenityOS developers. - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include - -namespace Web::Bindings { - -class WindowConstructor : public JS::NativeFunction { - JS_OBJECT(WindowConstructor, JS::NativeFunction); - -public: - explicit WindowConstructor(JS::Realm&); - virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; - virtual ~WindowConstructor() override; - - virtual JS::ThrowCompletionOr call() override; - virtual JS::ThrowCompletionOr> construct(JS::FunctionObject& new_target) override; - -private: - virtual bool has_constructor() const override { return true; } -}; - -} diff --git a/Userland/Libraries/LibWeb/Bindings/WindowPrototype.cpp b/Userland/Libraries/LibWeb/Bindings/WindowPrototype.cpp deleted file mode 100644 index 49f419a02bd..00000000000 --- a/Userland/Libraries/LibWeb/Bindings/WindowPrototype.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023, Tim Flynn - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include -#include - -namespace Web::Bindings { - -WindowPrototype::WindowPrototype(JS::Realm& realm) - : JS::Object(realm, nullptr) -{ -} - -JS::ThrowCompletionOr WindowPrototype::initialize(JS::Realm& realm) -{ - MUST_OR_THROW_OOM(Base::initialize(realm)); - set_prototype(&Bindings::ensure_web_prototype(realm, "EventTarget")); - - return {}; -} - -} diff --git a/Userland/Libraries/LibWeb/Bindings/WindowPrototype.h b/Userland/Libraries/LibWeb/Bindings/WindowPrototype.h deleted file mode 100644 index ec580702870..00000000000 --- a/Userland/Libraries/LibWeb/Bindings/WindowPrototype.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2022, the SerenityOS developers. - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include -#include -#include - -namespace Web::Bindings { - -class WindowPrototype final : public JS::Object { - JS_OBJECT(WindowPrototype, JS::Object); - -public: - explicit WindowPrototype(JS::Realm& realm); - -private: - virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; -}; - -} diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 0cd6b4d481a..9edac65af15 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -15,8 +15,6 @@ set(SOURCES Bindings/MainThreadVM.cpp Bindings/OptionConstructor.cpp Bindings/PlatformObject.cpp - Bindings/WindowConstructor.cpp - Bindings/WindowPrototype.cpp Crypto/Crypto.cpp Crypto/SubtleCrypto.cpp CSS/Angle.cpp diff --git a/Userland/Libraries/LibWeb/HTML/Window.idl b/Userland/Libraries/LibWeb/HTML/Window.idl new file mode 100644 index 00000000000..1de37150bae --- /dev/null +++ b/Userland/Libraries/LibWeb/HTML/Window.idl @@ -0,0 +1,6 @@ +#import + +// https://html.spec.whatwg.org/multipage/nav-history-apis.html#window +[Global=Window, Exposed=Window, LegacyUnenumerableNamedProperties] +interface Window : EventTarget { +}; diff --git a/Userland/Libraries/LibWeb/idl_files.cmake b/Userland/Libraries/LibWeb/idl_files.cmake index 2ea24eeb421..f54b19580d7 100644 --- a/Userland/Libraries/LibWeb/idl_files.cmake +++ b/Userland/Libraries/LibWeb/idl_files.cmake @@ -163,6 +163,7 @@ libweb_js_bindings(HTML/PromiseRejectionEvent) libweb_js_bindings(HTML/Storage) libweb_js_bindings(HTML/SubmitEvent) libweb_js_bindings(HTML/TextMetrics) +libweb_js_bindings(HTML/Window) libweb_js_bindings(HTML/Worker) libweb_js_bindings(HTML/WorkerGlobalScope) libweb_js_bindings(HTML/WorkerLocation)