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

LibWeb: Start fleshing out update document for history step application

This commit is contained in:
Aliaksandr Kalenik 2023-09-23 22:59:27 +02:00 committed by Andrew Kaster
parent 40cbe9e72b
commit 699ead0939
5 changed files with 62 additions and 14 deletions

View file

@ -3489,4 +3489,37 @@ Painting::ViewportPaintable* Document::paintable()
return static_cast<Painting::ViewportPaintable*>(Node::paintable());
}
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#update-document-for-history-step-application
void Document::update_for_history_step_application(JS::NonnullGCPtr<HTML::SessionHistoryEntry> entry, bool do_not_reactive, size_t script_history_length, size_t script_history_index)
{
// 1. Let documentIsNew be true if document's latest entry is null; otherwise false.
auto document_is_new = !m_latest_entry;
// 2. Let documentsEntryChanged be true if document's latest entry is not entry; otherwise false.
auto documents_entry_changed = m_latest_entry != entry;
// 3. Set document's history object's index to scriptHistoryIndex.
history()->m_index = script_history_index;
// 4. Set document's history object's length to scriptHistoryLength.
history()->m_length = script_history_length;
// 5. If documentsEntryChanged is true, then:
if (documents_entry_changed) {
// FIXME: Implement this.
}
// 6. If documentIsNew is true, then:
if (document_is_new) {
// FIXME: 1. Try to scroll to the fragment for document.
// FIXME: 2. At this point scripts may run for the newly-created document document.
}
// 7. Otherwise, if documentsEntryChanged is false and doNotReactivate is false, then:
if (!documents_entry_changed && !do_not_reactive) {
// FIXME: 1. Assert: entriesForNavigationAPI is given.
// FIXME: 2. Reactivate document given entry and entriesForNavigationAPI.
}
}
}

View file

@ -531,6 +531,8 @@ public:
HTML::SourceSnapshotParams snapshot_source_snapshot_params() const;
void update_for_history_step_application(JS::NonnullGCPtr<HTML::SessionHistoryEntry>, bool do_not_reactive, size_t script_history_length, size_t script_history_index);
protected:
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
@ -730,6 +732,9 @@ private:
RefPtr<Core::Timer> m_active_refresh_timer;
bool m_temporary_document_for_fragment_parsing { false };
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#latest-entry
JS::GCPtr<HTML::SessionHistoryEntry> m_latest_entry;
};
template<>