summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2017-02-03 11:34:09 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-03 08:40:45 +0000
commitb6d52c42e6595e1b283090ebb9bb21db50fed87b (patch)
treee22064712623739bda379a3e9fe263679e806c03
parent6b406688a4020916ba2966e6e5252d9c1385970f (diff)
Imported WebKit commit 7952fc64448c2e3c95c814b81cb055211c400786
Change-Id: I55b781a0908e86519ba08df274b16b8f169631dd Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
-rw-r--r--Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp4
-rw-r--r--Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp15
-rw-r--r--Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h4
-rw-r--r--Source/WebKit/qt/WidgetApi/qwebframe.cpp10
-rw-r--r--Source/WebKit/qt/WidgetApi/qwebframe_p.h4
-rw-r--r--Source/WebKit/qt/WidgetApi/qwebpage.cpp43
-rw-r--r--Source/WebKit/qt/WidgetApi/qwebpage.h2
-rw-r--r--Source/WebKit/qt/WidgetApi/qwebpage_p.cpp2
-rw-r--r--Source/WebKit/qt/WidgetApi/qwebpage_p.h3
-rw-r--r--Source/WebKit/qt/declarative/experimental/plugin.cpp2
-rw-r--r--Source/WebKit/qt/declarative/plugin.cpp2
11 files changed, 70 insertions, 21 deletions
diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index 37658861f..1ba5a8aa1 100644
--- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -688,8 +688,10 @@ void FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld &w
if (&world != &mainThreadNormalWorld())
return;
- if (m_webFrame)
+ if (m_webFrame) {
m_webFrame->didClearWindowObject();
+ m_webFrame->pageAdapter->clearCustomActions();
+ }
}
void FrameLoaderClientQt::registerForIconNotification(bool shouldRegister)
diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
index e1789f9e2..ee3339594 100644
--- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
@@ -876,8 +876,11 @@ void QWebPageAdapter::dynamicPropertyChangeEvent(QObject* obj, QDynamicPropertyC
#define MAP_ACTION_FROM_VALUE(Name, Value) \
case Value: return QWebPageAdapter::Name
-static QWebPageAdapter::MenuAction adapterActionForContextMenuAction(WebCore::ContextMenuAction action)
+static int adapterActionForContextMenuAction(WebCore::ContextMenuAction action)
{
+ if (action >= ContextMenuItemBaseCustomTag && action <= ContextMenuItemLastCustomTag)
+ return action;
+
switch (action) {
FOR_EACH_MAPPED_MENU_ACTION(MAP_ACTION_FROM_VALUE, SEMICOLON_SEPARATOR);
case WebCore::ContextMenuItemTagInspectElement:
@@ -899,7 +902,7 @@ QList<MenuItem> descriptionForPlatformMenu(const Vector<ContextMenuItem>& items,
switch (item.type()) {
case WebCore::CheckableActionType: /* fall through */
case WebCore::ActionType: {
- QWebPageAdapter::MenuAction action = adapterActionForContextMenuAction(item.action());
+ int action = adapterActionForContextMenuAction(item.action());
if (action > QWebPageAdapter::NoAction) {
description.type = MenuItem::Action;
description.action = action;
@@ -1186,6 +1189,14 @@ void QWebPageAdapter::triggerAction(QWebPageAdapter::MenuAction action, QWebHitT
}
}
+void QWebPageAdapter::triggerCustomAction(int action, const QString &title)
+{
+ if (action >= ContextMenuItemBaseCustomTag && action <= ContextMenuItemLastCustomTag)
+ page->contextMenuController().contextMenuItemSelected(static_cast<ContextMenuAction>(action), title);
+ else
+ ASSERT_NOT_REACHED();
+}
+
QString QWebPageAdapter::contextMenuItemTagForAction(QWebPageAdapter::MenuAction action, bool* checkable) const
{
diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h
index 324d0381d..7174d0d96 100644
--- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h
+++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h
@@ -228,6 +228,7 @@ public:
virtual void createUndoStep(QSharedPointer<UndoStepQt>) = 0;
virtual void updateNavigationActions() = 0;
+ virtual void clearCustomActions() = 0;
virtual QWebFrameAdapter* mainFrameAdapter() = 0;
@@ -273,7 +274,7 @@ public:
Separator,
SubMenu
} type;
- MenuAction action;
+ int action;
enum Trait {
None = 0,
Enabled = 1,
@@ -344,6 +345,7 @@ public:
QWebHitTestResultPrivate* updatePositionDependentMenuActions(const QPoint&, QBitArray*);
void updateActionInternal(MenuAction, const char* commandName, bool* enabled, bool* checked);
void triggerAction(MenuAction, QWebHitTestResultPrivate*, const char* commandName, bool endToEndReload);
+ void triggerCustomAction(int action, const QString &title);
QString contextMenuItemTagForAction(MenuAction, bool* checkable) const;
QStringList supportedContentTypes() const;
diff --git a/Source/WebKit/qt/WidgetApi/qwebframe.cpp b/Source/WebKit/qt/WidgetApi/qwebframe.cpp
index 30a58de5d..c936840a4 100644
--- a/Source/WebKit/qt/WidgetApi/qwebframe.cpp
+++ b/Source/WebKit/qt/WidgetApi/qwebframe.cpp
@@ -116,16 +116,6 @@ QWebFrameAdapter* QWebFramePrivate::createChildFrame(QWebFrameData* frameData)
return newFrame->d;
}
-QWebFrame *QWebFramePrivate::apiHandle()
-{
- return q;
-}
-
-QObject *QWebFramePrivate::handle()
-{
- return q;
-}
-
void QWebFramePrivate::contentsSizeDidChange(const QSize &size)
{
emit q->contentsSizeChanged(size);
diff --git a/Source/WebKit/qt/WidgetApi/qwebframe_p.h b/Source/WebKit/qt/WidgetApi/qwebframe_p.h
index 6b74aa516..e0e732f85 100644
--- a/Source/WebKit/qt/WidgetApi/qwebframe_p.h
+++ b/Source/WebKit/qt/WidgetApi/qwebframe_p.h
@@ -51,8 +51,8 @@ public:
static QWebFrame* kit(const QWebFrameAdapter*);
// Adapter implementation
- QWebFrame* apiHandle() override;
- QObject* handle() override;
+ QWebFrame* apiHandle() override { return q; }
+ QObject* handle() override { return q; }
void contentsSizeDidChange(const QSize &) override;
int scrollBarPolicy(Qt::Orientation) const override;
void emitUrlChanged() override;
diff --git a/Source/WebKit/qt/WidgetApi/qwebpage.cpp b/Source/WebKit/qt/WidgetApi/qwebpage.cpp
index a1ea49d35..009842830 100644
--- a/Source/WebKit/qt/WidgetApi/qwebpage.cpp
+++ b/Source/WebKit/qt/WidgetApi/qwebpage.cpp
@@ -477,8 +477,15 @@ QMenu *createContextMenu(QWebPage* page, const QList<MenuItem>& items, QBitArray
const MenuItem &item = items.at(i);
switch (item.type) {
case MenuItem::Action: {
- QWebPage::WebAction action = webActionForAdapterMenuAction(item.action);
- QAction *a = page->action(action);
+ QAction* a = nullptr;
+ if (item.action < QWebPageAdapter::ActionCount) {
+ QWebPage::WebAction action = webActionForAdapterMenuAction(static_cast<QWebPageAdapter::MenuAction>(item.action));
+ a = page->action(action);
+ if (a)
+ visitedWebActions->setBit(action);
+ } else {
+ a = page->customAction(item.action);
+ }
if (a) {
a->setText(item.title);
a->setEnabled(item.traits & MenuItem::Enabled);
@@ -486,7 +493,6 @@ QMenu *createContextMenu(QWebPage* page, const QList<MenuItem>& items, QBitArray
a->setChecked(item.traits & MenuItem::Checked);
menu->addAction(a);
- visitedWebActions->setBit(action);
}
break;
}
@@ -540,6 +546,16 @@ void QWebPagePrivate::_q_webActionTriggered(bool checked)
QWebPage::WebAction action = static_cast<QWebPage::WebAction>(a->data().toInt());
q->triggerAction(action, checked);
}
+
+void QWebPagePrivate::_q_customActionTriggered(bool checked)
+{
+ Q_UNUSED(checked);
+ QAction* a = qobject_cast<QAction*>(q->sender());
+ if (!a)
+ return;
+ int action = a->data().toInt();
+ triggerCustomAction(action, a->text());
+}
#endif // QT_NO_ACTION
void QWebPagePrivate::updateAction(QWebPage::WebAction action)
@@ -603,6 +619,12 @@ void QWebPagePrivate::updateNavigationActions()
updateAction(QWebPage::ReloadAndBypassCache);
}
+void QWebPagePrivate::clearCustomActions()
+{
+ qDeleteAll(customActions);
+ customActions.clear();
+}
+
QObject *QWebPagePrivate::inspectorHandle()
{
return getOrCreateInspector();
@@ -2441,6 +2463,21 @@ QAction *QWebPage::action(WebAction action) const
d->updateAction(action);
return a;
}
+
+QAction* QWebPage::customAction(int action) const
+{
+ auto actionIter = d->customActions.constFind(action);
+ if (actionIter != d->customActions.constEnd())
+ return *actionIter;
+
+ QAction* a = new QAction(d->q);
+ a->setData(action);
+ connect(a, SIGNAL(triggered(bool)),
+ this, SLOT(_q_customActionTriggered(bool)));
+
+ d->customActions.insert(action, a);
+ return a;
+}
#endif // QT_NO_ACTION
/*!
diff --git a/Source/WebKit/qt/WidgetApi/qwebpage.h b/Source/WebKit/qt/WidgetApi/qwebpage.h
index 12340cc75..50849494a 100644
--- a/Source/WebKit/qt/WidgetApi/qwebpage.h
+++ b/Source/WebKit/qt/WidgetApi/qwebpage.h
@@ -328,6 +328,7 @@ public:
#ifndef QT_NO_ACTION
QAction *action(WebAction action) const;
+ QAction *customAction(int action) const;
#endif
virtual void triggerAction(WebAction action, bool checked = false);
@@ -476,6 +477,7 @@ private:
Q_PRIVATE_SLOT(d, void _q_onLoadProgressChanged(int))
#ifndef QT_NO_ACTION
Q_PRIVATE_SLOT(d, void _q_webActionTriggered(bool checked))
+ Q_PRIVATE_SLOT(d, void _q_customActionTriggered(bool checked))
#endif
Q_PRIVATE_SLOT(d, void _q_cleanupLeakMessages())
Q_PRIVATE_SLOT(d, void _q_updateScreen(QScreen*))
diff --git a/Source/WebKit/qt/WidgetApi/qwebpage_p.cpp b/Source/WebKit/qt/WidgetApi/qwebpage_p.cpp
index da20e7266..17062646f 100644
--- a/Source/WebKit/qt/WidgetApi/qwebpage_p.cpp
+++ b/Source/WebKit/qt/WidgetApi/qwebpage_p.cpp
@@ -50,6 +50,8 @@ QWebPagePrivate::~QWebPagePrivate()
// in order for various destruction callbacks out of WebCore to
// work.
deletePage();
+
+ clearCustomActions();
}
QWebFramePrivate::~QWebFramePrivate() = default;
diff --git a/Source/WebKit/qt/WidgetApi/qwebpage_p.h b/Source/WebKit/qt/WidgetApi/qwebpage_p.h
index 630f85b5a..49e67af97 100644
--- a/Source/WebKit/qt/WidgetApi/qwebpage_p.h
+++ b/Source/WebKit/qt/WidgetApi/qwebpage_p.h
@@ -122,6 +122,7 @@ public:
const char* editorCommandForKeyEvent(QKeyEvent*) override;
void updateNavigationActions() override;
+ void clearCustomActions() override;
QObject* inspectorHandle() override;
void setInspectorFrontend(QObject*) override;
@@ -149,6 +150,7 @@ public:
void createMainFrame();
void _q_webActionTriggered(bool checked);
+ void _q_customActionTriggered(bool checked);
void updateAction(QWebPage::WebAction);
void updateEditorActions();
@@ -202,6 +204,7 @@ public:
bool useFixedLayout;
QAction *actions[QWebPage::WebActionCount];
+ QHash<int, QAction*> customActions;
QPointer <QWindow> window;
QWidget* inspectorFrontend;
diff --git a/Source/WebKit/qt/declarative/experimental/plugin.cpp b/Source/WebKit/qt/declarative/experimental/plugin.cpp
index 163c0cb47..e81c31dbd 100644
--- a/Source/WebKit/qt/declarative/experimental/plugin.cpp
+++ b/Source/WebKit/qt/declarative/experimental/plugin.cpp
@@ -45,7 +45,7 @@ public:
class WebKitQmlExperimentalExtensionPlugin: public QQmlExtensionPlugin {
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json")
+ Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid FILE "plugin.json")
public:
void registerTypes(const char* uri) override
{
diff --git a/Source/WebKit/qt/declarative/plugin.cpp b/Source/WebKit/qt/declarative/plugin.cpp
index f5d52e4bd..bcd4c1187 100644
--- a/Source/WebKit/qt/declarative/plugin.cpp
+++ b/Source/WebKit/qt/declarative/plugin.cpp
@@ -38,7 +38,7 @@
QT_BEGIN_NAMESPACE
class WebKitQmlPlugin : public QQmlExtensionPlugin {
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json")
+ Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid FILE "plugin.json")
Q_OBJECT
public:
#if defined(HAVE_WEBKIT2)