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"
|
2022-10-22 21:42:00 +00:00
|
|
|
#include <Browser/History.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>
|
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 ConsoleWidget;
|
|
|
|
class InspectorWidget;
|
|
|
|
|
2022-07-05 22:18:21 +00:00
|
|
|
class Tab final : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2023-08-01 20:39:19 +00:00
|
|
|
Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, WebView::UseJavaScriptBytecode, UseLagomNetworking);
|
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
|
|
|
|
2023-01-08 14:01:26 +00:00
|
|
|
enum class LoadType {
|
|
|
|
Normal,
|
|
|
|
HistoryNavigation,
|
|
|
|
};
|
|
|
|
void navigate(QString, LoadType = LoadType::Normal);
|
2023-05-17 16:37:31 +00:00
|
|
|
void back();
|
|
|
|
void forward();
|
|
|
|
void reload();
|
2022-07-06 13:38:50 +00:00
|
|
|
|
2022-12-04 18:43:54 +00:00
|
|
|
void debug_request(DeprecatedString const& request, DeprecatedString 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);
|
|
|
|
void show_console_window();
|
|
|
|
|
2023-07-08 02:48:11 +00:00
|
|
|
Ladybird::ConsoleWidget* console() { return m_console_widget; }
|
2023-05-17 15:54:36 +00:00
|
|
|
|
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();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void title_changed(int id, QString);
|
|
|
|
void favicon_changed(int id, QIcon);
|
|
|
|
|
|
|
|
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
|
|
|
void update_hover_label();
|
|
|
|
|
2023-05-15 16:27:10 +00:00
|
|
|
void open_link(URL const&);
|
|
|
|
void open_link_in_new_tab(URL const&);
|
|
|
|
void copy_link_url(URL const&);
|
|
|
|
|
2023-05-17 15:54:36 +00:00
|
|
|
void close_sub_widgets();
|
|
|
|
|
2022-07-05 22:18:21 +00:00
|
|
|
QBoxLayout* m_layout;
|
|
|
|
QToolBar* m_toolbar { 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 };
|
2022-09-21 19:17:13 +00:00
|
|
|
BrowserWindow* m_window { nullptr };
|
2022-07-06 13:38:50 +00:00
|
|
|
Browser::History m_history;
|
|
|
|
QString m_title;
|
2022-09-09 12:23:36 +00:00
|
|
|
QLabel* m_hover_label { nullptr };
|
2022-07-06 13:38:50 +00:00
|
|
|
|
2023-05-15 15:49:44 +00:00
|
|
|
OwnPtr<QMenu> m_page_context_menu;
|
|
|
|
|
2023-05-15 16:48:46 +00:00
|
|
|
OwnPtr<QMenu> m_link_context_menu;
|
|
|
|
URL m_link_context_menu_url;
|
|
|
|
|
2023-05-15 17:43:58 +00:00
|
|
|
OwnPtr<QMenu> m_image_context_menu;
|
|
|
|
Gfx::ShareableBitmap m_image_context_menu_bitmap;
|
|
|
|
URL m_image_context_menu_url;
|
|
|
|
|
2023-06-16 15:05:15 +00:00
|
|
|
OwnPtr<QMenu> m_audio_context_menu;
|
2023-05-15 16:27:10 +00:00
|
|
|
OwnPtr<QMenu> m_video_context_menu;
|
2023-06-16 14:51:38 +00:00
|
|
|
OwnPtr<QIcon> m_media_context_menu_play_icon;
|
|
|
|
OwnPtr<QIcon> m_media_context_menu_pause_icon;
|
2023-06-16 15:29:54 +00:00
|
|
|
OwnPtr<QIcon> m_media_context_menu_mute_icon;
|
|
|
|
OwnPtr<QIcon> m_media_context_menu_unmute_icon;
|
2023-06-16 14:51:38 +00:00
|
|
|
OwnPtr<QAction> m_media_context_menu_play_pause_action;
|
2023-06-16 15:29:54 +00:00
|
|
|
OwnPtr<QAction> m_media_context_menu_mute_unmute_action;
|
2023-06-16 14:51:38 +00:00
|
|
|
OwnPtr<QAction> m_media_context_menu_controls_action;
|
|
|
|
OwnPtr<QAction> m_media_context_menu_loop_action;
|
|
|
|
URL m_media_context_menu_url;
|
2023-05-15 16:27:10 +00:00
|
|
|
|
2022-07-05 22:18:21 +00:00
|
|
|
int tab_index();
|
2022-11-08 12:01:20 +00:00
|
|
|
|
|
|
|
bool m_is_history_navigation { false };
|
2023-05-17 15:54:36 +00:00
|
|
|
|
|
|
|
Ladybird::ConsoleWidget* m_console_widget { nullptr };
|
2023-07-19 13:26:29 +00:00
|
|
|
OwnPtr<QMenu> m_console_context_menu;
|
2023-05-17 15:54:36 +00:00
|
|
|
Ladybird::InspectorWidget* m_inspector_widget { nullptr };
|
2022-07-05 22:18:21 +00:00
|
|
|
};
|
2023-08-02 17:52:59 +00:00
|
|
|
|
|
|
|
}
|