summaryrefslogtreecommitdiffstats
path: root/Source/WebKit
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2019-09-05 03:35:35 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2019-09-05 16:07:12 +0300
commit34c2a6ebc0d579f08c18ce4e895fd3a9fadf7370 (patch)
treed5bd7a5f15e814298ef29920f157155b2ca3e24e /Source/WebKit
parent2c94535e5c4dc6ad22bc2f34f76f5a5da6cf652e (diff)
Import QtWebKit commit 55ed4f703de7bfbb0f554cd05dccff4c6db1bba3
Change-Id: I5063dd830f1cedda84e1ae66b0e659ffe7efa22c Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebKit')
-rw-r--r--Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp26
-rw-r--r--Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h3
-rw-r--r--Source/WebKit/qt/WidgetApi/qwebframe.h4
-rw-r--r--Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.cpp44
-rw-r--r--Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.h7
5 files changed, 71 insertions, 13 deletions
diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
index 1c14fcd07..b3b49f5d6 100644
--- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
@@ -192,19 +192,6 @@ static WebCore::FrameLoadRequest frameLoadRequest(const QUrl &url, WebCore::Fram
);
}
-static void openNewWindow(const QUrl& url, Frame* frame)
-{
- if (Page* oldPage = frame->page()) {
- WindowFeatures features;
- NavigationAction action;
- FrameLoadRequest request = frameLoadRequest(url, frame);
- if (Page* newPage = oldPage->chrome().createWindow(frame, request, features, action)) {
- newPage->mainFrame().loader().loadFrameRequest(request, /*event*/ 0, /*FormState*/ 0);
- newPage->chrome().show();
- }
- }
-}
-
// FIXME: Find a better place
static UserContentController& userContentProvider()
{
@@ -1590,3 +1577,16 @@ bool QWebPageAdapter::swallowContextMenuEvent(QContextMenuEvent *event, QWebFram
return !menu;
}
+
+void QWebPageAdapter::openNewWindow(const QUrl& url, Frame* frame)
+{
+ if (Page* oldPage = frame->page()) {
+ WindowFeatures features;
+ NavigationAction action;
+ FrameLoadRequest request = frameLoadRequest(url, frame);
+ if (Page* newPage = oldPage->chrome().createWindow(frame, request, features, action)) {
+ newPage->mainFrame().loader().loadFrameRequest(request, /*event*/ 0, /*FormState*/ 0);
+ newPage->chrome().show();
+ }
+ }
+}
diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h
index 1b7199a9c..e9c93958d 100644
--- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h
+++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h
@@ -49,6 +49,7 @@ class ChromeClientQt;
class DeviceOrientationClient;
class DeviceMotionClient;
class GeolocationClientQt;
+class Frame;
class Page;
class UndoStep;
struct ViewportArguments;
@@ -395,6 +396,8 @@ public:
const QWebElement& fullScreenElement() const;
void setFullScreenElement(const QWebElement&);
+ static void openNewWindow(const QUrl&, WebCore::Frame*);
+
QWebSettings *settings;
WebCore::Page *page;
diff --git a/Source/WebKit/qt/WidgetApi/qwebframe.h b/Source/WebKit/qt/WidgetApi/qwebframe.h
index a3374ff13..9502618ff 100644
--- a/Source/WebKit/qt/WidgetApi/qwebframe.h
+++ b/Source/WebKit/qt/WidgetApi/qwebframe.h
@@ -59,6 +59,9 @@ namespace WebCore {
class ChromeClientQt;
class TextureMapperLayerClientQt;
}
+namespace WebKit {
+ class InspectorClientWebPage;
+}
class QWebFrameData;
class QWebHitTestResultPrivate;
class QWebFrame;
@@ -242,6 +245,7 @@ private:
friend class WebCore::FrameLoaderClientQt;
friend class WebCore::ChromeClientQt;
friend class WebCore::TextureMapperLayerClientQt;
+ friend class WebKit::InspectorClientWebPage;
QWebFramePrivate *d;
Q_PRIVATE_SLOT(d, void _q_orientationChanged())
};
diff --git a/Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.cpp b/Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.cpp
index 9b2ba7dfd..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;
@@ -67,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");
@@ -83,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);
+}
diff --git a/Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.h b/Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.h
index 59cf74135..d996587cc 100644
--- a/Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.h
+++ b/Source/WebKit/qt/WidgetSupport/InspectorClientWebPage.h
@@ -43,9 +43,16 @@ public:
InspectorClientWebPage();
QWebPage* createWindow(QWebPage::WebWindowType) final;
+ bool event(QEvent*) final;
public Q_SLOTS:
void javaScriptWindowObjectCleared();
+
+protected:
+ void triggerAction(WebAction, bool checked = false) final;
+
+private:
+ QPoint m_clickPos;
};
} // namespace WebKit