mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 12:49:19 +00:00
LibWeb: Implement Resource Timing
This commit is contained in:
parent
23c84e62a5
commit
6d1f78198d
Notes:
github-actions[bot]
2025-03-06 16:01:58 +00:00
Author: https://github.com/Lubrsi
Commit: 6d1f78198d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3704
Reviewed-by: https://github.com/ADKaster ✅
21 changed files with 741 additions and 14 deletions
|
@ -17,6 +17,7 @@
|
|||
#include <LibWeb/NavigationTiming/PerformanceNavigation.h>
|
||||
#include <LibWeb/NavigationTiming/PerformanceTiming.h>
|
||||
#include <LibWeb/PerformanceTimeline/EntryTypes.h>
|
||||
#include <LibWeb/PerformanceTimeline/EventNames.h>
|
||||
|
||||
namespace Web::HighResolutionTime {
|
||||
|
||||
|
@ -330,6 +331,35 @@ void Performance::clear_measures(Optional<String> measure_name)
|
|||
// 3. Return undefined.
|
||||
}
|
||||
|
||||
// https://w3c.github.io/resource-timing/#dom-performance-clearresourcetimings
|
||||
void Performance::clear_resource_timings()
|
||||
{
|
||||
// 1. Remove all PerformanceResourceTiming objects in the performance entry buffer.
|
||||
// 2. Set resource timing buffer current size to 0.
|
||||
window_or_worker().clear_performance_entry_buffer({}, PerformanceTimeline::EntryTypes::resource);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/resource-timing/#dom-performance-setresourcetimingbuffersize
|
||||
void Performance::set_resource_timing_buffer_size(u32 max_size)
|
||||
{
|
||||
// 1. Set resource timing buffer size limit to the maxSize parameter. If the maxSize parameter is less than
|
||||
// resource timing buffer current size, no PerformanceResourceTiming objects are to be removed from the
|
||||
// performance entry buffer.
|
||||
window_or_worker().set_resource_timing_buffer_size_limit({}, max_size);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/resource-timing/#dom-performance-onresourcetimingbufferfull
|
||||
void Performance::set_onresourcetimingbufferfull(WebIDL::CallbackType* event_handler)
|
||||
{
|
||||
set_event_handler_attribute(PerformanceTimeline::EventNames::resourcetimingbufferfull, event_handler);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/resource-timing/#dom-performance-onresourcetimingbufferfull
|
||||
WebIDL::CallbackType* Performance::onresourcetimingbufferfull()
|
||||
{
|
||||
return event_handler_attribute(PerformanceTimeline::EventNames::resourcetimingbufferfull);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/performance-timeline/#getentries-method
|
||||
WebIDL::ExceptionOr<Vector<GC::Root<PerformanceTimeline::PerformanceEntry>>> Performance::get_entries() const
|
||||
{
|
||||
|
|
|
@ -30,6 +30,11 @@ public:
|
|||
WebIDL::ExceptionOr<GC::Ref<UserTiming::PerformanceMeasure>> measure(String const& measure_name, Variant<String, UserTiming::PerformanceMeasureOptions> const& start_or_measure_options, Optional<String> end_mark);
|
||||
void clear_measures(Optional<String> measure_name);
|
||||
|
||||
void clear_resource_timings();
|
||||
void set_resource_timing_buffer_size(u32 max_size);
|
||||
void set_onresourcetimingbufferfull(WebIDL::CallbackType*);
|
||||
WebIDL::CallbackType* onresourcetimingbufferfull();
|
||||
|
||||
WebIDL::ExceptionOr<Vector<GC::Root<PerformanceTimeline::PerformanceEntry>>> get_entries() const;
|
||||
WebIDL::ExceptionOr<Vector<GC::Root<PerformanceTimeline::PerformanceEntry>>> get_entries_by_type(String const& type) const;
|
||||
WebIDL::ExceptionOr<Vector<GC::Root<PerformanceTimeline::PerformanceEntry>>> get_entries_by_name(String const& name, Optional<String> type) const;
|
||||
|
|
|
@ -23,6 +23,12 @@ interface Performance : EventTarget {
|
|||
PerformanceMeasure measure(DOMString measureName, optional (DOMString or PerformanceMeasureOptions) startOrMeasureOptions = {}, optional DOMString endMark);
|
||||
undefined clearMeasures(optional DOMString measureName);
|
||||
|
||||
// https://w3c.github.io/resource-timing/#sec-extensions-performance-interface
|
||||
// "Resource Timing" extensions to the Performance interface
|
||||
undefined clearResourceTimings();
|
||||
undefined setResourceTimingBufferSize(unsigned long maxSize);
|
||||
attribute EventHandler onresourcetimingbufferfull;
|
||||
|
||||
// https://www.w3.org/TR/performance-timeline/#extensions-to-the-performance-interface
|
||||
// "Performance Timeline" extensions to the Performance interface
|
||||
PerformanceEntryList getEntries();
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
namespace Web::HighResolutionTime {
|
||||
|
||||
// Please keep these in alphabetical order based on the entry type :^)
|
||||
#define ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES \
|
||||
__ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES(PerformanceTimeline::EntryTypes::mark, UserTiming::PerformanceMark) \
|
||||
__ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES(PerformanceTimeline::EntryTypes::measure, UserTiming::PerformanceMeasure)
|
||||
#define ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES \
|
||||
__ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES(PerformanceTimeline::EntryTypes::mark, UserTiming::PerformanceMark) \
|
||||
__ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES(PerformanceTimeline::EntryTypes::measure, UserTiming::PerformanceMeasure) \
|
||||
__ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES(PerformanceTimeline::EntryTypes::resource, ResourceTiming::PerformanceResourceTiming)
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue