summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess')
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp15
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h2
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp36
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h10
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h4
-rw-r--r--Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp3
-rw-r--r--Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp12
-rw-r--r--Source/WebKit2/UIProcess/WebPageProxy.cpp2
-rw-r--r--Source/WebKit2/UIProcess/qt/ColorChooserContextObject.h57
-rw-r--r--Source/WebKit2/UIProcess/qt/DialogContextObjects.h287
-rw-r--r--Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.cpp181
-rw-r--r--Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.h119
-rw-r--r--Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp262
-rw-r--r--Source/WebKit2/UIProcess/qt/QtPageClient.cpp3
-rw-r--r--Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp29
-rw-r--r--Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp227
16 files changed, 717 insertions, 532 deletions
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
index b894d7338..7e4b37012 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
@@ -385,8 +385,10 @@ void QQuickWebViewPrivate::initialize(WKPageConfigurationRef configurationRef)
loadClient.didChangeProgress = didChangeProgress;
loadClient.didFinishProgress = didFinishProgress;
loadClient.didChangeBackForwardList = didChangeBackForwardList;
+ // FIXME: These three functions should not be part of this client.
loadClient.processDidBecomeUnresponsive = processDidBecomeUnresponsive;
loadClient.processDidBecomeResponsive = processDidBecomeResponsive;
+ loadClient.processDidCrash = processDidCrash;
WKPageSetPageLoaderClient(webPage.get(), &loadClient.base);
}
@@ -605,20 +607,21 @@ void QQuickWebViewPrivate::didRenderFrame()
}
}
-void QQuickWebViewPrivate::processDidCrash()
+void QQuickWebViewPrivate::processDidCrash(WKPageRef, const void* clientInfo)
{
- Q_Q(QQuickWebView);
+ QQuickWebViewPrivate* d = toQQuickWebViewPrivate(clientInfo);
+ QQuickWebView* q = d->q_ptr;
- QUrl url(URL(WebCore::ParsedURLString, webPageProxy->urlAtProcessExit()));
+ QUrl url(URL(WebCore::ParsedURLString, d->webPageProxy->urlAtProcessExit()));
qWarning("WARNING: The web process experienced a crash on '%s'.", qPrintable(url.toString(QUrl::RemoveUserInfo)));
- pageEventHandler->resetGestureRecognizers();
+ d->pageEventHandler->resetGestureRecognizers();
// Check if loading was ongoing, when process crashed.
- if (m_loadProgress > 0 && m_loadProgress < 100) {
+ if (d->m_loadProgress > 0 && d->m_loadProgress < 100) {
QWebLoadRequest loadRequest(url, QQuickWebView::LoadFailedStatus, QStringLiteral("The web process crashed."), QQuickWebView::InternalErrorDomain, 0);
- loadProgressDidChange(100);
+ d->loadProgressDidChange(100);
emit q->loadingChanged(&loadRequest);
}
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
index cca489582..dba68e792 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
@@ -128,7 +128,6 @@ public:
// PageClient.
WebCore::IntSize viewSize() const;
virtual void pageDidRequestScroll(const QPoint& pos) { }
- void processDidCrash();
void didRelaunchProcess();
std::unique_ptr<WebKit::DrawingAreaProxy> createDrawingAreaProxy();
void handleDownloadRequest(WebKit::DownloadProxy*);
@@ -176,6 +175,7 @@ protected:
static void didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef, WKArrayRef, const void *clientInfo);
static void processDidBecomeUnresponsive(WKPageRef, const void* clientInfo);
static void processDidBecomeResponsive(WKPageRef, const void* clientInfo);
+ static void processDidCrash(WKPageRef, const void* clientInfo);
QQuickWebViewPrivate(QQuickWebView* viewport);
RefPtr<WebKit::WebPageProxy> webPageProxy;
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
index c781a97ca..82a3db952 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
@@ -83,6 +83,10 @@ bool QWebPreferencesPrivate::testAttribute(QWebPreferencesPrivate::WebAttribute
return WKPreferencesGetUniversalAccessFromFileURLsAllowed(preferencesRef);
case FileAccessFromFileURLsAllowed:
return WKPreferencesGetFileAccessFromFileURLsAllowed(preferencesRef);
+ case LogsPageMessagesToSystemConsoleEnabled:
+ return WKPreferencesGetLogsPageMessagesToSystemConsoleEnabled(preferencesRef);
+ case WebSecurityEnabled:
+ return WKPreferencesGetWebSecurityEnabled(preferencesRef);
default:
ASSERT_NOT_REACHED();
return false;
@@ -156,6 +160,12 @@ void QWebPreferencesPrivate::setAttribute(QWebPreferencesPrivate::WebAttribute a
case FileAccessFromFileURLsAllowed:
WKPreferencesSetFileAccessFromFileURLsAllowed(preferencesRef, enable);
break;
+ case LogsPageMessagesToSystemConsoleEnabled:
+ WKPreferencesSetLogsPageMessagesToSystemConsoleEnabled(preferencesRef, enable);
+ break;
+ case WebSecurityEnabled:
+ WKPreferencesSetWebSecurityEnabled(preferencesRef, enable);
+ break;
default:
ASSERT_NOT_REACHED();
}
@@ -631,6 +641,32 @@ void QWebPreferences::setLinksIncludedInFocusChain(bool enable)
emit linksIncludedInFocusChainChanged();
}
+bool QWebPreferences::logsPageMessagesToSystemConsoleEnabled() const
+{
+ return d->testAttribute(QWebPreferencesPrivate::LogsPageMessagesToSystemConsoleEnabled);
+}
+
+void QWebPreferences::setLogsPageMessagesToSystemConsoleEnabled(bool enable)
+{
+ if (logsPageMessagesToSystemConsoleEnabled() == enable)
+ return;
+ d->setAttribute(QWebPreferencesPrivate::LogsPageMessagesToSystemConsoleEnabled, enable);
+ emit logsPageMessagesToSystemConsoleEnabledChanged();
+}
+
+bool QWebPreferences::webSecurityEnabled() const
+{
+ return d->testAttribute(QWebPreferencesPrivate::WebSecurityEnabled);
+}
+
+void QWebPreferences::setWebSecurityEnabled(bool enable)
+{
+ if (webSecurityEnabled() == enable)
+ return;
+ d->setAttribute(QWebPreferencesPrivate::WebSecurityEnabled, enable);
+ emit webSecurityEnabledChanged();
+}
+
QWebPreferencesPrivate* QWebPreferencesPrivate::get(QWebPreferences* preferences)
{
return preferences->d;
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h
index 08c4df2d8..702146c38 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h
@@ -51,6 +51,8 @@ public:
Q_PROPERTY(bool fileAccessFromFileURLsAllowed READ fileAccessFromFileURLsAllowed WRITE setFileAccessFromFileURLsAllowed NOTIFY fileAccessFromFileURLsAllowedChanged FINAL)
Q_PROPERTY(bool spatialNavigationEnabled READ spatialNavigationEnabled WRITE setSpatialNavigationEnabled NOTIFY spatialNavigationEnabledChanged FINAL)
Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain NOTIFY linksIncludedInFocusChainChanged FINAL)
+ Q_PROPERTY(bool logsPageMessagesToSystemConsoleEnabled READ logsPageMessagesToSystemConsoleEnabled WRITE setLogsPageMessagesToSystemConsoleEnabled NOTIFY logsPageMessagesToSystemConsoleEnabledChanged FINAL)
+ Q_PROPERTY(bool webSecurityEnabled READ webSecurityEnabled WRITE setWebSecurityEnabled NOTIFY webSecurityEnabledChanged FINAL)
Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily NOTIFY standardFontFamilyChanged FINAL)
Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily NOTIFY fixedFontFamilyChanged FINAL)
@@ -123,6 +125,12 @@ public:
bool linksIncludedInFocusChain() const;
void setLinksIncludedInFocusChain(bool enable);
+ bool logsPageMessagesToSystemConsoleEnabled() const;
+ void setLogsPageMessagesToSystemConsoleEnabled(bool);
+
+ bool webSecurityEnabled() const;
+ void setWebSecurityEnabled(bool);
+
QString standardFontFamily() const;
void setStandardFontFamily(const QString& family);
@@ -171,6 +179,8 @@ Q_SIGNALS:
void linksIncludedInFocusChainChanged();
void universalAccessFromFileURLsAllowedChanged();
void fileAccessFromFileURLsAllowedChanged();
+ void logsPageMessagesToSystemConsoleEnabledChanged();
+ void webSecurityEnabledChanged();
void standardFontFamilyChanged();
void fixedFontFamilyChanged();
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h
index 2b4c804ff..a5395c3c8 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h
@@ -44,7 +44,9 @@ public:
UniversalAccessFromFileURLsAllowed,
FileAccessFromFileURLsAllowed,
SpatialNavigationEnabled,
- LinksIncludedInFocusChain
+ LinksIncludedInFocusChain,
+ LogsPageMessagesToSystemConsoleEnabled,
+ WebSecurityEnabled
};
enum FontFamily {
diff --git a/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp
index e62e18d03..f5b66cd5f 100644
--- a/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp
+++ b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp
@@ -58,8 +58,7 @@ void ProcessLauncher::didFinishLaunchingProcess(PlatformProcessIdentifier proces
if (!m_client) {
// FIXME: Make Identifier a move-only object and release port rights/connections in the destructor.
-#if OS(DARWIN) && !PLATFORM(GTK)
- // FIXME: Should really be something like USE(MACH)
+#if USE(MACH_PORTS)
if (identifier.port)
mach_port_mod_refs(mach_task_self(), identifier.port, MACH_PORT_RIGHT_RECEIVE, -1);
#endif
diff --git a/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
index 51a3ffbba..694a759e6 100644
--- a/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
+++ b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
@@ -62,7 +62,7 @@
#include <QCoreApplication>
#endif
-#if OS(DARWIN)
+#if USE(MACH_PORTS)
#include <mach/mach_init.h>
#include <servers/bootstrap.h>
@@ -70,7 +70,7 @@ extern "C" kern_return_t bootstrap_register2(mach_port_t, name_t, mach_port_t, u
#endif
// for QNX we need SOCK_DGRAM, see https://bugs.webkit.org/show_bug.cgi?id=95553
-#if defined(SOCK_SEQPACKET) && !defined(Q_OS_MACX) && !OS(QNX)
+#if defined(SOCK_SEQPACKET) && !defined(Q_OS_MACOS) && !OS(QNX)
#define SOCKET_TYPE SOCK_SEQPACKET
#else
#define SOCKET_TYPE SOCK_DGRAM
@@ -101,7 +101,7 @@ void QtWebProcess::setupChildProcess()
#endif
prctl(PR_SET_PDEATHSIG, SIGKILL);
#endif
-#if defined(Q_OS_MACX)
+#if defined(Q_OS_MACOS)
qputenv("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM", QByteArray("1"));
#endif
}
@@ -126,7 +126,7 @@ void ProcessLauncher::launchProcess()
#if ENABLE(DATABASE_PROCESS)
} else if (m_launchOptions.processType == ProcessType::Database) {
commandLine = QLatin1String("%1 \"%2\" %3 %4");
- QByteArray processPrefix = qgetenv("QT_WEBKIT2_DP_CMD_PREFIX");
+ QByteArray processPrefix = qgetenv("QT_WEBKIT2_SP_CMD_PREFIX");
commandLine = commandLine.arg(QLatin1String(processPrefix.constData())).arg(QString(executablePathOfDatabaseProcess()));
#endif
} else {
@@ -134,7 +134,7 @@ void ProcessLauncher::launchProcess()
ASSERT_NOT_REACHED();
}
-#if OS(DARWIN)
+#if USE(MACH_PORTS)
// Create the listening port.
mach_port_t connector;
mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &connector);
@@ -216,7 +216,7 @@ void ProcessLauncher::launchProcess()
if (!webProcessOrSUIDHelper->waitForStarted()) {
qDebug() << "Failed to start" << commandLine;
ASSERT_NOT_REACHED();
-#if OS(DARWIN)
+#if USE(MACH_PORTS)
mach_port_deallocate(mach_task_self(), connector);
mach_port_mod_refs(mach_task_self(), connector, MACH_PORT_RIGHT_RECEIVE, -1);
#endif
diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp
index 5f6a16f70..d0ff9bca5 100644
--- a/Source/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp
@@ -6287,7 +6287,7 @@ void WebPageProxy::setURLSchemeHandlerForScheme(Ref<WebURLSchemeHandler>&& handl
WebURLSchemeHandler* WebPageProxy::urlSchemeHandlerForScheme(const String& scheme)
{
- return m_urlSchemeHandlersByScheme.get(scheme);
+ return scheme.isNull() ? nullptr : m_urlSchemeHandlersByScheme.get(scheme);
}
void WebPageProxy::startURLSchemeHandlerTask(uint64_t handlerIdentifier, uint64_t resourceIdentifier, const WebCore::ResourceRequest& request)
diff --git a/Source/WebKit2/UIProcess/qt/ColorChooserContextObject.h b/Source/WebKit2/UIProcess/qt/ColorChooserContextObject.h
new file mode 100644
index 000000000..0af685b61
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/ColorChooserContextObject.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#pragma once
+
+#include <QColor>
+#include <QObject>
+#include <QRectF>
+
+namespace WebKit {
+
+class ColorChooserContextObject : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QColor currentColor READ currentColor CONSTANT FINAL)
+ Q_PROPERTY(QRectF elementRect READ elementRect CONSTANT FINAL)
+
+public:
+ ColorChooserContextObject(const QColor& color, const QRectF& rect)
+ : m_currentColor(color)
+ , m_rect(rect)
+ {
+ }
+
+ QColor currentColor() const { return m_currentColor; }
+ QRectF elementRect() const { return m_rect; }
+
+ Q_INVOKABLE void accept(const QColor& color) { emit accepted(color); }
+ Q_INVOKABLE void reject() { emit rejected(); }
+
+Q_SIGNALS:
+ void accepted(const QColor&);
+ void rejected();
+
+private:
+ QColor m_currentColor;
+ QRectF m_rect;
+};
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/DialogContextObjects.h b/Source/WebKit2/UIProcess/qt/DialogContextObjects.h
new file mode 100644
index 000000000..c6257125e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/DialogContextObjects.h
@@ -0,0 +1,287 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#pragma once
+
+#include "QtDialogRunner.h"
+#include "WKRetainPtr.h"
+#include "WKStringQt.h"
+#include "qtwebsecurityorigin_p.h"
+
+namespace WebKit {
+
+// All dialogs need a way to support the state of the
+// dialog being done/finished/dismissed. This is handled
+// in the dialog base context.
+class DialogContextBase : public QObject {
+ Q_OBJECT
+
+public:
+ DialogContextBase()
+ : QObject()
+ , m_dismissed(false)
+ {
+ }
+
+public Q_SLOTS:
+ // Allows clients to call dismiss() directly, while also
+ // being able to hook up signals to automatically also
+ // dismiss the dialog since it's a slot.
+
+ void dismiss()
+ {
+ m_dismissed = true;
+ emit dismissed();
+ }
+
+Q_SIGNALS:
+ void dismissed();
+
+private:
+ // We store the dismissed state so that run() can check to see if a
+ // dialog has already been dismissed before spinning an event loop.
+ bool m_dismissed;
+ friend void QtDialogRunner::run();
+};
+
+class DialogContextObject : public DialogContextBase {
+ Q_OBJECT
+ Q_PROPERTY(QString message READ message CONSTANT)
+ Q_PROPERTY(QString defaultValue READ defaultValue CONSTANT)
+
+public:
+ DialogContextObject(const QString& message, const QString& defaultValue = QString())
+ : DialogContextBase()
+ , m_message(message)
+ , m_defaultValue(defaultValue)
+ {
+ connect(this, SIGNAL(accepted(QString)), SLOT(dismiss()));
+ connect(this, SIGNAL(rejected()), SLOT(dismiss()));
+ }
+ QString message() const { return m_message; }
+ QString defaultValue() const { return m_defaultValue; }
+
+public Q_SLOTS:
+ void accept(const QString& result = QString()) { emit accepted(result); }
+ void reject() { emit rejected(); }
+
+Q_SIGNALS:
+ void accepted(const QString& result);
+ void rejected();
+
+private:
+ QString m_message;
+ QString m_defaultValue;
+};
+
+class BaseAuthenticationContextObject : public DialogContextBase {
+ Q_OBJECT
+ Q_PROPERTY(QString hostname READ hostname CONSTANT)
+ Q_PROPERTY(QString prefilledUsername READ prefilledUsername CONSTANT)
+
+public:
+ BaseAuthenticationContextObject(const QString& hostname, const QString& prefilledUsername)
+ : DialogContextBase()
+ , m_hostname(hostname)
+ , m_prefilledUsername(prefilledUsername)
+ {
+ connect(this, SIGNAL(accepted(QString, QString)), SLOT(dismiss()));
+ connect(this, SIGNAL(rejected()), SLOT(dismiss()));
+ }
+
+ QString hostname() const { return m_hostname; }
+ QString prefilledUsername() const { return m_prefilledUsername; }
+
+public Q_SLOTS:
+ void accept(const QString& username, const QString& password) { emit accepted(username, password); }
+ void reject() { emit rejected(); }
+
+Q_SIGNALS:
+ void accepted(const QString& username, const QString& password);
+ void rejected();
+
+private:
+ QString m_hostname;
+ QString m_prefilledUsername;
+};
+
+class HttpAuthenticationDialogContextObject : public BaseAuthenticationContextObject {
+ Q_OBJECT
+ Q_PROPERTY(QString realm READ realm CONSTANT)
+
+public:
+ HttpAuthenticationDialogContextObject(const QString& hostname, const QString& realm, const QString& prefilledUsername)
+ : BaseAuthenticationContextObject(hostname, prefilledUsername)
+ , m_realm(realm)
+ {
+ }
+
+ QString realm() const { return m_realm; }
+
+private:
+ QString m_realm;
+};
+
+class ProxyAuthenticationDialogContextObject : public BaseAuthenticationContextObject {
+ Q_OBJECT
+ Q_PROPERTY(quint16 port READ port CONSTANT)
+
+public:
+ ProxyAuthenticationDialogContextObject(const QString& hostname, quint16 port, const QString& prefilledUsername)
+ : BaseAuthenticationContextObject(hostname, prefilledUsername)
+ , m_port(port)
+ {
+ }
+
+ quint16 port() const { return m_port; }
+
+private:
+ quint16 m_port;
+};
+
+class CertificateVerificationDialogContextObject : public DialogContextBase {
+ Q_OBJECT
+ Q_PROPERTY(QString hostname READ hostname CONSTANT)
+
+public:
+ CertificateVerificationDialogContextObject(const QString& hostname)
+ : DialogContextBase()
+ , m_hostname(hostname)
+ {
+ connect(this, SIGNAL(accepted()), SLOT(dismiss()));
+ connect(this, SIGNAL(rejected()), SLOT(dismiss()));
+ }
+
+ QString hostname() const { return m_hostname; }
+
+public Q_SLOTS:
+ void accept() { emit accepted(); }
+ void reject() { emit rejected(); }
+
+Q_SIGNALS:
+ void accepted();
+ void rejected();
+
+private:
+ QString m_hostname;
+};
+
+class FilePickerContextObject : public DialogContextBase {
+ Q_OBJECT
+ Q_PROPERTY(QStringList fileList READ fileList CONSTANT)
+ Q_PROPERTY(bool allowMultipleFiles READ allowMultipleFiles CONSTANT)
+
+public:
+ FilePickerContextObject(const QStringList& selectedFiles, bool allowMultiple)
+ : DialogContextBase()
+ , m_allowMultiple(allowMultiple)
+ , m_fileList(selectedFiles)
+ {
+ connect(this, SIGNAL(fileSelected(QStringList)), SLOT(dismiss()));
+ connect(this, SIGNAL(rejected()), SLOT(dismiss()));
+ }
+
+ QStringList fileList() const { return m_fileList; }
+ bool allowMultipleFiles() const { return m_allowMultiple;}
+
+public Q_SLOTS:
+ void reject() { emit rejected();}
+ void accept(const QVariant& path)
+ {
+ QStringList filesPath = path.toStringList();
+
+ if (filesPath.isEmpty()) {
+ emit rejected();
+ return;
+ }
+
+ // For single file upload, send only the first element if there are more than one file paths
+ if (!m_allowMultiple && filesPath.count() > 1)
+ filesPath = QStringList(filesPath.at(0));
+ emit fileSelected(filesPath);
+ }
+
+Q_SIGNALS:
+ void rejected();
+ void fileSelected(const QStringList&);
+
+private:
+ bool m_allowMultiple;
+ QStringList m_fileList;
+};
+
+class DatabaseQuotaDialogContextObject : public DialogContextBase {
+ Q_OBJECT
+ Q_PROPERTY(QString databaseName READ databaseName CONSTANT)
+ Q_PROPERTY(QString displayName READ displayName CONSTANT)
+ Q_PROPERTY(quint64 currentQuota READ currentQuota CONSTANT)
+ Q_PROPERTY(quint64 currentOriginUsage READ currentOriginUsage CONSTANT)
+ Q_PROPERTY(quint64 currentDatabaseUsage READ currentDatabaseUsage CONSTANT)
+ Q_PROPERTY(quint64 expectedUsage READ expectedUsage CONSTANT)
+ Q_PROPERTY(QtWebSecurityOrigin* origin READ securityOrigin CONSTANT)
+
+public:
+ DatabaseQuotaDialogContextObject(const QString& databaseName, const QString& displayName, WKSecurityOriginRef securityOrigin, quint64 currentQuota, quint64 currentOriginUsage, quint64 currentDatabaseUsage, quint64 expectedUsage)
+ : DialogContextBase()
+ , m_databaseName(databaseName)
+ , m_displayName(displayName)
+ , m_currentQuota(currentQuota)
+ , m_currentOriginUsage(currentOriginUsage)
+ , m_currentDatabaseUsage(currentDatabaseUsage)
+ , m_expectedUsage(expectedUsage)
+ {
+ WKRetainPtr<WKStringRef> scheme = adoptWK(WKSecurityOriginCopyProtocol(securityOrigin));
+ WKRetainPtr<WKStringRef> host = adoptWK(WKSecurityOriginCopyHost(securityOrigin));
+
+ m_securityOrigin.setScheme(WKStringCopyQString(scheme.get()));
+ m_securityOrigin.setHost(WKStringCopyQString(host.get()));
+ m_securityOrigin.setPort(static_cast<int>(WKSecurityOriginGetPort(securityOrigin)));
+
+ connect(this, SIGNAL(accepted(quint64)), SLOT(dismiss()));
+ connect(this, SIGNAL(rejected()), SLOT(dismiss()));
+ }
+
+ QString databaseName() const { return m_databaseName; }
+ QString displayName() const { return m_displayName; }
+ quint64 currentQuota() const { return m_currentQuota; }
+ quint64 currentOriginUsage() const { return m_currentOriginUsage; }
+ quint64 currentDatabaseUsage() const { return m_currentDatabaseUsage; }
+ quint64 expectedUsage() const { return m_expectedUsage; }
+ QtWebSecurityOrigin* securityOrigin() { return &m_securityOrigin; }
+
+public Q_SLOTS:
+ void accept(quint64 size) { emit accepted(size); }
+ void reject() { emit rejected(); }
+
+Q_SIGNALS:
+ void accepted(quint64 size);
+ void rejected();
+
+private:
+ QString m_databaseName;
+ QString m_displayName;
+ quint64 m_currentQuota;
+ quint64 m_currentOriginUsage;
+ quint64 m_currentDatabaseUsage;
+ quint64 m_expectedUsage;
+ QtWebSecurityOrigin m_securityOrigin;
+};
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.cpp b/Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.cpp
new file mode 100644
index 000000000..a78fe4964
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.cpp
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ItemSelectorContextObject.h"
+
+#include "PlatformPopupMenuData.h"
+#include "WebPopupItem.h"
+#include "WebPopupMenuProxyQt.h"
+#include "qquickwebview_p.h"
+#include "qquickwebview_p_p.h"
+#include <QtCore/QAbstractListModel>
+#include <QtQml/QQmlContext>
+#include <QtQml/QQmlEngine>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+ItemSelectorContextObject::ItemSelectorContextObject(const QRectF& elementRect, const Vector<WebPopupItem>& webPopupItems, bool multiple)
+ : m_elementRect(elementRect)
+ , m_items(webPopupItems, multiple)
+{
+ connect(&m_items, SIGNAL(indexUpdated()), SLOT(onIndexUpdate()));
+}
+
+void ItemSelectorContextObject::onIndexUpdate()
+{
+ // Send the update for multi-select list.
+ if (m_items.multiple())
+ emit acceptedWithOriginalIndex(m_items.selectedOriginalIndex());
+}
+
+
+void ItemSelectorContextObject::accept(int index)
+{
+ // If the index is not valid for multi-select lists, just hide the pop up as the selected indices have
+ // already been sent.
+ if ((index == -1) && m_items.multiple())
+ emit done();
+ else {
+ if (index != -1)
+ m_items.toggleItem(index);
+ emit acceptedWithOriginalIndex(m_items.selectedOriginalIndex());
+ }
+}
+
+static QHash<int, QByteArray> createRoleNamesHash()
+{
+ QHash<int, QByteArray> roles;
+ roles[Qt::DisplayRole] = "text";
+ roles[Qt::ToolTipRole] = "tooltip";
+ roles[PopupMenuItemModel::GroupRole] = "group";
+ roles[PopupMenuItemModel::EnabledRole] = "enabled";
+ roles[PopupMenuItemModel::SelectedRole] = "selected";
+ roles[PopupMenuItemModel::IsSeparatorRole] = "isSeparator";
+ return roles;
+}
+
+PopupMenuItemModel::PopupMenuItemModel(const Vector<WebPopupItem>& webPopupItems, bool multiple)
+ : m_selectedModelIndex(-1)
+ , m_allowMultiples(multiple)
+{
+ buildItems(webPopupItems);
+}
+
+QHash<int, QByteArray> PopupMenuItemModel::roleNames() const
+{
+ static QHash<int, QByteArray> roles = createRoleNamesHash();
+ return roles;
+}
+
+QVariant PopupMenuItemModel::data(const QModelIndex& index, int role) const
+{
+ if (!index.isValid() || index.row() < 0 || index.row() >= m_items.size())
+ return QVariant();
+
+ const Item& item = m_items[index.row()];
+ if (item.isSeparator) {
+ if (role == IsSeparatorRole)
+ return true;
+ return QVariant();
+ }
+
+ switch (role) {
+ case Qt::DisplayRole:
+ return item.text;
+ case Qt::ToolTipRole:
+ return item.toolTip;
+ case GroupRole:
+ return item.group;
+ case EnabledRole:
+ return item.enabled;
+ case SelectedRole:
+ return item.selected;
+ case IsSeparatorRole:
+ return false;
+ }
+
+ return QVariant();
+}
+
+void PopupMenuItemModel::select(int index)
+{
+ toggleItem(index);
+ emit indexUpdated();
+}
+
+void PopupMenuItemModel::toggleItem(int index)
+{
+ int oldIndex = m_selectedModelIndex;
+ if (index < 0 || index >= m_items.size())
+ return;
+ Item& item = m_items[index];
+ if (!item.enabled)
+ return;
+
+ m_selectedModelIndex = index;
+ if (m_allowMultiples)
+ item.selected = !item.selected;
+ else {
+ if (index == oldIndex)
+ return;
+ item.selected = true;
+ if (oldIndex != -1) {
+ Item& oldItem = m_items[oldIndex];
+ oldItem.selected = false;
+ emit dataChanged(this->index(oldIndex), this->index(oldIndex));
+ }
+ }
+
+ emit dataChanged(this->index(index), this->index(index));
+}
+
+int PopupMenuItemModel::selectedOriginalIndex() const
+{
+ if (m_selectedModelIndex == -1)
+ return -1;
+ return m_items[m_selectedModelIndex].originalIndex;
+}
+
+void PopupMenuItemModel::buildItems(const Vector<WebPopupItem>& webPopupItems)
+{
+ QString currentGroup;
+ m_items.reserveInitialCapacity(webPopupItems.size());
+ for (int i = 0; i < webPopupItems.size(); i++) {
+ const WebPopupItem& webPopupItem = webPopupItems[i];
+ if (webPopupItem.m_isLabel) {
+ currentGroup = webPopupItem.m_text;
+ continue;
+ }
+ if (webPopupItem.m_isSelected && !m_allowMultiples)
+ m_selectedModelIndex = m_items.size();
+ m_items.append(Item(webPopupItem, currentGroup, i));
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.h b/Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.h
new file mode 100644
index 000000000..ad63893d6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "WebPopupItem.h"
+#include <QtCore/QAbstractListModel>
+#include <QtCore/QRectF>
+#include <wtf/Vector.h>
+
+namespace WebKit {
+
+class PopupMenuItemModel final : public QAbstractListModel {
+ Q_OBJECT
+
+public:
+ enum Roles {
+ GroupRole = Qt::UserRole,
+ EnabledRole = Qt::UserRole + 1,
+ SelectedRole = Qt::UserRole + 2,
+ IsSeparatorRole = Qt::UserRole + 3
+ };
+
+ PopupMenuItemModel(const Vector<WebPopupItem>&, bool multiple);
+ int rowCount(const QModelIndex& parent = QModelIndex()) const final { return m_items.size(); }
+ QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const final;
+ QHash<int, QByteArray> roleNames() const final;
+
+ Q_INVOKABLE void select(int);
+
+ int selectedOriginalIndex() const;
+ bool multiple() const { return m_allowMultiples; }
+ void toggleItem(int);
+
+Q_SIGNALS:
+ void indexUpdated();
+
+private:
+ struct Item {
+ Item(const WebPopupItem& webPopupItem, const QString& group, int originalIndex)
+ : text(webPopupItem.m_text)
+ , toolTip(webPopupItem.m_toolTip)
+ , group(group)
+ , originalIndex(originalIndex)
+ , enabled(webPopupItem.m_isEnabled)
+ , selected(webPopupItem.m_isSelected)
+ , isSeparator(webPopupItem.m_type == WebPopupItem::Separator)
+ { }
+
+ QString text;
+ QString toolTip;
+ QString group;
+ // Keep track of originalIndex because we don't add the label (group) items to our vector.
+ int originalIndex;
+ bool enabled;
+ bool selected;
+ bool isSeparator;
+ };
+
+ void buildItems(const Vector<WebPopupItem>& webPopupItems);
+
+ Vector<Item> m_items;
+ int m_selectedModelIndex;
+ bool m_allowMultiples;
+};
+
+class ItemSelectorContextObject : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QRectF elementRect READ elementRect CONSTANT FINAL)
+ Q_PROPERTY(QObject* items READ items CONSTANT FINAL)
+ Q_PROPERTY(bool allowMultiSelect READ allowMultiSelect CONSTANT FINAL)
+
+public:
+ ItemSelectorContextObject(const QRectF& elementRect, const Vector<WebPopupItem>&, bool multiple);
+
+ QRectF elementRect() const { return m_elementRect; }
+ PopupMenuItemModel* items() { return &m_items; }
+ bool allowMultiSelect() { return m_items.multiple(); }
+
+ Q_INVOKABLE void accept(int index = -1);
+ Q_INVOKABLE void reject() { emit done(); }
+ Q_INVOKABLE void dismiss() { emit done(); }
+
+Q_SIGNALS:
+ void acceptedWithOriginalIndex(int);
+ void done();
+
+private Q_SLOTS:
+ void onIndexUpdate();
+
+private:
+ QRectF m_elementRect;
+ PopupMenuItemModel m_items;
+};
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp b/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp
index 5043a170f..2cd5828a8 100644
--- a/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp
+++ b/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp
@@ -21,8 +21,7 @@
#include "config.h"
#include "QtDialogRunner.h"
-#include "WKRetainPtr.h"
-#include "WKStringQt.h"
+#include "DialogContextObjects.h"
#include "qquickwebview_p_p.h"
#include "qwebpermissionrequest_p.h"
#include <QtQml/QQmlComponent>
@@ -43,263 +42,6 @@ QtDialogRunner::~QtDialogRunner()
{
}
-// All dialogs need a way to support the state of the
-// dialog being done/finished/dismissed. This is handled
-// in the dialog base context.
-class DialogContextBase : public QObject {
- Q_OBJECT
-
-public:
- DialogContextBase()
- : QObject()
- , m_dismissed(false)
- {
- }
-
-public Q_SLOTS:
- // Allows clients to call dismiss() directly, while also
- // being able to hook up signals to automatically also
- // dismiss the dialog since it's a slot.
-
- void dismiss()
- {
- m_dismissed = true;
- emit dismissed();
- }
-
-Q_SIGNALS:
- void dismissed();
-
-private:
- // We store the dismissed state so that run() can check to see if a
- // dialog has already been dismissed before spinning an event loop.
- bool m_dismissed;
- friend void QtDialogRunner::run();
-};
-
-class DialogContextObject : public DialogContextBase {
- Q_OBJECT
- Q_PROPERTY(QString message READ message CONSTANT)
- Q_PROPERTY(QString defaultValue READ defaultValue CONSTANT)
-
-public:
- DialogContextObject(const QString& message, const QString& defaultValue = QString())
- : DialogContextBase()
- , m_message(message)
- , m_defaultValue(defaultValue)
- {
- connect(this, SIGNAL(accepted(QString)), SLOT(dismiss()));
- connect(this, SIGNAL(rejected()), SLOT(dismiss()));
- }
- QString message() const { return m_message; }
- QString defaultValue() const { return m_defaultValue; }
-
-public Q_SLOTS:
- void accept(const QString& result = QString()) { emit accepted(result); }
- void reject() { emit rejected(); }
-
-Q_SIGNALS:
- void accepted(const QString& result);
- void rejected();
-
-private:
- QString m_message;
- QString m_defaultValue;
-};
-
-class BaseAuthenticationContextObject : public DialogContextBase {
- Q_OBJECT
- Q_PROPERTY(QString hostname READ hostname CONSTANT)
- Q_PROPERTY(QString prefilledUsername READ prefilledUsername CONSTANT)
-
-public:
- BaseAuthenticationContextObject(const QString& hostname, const QString& prefilledUsername)
- : DialogContextBase()
- , m_hostname(hostname)
- , m_prefilledUsername(prefilledUsername)
- {
- connect(this, SIGNAL(accepted(QString, QString)), SLOT(dismiss()));
- connect(this, SIGNAL(rejected()), SLOT(dismiss()));
- }
-
- QString hostname() const { return m_hostname; }
- QString prefilledUsername() const { return m_prefilledUsername; }
-
-public Q_SLOTS:
- void accept(const QString& username, const QString& password) { emit accepted(username, password); }
- void reject() { emit rejected(); }
-
-Q_SIGNALS:
- void accepted(const QString& username, const QString& password);
- void rejected();
-
-private:
- QString m_hostname;
- QString m_prefilledUsername;
-};
-
-class HttpAuthenticationDialogContextObject : public BaseAuthenticationContextObject {
- Q_OBJECT
- Q_PROPERTY(QString realm READ realm CONSTANT)
-
-public:
- HttpAuthenticationDialogContextObject(const QString& hostname, const QString& realm, const QString& prefilledUsername)
- : BaseAuthenticationContextObject(hostname, prefilledUsername)
- , m_realm(realm)
- {
- }
-
- QString realm() const { return m_realm; }
-
-private:
- QString m_realm;
-};
-
-class ProxyAuthenticationDialogContextObject : public BaseAuthenticationContextObject {
- Q_OBJECT
- Q_PROPERTY(quint16 port READ port CONSTANT)
-
-public:
- ProxyAuthenticationDialogContextObject(const QString& hostname, quint16 port, const QString& prefilledUsername)
- : BaseAuthenticationContextObject(hostname, prefilledUsername)
- , m_port(port)
- {
- }
-
- quint16 port() const { return m_port; }
-
-private:
- quint16 m_port;
-};
-
-class CertificateVerificationDialogContextObject : public DialogContextBase {
- Q_OBJECT
- Q_PROPERTY(QString hostname READ hostname CONSTANT)
-
-public:
- CertificateVerificationDialogContextObject(const QString& hostname)
- : DialogContextBase()
- , m_hostname(hostname)
- {
- connect(this, SIGNAL(accepted()), SLOT(dismiss()));
- connect(this, SIGNAL(rejected()), SLOT(dismiss()));
- }
-
- QString hostname() const { return m_hostname; }
-
-public Q_SLOTS:
- void accept() { emit accepted(); }
- void reject() { emit rejected(); }
-
-Q_SIGNALS:
- void accepted();
- void rejected();
-
-private:
- QString m_hostname;
-};
-
-class FilePickerContextObject : public DialogContextBase {
- Q_OBJECT
- Q_PROPERTY(QStringList fileList READ fileList CONSTANT)
- Q_PROPERTY(bool allowMultipleFiles READ allowMultipleFiles CONSTANT)
-
-public:
- FilePickerContextObject(const QStringList& selectedFiles, bool allowMultiple)
- : DialogContextBase()
- , m_allowMultiple(allowMultiple)
- , m_fileList(selectedFiles)
- {
- connect(this, SIGNAL(fileSelected(QStringList)), SLOT(dismiss()));
- connect(this, SIGNAL(rejected()), SLOT(dismiss()));
- }
-
- QStringList fileList() const { return m_fileList; }
- bool allowMultipleFiles() const { return m_allowMultiple;}
-
-public Q_SLOTS:
- void reject() { emit rejected();}
- void accept(const QVariant& path)
- {
- QStringList filesPath = path.toStringList();
-
- if (filesPath.isEmpty()) {
- emit rejected();
- return;
- }
-
- // For single file upload, send only the first element if there are more than one file paths
- if (!m_allowMultiple && filesPath.count() > 1)
- filesPath = QStringList(filesPath.at(0));
- emit fileSelected(filesPath);
- }
-
-Q_SIGNALS:
- void rejected();
- void fileSelected(const QStringList&);
-
-private:
- bool m_allowMultiple;
- QStringList m_fileList;
-};
-
-class DatabaseQuotaDialogContextObject : public DialogContextBase {
- Q_OBJECT
- Q_PROPERTY(QString databaseName READ databaseName CONSTANT)
- Q_PROPERTY(QString displayName READ displayName CONSTANT)
- Q_PROPERTY(quint64 currentQuota READ currentQuota CONSTANT)
- Q_PROPERTY(quint64 currentOriginUsage READ currentOriginUsage CONSTANT)
- Q_PROPERTY(quint64 currentDatabaseUsage READ currentDatabaseUsage CONSTANT)
- Q_PROPERTY(quint64 expectedUsage READ expectedUsage CONSTANT)
- Q_PROPERTY(QtWebSecurityOrigin* origin READ securityOrigin CONSTANT)
-
-public:
- DatabaseQuotaDialogContextObject(const QString& databaseName, const QString& displayName, WKSecurityOriginRef securityOrigin, quint64 currentQuota, quint64 currentOriginUsage, quint64 currentDatabaseUsage, quint64 expectedUsage)
- : DialogContextBase()
- , m_databaseName(databaseName)
- , m_displayName(displayName)
- , m_currentQuota(currentQuota)
- , m_currentOriginUsage(currentOriginUsage)
- , m_currentDatabaseUsage(currentDatabaseUsage)
- , m_expectedUsage(expectedUsage)
- {
- WKRetainPtr<WKStringRef> scheme = adoptWK(WKSecurityOriginCopyProtocol(securityOrigin));
- WKRetainPtr<WKStringRef> host = adoptWK(WKSecurityOriginCopyHost(securityOrigin));
-
- m_securityOrigin.setScheme(WKStringCopyQString(scheme.get()));
- m_securityOrigin.setHost(WKStringCopyQString(host.get()));
- m_securityOrigin.setPort(static_cast<int>(WKSecurityOriginGetPort(securityOrigin)));
-
- connect(this, SIGNAL(accepted(quint64)), SLOT(dismiss()));
- connect(this, SIGNAL(rejected()), SLOT(dismiss()));
- }
-
- QString databaseName() const { return m_databaseName; }
- QString displayName() const { return m_displayName; }
- quint64 currentQuota() const { return m_currentQuota; }
- quint64 currentOriginUsage() const { return m_currentOriginUsage; }
- quint64 currentDatabaseUsage() const { return m_currentDatabaseUsage; }
- quint64 expectedUsage() const { return m_expectedUsage; }
- QtWebSecurityOrigin* securityOrigin() { return &m_securityOrigin; }
-
-public Q_SLOTS:
- void accept(quint64 size) { emit accepted(size); }
- void reject() { emit rejected(); }
-
-Q_SIGNALS:
- void accepted(quint64 size);
- void rejected();
-
-private:
- QString m_databaseName;
- QString m_displayName;
- quint64 m_currentQuota;
- quint64 m_currentOriginUsage;
- quint64 m_currentDatabaseUsage;
- quint64 m_expectedUsage;
- QtWebSecurityOrigin m_securityOrigin;
-};
-
void QtDialogRunner::run()
{
DialogContextBase* context = static_cast<DialogContextBase*>(m_dialogContext->contextObject());
@@ -476,5 +218,5 @@ void QtDialogRunner::onDatabaseQuotaAccepted(quint64 quota)
} // namespace WebKit
-#include "QtDialogRunner.moc"
+#include "moc_DialogContextObjects.cpp"
#include "moc_QtDialogRunner.cpp"
diff --git a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp
index 53faa7647..fd410ffdd 100644
--- a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp
+++ b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp
@@ -90,7 +90,8 @@ void QtPageClient::pageDidRequestScroll(const IntPoint& pos)
void QtPageClient::processDidExit()
{
- QQuickWebViewPrivate::get(m_webView)->processDidCrash();
+ // TODO: Do we need this signal?
+ // QQuickWebViewPrivate::get(m_webView)->processDidExit();
}
void QtPageClient::didRelaunchProcess()
diff --git a/Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp b/Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp
index 031c32d9e..c37099654 100644
--- a/Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp
+++ b/Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp
@@ -22,6 +22,7 @@
#include "config.h"
#include "WebColorPickerQt.h"
+#include "ColorChooserContextObject.h"
#include "qquickwebview_p.h"
#include "qquickwebview_p_p.h"
#include <QtQml/QQmlContext>
@@ -31,33 +32,6 @@ using namespace WebCore;
namespace WebKit {
-class ColorChooserContextObject : public QObject {
- Q_OBJECT
- Q_PROPERTY(QColor currentColor READ currentColor CONSTANT FINAL)
- Q_PROPERTY(QRectF elementRect READ elementRect CONSTANT FINAL)
-
-public:
- ColorChooserContextObject(const QColor& color, const QRectF& rect)
- : m_currentColor(color)
- , m_rect(rect)
- {
- }
-
- QColor currentColor() const { return m_currentColor; }
- QRectF elementRect() const { return m_rect; }
-
- Q_INVOKABLE void accept(const QColor& color) { emit accepted(color); }
- Q_INVOKABLE void reject() { emit rejected(); }
-
-Q_SIGNALS:
- void accepted(const QColor&);
- void rejected();
-
-private:
- QColor m_currentColor;
- QRectF m_rect;
-};
-
WebColorPickerQt::WebColorPickerQt(WebColorPicker::Client* client, QQuickWebView* webView, const Color& initialColor, const IntRect& elementRect)
: WebColorPicker(client)
, m_webView(webView)
@@ -149,5 +123,4 @@ void WebColorPickerQt::endPicker()
} // namespace WebKit
-#include "WebColorPickerQt.moc"
#include "moc_WebColorPickerQt.cpp"
diff --git a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
index 249de62ec..066e273a9 100644
--- a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
+++ b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
@@ -27,6 +27,7 @@
#include "config.h"
#include "WebPopupMenuProxyQt.h"
+#include "ItemSelectorContextObject.h"
#include "PlatformPopupMenuData.h"
#include "WebPopupItem.h"
#include "qquickwebview_p.h"
@@ -39,229 +40,6 @@ using namespace WebCore;
namespace WebKit {
-static QHash<int, QByteArray> createRoleNamesHash();
-
-class PopupMenuItemModel final : public QAbstractListModel {
- Q_OBJECT
-
-public:
- enum Roles {
- GroupRole = Qt::UserRole,
- EnabledRole = Qt::UserRole + 1,
- SelectedRole = Qt::UserRole + 2,
- IsSeparatorRole = Qt::UserRole + 3
- };
-
- PopupMenuItemModel(const Vector<WebPopupItem>&, bool multiple);
- int rowCount(const QModelIndex& parent = QModelIndex()) const final { return m_items.size(); }
- QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const final;
- QHash<int, QByteArray> roleNames() const final;
-
- Q_INVOKABLE void select(int);
-
- int selectedOriginalIndex() const;
- bool multiple() const { return m_allowMultiples; }
- void toggleItem(int);
-
-Q_SIGNALS:
- void indexUpdated();
-
-private:
- struct Item {
- Item(const WebPopupItem& webPopupItem, const QString& group, int originalIndex)
- : text(webPopupItem.m_text)
- , toolTip(webPopupItem.m_toolTip)
- , group(group)
- , originalIndex(originalIndex)
- , enabled(webPopupItem.m_isEnabled)
- , selected(webPopupItem.m_isSelected)
- , isSeparator(webPopupItem.m_type == WebPopupItem::Separator)
- { }
-
- QString text;
- QString toolTip;
- QString group;
- // Keep track of originalIndex because we don't add the label (group) items to our vector.
- int originalIndex;
- bool enabled;
- bool selected;
- bool isSeparator;
- };
-
- void buildItems(const Vector<WebPopupItem>& webPopupItems);
-
- Vector<Item> m_items;
- int m_selectedModelIndex;
- bool m_allowMultiples;
-};
-
-class ItemSelectorContextObject : public QObject {
- Q_OBJECT
- Q_PROPERTY(QRectF elementRect READ elementRect CONSTANT FINAL)
- Q_PROPERTY(QObject* items READ items CONSTANT FINAL)
- Q_PROPERTY(bool allowMultiSelect READ allowMultiSelect CONSTANT FINAL)
-
-public:
- ItemSelectorContextObject(const QRectF& elementRect, const Vector<WebPopupItem>&, bool multiple);
-
- QRectF elementRect() const { return m_elementRect; }
- PopupMenuItemModel* items() { return &m_items; }
- bool allowMultiSelect() { return m_items.multiple(); }
-
- Q_INVOKABLE void accept(int index = -1);
- Q_INVOKABLE void reject() { emit done(); }
- Q_INVOKABLE void dismiss() { emit done(); }
-
-Q_SIGNALS:
- void acceptedWithOriginalIndex(int);
- void done();
-
-private Q_SLOTS:
- void onIndexUpdate();
-
-private:
- QRectF m_elementRect;
- PopupMenuItemModel m_items;
-};
-
-ItemSelectorContextObject::ItemSelectorContextObject(const QRectF& elementRect, const Vector<WebPopupItem>& webPopupItems, bool multiple)
- : m_elementRect(elementRect)
- , m_items(webPopupItems, multiple)
-{
- connect(&m_items, SIGNAL(indexUpdated()), SLOT(onIndexUpdate()));
-}
-
-void ItemSelectorContextObject::onIndexUpdate()
-{
- // Send the update for multi-select list.
- if (m_items.multiple())
- emit acceptedWithOriginalIndex(m_items.selectedOriginalIndex());
-}
-
-
-void ItemSelectorContextObject::accept(int index)
-{
- // If the index is not valid for multi-select lists, just hide the pop up as the selected indices have
- // already been sent.
- if ((index == -1) && m_items.multiple())
- emit done();
- else {
- if (index != -1)
- m_items.toggleItem(index);
- emit acceptedWithOriginalIndex(m_items.selectedOriginalIndex());
- }
-}
-
-static QHash<int, QByteArray> createRoleNamesHash()
-{
- QHash<int, QByteArray> roles;
- roles[Qt::DisplayRole] = "text";
- roles[Qt::ToolTipRole] = "tooltip";
- roles[PopupMenuItemModel::GroupRole] = "group";
- roles[PopupMenuItemModel::EnabledRole] = "enabled";
- roles[PopupMenuItemModel::SelectedRole] = "selected";
- roles[PopupMenuItemModel::IsSeparatorRole] = "isSeparator";
- return roles;
-}
-
-PopupMenuItemModel::PopupMenuItemModel(const Vector<WebPopupItem>& webPopupItems, bool multiple)
- : m_selectedModelIndex(-1)
- , m_allowMultiples(multiple)
-{
- buildItems(webPopupItems);
-}
-
-QHash<int, QByteArray> PopupMenuItemModel::roleNames() const
-{
- static QHash<int, QByteArray> roles = createRoleNamesHash();
- return roles;
-}
-
-QVariant PopupMenuItemModel::data(const QModelIndex& index, int role) const
-{
- if (!index.isValid() || index.row() < 0 || index.row() >= m_items.size())
- return QVariant();
-
- const Item& item = m_items[index.row()];
- if (item.isSeparator) {
- if (role == IsSeparatorRole)
- return true;
- return QVariant();
- }
-
- switch (role) {
- case Qt::DisplayRole:
- return item.text;
- case Qt::ToolTipRole:
- return item.toolTip;
- case GroupRole:
- return item.group;
- case EnabledRole:
- return item.enabled;
- case SelectedRole:
- return item.selected;
- case IsSeparatorRole:
- return false;
- }
-
- return QVariant();
-}
-
-void PopupMenuItemModel::select(int index)
-{
- toggleItem(index);
- emit indexUpdated();
-}
-
-void PopupMenuItemModel::toggleItem(int index)
-{
- int oldIndex = m_selectedModelIndex;
- if (index < 0 || index >= m_items.size())
- return;
- Item& item = m_items[index];
- if (!item.enabled)
- return;
-
- m_selectedModelIndex = index;
- if (m_allowMultiples)
- item.selected = !item.selected;
- else {
- if (index == oldIndex)
- return;
- item.selected = true;
- if (oldIndex != -1) {
- Item& oldItem = m_items[oldIndex];
- oldItem.selected = false;
- emit dataChanged(this->index(oldIndex), this->index(oldIndex));
- }
- }
-
- emit dataChanged(this->index(index), this->index(index));
-}
-
-int PopupMenuItemModel::selectedOriginalIndex() const
-{
- if (m_selectedModelIndex == -1)
- return -1;
- return m_items[m_selectedModelIndex].originalIndex;
-}
-
-void PopupMenuItemModel::buildItems(const Vector<WebPopupItem>& webPopupItems)
-{
- QString currentGroup;
- m_items.reserveInitialCapacity(webPopupItems.size());
- for (int i = 0; i < webPopupItems.size(); i++) {
- const WebPopupItem& webPopupItem = webPopupItems[i];
- if (webPopupItem.m_isLabel) {
- currentGroup = webPopupItem.m_text;
- continue;
- }
- if (webPopupItem.m_isSelected && !m_allowMultiples)
- m_selectedModelIndex = m_items.size();
- m_items.append(Item(webPopupItem, currentGroup, i));
- }
-}
-
WebPopupMenuProxyQt::WebPopupMenuProxyQt(WebPopupMenuProxy::Client& client, QQuickWebView* webView)
: WebPopupMenuProxy(client)
, m_webView(webView)
@@ -348,8 +126,5 @@ void WebPopupMenuProxyQt::createContext(QQmlComponent* component, QObject* conte
} // namespace WebKit
-// Since we define QObjects in WebPopupMenuProxyQt.cpp, this will trigger moc to run on .cpp.
-#include "WebPopupMenuProxyQt.moc"
-
// And we can't compile the moc for WebPopupMenuProxyQt.h by itself, since it doesn't include "config.h"
#include "moc_WebPopupMenuProxyQt.cpp"