Screen.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. JS::NonnullGCPtr<ScreenOrientation> orientation();
  24. private:
  25. explicit Screen(HTML::Window&);
  26. virtual void initialize(JS::Realm&) override;
  27. virtual void visit_edges(Cell::Visitor&) override;
  28. HTML::Window const& window() const { return *m_window; }
  29. Gfx::IntRect screen_rect() const;
  30. JS::NonnullGCPtr<HTML::Window> m_window;
  31. JS::GCPtr<ScreenOrientation> m_orientation;
  32. };
  33. }