mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
Browser: Implement history state change mechanics
We now appropriately update the current history item or create a new history item in the chrome process.
This commit is contained in:
1 parent
8b1ad5c496
commit
245489e68c
1 file changed
+18
@@ -43,6 +43,7 @@
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibURL/URL.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/HistoryHandlingBehavior.h>
|
||||
#include <LibWeb/HTML/SelectedFile.h>
|
||||
#include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
|
||||
#include <LibWeb/Layout/BlockContainer.h>
|
||||
@@ -257,6 +258,23 @@ Tab::Tab(BrowserWindow& window)
|
||||
m_dom_inspector_widget->inspect();
|
||||
};
|
||||
|
||||
view().on_url_updated = [this](auto const& url, auto history_behavior) {
|
||||
switch (history_behavior) {
|
||||
case Web::HTML::HistoryHandlingBehavior::Push:
|
||||
m_history.push(url, m_title);
|
||||
break;
|
||||
case Web::HTML::HistoryHandlingBehavior::Replace:
|
||||
m_history.replace_current(url, m_title);
|
||||
break;
|
||||
}
|
||||
|
||||
auto url_serialized = url.serialize();
|
||||
m_location_box->set_text(url_serialized);
|
||||
|
||||
update_actions();
|
||||
update_bookmark_button(url_serialized);
|
||||
};
|
||||
|
||||
view().on_navigate_back = [this]() {
|
||||
go_back(1);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user