mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-02 17:28:48 +00:00
LibWeb: Use "current high resolution time" AO where relevant
And updating some spec comments to latest spec where it is not relevant.
This commit is contained in:
parent
33bd6cfc2a
commit
51a52a867c
Notes:
sideshowbarker
2024-07-16 23:59:28 +09:00
Author: https://github.com/shannonbooth
Commit: 51a52a867c
Pull-request: https://github.com/SerenityOS/serenity/pull/23935
6 changed files with 13 additions and 17 deletions
|
@ -2148,7 +2148,7 @@ void Document::update_readiness(HTML::DocumentReadyState readiness_value)
|
||||||
// 3. If document is associated with an HTML parser, then:
|
// 3. If document is associated with an HTML parser, then:
|
||||||
if (m_parser) {
|
if (m_parser) {
|
||||||
// 1. Let now be the current high resolution time given document's relevant global object.
|
// 1. Let now be the current high resolution time given document's relevant global object.
|
||||||
auto now = HighResolutionTime::unsafe_shared_current_time();
|
auto now = HighResolutionTime::current_high_resolution_time(relevant_global_object(*this));
|
||||||
|
|
||||||
// 2. If readinessValue is "complete", and document's load timing info's DOM complete time is 0,
|
// 2. If readinessValue is "complete", and document's load timing info's DOM complete time is 0,
|
||||||
// then set document's load timing info's DOM complete time to now.
|
// then set document's load timing info's DOM complete time to now.
|
||||||
|
|
|
@ -179,10 +179,7 @@ void EventLoop::process()
|
||||||
// 1. Let oldestTask be null.
|
// 1. Let oldestTask be null.
|
||||||
JS::GCPtr<Task> oldest_task;
|
JS::GCPtr<Task> oldest_task;
|
||||||
|
|
||||||
// 2. Let taskStartTime be the current high resolution time.
|
// 2. Set taskStartTime to the unsafe shared current time.
|
||||||
// FIXME: 'current high resolution time' in hr-time-3 takes a global object,
|
|
||||||
// the HTML spec has not been updated to reflect this, let's use the shared timer.
|
|
||||||
// - https://github.com/whatwg/html/issues/7776
|
|
||||||
double task_start_time = HighResolutionTime::unsafe_shared_current_time();
|
double task_start_time = HighResolutionTime::unsafe_shared_current_time();
|
||||||
|
|
||||||
// 3. Let taskQueue be one of the event loop's task queues, chosen in an implementation-defined manner,
|
// 3. Let taskQueue be one of the event loop's task queues, chosen in an implementation-defined manner,
|
||||||
|
@ -377,7 +374,7 @@ void EventLoop::process()
|
||||||
// - hasARenderingOpportunity is false
|
// - hasARenderingOpportunity is false
|
||||||
// FIXME: has_a_rendering_opportunity is always true
|
// FIXME: has_a_rendering_opportunity is always true
|
||||||
if (m_type == Type::Window && !task_queue.has_runnable_tasks() && m_microtask_queue->is_empty() /*&& !has_a_rendering_opportunity*/) {
|
if (m_type == Type::Window && !task_queue.has_runnable_tasks() && m_microtask_queue->is_empty() /*&& !has_a_rendering_opportunity*/) {
|
||||||
// 1. Set this event loop's last idle period start time to the current high resolution time.
|
// 1. Set this event loop's last idle period start time to the unsafe shared current time.
|
||||||
m_last_idle_period_start_time = HighResolutionTime::unsafe_shared_current_time();
|
m_last_idle_period_start_time = HighResolutionTime::unsafe_shared_current_time();
|
||||||
|
|
||||||
// 2. Let computeDeadline be the following steps:
|
// 2. Let computeDeadline be the following steps:
|
||||||
|
|
|
@ -293,7 +293,7 @@ void HTMLParser::the_end(JS::NonnullGCPtr<DOM::Document> document, JS::GCPtr<HTM
|
||||||
// 6. Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following substeps:
|
// 6. Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following substeps:
|
||||||
queue_global_task(HTML::Task::Source::DOMManipulation, *document, [document = document] {
|
queue_global_task(HTML::Task::Source::DOMManipulation, *document, [document = document] {
|
||||||
// 1. Set the Document's load timing info's DOM content loaded event start time to the current high resolution time given the Document's relevant global object.
|
// 1. Set the Document's load timing info's DOM content loaded event start time to the current high resolution time given the Document's relevant global object.
|
||||||
document->load_timing_info().dom_content_loaded_event_start_time = HighResolutionTime::unsafe_shared_current_time();
|
document->load_timing_info().dom_content_loaded_event_start_time = HighResolutionTime::current_high_resolution_time(relevant_global_object(*document));
|
||||||
|
|
||||||
// 2. Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true.
|
// 2. Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true.
|
||||||
auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded);
|
auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded);
|
||||||
|
@ -301,7 +301,7 @@ void HTMLParser::the_end(JS::NonnullGCPtr<DOM::Document> document, JS::GCPtr<HTM
|
||||||
document->dispatch_event(content_loaded_event);
|
document->dispatch_event(content_loaded_event);
|
||||||
|
|
||||||
// 3. Set the Document's load timing info's DOM content loaded event end time to the current high resolution time given the Document's relevant global object.
|
// 3. Set the Document's load timing info's DOM content loaded event end time to the current high resolution time given the Document's relevant global object.
|
||||||
document->load_timing_info().dom_content_loaded_event_end_time = HighResolutionTime::unsafe_shared_current_time();
|
document->load_timing_info().dom_content_loaded_event_end_time = HighResolutionTime::current_high_resolution_time(relevant_global_object(*document));
|
||||||
|
|
||||||
// FIXME: 4. Enable the client message queue of the ServiceWorkerContainer object whose associated service worker client is the Document object's relevant settings object.
|
// FIXME: 4. Enable the client message queue of the ServiceWorkerContainer object whose associated service worker client is the Document object's relevant settings object.
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ void HTMLParser::the_end(JS::NonnullGCPtr<DOM::Document> document, JS::GCPtr<HTM
|
||||||
auto& window = verify_cast<Window>(relevant_global_object(*document));
|
auto& window = verify_cast<Window>(relevant_global_object(*document));
|
||||||
|
|
||||||
// 4. Set the Document's load timing info's load event start time to the current high resolution time given window.
|
// 4. Set the Document's load timing info's load event start time to the current high resolution time given window.
|
||||||
document->load_timing_info().load_event_start_time = HighResolutionTime::unsafe_shared_current_time();
|
document->load_timing_info().load_event_start_time = HighResolutionTime::current_high_resolution_time(window);
|
||||||
|
|
||||||
// 5. Fire an event named load at window, with legacy target override flag set.
|
// 5. Fire an event named load at window, with legacy target override flag set.
|
||||||
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
|
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
|
||||||
|
@ -343,7 +343,7 @@ void HTMLParser::the_end(JS::NonnullGCPtr<DOM::Document> document, JS::GCPtr<HTM
|
||||||
// FIXME: 7. Set the Document object's navigation id to null.
|
// FIXME: 7. Set the Document object's navigation id to null.
|
||||||
|
|
||||||
// 8. Set the Document's load timing info's load event end time to the current high resolution time given window.
|
// 8. Set the Document's load timing info's load event end time to the current high resolution time given window.
|
||||||
document->load_timing_info().load_event_end_time = HighResolutionTime::unsafe_shared_current_time();
|
document->load_timing_info().load_event_end_time = HighResolutionTime::current_high_resolution_time(window);
|
||||||
|
|
||||||
// 9. Assert: Document's page showing is false.
|
// 9. Assert: Document's page showing is false.
|
||||||
VERIFY(!document->page_showing());
|
VERIFY(!document->page_showing());
|
||||||
|
|
|
@ -604,8 +604,7 @@ bool Window::has_transient_activation() const
|
||||||
static constexpr HighResolutionTime::DOMHighResTimeStamp transient_activation_duration_ms = 5000;
|
static constexpr HighResolutionTime::DOMHighResTimeStamp transient_activation_duration_ms = 5000;
|
||||||
|
|
||||||
// When the current high resolution time given W
|
// When the current high resolution time given W
|
||||||
auto unsafe_shared_time = HighResolutionTime::unsafe_shared_current_time();
|
auto current_time = HighResolutionTime::current_high_resolution_time(*this);
|
||||||
auto current_time = HighResolutionTime::relative_high_resolution_time(unsafe_shared_time, realm().global_object());
|
|
||||||
|
|
||||||
// is greater than or equal to the last activation timestamp in W
|
// is greater than or equal to the last activation timestamp in W
|
||||||
if (current_time >= m_last_activation_timestamp) {
|
if (current_time >= m_last_activation_timestamp) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ double IdleDeadline::time_remaining() const
|
||||||
{
|
{
|
||||||
auto const& event_loop = HTML::main_thread_event_loop();
|
auto const& event_loop = HTML::main_thread_event_loop();
|
||||||
// 1. Let now be a DOMHighResTimeStamp representing current high resolution time in milliseconds.
|
// 1. Let now be a DOMHighResTimeStamp representing current high resolution time in milliseconds.
|
||||||
auto now = HighResolutionTime::unsafe_shared_current_time();
|
auto now = HighResolutionTime::current_high_resolution_time(global_object());
|
||||||
// 2. Let deadline be the result of calling IdleDeadline's get deadline time algorithm.
|
// 2. Let deadline be the result of calling IdleDeadline's get deadline time algorithm.
|
||||||
auto deadline = event_loop.compute_deadline();
|
auto deadline = event_loop.compute_deadline();
|
||||||
// 3. Let timeRemaining be deadline - now.
|
// 3. Let timeRemaining be deadline - now.
|
||||||
|
|
|
@ -201,7 +201,7 @@ void XMLDocumentBuilder::document_end()
|
||||||
// Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following substeps:
|
// Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following substeps:
|
||||||
queue_global_task(HTML::Task::Source::DOMManipulation, m_document, [document = m_document] {
|
queue_global_task(HTML::Task::Source::DOMManipulation, m_document, [document = m_document] {
|
||||||
// Set the Document's load timing info's DOM content loaded event start time to the current high resolution time given the Document's relevant global object.
|
// Set the Document's load timing info's DOM content loaded event start time to the current high resolution time given the Document's relevant global object.
|
||||||
document->load_timing_info().dom_content_loaded_event_start_time = HighResolutionTime::unsafe_shared_current_time();
|
document->load_timing_info().dom_content_loaded_event_start_time = HighResolutionTime::current_high_resolution_time(relevant_global_object(*document));
|
||||||
|
|
||||||
// Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true.
|
// Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true.
|
||||||
auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded);
|
auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded);
|
||||||
|
@ -209,7 +209,7 @@ void XMLDocumentBuilder::document_end()
|
||||||
document->dispatch_event(content_loaded_event);
|
document->dispatch_event(content_loaded_event);
|
||||||
|
|
||||||
// Set the Document's load timing info's DOM content loaded event end time to the current high resolution time given the Document's relevant global object.
|
// Set the Document's load timing info's DOM content loaded event end time to the current high resolution time given the Document's relevant global object.
|
||||||
document->load_timing_info().dom_content_loaded_event_end_time = HighResolutionTime::unsafe_shared_current_time();
|
document->load_timing_info().dom_content_loaded_event_end_time = HighResolutionTime::current_high_resolution_time(relevant_global_object(*document));
|
||||||
|
|
||||||
// FIXME: Enable the client message queue of the ServiceWorkerContainer object whose associated service worker client is the Document object's relevant settings object.
|
// FIXME: Enable the client message queue of the ServiceWorkerContainer object whose associated service worker client is the Document object's relevant settings object.
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ void XMLDocumentBuilder::document_end()
|
||||||
JS::NonnullGCPtr<HTML::Window> window = verify_cast<HTML::Window>(relevant_global_object(*document));
|
JS::NonnullGCPtr<HTML::Window> window = verify_cast<HTML::Window>(relevant_global_object(*document));
|
||||||
|
|
||||||
// Set the Document's load timing info's load event start time to the current high resolution time given window.
|
// Set the Document's load timing info's load event start time to the current high resolution time given window.
|
||||||
document->load_timing_info().load_event_start_time = HighResolutionTime::unsafe_shared_current_time();
|
document->load_timing_info().load_event_start_time = HighResolutionTime::current_high_resolution_time(window);
|
||||||
|
|
||||||
// Fire an event named load at window, with legacy target override flag set.
|
// Fire an event named load at window, with legacy target override flag set.
|
||||||
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
|
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
|
||||||
|
@ -251,7 +251,7 @@ void XMLDocumentBuilder::document_end()
|
||||||
// FIXME: Set the Document object's navigation id to null.
|
// FIXME: Set the Document object's navigation id to null.
|
||||||
|
|
||||||
// Set the Document's load timing info's load event end time to the current high resolution time given window.
|
// Set the Document's load timing info's load event end time to the current high resolution time given window.
|
||||||
document->load_timing_info().dom_content_loaded_event_end_time = HighResolutionTime::unsafe_shared_current_time();
|
document->load_timing_info().dom_content_loaded_event_end_time = HighResolutionTime::current_high_resolution_time(window);
|
||||||
|
|
||||||
// Assert: Document's page showing is false.
|
// Assert: Document's page showing is false.
|
||||||
VERIFY(!document->page_showing());
|
VERIFY(!document->page_showing());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue