Screen.h 949 B

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/Wrappable.h>
  9. #include <LibWeb/Forward.h>
  10. namespace Web::CSS {
  11. class Screen final
  12. : public RefCounted<Screen>
  13. , public Bindings::Wrappable {
  14. public:
  15. using WrapperType = Bindings::ScreenWrapper;
  16. static NonnullRefPtr<Screen> create(DOM::Window& window)
  17. {
  18. return adopt_ref(*new Screen(window));
  19. }
  20. i32 width() const { return screen_rect().width(); }
  21. i32 height() const { return screen_rect().height(); }
  22. i32 avail_width() const { return screen_rect().width(); }
  23. i32 avail_height() const { return screen_rect().height(); }
  24. u32 color_depth() const { return 24; }
  25. u32 pixel_depth() const { return 24; }
  26. private:
  27. explicit Screen(DOM::Window&);
  28. Gfx::IntRect screen_rect() const;
  29. DOM::Window& m_window;
  30. };
  31. }