PlatformObject.cpp 723 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/TypeCasts.h>
  7. #include <LibJS/Runtime/Realm.h>
  8. #include <LibWeb/Bindings/PlatformObject.h>
  9. #include <LibWeb/HTML/Window.h>
  10. namespace Web::Bindings {
  11. PlatformObject::PlatformObject(JS::Realm& realm)
  12. : JS::Object(realm, nullptr)
  13. {
  14. }
  15. PlatformObject::PlatformObject(JS::Object& prototype)
  16. : JS::Object(ConstructWithPrototypeTag::Tag, prototype)
  17. {
  18. }
  19. PlatformObject::~PlatformObject() = default;
  20. JS::Realm& PlatformObject::realm() const
  21. {
  22. return shape().realm();
  23. }
  24. HTML::Window& PlatformObject::global_object() const
  25. {
  26. return verify_cast<HTML::Window>(realm().global_object());
  27. }
  28. }