From 8341f142ea31c92170f1edce7a1e3f4146547b7b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 3 Sep 2022 18:38:47 +0200 Subject: LibWeb: Add HTML::Window::cached_web_prototype() This is a simpler version of ensure_web_prototype(). This new version assumes that we already have a cached instance of the prototype. --- Userland/Libraries/LibWeb/HTML/Window.cpp | 10 ++++++++++ Userland/Libraries/LibWeb/HTML/Window.h | 2 ++ 2 files changed, 12 insertions(+) (limited to 'Userland') diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index fd8b068f32..6907e41210 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -123,6 +123,16 @@ void Window::visit_edges(JS::Cell::Visitor& visitor) Window::~Window() = default; +JS::Object& Window::cached_web_prototype(String const& class_name) +{ + auto it = m_prototypes.find(class_name); + if (it == m_prototypes.end()) { + dbgln("Missing prototype: {}", class_name); + } + VERIFY(it != m_prototypes.end()); + return *it->value; +} + HighResolutionTime::Performance& Window::performance() { if (!m_performance) diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index 736bfdf5fd..00a33f37a2 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -169,6 +169,8 @@ public: JS::Object* web_prototype(String const& class_name) { return m_prototypes.get(class_name).value_or(nullptr); } JS::NativeFunction* web_constructor(String const& class_name) { return m_constructors.get(class_name).value_or(nullptr); } + JS::Object& cached_web_prototype(String const& class_name); + template JS::Object& ensure_web_prototype(String const& class_name) { -- cgit v1.2.3