1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:37:36 +00:00

LibWeb: Implement PerformanceObserver

This commit is contained in:
Luke Wilde 2023-08-25 01:26:47 +01:00 committed by Andreas Kling
parent 5055883b9f
commit af2886449a
22 changed files with 793 additions and 57 deletions

View file

@ -0,0 +1,38 @@
/*
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Bindings/PlatformObject.h>
namespace Web::PerformanceTimeline {
// https://w3c.github.io/performance-timeline/#performanceobserverentrylist-interface
class PerformanceObserverEntryList final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(PerformanceObserverEntryList, Bindings::PlatformObject);
public:
virtual ~PerformanceObserverEntryList() override;
WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> get_entries() const;
WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> get_entries_by_type(String const& type) const;
WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> get_entries_by_name(String const& name, Optional<String> type) const;
private:
PerformanceObserverEntryList(JS::Realm&, Vector<JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry>>&&);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
// https://w3c.github.io/performance-timeline/#dfn-entry-list
// Returns a PerformanceEntryList object returned by filter buffer by name and type algorithm with this's entry list,
// name and type set to null.
Vector<JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry>> m_entry_list;
};
ErrorOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> filter_buffer_by_name_and_type(Vector<JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry>> const& buffer, Optional<String> name, Optional<String> type);
}