summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Ladybird/BrowserWindow.cpp19
-rw-r--r--Ladybird/WebView.cpp8
-rw-r--r--Ladybird/WebView.h2
3 files changed, 29 insertions, 0 deletions
diff --git a/Ladybird/BrowserWindow.cpp b/Ladybird/BrowserWindow.cpp
index a14624f282..b1f0d68782 100644
--- a/Ladybird/BrowserWindow.cpp
+++ b/Ladybird/BrowserWindow.cpp
@@ -9,6 +9,7 @@
#include "WebView.h"
#include <LibCore/EventLoop.h>
#include <QAction>
+#include <QPlainTextEdit>
#include <QStatusBar>
extern String s_serenity_resource_root;
@@ -31,6 +32,24 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
quit_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q));
menu->addAction(quit_action);
+ auto* inspect_menu = menuBar()->addMenu("&Inspect");
+
+ auto* view_source_action = new QAction("View &Source");
+ view_source_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-html.png").arg(s_serenity_resource_root.characters())));
+ view_source_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_U));
+ inspect_menu->addAction(view_source_action);
+ QObject::connect(view_source_action, &QAction::triggered, this, [this] {
+ if (m_current_tab) {
+ auto source = m_current_tab->view().source();
+
+ auto* text_edit = new QPlainTextEdit;
+ text_edit->setFont(QFontDatabase::systemFont(QFontDatabase::SystemFont::FixedFont));
+ text_edit->resize(800, 600);
+ text_edit->setPlainText(source.characters());
+ text_edit->show();
+ }
+ });
+
auto* debug_menu = menuBar()->addMenu("&Debug");
auto* dump_dom_tree_action = new QAction("Dump DOM Tree");
diff --git a/Ladybird/WebView.cpp b/Ladybird/WebView.cpp
index f7d5c27932..3383d38267 100644
--- a/Ladybird/WebView.cpp
+++ b/Ladybird/WebView.cpp
@@ -664,3 +664,11 @@ void WebView::debug_request(String const& request, String const& argument)
doc->window().local_storage()->dump();
}
}
+
+String WebView::source() const
+{
+ auto* document = m_page_client->page().top_level_browsing_context().active_document();
+ if (!document)
+ return String::empty();
+ return document->source();
+}
diff --git a/Ladybird/WebView.h b/Ladybird/WebView.h
index 94e53f52a0..b2d185c4fc 100644
--- a/Ladybird/WebView.h
+++ b/Ladybird/WebView.h
@@ -32,6 +32,8 @@ public:
void debug_request(String const& request, String const& argument);
+ String source() const;
+
signals:
void linkHovered(QString, int timeout = 0);
void linkUnhovered();