2021-04-04 01:14:39 +03:00
|
|
|
/*
|
2022-12-14 20:40:33 +03:00
|
|
|
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
2021-04-04 01:14:39 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-04 01:14:39 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibGfx/Rect.h>
|
2022-09-25 01:34:04 +03:00
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
|
|
|
#include <LibWeb/Bindings/ScreenPrototype.h>
|
2021-04-04 01:14:39 +03:00
|
|
|
#include <LibWeb/CSS/Screen.h>
|
|
|
|
#include <LibWeb/DOM/Document.h>
|
|
|
|
#include <LibWeb/Page/Page.h>
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
2023-11-19 21:47:52 +03:00
|
|
|
JS_DEFINE_ALLOCATOR(Screen);
|
|
|
|
|
2023-08-13 14:05:26 +03:00
|
|
|
JS::NonnullGCPtr<Screen> Screen::create(HTML::Window& window)
|
2022-08-31 19:52:54 +03:00
|
|
|
{
|
2023-08-13 14:05:26 +03:00
|
|
|
return window.heap().allocate<Screen>(window.realm(), window);
|
2022-08-31 19:52:54 +03:00
|
|
|
}
|
|
|
|
|
2022-03-08 01:08:26 +03:00
|
|
|
Screen::Screen(HTML::Window& window)
|
2022-08-31 19:52:54 +03:00
|
|
|
: PlatformObject(window.realm())
|
|
|
|
, m_window(window)
|
|
|
|
{
|
2023-01-10 14:28:20 +03:00
|
|
|
}
|
|
|
|
|
2023-08-07 09:41:28 +03:00
|
|
|
void Screen::initialize(JS::Realm& realm)
|
2023-01-10 14:28:20 +03:00
|
|
|
{
|
2023-08-07 09:41:28 +03:00
|
|
|
Base::initialize(realm);
|
2024-03-16 15:13:08 +03:00
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(Screen);
|
2022-08-31 19:52:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Screen::visit_edges(Cell::Visitor& visitor)
|
2021-04-04 01:14:39 +03:00
|
|
|
{
|
2022-08-31 19:52:54 +03:00
|
|
|
Base::visit_edges(visitor);
|
2023-11-19 06:18:00 +03:00
|
|
|
visitor.visit(m_window);
|
2021-04-04 01:14:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Gfx::IntRect Screen::screen_rect() const
|
|
|
|
{
|
2023-12-15 22:33:16 +03:00
|
|
|
auto screen_rect_in_css_pixels = window().page().web_exposed_screen_area();
|
2022-11-25 20:07:19 +03:00
|
|
|
return {
|
2023-06-12 21:37:35 +03:00
|
|
|
screen_rect_in_css_pixels.x().to_int(),
|
|
|
|
screen_rect_in_css_pixels.y().to_int(),
|
|
|
|
screen_rect_in_css_pixels.width().to_int(),
|
|
|
|
screen_rect_in_css_pixels.height().to_int()
|
2022-11-25 20:07:19 +03:00
|
|
|
};
|
2021-04-04 01:14:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|