Screen.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibGfx/Rect.h>
  8. #include <LibWeb/Bindings/PlatformObject.h>
  9. #include <LibWeb/Forward.h>
  10. #include <LibWeb/HTML/Window.h>
  11. namespace Web::CSS {
  12. class Screen final : public Bindings::PlatformObject {
  13. WEB_PLATFORM_OBJECT(Screen, Bindings::PlatformObject);
  14. JS_DECLARE_ALLOCATOR(Screen);
  15. public:
  16. [[nodiscard]] static JS::NonnullGCPtr<Screen> create(HTML::Window&);
  17. i32 width() const { return screen_rect().width(); }
  18. i32 height() const { return screen_rect().height(); }
  19. i32 avail_width() const { return screen_rect().width(); }
  20. i32 avail_height() const { return screen_rect().height(); }
  21. u32 color_depth() const { return 24; }
  22. u32 pixel_depth() const { return 24; }
  23. private:
  24. explicit Screen(HTML::Window&);
  25. virtual void initialize(JS::Realm&) override;
  26. virtual void visit_edges(Cell::Visitor&) override;
  27. HTML::Window const& window() const { return *m_window; }
  28. Gfx::IntRect screen_rect() const;
  29. JS::NonnullGCPtr<HTML::Window> m_window;
  30. };
  31. }