mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 21:59:07 +00:00
LibWeb: Allow the Performance object to be used by workers
This commit is contained in:
parent
adf061a29c
commit
eebdc7bc88
Notes:
sideshowbarker
2024-07-17 16:42:19 +09:00
Author: https://github.com/tcl3
Commit: eebdc7bc88
Pull-request: https://github.com/SerenityOS/serenity/pull/23771
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/kalenikaliaksandr
Reviewed-by: https://github.com/shannonbooth
15 changed files with 49 additions and 32 deletions
|
@ -20,9 +20,9 @@ namespace Web::HighResolutionTime {
|
|||
|
||||
JS_DEFINE_ALLOCATOR(Performance);
|
||||
|
||||
Performance::Performance(HTML::Window& window)
|
||||
: DOM::EventTarget(window.realm())
|
||||
, m_window(window)
|
||||
Performance::Performance(HTML::WindowOrWorkerGlobalScopeMixin& window_or_worker)
|
||||
: DOM::EventTarget(window_or_worker.this_impl().realm())
|
||||
, m_window_or_worker(window_or_worker)
|
||||
, m_timer(Core::TimerType::Precise)
|
||||
{
|
||||
m_timer.start();
|
||||
|
@ -39,14 +39,14 @@ void Performance::initialize(JS::Realm& realm)
|
|||
void Performance::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_window);
|
||||
visitor.visit(m_timing);
|
||||
visitor.visit(m_window_or_worker->this_impl());
|
||||
}
|
||||
|
||||
JS::GCPtr<NavigationTiming::PerformanceTiming> Performance::timing()
|
||||
{
|
||||
if (!m_timing)
|
||||
m_timing = heap().allocate<NavigationTiming::PerformanceTiming>(realm(), *m_window);
|
||||
m_timing = heap().allocate<NavigationTiming::PerformanceTiming>(realm(), *m_window_or_worker);
|
||||
return m_timing;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <LibCore/ElapsedTimer.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
#include <LibWeb/HTML/WindowOrWorkerGlobalScope.h>
|
||||
#include <LibWeb/UserTiming/PerformanceMark.h>
|
||||
#include <LibWeb/UserTiming/PerformanceMeasure.h>
|
||||
|
||||
|
@ -36,7 +37,7 @@ public:
|
|||
WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> get_entries_by_name(String const& name, Optional<String> type) const;
|
||||
|
||||
private:
|
||||
explicit Performance(HTML::Window&);
|
||||
explicit Performance(HTML::WindowOrWorkerGlobalScopeMixin&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
@ -44,7 +45,7 @@ private:
|
|||
WebIDL::ExceptionOr<HighResolutionTime::DOMHighResTimeStamp> convert_name_to_timestamp(JS::Realm& realm, String const& name);
|
||||
WebIDL::ExceptionOr<HighResolutionTime::DOMHighResTimeStamp> convert_mark_to_timestamp(JS::Realm& realm, Variant<String, HighResolutionTime::DOMHighResTimeStamp> mark);
|
||||
|
||||
JS::NonnullGCPtr<HTML::Window> m_window;
|
||||
JS::NonnullGCPtr<HTML::WindowOrWorkerGlobalScopeMixin> m_window_or_worker;
|
||||
JS::GCPtr<NavigationTiming::PerformanceTiming> m_timing;
|
||||
|
||||
Core::ElapsedTimer m_timer;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue