1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-28 07:32:12 +00:00
serenity/Userland/Libraries/LibWeb/CSS/Screen.h
Andreas Kling 6f433c8656 LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.

There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
2022-09-06 00:27:09 +02:00

47 lines
1.1 KiB
C++

/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/RefCountForwarder.h>
#include <LibGfx/Rect.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/Window.h>
namespace Web::CSS {
class Screen final
: public RefCounted<Screen>
, public Bindings::Wrappable {
public:
using WrapperType = Bindings::ScreenWrapper;
using AllowOwnPtr = TrueType;
static NonnullOwnPtr<Screen> create(Badge<HTML::Window>, HTML::Window& window)
{
return adopt_own(*new Screen(window));
}
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; }
private:
explicit Screen(HTML::Window&);
HTML::Window const& window() const { return *m_window; }
Gfx::IntRect screen_rect() const;
JS::Handle<HTML::Window> m_window;
};
}