Serenity Operating System
1/*
2 * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#include <LibGfx/Rect.h>
10#include <LibWeb/Bindings/PlatformObject.h>
11#include <LibWeb/Forward.h>
12#include <LibWeb/HTML/Window.h>
13
14namespace Web::CSS {
15
16class Screen final : public Bindings::PlatformObject {
17 WEB_PLATFORM_OBJECT(Screen, Bindings::PlatformObject);
18
19public:
20 static WebIDL::ExceptionOr<JS::NonnullGCPtr<Screen>> create(HTML::Window&);
21
22 i32 width() const { return screen_rect().width(); }
23 i32 height() const { return screen_rect().height(); }
24 i32 avail_width() const { return screen_rect().width(); }
25 i32 avail_height() const { return screen_rect().height(); }
26 u32 color_depth() const { return 24; }
27 u32 pixel_depth() const { return 24; }
28
29private:
30 explicit Screen(HTML::Window&);
31
32 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
33 virtual void visit_edges(Cell::Visitor&) override;
34
35 HTML::Window const& window() const { return *m_window; }
36
37 Gfx::IntRect screen_rect() const;
38
39 JS::NonnullGCPtr<HTML::Window> m_window;
40};
41
42}