summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibWeb/CSS/Screen.cpp5
-rw-r--r--Userland/Libraries/LibWeb/CSS/Screen.h13
-rw-r--r--Userland/Libraries/LibWeb/DOM/Window.cpp2
-rw-r--r--Userland/Libraries/LibWeb/DOM/Window.h2
4 files changed, 12 insertions, 10 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Screen.cpp b/Userland/Libraries/LibWeb/CSS/Screen.cpp
index 09ddfa1bb3..c4610b7f28 100644
--- a/Userland/Libraries/LibWeb/CSS/Screen.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Screen.cpp
@@ -7,19 +7,18 @@
#include <LibGfx/Rect.h>
#include <LibWeb/CSS/Screen.h>
#include <LibWeb/DOM/Document.h>
-#include <LibWeb/DOM/Window.h>
#include <LibWeb/Page/Page.h>
namespace Web::CSS {
Screen::Screen(DOM::Window& window)
- : m_window(window)
+ : RefCountForwarder(window)
{
}
Gfx::IntRect Screen::screen_rect() const
{
- return m_window.page()->screen_rect();
+ return window().page()->screen_rect();
}
}
diff --git a/Userland/Libraries/LibWeb/CSS/Screen.h b/Userland/Libraries/LibWeb/CSS/Screen.h
index 7ca9b0f6d0..d76a5c0620 100644
--- a/Userland/Libraries/LibWeb/CSS/Screen.h
+++ b/Userland/Libraries/LibWeb/CSS/Screen.h
@@ -6,22 +6,25 @@
#pragma once
+#include <AK/RefCountForwarder.h>
#include <LibGfx/Rect.h>
#include <LibWeb/Bindings/Wrappable.h>
+#include <LibWeb/DOM/Window.h>
#include <LibWeb/Forward.h>
namespace Web::CSS {
class Screen final
- : public RefCounted<Screen>
+ : public RefCountForwarder<DOM::Window>
, public Bindings::Wrappable {
public:
using WrapperType = Bindings::ScreenWrapper;
+ using AllowOwnPtr = TrueType;
- static NonnullRefPtr<Screen> create(DOM::Window& window)
+ static NonnullOwnPtr<Screen> create(Badge<DOM::Window>, DOM::Window& window)
{
- return adopt_ref(*new Screen(window));
+ return adopt_own(*new Screen(window));
}
i32 width() const { return screen_rect().width(); }
@@ -34,9 +37,9 @@ public:
private:
explicit Screen(DOM::Window&);
- Gfx::IntRect screen_rect() const;
+ DOM::Window const& window() const { return ref_count_target(); }
- DOM::Window& m_window;
+ Gfx::IntRect screen_rect() const;
};
}
diff --git a/Userland/Libraries/LibWeb/DOM/Window.cpp b/Userland/Libraries/LibWeb/DOM/Window.cpp
index 67d82dbf58..4453b9bb12 100644
--- a/Userland/Libraries/LibWeb/DOM/Window.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Window.cpp
@@ -111,7 +111,7 @@ Window::Window(Document& document)
, m_associated_document(document)
, m_performance(make<HighResolutionTime::Performance>(*this))
, m_crypto(Crypto::Crypto::create())
- , m_screen(CSS::Screen::create(*this))
+ , m_screen(CSS::Screen::create({}, *this))
{
}
diff --git a/Userland/Libraries/LibWeb/DOM/Window.h b/Userland/Libraries/LibWeb/DOM/Window.h
index 4a118b4498..19394449a2 100644
--- a/Userland/Libraries/LibWeb/DOM/Window.h
+++ b/Userland/Libraries/LibWeb/DOM/Window.h
@@ -114,7 +114,7 @@ private:
NonnullOwnPtr<HighResolutionTime::Performance> m_performance;
NonnullRefPtr<Crypto::Crypto> m_crypto;
- NonnullRefPtr<CSS::Screen> m_screen;
+ NonnullOwnPtr<CSS::Screen> m_screen;
RefPtr<Event> m_current_event;
HashMap<i32, NonnullRefPtr<RequestAnimationFrameCallback>> m_request_animation_frame_callbacks;