diff options
19 files changed, 740 insertions, 538 deletions
diff --git a/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp b/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp index 908d881f1..2c8571ace 100644 --- a/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp @@ -41,7 +41,7 @@ std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffe const QByteArray fontData(buffer.data(), buffer.size()); // Pixel size doesn't matter at this point, it is set in FontCustomPlatformData::fontPlatformData. - QRawFont rawFont(fontData, /*pixelSize = */0, QFont::PreferDefaultHinting); + QRawFont rawFont(fontData, /*pixelSize = */0, QFont::PreferVerticalHinting); if (!rawFont.isValid()) return 0; diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp index 98f2ec964..a56a47a3e 100644 --- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp +++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp @@ -193,15 +193,6 @@ void MediaPlayerPrivateMediaFoundation::cancelLoad() notImplemented(); } -void MediaPlayerPrivateMediaFoundation::prepareToPlay() -{ - // We call startSession() to start buffering video data. - // When we have received enough data, we pause, so that we don't actually start the playback. - ASSERT(m_paused); - ASSERT(!m_preparingToPlay); - m_preparingToPlay = startSession(); -} - void MediaPlayerPrivateMediaFoundation::play() { m_paused = !startSession(); @@ -937,7 +928,11 @@ void MediaPlayerPrivateMediaFoundation::onTopologySet() } // It is expected that we start buffering data from the network now. - prepareToPlay(); + // We call startSession() to start buffering video data. + // When we have received enough data, we pause, so that we don't actually start the playback. + ASSERT(m_paused); + ASSERT(!m_preparingToPlay); + m_preparingToPlay = startSession(); } void MediaPlayerPrivateMediaFoundation::onBufferingStarted() @@ -2920,6 +2915,7 @@ HRESULT MediaPlayerPrivateMediaFoundation::Direct3DPresenter::presentSample(IMFS D3DSURFACE_DESC desc; if (SUCCEEDED(surface->GetDesc(&desc))) format = desc.Format; + m_memSurface.clear(); hr = m_device->CreateOffscreenPlainSurface(width, height, format, D3DPOOL_SYSTEMMEM, &m_memSurface, nullptr); m_width = width; m_height = height; diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h index 0fe07fa13..d945c20d0 100644 --- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h +++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h @@ -60,8 +60,6 @@ public: void load(const String& url) override; void cancelLoad() override; - void prepareToPlay() override; - void play() override; void pause() override; diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h index 8465db721..8bfc1d46e 100644 --- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h @@ -32,9 +32,7 @@ #include "FormState.h" #include "FrameLoaderClient.h" -#include "HTMLFormElement.h" #include "ResourceResponse.h" -#include "SharedBuffer.h" #include "URL.h" #include <QUrl> #include <qobject.h> diff --git a/Source/WebKit/qt/WebCoreSupport/ProgressTrackerClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/ProgressTrackerClientQt.cpp index 7cf620bd4..4e7f61d63 100644 --- a/Source/WebKit/qt/WebCoreSupport/ProgressTrackerClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/ProgressTrackerClientQt.cpp @@ -26,9 +26,11 @@ #include "config.h" #include "ProgressTrackerClientQt.h" +#include "Document.h" #include "EventHandler.h" #include "Frame.h" #include "FrameLoaderClientQt.h" +#include "HTMLFormElement.h" #include "ProgressTracker.h" #include "QWebFrameAdapter.h" #include "QWebPageAdapter.h" diff --git a/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp index df28e9f21..841d0544a 100644 --- a/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp +++ b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp @@ -31,6 +31,7 @@ #include "FrameLoaderClientQt.h" #include "FrameView.h" #include "HTMLCollection.h" +#include "HTMLFormElement.h" #include "HTMLMetaElement.h" #include "HTTPParsers.h" #include "HitTestResult.h" diff --git a/Source/WebKit/qt/WebCoreSupport/QWebFrameData.cpp b/Source/WebKit/qt/WebCoreSupport/QWebFrameData.cpp index d09ad3a35..f3f1534e0 100644 --- a/Source/WebKit/qt/WebCoreSupport/QWebFrameData.cpp +++ b/Source/WebKit/qt/WebCoreSupport/QWebFrameData.cpp @@ -21,6 +21,8 @@ #include "config.h" #include "QWebFrameData.h" +#include "Document.h" +#include "HTMLFormElement.h" #include "FrameLoaderClientQt.h" #include "MainFrame.h" #include "Page.h" diff --git a/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp index ab15c6315..a4056f996 100644 --- a/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -170,12 +170,7 @@ void tst_QWebFrame::progressSignal() ::waitForSignal(m_view, SIGNAL(loadFinished(bool))); - QVERIFY(progressSpy.size() >= 2); - - // WebKit defines initialProgressValue as 10%, not 0% - QCOMPARE(progressSpy.first().first().toInt(), 10); - - // But we always end at 100% + QVERIFY(progressSpy.size() >= 1); QCOMPARE(progressSpy.last().first().toInt(), 100); } diff --git a/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 73427cb4b..760a242af 100644 --- a/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -3329,9 +3329,12 @@ void tst_QWebPage::contextMenuPopulatedOnce() QList<QAction *> list = contextMenu->actions(); QStringList entries; while (!list.isEmpty()) { - QString entry = list.takeFirst()->text(); - QVERIFY(!entries.contains(entry)); - entries << entry; + const QAction* action = list.takeFirst(); + if (!action->isSeparator()) { + QString entry = action->text(); + QVERIFY(!entries.contains(entry)); + entries << entry; + } } } diff --git a/Source/WebKit2/PlatformQt.cmake b/Source/WebKit2/PlatformQt.cmake index 5883096eb..a033f1cf1 100644 --- a/Source/WebKit2/PlatformQt.cmake +++ b/Source/WebKit2/PlatformQt.cmake @@ -156,6 +156,9 @@ list(APPEND WebKit2_SOURCES UIProcess/gstreamer/WebPageProxyGStreamer.cpp UIProcess/qt/BackingStoreQt.cpp + UIProcess/qt/ColorChooserContextObject.h + UIProcess/qt/DialogContextObjects.h + UIProcess/qt/ItemSelectorContextObject.cpp UIProcess/qt/PageViewportControllerClientQt.cpp UIProcess/qt/QrcSchemeHandler.cpp UIProcess/qt/QtDialogRunner.cpp 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/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" diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake index ac1065d92..2756a928c 100644 --- a/Source/cmake/OptionsQt.cmake +++ b/Source/cmake/OptionsQt.cmake @@ -295,6 +295,7 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(USE_SYSTEM_MALLOC PUBLIC OFF) # we need a value different from the default defined in WebKitFeatures.cmake. # Changing these options is completely unsupported. WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_3D_TRANSFORMS PRIVATE ON) +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_COMPOSITING PRIVATE ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_IMAGE_SET PRIVATE ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_REGIONS PRIVATE ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_SHAPES PRIVATE ON) diff --git a/Tools/qt/make-release.pl b/Tools/qt/make-release.pl new file mode 100755 index 000000000..facc3124f --- /dev/null +++ b/Tools/qt/make-release.pl @@ -0,0 +1,69 @@ +#!/usr/bin/env perl +# Copyright (C) 2019 Konstantin Tokarev <annulen@yandex.ru> +# +# 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. + +use Cwd; +use File::Basename; +use strict; +use warnings; + +sub usage { + my $msg = shift || ""; + die $msg . "Usage: cd snapshot/repo/path; $0 <version>"; +} + +scalar @ARGV == 1 || usage(); + +my $version = shift; + +-f "ChangeLog" && die "This script must be run in snapshots repository"; +-d ".git" || usage(); + +`LC_ALL=C LANG=C git status` =~ "nothing to commit, working tree clean" or die "Snapshots working tree is dirty"; + +my $snapshotTag = "v$version"; +my $originalTag = "qtwebkit-$version"; + +`git tag -l $snapshotTag` && print "Found $snapshotTag\n" || die "Tag $snapshotTag is not found"; +`git tag -l $originalTag` && print "Found $originalTag\n" || die "Tag $originalTag is not found"; + +my $originalTagHash = `git log -1 --format=format:"%H" $originalTag`; +chomp $originalTagHash; + +open (my $gitShow, "-|", "git show -s --format=%B $snapshotTag") or die "Failed to run git show: $!"; +while (<$gitShow>) { + if (/^Import WebKit commit ([0-9a-f]+)$/) { + print "Snaphot imported tag = $1\n"; + unless ($1 eq $originalTagHash) { + die "Imported tag '$snapshotTag' does not point to '$originalTag' ('$originalTagHash')"; + } + last; + } +} + +# Now we are ok, let's finally make tarball +my $cmd = "git archive --prefix=$originalTag/ $snapshotTag | xz -9 > $originalTag.tar.xz"; +print "$cmd\n"; +system($cmd) == 0 or die "git archive failed: $!"; + +# TODO: Upload to GitHub? |