mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb+LibWebView+WebContent: Add did_update_navigation_buttons_state()
It is going to be used to communicate whether it is possible to navigate back or forward after session history stored on browser side will no longer be used to driver navigation.
This commit is contained in:
parent
0c839f0421
commit
461184d964
Notes:
sideshowbarker
2024-07-16 22:14:49 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/461184d964 Pull-request: https://github.com/SerenityOS/serenity/pull/23952 Reviewed-by: https://github.com/trflynn89
9 changed files with 30 additions and 0 deletions
|
@ -782,6 +782,12 @@ TraversableNavigable::HistoryStepResult TraversableNavigable::apply_the_history_
|
|||
// 20. Set traversable's current session history step to targetStep.
|
||||
m_current_session_history_step = target_step;
|
||||
|
||||
// Not in the spec:
|
||||
auto back_enabled = m_current_session_history_step > 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;
|
||||
page().client().page_did_update_navigation_buttons_state(back_enabled, forward_enabled);
|
||||
|
||||
// 21. Return "applied".
|
||||
return HistoryStepResult::Applied;
|
||||
}
|
||||
|
|
|
@ -299,6 +299,7 @@ public:
|
|||
virtual NewWebViewResult page_did_request_new_web_view(HTML::ActivateTab, HTML::WebViewHints, HTML::TokenizedFeature::NoOpener) { return {}; }
|
||||
virtual void page_did_request_activate_tab() { }
|
||||
virtual void page_did_close_top_level_traversable() { }
|
||||
virtual void page_did_update_navigation_buttons_state([[maybe_unused]] bool back_enabled, [[maybe_unused]] bool forward_enabled) { }
|
||||
|
||||
virtual void request_file(FileRequest) = 0;
|
||||
|
||||
|
|
|
@ -355,6 +355,12 @@ void ViewImplementation::did_change_audio_play_state(Badge<WebContentClient>, We
|
|||
on_audio_play_state_changed(m_audio_play_state);
|
||||
}
|
||||
|
||||
void ViewImplementation::did_update_navigation_buttons_state(Badge<WebContentClient>, bool back_enabled, bool forward_enabled) const
|
||||
{
|
||||
if (on_navigation_buttons_state_changed)
|
||||
on_navigation_buttons_state_changed(back_enabled, forward_enabled);
|
||||
}
|
||||
|
||||
void ViewImplementation::handle_resize()
|
||||
{
|
||||
resize_backing_stores_if_needed(WindowResizeInProgress::Yes);
|
||||
|
|
|
@ -110,6 +110,8 @@ public:
|
|||
void did_change_audio_play_state(Badge<WebContentClient>, Web::HTML::AudioPlayState);
|
||||
Web::HTML::AudioPlayState audio_play_state() const { return m_audio_play_state; }
|
||||
|
||||
void did_update_navigation_buttons_state(Badge<WebContentClient>, bool back_enabled, bool forward_enabled) const;
|
||||
|
||||
enum class ScreenshotType {
|
||||
Visible,
|
||||
Full,
|
||||
|
@ -189,6 +191,7 @@ public:
|
|||
Function<void(Gfx::Color)> on_theme_color_change;
|
||||
Function<void(String const&, String const&, String const&)> on_insert_clipboard_entry;
|
||||
Function<void(Web::HTML::AudioPlayState)> on_audio_play_state_changed;
|
||||
Function<void(bool, bool)> on_navigation_buttons_state_changed;
|
||||
Function<void()> on_inspector_loaded;
|
||||
Function<void(i32, Optional<Web::CSS::Selector::PseudoElement::Type> const&)> on_inspector_selected_dom_node;
|
||||
Function<void(i32, String const&)> on_inspector_set_dom_node_text;
|
||||
|
|
|
@ -588,6 +588,12 @@ void WebContentClient::did_change_audio_play_state(u64 page_id, Web::HTML::Audio
|
|||
view->did_change_audio_play_state({}, play_state);
|
||||
}
|
||||
|
||||
void WebContentClient::did_update_navigation_buttons_state(u64 page_id, bool back_enabled, bool forward_enabled)
|
||||
{
|
||||
if (auto view = view_for_page_id(page_id); view.has_value())
|
||||
view->did_update_navigation_buttons_state({}, back_enabled, forward_enabled);
|
||||
}
|
||||
|
||||
void WebContentClient::inspector_did_load(u64 page_id)
|
||||
{
|
||||
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
||||
|
|
|
@ -101,6 +101,7 @@ private:
|
|||
virtual void did_change_theme_color(u64 page_id, Gfx::Color color) override;
|
||||
virtual void did_insert_clipboard_entry(u64 page_id, String const& data, String const& presentation_style, String const& mime_type) override;
|
||||
virtual void did_change_audio_play_state(u64 page_id, Web::HTML::AudioPlayState) override;
|
||||
virtual void did_update_navigation_buttons_state(u64 page_id, bool back_enabled, bool forward_enabled) override;
|
||||
virtual void inspector_did_load(u64 page_id) override;
|
||||
virtual void inspector_did_select_dom_node(u64 page_id, i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> const& pseudo_element) override;
|
||||
virtual void inspector_did_set_dom_node_text(u64 page_id, i32 node_id, String const& text) override;
|
||||
|
|
|
@ -562,6 +562,11 @@ void PageClient::page_did_close_top_level_traversable()
|
|||
m_owner.remove_page({}, m_id);
|
||||
}
|
||||
|
||||
void PageClient::page_did_update_navigation_buttons_state(bool back_enabled, bool forward_enabled)
|
||||
{
|
||||
client().async_did_update_navigation_buttons_state(m_id, back_enabled, forward_enabled);
|
||||
}
|
||||
|
||||
void PageClient::request_file(Web::FileRequest file_request)
|
||||
{
|
||||
client().request_file(m_id, move(file_request));
|
||||
|
|
|
@ -137,6 +137,7 @@ private:
|
|||
virtual NewWebViewResult page_did_request_new_web_view(Web::HTML::ActivateTab, Web::HTML::WebViewHints, Web::HTML::TokenizedFeature::NoOpener) override;
|
||||
virtual void page_did_request_activate_tab() override;
|
||||
virtual void page_did_close_top_level_traversable() override;
|
||||
virtual void page_did_update_navigation_buttons_state(bool back_enabled, bool forward_enabled) override;
|
||||
virtual void request_file(Web::FileRequest) override;
|
||||
virtual void page_did_request_color_picker(Color current_color) override;
|
||||
virtual void page_did_request_file_picker(Web::HTML::FileFilter accepted_file_types, Web::HTML::AllowMultipleFiles) override;
|
||||
|
|
|
@ -83,6 +83,7 @@ endpoint WebContentClient
|
|||
did_finish_handling_input_event(u64 page_id, bool event_was_accepted) =|
|
||||
did_change_theme_color(u64 page_id, Gfx::Color color) =|
|
||||
did_insert_clipboard_entry(u64 page_id, String data, String presentation_style, String mime_type) =|
|
||||
did_update_navigation_buttons_state(u64 page_id, bool back_enabled, bool forward_enabled) =|
|
||||
|
||||
did_change_audio_play_state(u64 page_id, Web::HTML::AudioPlayState play_state) =|
|
||||
|
||||
|
|
Loading…
Reference in a new issue