mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:07:34 +00:00
LibWeb: Add index
and length
into HTML::History
This commit is contained in:
parent
0f8ae12d44
commit
40cbe9e72b
3 changed files with 11 additions and 10 deletions
|
@ -54,16 +54,12 @@ WebIDL::ExceptionOr<void> History::replace_state(JS::Value data, String const&,
|
|||
// https://html.spec.whatwg.org/multipage/history.html#dom-history-length
|
||||
WebIDL::ExceptionOr<u64> History::length() const
|
||||
{
|
||||
// 1. If this's associated Document is not fully active, then throw a "SecurityError" DOMException.
|
||||
// 1. If this's relevant global object's associated Document is not fully active, then throw a "SecurityError" DOMException.
|
||||
if (!m_associated_document->is_fully_active())
|
||||
return WebIDL::SecurityError::create(realm(), "Cannot perform length on a document that isn't fully active."_fly_string);
|
||||
|
||||
// 2. Return the number of entries in the top-level browsing context's joint session history.
|
||||
auto const* browsing_context = m_associated_document->browsing_context();
|
||||
|
||||
// FIXME: We don't have the concept of "joint session history", this is an ad-hoc implementation.
|
||||
// See: https://html.spec.whatwg.org/multipage/history.html#joint-session-history
|
||||
return browsing_context->session_history().size();
|
||||
// 2. Return this's length.
|
||||
return m_length;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#dom-history-go
|
||||
|
|
|
@ -27,6 +27,9 @@ public:
|
|||
WebIDL::ExceptionOr<void> forward();
|
||||
WebIDL::ExceptionOr<u64> length() const;
|
||||
|
||||
u64 m_index { 0 };
|
||||
u64 m_length { 0 };
|
||||
|
||||
private:
|
||||
History(JS::Realm&, DOM::Document&);
|
||||
|
||||
|
|
|
@ -1744,9 +1744,11 @@ void perform_url_and_history_update_steps(DOM::Document& document, AK::URL new_u
|
|||
|
||||
// 6. If historyHandling is "push", then:
|
||||
if (history_handling == HistoryHandlingBehavior::Push) {
|
||||
// FIXME: 1. Increment document's history object's index.
|
||||
// FIXME: 2. Set document's history object's length to its index + 1.
|
||||
TODO();
|
||||
// 1. Increment document's history object's index.
|
||||
document.history()->m_index++;
|
||||
|
||||
// 2. Set document's history object's length to its index + 1.
|
||||
document.history()->m_length = document.history()->m_index + 1;
|
||||
}
|
||||
|
||||
// FIXME: 7. If serializedData is not null, then restore the history object state given document and newEntry.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue