mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-07 01:56:38 +00:00
LibWeb: Implement PerformanceObserver.supportedEntryTypes
This commit is contained in:
parent
316814988f
commit
facece1a2a
Notes:
sideshowbarker
2024-07-17 23:00:03 +09:00
Author: https://github.com/Lubrsi
Commit: facece1a2a
Pull-request: https://github.com/SerenityOS/serenity/pull/23794
7 changed files with 71 additions and 1 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <AK/Utf8View.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibJS/Heap/HeapFunction.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibTextCodec/Decoder.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/Fetch/FetchMethod.h>
|
||||
|
@ -59,6 +60,7 @@ void WindowOrWorkerGlobalScopeMixin::initialize(JS::Realm&)
|
|||
void WindowOrWorkerGlobalScopeMixin::visit_edges(JS::Cell::Visitor& visitor)
|
||||
{
|
||||
visitor.visit(m_performance);
|
||||
visitor.visit(m_supported_entry_types_array);
|
||||
for (auto& it : m_timers)
|
||||
visitor.visit(it.value);
|
||||
for (auto& observer : m_registered_performance_observer_objects)
|
||||
|
@ -595,4 +597,28 @@ JS::NonnullGCPtr<HighResolutionTime::Performance> WindowOrWorkerGlobalScopeMixin
|
|||
return JS::NonnullGCPtr { *m_performance };
|
||||
}
|
||||
|
||||
// https://w3c.github.io/performance-timeline/#dfn-frozen-array-of-supported-entry-types
|
||||
JS::NonnullGCPtr<JS::Object> WindowOrWorkerGlobalScopeMixin::supported_entry_types() const
|
||||
{
|
||||
// Each global object has an associated frozen array of supported entry types, which is initialized to the
|
||||
// FrozenArray created from the sequence of strings among the registry that are supported for the global
|
||||
// object, in alphabetical order.
|
||||
auto& vm = this_impl().vm();
|
||||
auto& realm = this_impl().realm();
|
||||
|
||||
if (!m_supported_entry_types_array) {
|
||||
Vector<JS::Value> supported_entry_types;
|
||||
|
||||
#define __ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES(entry_type, cpp_class) \
|
||||
supported_entry_types.append(JS::PrimitiveString::create(vm, entry_type));
|
||||
ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES
|
||||
#undef __ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES
|
||||
|
||||
m_supported_entry_types_array = JS::Array::create_from(realm, supported_entry_types);
|
||||
MUST(m_supported_entry_types_array->set_integrity_level(JS::Object::IntegrityLevel::Frozen));
|
||||
}
|
||||
|
||||
return *m_supported_entry_types_array;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,6 +65,8 @@ public:
|
|||
|
||||
[[nodiscard]] JS::NonnullGCPtr<HighResolutionTime::Performance> performance();
|
||||
|
||||
JS::NonnullGCPtr<JS::Object> supported_entry_types() const;
|
||||
|
||||
protected:
|
||||
void initialize(JS::Realm&);
|
||||
void visit_edges(JS::Cell::Visitor&);
|
||||
|
@ -95,6 +97,8 @@ private:
|
|||
OrderedHashMap<FlyString, PerformanceTimeline::PerformanceEntryTuple> m_performance_entry_buffer_map;
|
||||
|
||||
JS::GCPtr<HighResolutionTime::Performance> m_performance;
|
||||
|
||||
mutable JS::GCPtr<JS::Object> m_supported_entry_types_array;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue