2021-04-04 00:14:39 +02:00
|
|
|
/*
|
2021-04-22 22:51:19 +02:00
|
|
|
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
2021-04-04 00:14:39 +02:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-04 00:14:39 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-12-09 15:47:48 +01:00
|
|
|
#include <AK/RefCountForwarder.h>
|
2021-04-04 00:14:39 +02:00
|
|
|
#include <LibGfx/Rect.h>
|
|
|
|
#include <LibWeb/Bindings/Wrappable.h>
|
|
|
|
#include <LibWeb/Forward.h>
|
2022-03-07 23:08:26 +01:00
|
|
|
#include <LibWeb/HTML/Window.h>
|
2021-04-04 00:14:39 +02:00
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
|
|
class Screen final
|
2022-08-28 13:42:07 +02:00
|
|
|
: public RefCounted<Screen>
|
2021-04-04 00:14:39 +02:00
|
|
|
, public Bindings::Wrappable {
|
|
|
|
|
|
|
|
public:
|
|
|
|
using WrapperType = Bindings::ScreenWrapper;
|
2021-12-09 15:47:48 +01:00
|
|
|
using AllowOwnPtr = TrueType;
|
2021-04-04 00:14:39 +02:00
|
|
|
|
2022-03-07 23:08:26 +01:00
|
|
|
static NonnullOwnPtr<Screen> create(Badge<HTML::Window>, HTML::Window& window)
|
2021-04-04 00:14:39 +02:00
|
|
|
{
|
2021-12-09 15:47:48 +01:00
|
|
|
return adopt_own(*new Screen(window));
|
2021-04-04 00:14:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
i32 width() const { return screen_rect().width(); }
|
|
|
|
i32 height() const { return screen_rect().height(); }
|
|
|
|
i32 avail_width() const { return screen_rect().width(); }
|
|
|
|
i32 avail_height() const { return screen_rect().height(); }
|
|
|
|
u32 color_depth() const { return 24; }
|
|
|
|
u32 pixel_depth() const { return 24; }
|
|
|
|
|
|
|
|
private:
|
2022-03-07 23:08:26 +01:00
|
|
|
explicit Screen(HTML::Window&);
|
2021-04-04 00:14:39 +02:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
HTML::Window const& window() const { return *m_window; }
|
2021-04-04 00:14:39 +02:00
|
|
|
|
2021-12-09 15:47:48 +01:00
|
|
|
Gfx::IntRect screen_rect() const;
|
2022-08-28 13:42:07 +02:00
|
|
|
|
|
|
|
JS::Handle<HTML::Window> m_window;
|
2021-04-04 00:14:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|