diff options
author | Andreas Kling <kling@serenityos.org> | 2022-09-03 18:38:47 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-09-06 00:27:09 +0200 |
commit | 8341f142ea31c92170f1edce7a1e3f4146547b7b (patch) | |
tree | 912158904d1fb6d337ca464f59e0d91a44c566e4 /Userland | |
parent | 6f433c86564c24d47d520cb5bdcc2209d724ac96 (diff) | |
download | serenity-8341f142ea31c92170f1edce7a1e3f4146547b7b.zip |
LibWeb: Add HTML::Window::cached_web_prototype()
This is a simpler version of ensure_web_prototype<T>(). This new version
assumes that we already have a cached instance of the prototype.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Window.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Window.h | 2 |
2 files changed, 12 insertions, 0 deletions
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<typename T> JS::Object& ensure_web_prototype(String const& class_name) { |