Coverage Report

Created: 2026-11-13 08:07

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/CSS/Screen.cpp
Line
Count
Source
1
/*
2
 * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include <LibGfx/Rect.h>
8
#include <LibWeb/Bindings/Intrinsics.h>
9
#include <LibWeb/Bindings/ScreenPrototype.h>
10
#include <LibWeb/CSS/Screen.h>
11
#include <LibWeb/CSS/ScreenOrientation.h>
12
#include <LibWeb/DOM/Document.h>
13
#include <LibWeb/Page/Page.h>
14
15
namespace Web::CSS {
16
17
JS_DEFINE_ALLOCATOR(Screen);
18
19
JS::NonnullGCPtr<Screen> Screen::create(HTML::Window& window)
20
0
{
21
0
    return window.heap().allocate<Screen>(window.realm(), window);
22
0
}
23
24
Screen::Screen(HTML::Window& window)
25
0
    : DOM::EventTarget(window.realm())
26
0
    , m_window(window)
27
0
{
28
0
}
29
30
void Screen::initialize(JS::Realm& realm)
31
0
{
32
0
    Base::initialize(realm);
33
0
    WEB_SET_PROTOTYPE_FOR_INTERFACE(Screen);
34
0
}
35
36
void Screen::visit_edges(Cell::Visitor& visitor)
37
0
{
38
0
    Base::visit_edges(visitor);
39
0
    visitor.visit(m_window);
40
0
    visitor.visit(m_orientation);
41
0
}
42
43
Gfx::IntRect Screen::screen_rect() const
44
0
{
45
0
    auto screen_rect_in_css_pixels = window().page().web_exposed_screen_area();
46
0
    return {
47
0
        screen_rect_in_css_pixels.x().to_int(),
48
0
        screen_rect_in_css_pixels.y().to_int(),
49
0
        screen_rect_in_css_pixels.width().to_int(),
50
0
        screen_rect_in_css_pixels.height().to_int()
51
0
    };
52
0
}
53
54
JS::NonnullGCPtr<ScreenOrientation> Screen::orientation()
55
0
{
56
0
    if (!m_orientation)
57
0
        m_orientation = ScreenOrientation::create(realm());
58
0
    return *m_orientation;
59
0
}
60
61
// https://w3c.github.io/window-management/#dom-screen-isextended
62
bool Screen::is_extended() const
63
0
{
64
0
    dbgln("FIXME: Unimplemented Screen::is_extended");
65
0
    return false;
66
0
}
67
68
// https://w3c.github.io/window-management/#dom-screen-onchange
69
void Screen::set_onchange(JS::GCPtr<WebIDL::CallbackType> event_handler)
70
0
{
71
0
    set_event_handler_attribute(HTML::EventNames::change, event_handler);
72
0
}
73
74
// https://w3c.github.io/window-management/#dom-screen-onchange
75
JS::GCPtr<WebIDL::CallbackType> Screen::onchange()
76
0
{
77
0
    return event_handler_attribute(HTML::EventNames::change);
78
0
}
79
80
}