Files
ladybird/Libraries/LibWeb/EventTiming/PerformanceEventTiming.h
Aliaksandr Kalenik 30e4779acb AK+LibWeb: Reduce recompilation impact of DOM/Node.h
Remove includes from Node.h that are only needed for forward
declarations (AccessibilityTreeNode.h, XMLSerializer.h,
JsonObjectSerializer.h). Extract StyleInvalidationReason and
FragmentSerializationMode enums into standalone lightweight
headers so downstream headers (CSSStyleSheet.h, CSSStyleProperties.h,
HTMLParser.h) can include just the enum they need instead of all of
Node.h. Replace Node.h with forward declarations in headers that only
use Node by pointer/reference.

This breaks the circular dependency between Node.h and
AccessibilityTreeNode.h, reducing AccessibilityTreeNode.h's
recompilation footprint from ~1399 to ~25 files.
2026-02-11 20:02:28 +01:00

68 lines
2.9 KiB
C++

/*
* Copyright (c) 2024, Noah Bright <noah.bright.1@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Forward.h>
#include <LibWeb/PerformanceTimeline/PerformanceEntry.h>
namespace Web::EventTiming {
// https://www.w3.org/TR/event-timing/#sec-performance-event-timing
class PerformanceEventTiming final : public PerformanceTimeline::PerformanceEntry {
WEB_PLATFORM_OBJECT(PerformanceEventTiming, PerformanceTimeline::PerformanceEntry);
GC_DECLARE_ALLOCATOR(PerformanceEventTiming);
public:
virtual ~PerformanceEventTiming();
HighResolutionTime::DOMHighResTimeStamp processing_start() const;
HighResolutionTime::DOMHighResTimeStamp processing_end() const;
bool cancelable() const;
JS::ThrowCompletionOr<GC::Ptr<DOM::Node>> target();
unsigned long long interaction_id();
// from the registry:
// https://w3c.github.io/timing-entrytypes-registry/#dfn-availablefromtimeline
static PerformanceTimeline::AvailableFromTimeline available_from_timeline();
// https://w3c.github.io/timing-entrytypes-registry/#dfn-maxbuffersize
static Optional<u64> max_buffer_size();
// https://w3c.github.io/timing-entrytypes-registry/#dfn-should-add-entry
virtual PerformanceTimeline::ShouldAddEntry should_add_entry(Optional<PerformanceTimeline::PerformanceObserverInit const&> = {}) const override;
virtual FlyString const& entry_type() const override;
private:
PerformanceEventTiming(JS::Realm& realm, String const& name, HighResolutionTime::DOMHighResTimeStamp start_time, HighResolutionTime::DOMHighResTimeStamp duration,
DOM::Event const& event, HighResolutionTime::DOMHighResTimeStamp processing_start, unsigned long long interaction_id);
// m_entry_type defined here for both "event"s and "first-input"s
// this is the only PerformanceEntry that has two event types it could represent
// That complicates implementing the registry functions if they remain static
FlyString m_entry_type;
GC::Ptr<DOM::EventTarget> m_event_target;
HighResolutionTime::DOMHighResTimeStamp m_start_time;
HighResolutionTime::DOMHighResTimeStamp m_processing_start;
bool m_cancelable;
unsigned long long m_interaction_id;
static WebIDL::ExceptionOr<GC::Ref<PerformanceEventTiming>> construct_impl(DOM::Event const&, HighResolutionTime::DOMHighResTimeStamp, unsigned long long);
virtual void initialize(JS::Realm&) override;
PerformanceTimeline::ShouldAddEntry should_add_performance_event_timing() const;
virtual void visit_edges(JS::Cell::Visitor&) override;
// FIXME: remaining algorithms described in this spec:
// https://www.w3.org/TR/event-timing/#sec-increasing-interaction-count
// https://www.w3.org/TR/event-timing/#sec-computing-interactionid
// https://www.w3.org/TR/event-timing/#sec-fin-event-timing
// https://www.w3.org/TR/event-timing/#sec-dispatch-pending
};
}