2021-04-03 19:14:39 -03:00
|
|
|
/*
|
2022-12-14 14:40:33 -03:00
|
|
|
* Copyright (c) 2021-2022, 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
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibGfx/Rect.h>
|
2022-09-24 19:34:04 -03:00
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
|
|
|
|
#include <LibWeb/Bindings/ScreenPrototype.h>
|
2021-04-03 19:14:39 -03:00
|
|
|
#include <LibWeb/CSS/Screen.h>
|
|
|
|
|
#include <LibWeb/DOM/Document.h>
|
|
|
|
|
#include <LibWeb/Page/Page.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
2023-02-14 16:07:40 -03:00
|
|
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<Screen>> Screen::create(HTML::Window& window)
|
2022-08-31 13:52:54 -03:00
|
|
|
{
|
2023-02-14 16:07:40 -03:00
|
|
|
return MUST_OR_THROW_OOM(window.heap().allocate<Screen>(window.realm(), window));
|
2022-08-31 13:52:54 -03:00
|
|
|
}
|
|
|
|
|
|
2022-03-07 19:08:26 -03:00
|
|
|
Screen::Screen(HTML::Window& window)
|
2022-08-31 13:52:54 -03:00
|
|
|
: PlatformObject(window.realm())
|
|
|
|
|
, m_window(window)
|
|
|
|
|
{
|
2023-01-10 08:28:20 -03:00
|
|
|
}
|
|
|
|
|
|
2023-01-28 14:33:35 -03:00
|
|
|
JS::ThrowCompletionOr<void> Screen::initialize(JS::Realm& realm)
|
2023-01-10 08:28:20 -03:00
|
|
|
{
|
2023-01-28 14:33:35 -03:00
|
|
|
MUST_OR_THROW_OOM(Base::initialize(realm));
|
2023-01-10 08:28:20 -03:00
|
|
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::ScreenPrototype>(realm, "Screen"));
|
2023-01-28 14:33:35 -03:00
|
|
|
|
|
|
|
|
return {};
|
2022-08-31 13:52:54 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Screen::visit_edges(Cell::Visitor& visitor)
|
2021-04-03 19:14:39 -03:00
|
|
|
{
|
2022-08-31 13:52:54 -03:00
|
|
|
Base::visit_edges(visitor);
|
|
|
|
|
visitor.visit(m_window.ptr());
|
2021-04-03 19:14:39 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gfx::IntRect Screen::screen_rect() const
|
|
|
|
|
{
|
2022-11-25 14:07:19 -03:00
|
|
|
auto screen_rect_in_css_pixels = window().page()->web_exposed_screen_area();
|
|
|
|
|
return {
|
|
|
|
|
screen_rect_in_css_pixels.x().value(),
|
|
|
|
|
screen_rect_in_css_pixels.y().value(),
|
|
|
|
|
screen_rect_in_css_pixels.width().value(),
|
|
|
|
|
screen_rect_in_css_pixels.height().value()
|
|
|
|
|
};
|
2021-04-03 19:14:39 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|