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