mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00: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:
parent
8b1ad5c496
commit
245489e68c
Notes:
sideshowbarker
2024-07-16 20:39:14 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/245489e68c Pull-request: https://github.com/SerenityOS/serenity/pull/23758 Reviewed-by: https://github.com/kalenikaliaksandr ✅
1 changed files with 18 additions and 0 deletions
|
@ -43,6 +43,7 @@
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
#include <LibURL/URL.h>
|
#include <LibURL/URL.h>
|
||||||
#include <LibWeb/HTML/BrowsingContext.h>
|
#include <LibWeb/HTML/BrowsingContext.h>
|
||||||
|
#include <LibWeb/HTML/HistoryHandlingBehavior.h>
|
||||||
#include <LibWeb/HTML/SelectedFile.h>
|
#include <LibWeb/HTML/SelectedFile.h>
|
||||||
#include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
|
#include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
|
||||||
#include <LibWeb/Layout/BlockContainer.h>
|
#include <LibWeb/Layout/BlockContainer.h>
|
||||||
|
@ -257,6 +258,23 @@ Tab::Tab(BrowserWindow& window)
|
||||||
m_dom_inspector_widget->inspect();
|
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]() {
|
view().on_navigate_back = [this]() {
|
||||||
go_back(1);
|
go_back(1);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue