summaryrefslogtreecommitdiff
path: root/Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-09-10 13:08:05 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-09-10 13:08:05 +0200
commit81cbb264cb9446c4408124d50aeff50164ad0ab4 (patch)
tree6acc39b8ea0165562d480f1c54608c6c4ae9f865 /Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.cpp
parentbeaeeb99881184fd368c121fcbb1a31c78b794a3 (diff)
parent5087e0ced43d813eb6f765913a6fc3958d2a7a9d (diff)
downloadqtwebkit-81cbb264cb9446c4408124d50aeff50164ad0ab4.tar.gz
Merge remote-tracking branch 'origin/5.212' into dev
Change-Id: I4e185b15690118515df80a79b786cbb8b30dd144
Diffstat (limited to 'Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.cpp')
-rw-r--r--Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.cpp b/Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.cpp
index 8e5427b23..2d498c5b8 100644
--- a/Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.cpp
+++ b/Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.cpp
@@ -32,7 +32,14 @@
#include "config.h"
#include "InspectorClientWebPage.h"
+#include <QApplication>
+#include <QClipboard>
+#include <QContextMenuEvent>
+
+#include <qwebelement.h>
#include <qwebframe.h>
+#include <qwebframe_p.h>
+#include <qwebpage_p.h>
using namespace WebKit;
@@ -41,7 +48,21 @@ InspectorClientWebPage::InspectorClientWebPage()
QWebView* view = new QWebView;
view->setPage(this);
setParent(view);
+ settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
+#if !ENABLE(DEVELOPER_MODE)
+ settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, false);
+#endif
connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), SLOT(javaScriptWindowObjectCleared()));
+
+ // FIXME: Find out what's going on with Settings
+ settings()->setAttribute(QWebSettings::AcceleratedCompositingEnabled, false);
+
+ // We treat "qrc:" scheme as local, but by default local content is not allowed to use
+ // LocalStorage which is required for Inspector to work.
+ // See https://bugs.webkit.org/show_bug.cgi?id=155265
+ // Alternatively we can make "qrc:" scheme non-local like GTK port does:
+ // https://bugs.webkit.org/show_bug.cgi?id=155497
+ settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
}
QWebPage* InspectorClientWebPage::createWindow(QWebPage::WebWindowType)
@@ -53,6 +74,18 @@ QWebPage* InspectorClientWebPage::createWindow(QWebPage::WebWindowType)
return page;
}
+bool InspectorClientWebPage::event(QEvent* ev)
+{
+ if (ev->type() == QEvent::ContextMenu) {
+ auto* contextMenuEvent = static_cast<QContextMenuEvent*>(ev);
+
+ if (contextMenuEvent)
+ m_clickPos = contextMenuEvent->pos();
+ }
+
+ return QWebPage::event(ev);
+}
+
void InspectorClientWebPage::javaScriptWindowObjectCleared()
{
QVariant inspectorJavaScriptWindowObjects = property("_q_inspectorJavaScriptWindowObjects");
@@ -69,3 +102,28 @@ void InspectorClientWebPage::javaScriptWindowObjectCleared()
}
}
+void InspectorClientWebPage::triggerAction(WebAction action, bool checked)
+{
+ const QWebHitTestResult hitTestResult = mainFrame()->hitTestContent(m_clickPos);
+
+ if (hitTestResult.imageUrl().isValid() && hitTestResult.element().hasAttribute(QStringLiteral("data-url"))) {
+ switch (action) {
+ case OpenImageInNewWindow: {
+ auto* frame = static_cast<QWebFramePrivate*>(hitTestResult.frame()->d);
+
+ if (frame) {
+ QWebPagePrivate::openNewWindow(QUrl(hitTestResult.element().attribute(QStringLiteral("data-url"))), frame->frame);
+ return;
+ }
+ }
+
+ case CopyImageUrlToClipboard:
+ QApplication::clipboard()->setText(hitTestResult.element().attribute(QStringLiteral("data-url")));
+ return;
+ default:
+ break;
+ }
+ }
+
+ QWebPage::triggerAction(action, checked);
+}