2021-04-03 19:14:39 -03:00
|
|
|
/*
|
2021-04-22 17:51:19 -03:00
|
|
|
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
2021-04-03 19:14:39 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-03 19:14:39 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <LibGfx/Rect.h>
|
2022-08-31 13:52:54 -03:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2024-04-05 13:15:43 -03:00
|
|
|
#include <LibWeb/DOM/EventTarget.h>
|
2021-04-03 19:14:39 -03:00
|
|
|
#include <LibWeb/Forward.h>
|
2022-03-07 19:08:26 -03:00
|
|
|
#include <LibWeb/HTML/Window.h>
|
2021-04-03 19:14:39 -03:00
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
2024-04-05 13:15:43 -03:00
|
|
|
class Screen final : public DOM::EventTarget {
|
|
|
|
|
WEB_PLATFORM_OBJECT(Screen, DOM::EventTarget);
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_DECLARE_ALLOCATOR(Screen);
|
2021-04-03 19:14:39 -03:00
|
|
|
|
|
|
|
|
public:
|
2024-11-14 12:01:23 -03:00
|
|
|
[[nodiscard]] static GC::Ref<Screen> create(HTML::Window&);
|
2021-04-03 19:14:39 -03: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; }
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ref<ScreenOrientation> orientation();
|
2021-04-03 19:14:39 -03:00
|
|
|
|
2024-04-05 13:15:43 -03:00
|
|
|
bool is_extended() const;
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
void set_onchange(GC::Ptr<WebIDL::CallbackType> event_handler);
|
|
|
|
|
GC::Ptr<WebIDL::CallbackType> onchange();
|
2024-04-05 13:15:43 -03:00
|
|
|
|
2021-04-03 19:14:39 -03:00
|
|
|
private:
|
2022-03-07 19:08:26 -03:00
|
|
|
explicit Screen(HTML::Window&);
|
2021-04-03 19:14:39 -03:00
|
|
|
|
2023-08-07 03:41:28 -03:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-08-31 13:52:54 -03:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
2022-08-28 08:42:07 -03:00
|
|
|
HTML::Window const& window() const { return *m_window; }
|
2021-04-03 19:14:39 -03:00
|
|
|
|
2021-12-09 11:47:48 -03:00
|
|
|
Gfx::IntRect screen_rect() const;
|
2022-08-28 08:42:07 -03:00
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ref<HTML::Window> m_window;
|
|
|
|
|
GC::Ptr<ScreenOrientation> m_orientation;
|
2021-04-03 19:14:39 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|