Screen.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 WebIDL::ExceptionOr<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 JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  25. virtual void visit_edges(Cell::Visitor&) override;
  26. HTML::Window const& window() const { return *m_window; }
  27. Gfx::IntRect screen_rect() const;
  28. JS::NonnullGCPtr<HTML::Window> m_window;
  29. };
  30. }