43
43
#include < LibGUI/Window.h>
44
44
#include < LibURL/URL.h>
45
45
#include < LibWeb/HTML/BrowsingContext.h>
46
- #include < LibWeb/HTML/HistoryHandlingBehavior.h>
47
46
#include < LibWeb/HTML/SelectedFile.h>
48
47
#include < LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
49
48
#include < LibWeb/Layout/BlockContainer.h>
@@ -134,28 +133,18 @@ Tab::Tab(BrowserWindow& window)
134
133
135
134
auto & go_back_button = toolbar.add_action (window.go_back_action ());
136
135
go_back_button.on_context_menu_request = [&](auto &) {
137
- if (!m_history. can_go_back () )
136
+ if (!m_can_navigate_back )
138
137
return ;
139
- int i = 0 ;
140
- m_go_back_context_menu = GUI::Menu::construct ();
141
- for (auto & url : m_history.get_back_title_history ()) {
142
- i++;
143
- m_go_back_context_menu->add_action (GUI::Action::create (url.to_byte_string (), g_icon_bag.filetype_html , [this , i](auto &) { go_back (i); }));
144
- }
145
- m_go_back_context_menu->popup (go_back_button.screen_relative_rect ().bottom_left ().moved_up (1 ));
138
+
139
+ // FIXME: Reimplement selecting a specific entry using WebContent's history.
146
140
};
147
141
148
142
auto & go_forward_button = toolbar.add_action (window.go_forward_action ());
149
143
go_forward_button.on_context_menu_request = [&](auto &) {
150
- if (!m_history. can_go_forward () )
144
+ if (!m_can_navigate_forward )
151
145
return ;
152
- int i = 0 ;
153
- m_go_forward_context_menu = GUI::Menu::construct ();
154
- for (auto & url : m_history.get_forward_title_history ()) {
155
- i++;
156
- m_go_forward_context_menu->add_action (GUI::Action::create (url.to_byte_string (), g_icon_bag.filetype_html , [this , i](auto &) { go_forward (i); }));
157
- }
158
- m_go_forward_context_menu->popup (go_forward_button.screen_relative_rect ().bottom_left ().moved_up (1 ));
146
+
147
+ // FIXME: Reimplement selecting a specific entry using WebContent's history.
159
148
};
160
149
161
150
auto & go_home_button = toolbar.add_action (window.go_home_action ());
@@ -215,16 +204,10 @@ Tab::Tab(BrowserWindow& window)
215
204
m_bookmark_button->set_icon (g_icon_bag.bookmark_contour );
216
205
m_bookmark_button->set_fixed_size (22 , 22 );
217
206
218
- view ().on_load_start = [this ](auto & url, bool is_redirect ) {
207
+ view ().on_load_start = [this ](auto & url, bool ) {
219
208
m_navigating_url = url;
220
209
m_loaded = false ;
221
210
222
- // If we are loading due to a redirect, we replace the current history entry
223
- // with the loaded URL
224
- if (is_redirect) {
225
- m_history.replace_current (url, title ());
226
- }
227
-
228
211
auto url_serialized = url.serialize ();
229
212
230
213
m_title = url_serialized;
@@ -235,17 +218,10 @@ Tab::Tab(BrowserWindow& window)
235
218
if (on_favicon_change)
236
219
on_favicon_change (*m_icon);
237
220
238
- update_status ();
239
-
240
221
m_location_box->set_icon (nullptr );
241
222
m_location_box->set_text (url_serialized);
242
223
243
- // don't add to history if back or forward is pressed
244
- if (!m_is_history_navigation)
245
- m_history.push (url, title ());
246
- m_is_history_navigation = false ;
247
-
248
- update_actions ();
224
+ update_status ();
249
225
update_bookmark_button (url_serialized);
250
226
251
227
if (m_dom_inspector_widget)
@@ -262,29 +238,25 @@ Tab::Tab(BrowserWindow& window)
262
238
m_dom_inspector_widget->inspect ();
263
239
};
264
240
265
- view ().on_history_api_push_or_replace = [this ](auto const & url, auto history_behavior) {
266
- switch (history_behavior) {
267
- case Web::HTML::HistoryHandlingBehavior::Push:
268
- m_history.push (url, m_title);
269
- break ;
270
- case Web::HTML::HistoryHandlingBehavior::Replace:
271
- m_history.replace_current (url, m_title);
272
- break ;
273
- }
274
-
241
+ view ().on_url_change = [this ](auto const & url) {
275
242
auto url_serialized = url.serialize ();
276
243
m_location_box->set_text (url_serialized);
277
244
278
- update_actions ();
279
245
update_bookmark_button (url_serialized);
280
246
};
281
247
248
+ view ().on_navigation_buttons_state_changed = [this ](auto back_enabled, auto forward_enabled) {
249
+ m_can_navigate_back = back_enabled;
250
+ m_can_navigate_forward = forward_enabled;
251
+ update_actions ();
252
+ };
253
+
282
254
view ().on_navigate_back = [this ]() {
283
- go_back (1 );
255
+ go_back ();
284
256
};
285
257
286
258
view ().on_navigate_forward = [this ]() {
287
- go_forward (1 );
259
+ go_forward ();
288
260
};
289
261
290
262
view ().on_refresh = [this ]() {
@@ -499,7 +471,6 @@ Tab::Tab(BrowserWindow& window)
499
471
};
500
472
501
473
view ().on_title_change = [this ](auto const & title) {
502
- m_history.update_title (title);
503
474
m_title = title;
504
475
505
476
if (on_title_change)
@@ -831,9 +802,8 @@ void Tab::update_reset_zoom_button()
831
802
}
832
803
}
833
804
834
- void Tab::load (URL::URL const & url, LoadType load_type )
805
+ void Tab::load (URL::URL const & url)
835
806
{
836
- m_is_history_navigation = (load_type == LoadType::HistoryNavigation);
837
807
m_web_content_view->load (url);
838
808
m_location_box->set_focus (false );
839
809
}
@@ -845,40 +815,26 @@ URL::URL Tab::url() const
845
815
846
816
void Tab::reload ()
847
817
{
848
- if (m_history.is_empty ())
849
- return ;
850
-
851
- load (url ());
818
+ view ().reload ();
852
819
}
853
820
854
- void Tab::go_back (int steps )
821
+ void Tab::go_back ()
855
822
{
856
- if (!m_history.can_go_back (steps))
857
- return ;
858
-
859
- m_history.go_back (steps);
860
- update_actions ();
861
- load (m_history.current ().url , LoadType::HistoryNavigation);
823
+ view ().traverse_the_history_by_delta (-1 );
862
824
}
863
825
864
- void Tab::go_forward (int steps )
826
+ void Tab::go_forward ()
865
827
{
866
- if (!m_history.can_go_forward (steps))
867
- return ;
868
-
869
- m_history.go_forward (steps);
870
- update_actions ();
871
- load (m_history.current ().url , LoadType::HistoryNavigation);
828
+ view ().traverse_the_history_by_delta (1 );
872
829
}
873
830
874
831
void Tab::update_actions ()
875
832
{
876
833
auto & window = this ->window ();
877
834
if (this != &window.active_tab ())
878
835
return ;
879
- window.go_back_action ().set_enabled (m_history.can_go_back ());
880
- window.go_forward_action ().set_enabled (m_history.can_go_forward ());
881
- window.reload_action ().set_enabled (!m_history.is_empty ());
836
+ window.go_back_action ().set_enabled (m_can_navigate_back);
837
+ window.go_forward_action ().set_enabled (m_can_navigate_forward);
882
838
}
883
839
884
840
ErrorOr<void > Tab::bookmark_current_url ()
@@ -1077,8 +1033,8 @@ void Tab::show_history_inspector()
1077
1033
m_history_widget = history_window->set_main_widget <HistoryWidget>();
1078
1034
}
1079
1035
1036
+ // FIXME: Reimplement viewing history entries using WebContent's history.
1080
1037
m_history_widget->clear_history_entries ();
1081
- m_history_widget->set_history_entries (m_history.get_all_history_entries ());
1082
1038
1083
1039
auto * window = m_history_widget->window ();
1084
1040
window->show ();
0 commit comments