mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-27 19:59:03 +00:00
LibWeb: Look into nested session histories to find max history step
Fixes bug when "navigate forward" button in UI is disabled after performing following steps: 1. Load page with an iframe (top step = 0, iframe step = 0) 2. Navigate iframe to different document (top step = 0, iframe step = 1) 3. Navigate back from browser UI (top step = 0, iframe step = 0) No test because change is only observable from browser UI.
This commit is contained in:
parent
768b1455d6
commit
9f4b922f1c
Notes:
sideshowbarker
2024-07-17 00:57:24 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: 9f4b922f1c
Pull-request: https://github.com/SerenityOS/serenity/pull/23978
2 changed files with 25 additions and 1 deletions
|
@ -784,7 +784,7 @@ TraversableNavigable::HistoryStepResult TraversableNavigable::apply_the_history_
|
||||||
// Not in the spec:
|
// Not in the spec:
|
||||||
auto back_enabled = m_current_session_history_step > 0;
|
auto back_enabled = m_current_session_history_step > 0;
|
||||||
VERIFY(m_session_history_entries.size() > 0);
|
VERIFY(m_session_history_entries.size() > 0);
|
||||||
auto forward_enabled = m_current_session_history_step < static_cast<int>(m_session_history_entries.size()) - 1;
|
auto forward_enabled = can_go_forward();
|
||||||
page().client().page_did_update_navigation_buttons_state(back_enabled, forward_enabled);
|
page().client().page_did_update_navigation_buttons_state(back_enabled, forward_enabled);
|
||||||
|
|
||||||
page().client().page_did_change_url(current_session_history_entry()->url());
|
page().client().page_did_change_url(current_session_history_entry()->url());
|
||||||
|
@ -895,6 +895,28 @@ void TraversableNavigable::clear_the_forward_session_history()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TraversableNavigable::can_go_forward() const
|
||||||
|
{
|
||||||
|
auto step = current_session_history_step();
|
||||||
|
|
||||||
|
Vector<Vector<JS::NonnullGCPtr<SessionHistoryEntry>> const&> entry_lists;
|
||||||
|
entry_lists.append(session_history_entries());
|
||||||
|
|
||||||
|
while (!entry_lists.is_empty()) {
|
||||||
|
auto const& entry_list = entry_lists.take_first();
|
||||||
|
|
||||||
|
for (auto const& entry : entry_list) {
|
||||||
|
if (entry->step().template get<int>() > step)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (auto& nested_history : entry->document_state()->nested_histories())
|
||||||
|
entry_lists.append(nested_history.entries);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#traverse-the-history-by-a-delta
|
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#traverse-the-history-by-a-delta
|
||||||
void TraversableNavigable::traverse_the_history_by_delta(int delta, Optional<DOM::Document&> source_document)
|
void TraversableNavigable::traverse_the_history_by_delta(int delta, Optional<DOM::Document&> source_document)
|
||||||
{
|
{
|
||||||
|
|
|
@ -102,6 +102,8 @@ private:
|
||||||
|
|
||||||
Vector<JS::NonnullGCPtr<SessionHistoryEntry>> get_session_history_entries_for_the_navigation_api(JS::NonnullGCPtr<Navigable>, int);
|
Vector<JS::NonnullGCPtr<SessionHistoryEntry>> get_session_history_entries_for_the_navigation_api(JS::NonnullGCPtr<Navigable>, int);
|
||||||
|
|
||||||
|
[[nodiscard]] bool can_go_forward() const;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#tn-current-session-history-step
|
// https://html.spec.whatwg.org/multipage/document-sequences.html#tn-current-session-history-step
|
||||||
int m_current_session_history_step { 0 };
|
int m_current_session_history_step { 0 };
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue