2022-07-05 22:18:21 +00:00
|
|
|
/*
|
2022-07-19 10:23:11 +00:00
|
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
2022-07-05 22:18:21 +00:00
|
|
|
* Copyright (c) 2022, Matthew Costa <ucosty@gmail.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-01-18 14:12:13 +00:00
|
|
|
#include "LocationEdit.h"
|
2022-10-05 13:23:41 +00:00
|
|
|
#include "WebContentView.h"
|
2024-05-29 19:12:21 +00:00
|
|
|
#include <Ladybird/Qt/FindInPageWidget.h>
|
2024-03-28 15:16:10 +00:00
|
|
|
#include <LibWeb/HTML/AudioPlayState.h>
|
2022-07-05 22:18:21 +00:00
|
|
|
#include <QBoxLayout>
|
2022-09-09 12:23:36 +00:00
|
|
|
#include <QLabel>
|
2022-07-05 22:18:21 +00:00
|
|
|
#include <QLineEdit>
|
2023-07-19 13:26:29 +00:00
|
|
|
#include <QMenu>
|
2023-05-17 18:23:34 +00:00
|
|
|
#include <QPointer>
|
2022-07-05 22:18:21 +00:00
|
|
|
#include <QToolBar>
|
2023-03-28 23:25:42 +00:00
|
|
|
#include <QToolButton>
|
2022-07-05 22:18:21 +00:00
|
|
|
#include <QWidget>
|
|
|
|
|
2023-05-17 15:54:36 +00:00
|
|
|
namespace Ladybird {
|
2023-08-02 17:52:59 +00:00
|
|
|
|
|
|
|
class BrowserWindow;
|
2023-05-17 15:54:36 +00:00
|
|
|
class InspectorWidget;
|
|
|
|
|
2022-07-05 22:18:21 +00:00
|
|
|
class Tab final : public QWidget {
|
|
|
|
Q_OBJECT
|
2023-12-01 17:18:40 +00:00
|
|
|
|
2022-07-05 22:18:21 +00:00
|
|
|
public:
|
2024-01-30 16:12:14 +00:00
|
|
|
Tab(BrowserWindow* window, WebContentOptions const&, StringView webdriver_content_ipc_path, RefPtr<WebView::WebContentClient> parent_client = nullptr, size_t page_index = 0);
|
2023-05-17 15:54:36 +00:00
|
|
|
virtual ~Tab() override;
|
2022-07-05 22:18:21 +00:00
|
|
|
|
2022-10-05 13:23:41 +00:00
|
|
|
WebContentView& view() { return *m_view; }
|
2022-07-05 22:18:21 +00:00
|
|
|
|
2024-03-18 03:22:27 +00:00
|
|
|
void navigate(URL::URL const&);
|
2023-09-17 15:12:17 +00:00
|
|
|
void load_html(StringView);
|
2023-08-28 20:14:34 +00:00
|
|
|
|
2023-05-17 16:37:31 +00:00
|
|
|
void back();
|
|
|
|
void forward();
|
|
|
|
void reload();
|
2022-07-06 13:38:50 +00:00
|
|
|
|
2024-06-05 23:07:10 +00:00
|
|
|
void debug_request(ByteString const& request, ByteString const& argument = "");
|
2022-07-08 12:14:40 +00:00
|
|
|
|
2023-05-25 21:47:12 +00:00
|
|
|
void open_file();
|
2023-03-28 23:25:42 +00:00
|
|
|
void update_reset_zoom_button();
|
|
|
|
|
2023-05-17 15:54:36 +00:00
|
|
|
enum class InspectorTarget {
|
|
|
|
Document,
|
|
|
|
HoveredElement
|
|
|
|
};
|
|
|
|
void show_inspector_window(InspectorTarget = InspectorTarget::Document);
|
|
|
|
|
2024-05-29 19:12:21 +00:00
|
|
|
void show_find_in_page();
|
2024-06-13 20:09:49 +00:00
|
|
|
void find_previous();
|
|
|
|
void find_next();
|
2024-05-29 19:12:21 +00:00
|
|
|
|
2024-03-28 15:11:02 +00:00
|
|
|
QIcon const& favicon() const { return m_favicon; }
|
2024-04-27 13:33:09 +00:00
|
|
|
QString const& title() const { return m_title; }
|
2024-03-28 15:11:02 +00:00
|
|
|
|
2024-04-28 14:07:23 +00:00
|
|
|
QMenu* context_menu() const { return m_context_menu; }
|
|
|
|
|
2024-04-13 22:05:47 +00:00
|
|
|
void update_navigation_buttons_state();
|
|
|
|
|
2024-05-07 22:39:25 +00:00
|
|
|
QToolButton* hamburger_button() const { return m_hamburger_button; }
|
|
|
|
|
2024-05-29 19:12:21 +00:00
|
|
|
void update_hover_label();
|
|
|
|
|
2024-06-05 19:29:12 +00:00
|
|
|
void set_block_popups(bool);
|
2024-06-04 12:28:48 +00:00
|
|
|
void set_line_box_borders(bool);
|
2024-06-05 19:29:12 +00:00
|
|
|
void set_same_origin_policy(bool);
|
|
|
|
void set_scripting(bool);
|
2024-06-05 23:07:10 +00:00
|
|
|
void set_user_agent_string(ByteString const&);
|
2024-06-04 12:28:48 +00:00
|
|
|
|
2024-07-02 19:31:14 +00:00
|
|
|
void set_enable_do_not_track(bool);
|
|
|
|
|
2024-06-10 09:33:35 +00:00
|
|
|
bool url_is_hidden() const { return m_location_edit->url_is_hidden(); }
|
|
|
|
void set_url_is_hidden(bool url_is_hidden) { m_location_edit->set_url_is_hidden(url_is_hidden); }
|
|
|
|
|
2022-07-05 22:18:21 +00:00
|
|
|
public slots:
|
2022-09-12 07:12:04 +00:00
|
|
|
void focus_location_editor();
|
2022-07-05 22:18:21 +00:00
|
|
|
void location_edit_return_pressed();
|
2023-12-07 14:53:49 +00:00
|
|
|
void select_dropdown_action();
|
2022-07-05 22:18:21 +00:00
|
|
|
|
|
|
|
signals:
|
2024-03-28 15:11:02 +00:00
|
|
|
void title_changed(int id, QString const&);
|
|
|
|
void favicon_changed(int id, QIcon const&);
|
2024-03-28 15:16:10 +00:00
|
|
|
void audio_play_state_changed(int id, Web::HTML::AudioPlayState);
|
2024-04-13 22:05:47 +00:00
|
|
|
void navigation_buttons_state_changed(int id);
|
2022-07-05 22:18:21 +00:00
|
|
|
|
|
|
|
private:
|
2022-09-09 12:23:36 +00:00
|
|
|
virtual void resizeEvent(QResizeEvent*) override;
|
2023-05-05 13:38:46 +00:00
|
|
|
virtual bool event(QEvent*) override;
|
2022-09-09 12:23:36 +00:00
|
|
|
|
2023-07-29 18:46:47 +00:00
|
|
|
void recreate_toolbar_icons();
|
2022-09-09 12:23:36 +00:00
|
|
|
|
2024-03-18 03:22:27 +00:00
|
|
|
void open_link(URL::URL const&);
|
|
|
|
void open_link_in_new_tab(URL::URL const&);
|
|
|
|
void copy_link_url(URL::URL const&);
|
2023-05-15 16:27:10 +00:00
|
|
|
|
2023-05-17 15:54:36 +00:00
|
|
|
void close_sub_widgets();
|
|
|
|
|
2023-12-04 14:39:22 +00:00
|
|
|
QBoxLayout* m_layout { nullptr };
|
2022-07-05 22:18:21 +00:00
|
|
|
QToolBar* m_toolbar { nullptr };
|
2024-05-05 15:11:51 +00:00
|
|
|
QToolButton* m_hamburger_button { nullptr };
|
|
|
|
QAction* m_hamburger_button_action { nullptr };
|
2023-03-28 23:25:42 +00:00
|
|
|
QToolButton* m_reset_zoom_button { nullptr };
|
|
|
|
QAction* m_reset_zoom_button_action { nullptr };
|
2023-01-18 14:12:13 +00:00
|
|
|
LocationEdit* m_location_edit { nullptr };
|
2022-10-05 13:23:41 +00:00
|
|
|
WebContentView* m_view { nullptr };
|
2024-05-29 19:12:21 +00:00
|
|
|
FindInPageWidget* m_find_in_page { nullptr };
|
2022-09-21 19:17:13 +00:00
|
|
|
BrowserWindow* m_window { nullptr };
|
2022-07-06 13:38:50 +00:00
|
|
|
QString m_title;
|
2022-09-09 12:23:36 +00:00
|
|
|
QLabel* m_hover_label { nullptr };
|
2024-03-28 15:11:02 +00:00
|
|
|
QIcon m_favicon;
|
2022-07-06 13:38:50 +00:00
|
|
|
|
2024-04-28 14:07:23 +00:00
|
|
|
QMenu* m_context_menu { nullptr };
|
|
|
|
|
2023-12-04 14:39:22 +00:00
|
|
|
QMenu* m_page_context_menu { nullptr };
|
2023-10-23 16:49:53 +00:00
|
|
|
Optional<String> m_page_context_menu_search_text;
|
2023-05-15 15:49:44 +00:00
|
|
|
|
2023-12-04 14:39:22 +00:00
|
|
|
QMenu* m_link_context_menu { nullptr };
|
2023-12-05 13:04:15 +00:00
|
|
|
QAction* m_link_context_menu_copy_url_action { nullptr };
|
2024-03-18 03:22:27 +00:00
|
|
|
URL::URL m_link_context_menu_url;
|
2023-05-15 16:48:46 +00:00
|
|
|
|
2023-12-04 14:39:22 +00:00
|
|
|
QMenu* m_image_context_menu { nullptr };
|
2023-05-15 17:43:58 +00:00
|
|
|
Gfx::ShareableBitmap m_image_context_menu_bitmap;
|
2024-03-18 03:22:27 +00:00
|
|
|
URL::URL m_image_context_menu_url;
|
2023-05-15 17:43:58 +00:00
|
|
|
|
2023-12-04 14:39:22 +00:00
|
|
|
QMenu* m_audio_context_menu { nullptr };
|
|
|
|
QMenu* m_video_context_menu { nullptr };
|
2023-11-05 12:45:43 +00:00
|
|
|
QIcon m_media_context_menu_play_icon;
|
|
|
|
QIcon m_media_context_menu_pause_icon;
|
|
|
|
QIcon m_media_context_menu_mute_icon;
|
|
|
|
QIcon m_media_context_menu_unmute_icon;
|
2023-12-04 14:39:22 +00:00
|
|
|
QAction* m_media_context_menu_play_pause_action { nullptr };
|
|
|
|
QAction* m_media_context_menu_mute_unmute_action { nullptr };
|
|
|
|
QAction* m_media_context_menu_controls_action { nullptr };
|
|
|
|
QAction* m_media_context_menu_loop_action { nullptr };
|
2024-03-18 03:22:27 +00:00
|
|
|
URL::URL m_media_context_menu_url;
|
2023-05-15 16:27:10 +00:00
|
|
|
|
2023-12-07 14:53:49 +00:00
|
|
|
QMenu* m_select_dropdown { nullptr };
|
|
|
|
|
2022-07-05 22:18:21 +00:00
|
|
|
int tab_index();
|
2022-11-08 12:01:20 +00:00
|
|
|
|
2023-05-17 15:54:36 +00:00
|
|
|
Ladybird::InspectorWidget* m_inspector_widget { nullptr };
|
2023-05-17 18:23:34 +00:00
|
|
|
|
|
|
|
QPointer<QDialog> m_dialog;
|
2024-04-13 22:05:47 +00:00
|
|
|
|
|
|
|
bool m_can_navigate_back { false };
|
|
|
|
bool m_can_navigate_forward { false };
|
2022-07-05 22:18:21 +00:00
|
|
|
};
|
2023-08-02 17:52:59 +00:00
|
|
|
|
|
|
|
}
|