/* * Copyright (c) 2021-2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include namespace Web::CSS { WebIDL::ExceptionOr> Screen::create(HTML::Window& window) { return MUST_OR_THROW_OOM(window.heap().allocate(window.realm(), window)); } Screen::Screen(HTML::Window& window) : PlatformObject(window.realm()) , m_window(window) { } JS::ThrowCompletionOr Screen::initialize(JS::Realm& realm) { MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype(realm, "Screen")); return {}; } void Screen::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(m_window.ptr()); } Gfx::IntRect Screen::screen_rect() const { 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() }; } }