mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
LibWeb: Add stub implementation of performance.navigation
This commit is contained in:
parent
cca03e484b
commit
14267b5d63
Notes:
github-actions[bot]
2024-08-04 08:39:27 +00:00
Author: https://github.com/vpzomtrrfrt Commit: https://github.com/LadybirdBrowser/ladybird/commit/14267b5d631 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/948
@ -74,6 +74,7 @@ static bool is_platform_object(Type const& type)
|
||||
"Path2D"sv,
|
||||
"PerformanceEntry"sv,
|
||||
"PerformanceMark"sv,
|
||||
"PerformanceNavigation"sv,
|
||||
"PeriodicWave"sv,
|
||||
"PointerEvent"sv,
|
||||
"ReadableStreamBYOBReader"sv,
|
||||
|
@ -237,6 +237,7 @@ Performance
|
||||
PerformanceEntry
|
||||
PerformanceMark
|
||||
PerformanceMeasure
|
||||
PerformanceNavigation
|
||||
PerformanceObserver
|
||||
PerformanceObserverEntryList
|
||||
PerformanceTiming
|
||||
|
3
Tests/LibWeb/Text/expected/performance-navigation.txt
Normal file
3
Tests/LibWeb/Text/expected/performance-navigation.txt
Normal file
@ -0,0 +1,3 @@
|
||||
0
|
||||
0
|
||||
true
|
8
Tests/LibWeb/Text/input/performance-navigation.html
Normal file
8
Tests/LibWeb/Text/input/performance-navigation.html
Normal file
@ -0,0 +1,8 @@
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
println(performance.navigation.type);
|
||||
println(performance.navigation.redirectCount);
|
||||
println(performance.navigation === performance.navigation);
|
||||
});
|
||||
</script>
|
@ -538,6 +538,7 @@ set(SOURCES
|
||||
MixedContent/AbstractOperations.cpp
|
||||
Namespace.cpp
|
||||
NavigationTiming/EntryNames.cpp
|
||||
NavigationTiming/PerformanceNavigation.cpp
|
||||
NavigationTiming/PerformanceTiming.cpp
|
||||
Page/EditEventHandler.cpp
|
||||
Page/EventHandler.cpp
|
||||
|
@ -582,6 +582,7 @@ class MimeType;
|
||||
}
|
||||
|
||||
namespace Web::NavigationTiming {
|
||||
class PerformanceNavigation;
|
||||
class PerformanceTiming;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <LibWeb/HighResolutionTime/Performance.h>
|
||||
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
|
||||
#include <LibWeb/NavigationTiming/EntryNames.h>
|
||||
#include <LibWeb/NavigationTiming/PerformanceNavigation.h>
|
||||
#include <LibWeb/NavigationTiming/PerformanceTiming.h>
|
||||
#include <LibWeb/PerformanceTimeline/EntryTypes.h>
|
||||
|
||||
@ -50,6 +51,19 @@ JS::GCPtr<NavigationTiming::PerformanceTiming> Performance::timing()
|
||||
return m_timing;
|
||||
}
|
||||
|
||||
JS::GCPtr<NavigationTiming::PerformanceNavigation> Performance::navigation()
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
if (!m_navigation) {
|
||||
// FIXME actually determine values for these
|
||||
u16 type = 0;
|
||||
u16 redirect_count = 0;
|
||||
|
||||
m_navigation = heap().allocate<NavigationTiming::PerformanceNavigation>(realm, realm, type, redirect_count);
|
||||
}
|
||||
return m_navigation;
|
||||
}
|
||||
|
||||
double Performance::time_origin() const
|
||||
{
|
||||
return static_cast<double>(m_timer.origin_time().nanoseconds()) / 1e6;
|
||||
|
@ -25,8 +25,6 @@ public:
|
||||
double now() const { return static_cast<double>(m_timer.elapsed_time().to_nanoseconds()) / 1e6; }
|
||||
double time_origin() const;
|
||||
|
||||
JS::GCPtr<NavigationTiming::PerformanceTiming> timing();
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<UserTiming::PerformanceMark>> mark(String const& mark_name, UserTiming::PerformanceMarkOptions const& mark_options = {});
|
||||
void clear_marks(Optional<String> mark_name);
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<UserTiming::PerformanceMeasure>> measure(String const& measure_name, Variant<String, UserTiming::PerformanceMeasureOptions> const& start_or_measure_options, Optional<String> end_mark);
|
||||
@ -36,6 +34,9 @@ public:
|
||||
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;
|
||||
|
||||
JS::GCPtr<NavigationTiming::PerformanceTiming> timing();
|
||||
JS::GCPtr<NavigationTiming::PerformanceNavigation> navigation();
|
||||
|
||||
private:
|
||||
explicit Performance(JS::Realm&);
|
||||
|
||||
@ -48,6 +49,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::GCPtr<NavigationTiming::PerformanceNavigation> m_navigation;
|
||||
JS::GCPtr<NavigationTiming::PerformanceTiming> m_timing;
|
||||
|
||||
Core::ElapsedTimer m_timer;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#import <DOM/EventTarget.idl>
|
||||
#import <HighResolutionTime/DOMHighResTimeStamp.idl>
|
||||
#import <NavigationTiming/PerformanceNavigation.idl>
|
||||
#import <NavigationTiming/PerformanceTiming.idl>
|
||||
#import <PerformanceTimeline/PerformanceEntry.idl>
|
||||
#import <UserTiming/PerformanceMark.idl>
|
||||
@ -15,8 +16,6 @@ interface Performance : EventTarget {
|
||||
readonly attribute DOMHighResTimeStamp timeOrigin;
|
||||
[Default] object toJSON();
|
||||
|
||||
readonly attribute PerformanceTiming timing;
|
||||
|
||||
// https://w3c.github.io/user-timing/#extensions-performance-interface
|
||||
// "User Timing" extensions to the Performance interface
|
||||
PerformanceMark mark(DOMString markName, optional PerformanceMarkOptions markOptions = {});
|
||||
@ -29,4 +28,11 @@ interface Performance : EventTarget {
|
||||
PerformanceEntryList getEntries();
|
||||
PerformanceEntryList getEntriesByType(DOMString type);
|
||||
PerformanceEntryList getEntriesByName(DOMString name, optional DOMString type);
|
||||
|
||||
// https://w3c.github.io/navigation-timing/#extensions-to-the-performance-interface
|
||||
// Obsolete "Navigation Timing" extensions to the Performance interface
|
||||
[SameObject]
|
||||
readonly attribute PerformanceTiming timing;
|
||||
[SameObject]
|
||||
readonly attribute PerformanceNavigation navigation;
|
||||
};
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2024, Colin Reeder <colin@vpzom.click>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/PerformanceNavigationPrototype.h>
|
||||
#include <LibWeb/NavigationTiming/PerformanceNavigation.h>
|
||||
|
||||
namespace Web::NavigationTiming {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(PerformanceNavigation);
|
||||
|
||||
PerformanceNavigation::PerformanceNavigation(JS::Realm& realm, u16 type, u16 redirect_count)
|
||||
: PlatformObject(realm)
|
||||
, m_type(type)
|
||||
, m_redirect_count(redirect_count)
|
||||
{
|
||||
}
|
||||
PerformanceNavigation::~PerformanceNavigation() = default;
|
||||
|
||||
void PerformanceNavigation::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(PerformanceNavigation);
|
||||
}
|
||||
|
||||
u16 PerformanceNavigation::type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
u16 PerformanceNavigation::redirect_count() const
|
||||
{
|
||||
return m_redirect_count;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2024, Colin Reeder <colin@vpzom.click>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
|
||||
namespace Web::NavigationTiming {
|
||||
|
||||
class PerformanceNavigation final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(PerformanceNavigation, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(PerformanceNavigation);
|
||||
|
||||
public:
|
||||
~PerformanceNavigation();
|
||||
|
||||
u16 type() const;
|
||||
u16 redirect_count() const;
|
||||
|
||||
private:
|
||||
explicit PerformanceNavigation(JS::Realm&, u16 type, u16 redirect_count);
|
||||
|
||||
void initialize(JS::Realm&) override;
|
||||
|
||||
u16 m_type;
|
||||
u16 m_redirect_count;
|
||||
};
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
[Exposed=Window]
|
||||
interface PerformanceNavigation {
|
||||
const unsigned short TYPE_NAVIGATE = 0;
|
||||
const unsigned short TYPE_RELOAD = 1;
|
||||
const unsigned short TYPE_BACK_FORWARD = 2;
|
||||
const unsigned short TYPE_RESERVED = 255;
|
||||
readonly attribute unsigned short type;
|
||||
readonly attribute unsigned short redirectCount;
|
||||
[Default] object toJSON();
|
||||
};
|
@ -236,6 +236,7 @@ libweb_js_bindings(Internals/Internals)
|
||||
libweb_js_bindings(IntersectionObserver/IntersectionObserver)
|
||||
libweb_js_bindings(IntersectionObserver/IntersectionObserverEntry)
|
||||
libweb_js_bindings(MathML/MathMLElement)
|
||||
libweb_js_bindings(NavigationTiming/PerformanceNavigation)
|
||||
libweb_js_bindings(NavigationTiming/PerformanceTiming)
|
||||
libweb_js_bindings(PerformanceTimeline/PerformanceEntry)
|
||||
libweb_js_bindings(PerformanceTimeline/PerformanceObserver)
|
||||
|
Loading…
Reference in New Issue
Block a user