Screen.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. public:
  15. static JS::NonnullGCPtr<Screen> create(HTML::Window&);
  16. i32 width() const { return screen_rect().width(); }
  17. i32 height() const { return screen_rect().height(); }
  18. i32 avail_width() const { return screen_rect().width(); }
  19. i32 avail_height() const { return screen_rect().height(); }
  20. u32 color_depth() const { return 24; }
  21. u32 pixel_depth() const { return 24; }
  22. private:
  23. explicit Screen(HTML::Window&);
  24. virtual void visit_edges(Cell::Visitor&) override;
  25. HTML::Window const& window() const { return *m_window; }
  26. Gfx::IntRect screen_rect() const;
  27. JS::NonnullGCPtr<HTML::Window> m_window;
  28. };
  29. }