Diff
Modified: trunk/Source/WebKit2/ChangeLog (112194 => 112195)
--- trunk/Source/WebKit2/ChangeLog 2012-03-27 02:17:23 UTC (rev 112194)
+++ trunk/Source/WebKit2/ChangeLog 2012-03-27 02:29:41 UTC (rev 112195)
@@ -1,3 +1,31 @@
+2012-03-26 Dinu Jacob <[email protected]>
+
+ [Qt][WK2] Support multi-file upload
+ https://bugs.webkit.org/show_bug.cgi?id=81589
+
+ Reviewed by Simon Hausmann.
+
+ Added 'allowMutipleFiles' property to filePicker context property to indicate whether to allow
+ multiple file selections.
+
+ * UIProcess/API/qt/qquickwebview.cpp:
+ (QQuickWebViewPrivate::chooseFiles):
+ * UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro:
+ * UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_multiFileUpload.qml: Added.
+ * UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_singleFileUpload.qml:
+ * UIProcess/API/qt/tests/qmltests/common/multifileupload.html: Added.
+ * UIProcess/API/qt/tests/qmltests/common/singlefileupload.html:
+ * UIProcess/API/qt/tests/qmltests/common/titleupdate.js: Added.
+ (updateTitle):
+ * UIProcess/qt/QtDialogRunner.cpp:
+ (FilePickerContextObject):
+ (FilePickerContextObject::FilePickerContextObject):
+ (FilePickerContextObject::allowMultipleFiles):
+ (FilePickerContextObject::accept):
+ (QtDialogRunner::initForFilePicker):
+ * UIProcess/qt/QtDialogRunner.h:
+ (QtDialogRunner):
+
2012-03-26 Adam Barth <[email protected]>
FrameLoader::shouldAllowNavigation uses Frame for context rather than Document
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp (112194 => 112195)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2012-03-27 02:17:23 UTC (rev 112194)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2012-03-27 02:29:41 UTC (rev 112195)
@@ -364,11 +364,11 @@
{
Q_Q(QQuickWebView);
- if (!filePicker || type == QtWebPageUIClient::MultipleFilesSelection)
+ if (!filePicker)
return;
QtDialogRunner dialogRunner;
- if (!dialogRunner.initForFilePicker(filePicker, q, selectedFileNames))
+ if (!dialogRunner.initForFilePicker(filePicker, q, selectedFileNames, (type == QtWebPageUIClient::MultipleFilesSelection)))
return;
execDialogRunner(dialogRunner);
Copied: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_multiFileUpload.qml (from rev 112194, trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_singleFileUpload.qml) (0 => 112195)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_multiFileUpload.qml (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_multiFileUpload.qml 2012-03-27 02:29:41 UTC (rev 112195)
@@ -0,0 +1,66 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 1.0
+import "../common"
+
+// FIXME: Added to Desktop tests because we want to have mouseClick() to open the <input> tag. We can move it back
+// when TestCase starts supporting touch events, see https://bugreports.qt.nokia.com/browse/QTBUG-23083.
+TestWebView {
+ id: webView
+
+ width: 400
+ height: 400
+
+ property bool selectFile
+
+ experimental.filePicker: Item {
+ Timer {
+ running: true
+ interval: 1
+ onTriggered: {
+ var selectedFiles = ["filename1", "filename2"]
+ if (selectFile)
+ model.accept(selectedFiles)
+ else
+ model.reject();
+ }
+ }
+ }
+
+ SignalSpy {
+ id: titleSpy
+ target: webView
+ signalName: "titleChanged"
+ }
+
+ TestCase {
+ id: test
+ name: "WebViewMultiFilePicker"
+ when: windowShown
+
+ function init() {
+ webView.url = ""
+ verify(webView.waitForLoadSucceeded())
+ titleSpy.clear()
+ }
+
+ function openItemSelector() {
+ mouseClick(webView, 15, 15, Qt.LeftButton)
+ }
+
+ function test_accept() {
+ webView.selectFile = true;
+ openItemSelector()
+ titleSpy.wait()
+ compare(webView.title, "filename1,filename2")
+ }
+
+ function test_reject() {
+ var oldTitle = webView.title
+ webView.selectFile = false;
+ openItemSelector()
+ compare(webView.title, oldTitle)
+ }
+ }
+}
Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_singleFileUpload.qml (112194 => 112195)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_singleFileUpload.qml 2012-03-27 02:17:23 UTC (rev 112194)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_singleFileUpload.qml 2012-03-27 02:29:41 UTC (rev 112195)
@@ -13,14 +13,20 @@
height: 400
property bool selectFile
+ property bool acceptMultiple: false
experimental.filePicker: Item {
Timer {
running: true
interval: 1
onTriggered: {
- if (selectFile)
- model.accept("acceptedfilename");
+ var selectedFiles = ["filename1", "filename2"]
+ if (selectFile) {
+ if (acceptMultiple)
+ model.accept(selectedFiles)
+ else
+ model.accept("acceptedfilename");
+ }
else
model.reject();
}
@@ -55,6 +61,14 @@
compare(webView.title, "acceptedfilename")
}
+ function test_multiple() {
+ webView.selectFile = true;
+ webView.acceptMultiple = true;
+ openItemSelector()
+ titleSpy.wait()
+ compare(webView.title, "filename1")
+ }
+
function test_reject() {
var oldTitle = webView.title
webView.selectFile = false;
Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro (112194 => 112195)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro 2012-03-27 02:17:23 UTC (rev 112194)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro 2012-03-27 02:29:41 UTC (rev 112195)
@@ -20,4 +20,5 @@
DesktopBehavior/tst_loadHtml.qml \
DesktopBehavior/tst_messaging.qml \
DesktopBehavior/tst_navigationRequested.qml \
- DesktopBehavior/tst_singlefileupload.qml
+ DesktopBehavior/tst_singleFileupload.qml \
+ DesktopBehavior/tst_multiFileupload.qml
Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/multifileupload.html (0 => 112195)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/multifileupload.html (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/multifileupload.html 2012-03-27 02:29:41 UTC (rev 112195)
@@ -0,0 +1,11 @@
+<html>
+<head>
+<meta name="viewport" initial-scale=1">
+<title> Mutli-file Upload </title>
+<script src = ""
+</script>
+
+<body>
+<input type="file" name="file" id="upfile" _onchange_="updateTitle()" multiple/>
+</body>
+</html>
Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/singlefileupload.html (112194 => 112195)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/singlefileupload.html 2012-03-27 02:17:23 UTC (rev 112194)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/singlefileupload.html 2012-03-27 02:29:41 UTC (rev 112195)
@@ -1,23 +1,8 @@
<html>
<head>
<meta name="viewport" initial-scale=1">
-<title>No file selected</title>
-<script>
-function updateTitle()
-{
- var inp = document.getElementById("upfile");
- var allfiles = new String("");
- var name = new String("");
- for (var i = 0; i < inp.files.length; ++i)
- {
- name = inp.files.item(i).name;
- if (allfiles.length == 0)
- allfiles = name;
- else
- allfiles = allfiles + "," + name;
- }
- document.title = allfiles;
-}
+<title> Single File Upload </title>
+<script src = ""
</script>
<body>
Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/titleupdate.js (0 => 112195)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/titleupdate.js (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/titleupdate.js 2012-03-27 02:29:41 UTC (rev 112195)
@@ -0,0 +1,15 @@
+function updateTitle()
+{
+ var inp = document.getElementById("upfile");
+ var allfiles = new String("");
+ var name = new String("");
+ for (var i = 0; i < inp.files.length; ++i)
+ {
+ name = inp.files.item(i).name;
+ if (allfiles.length == 0)
+ allfiles = name;
+ else
+ allfiles = allfiles + "," + name;
+ }
+ document.title = allfiles;
+}
Modified: trunk/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp (112194 => 112195)
--- trunk/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp 2012-03-27 02:17:23 UTC (rev 112194)
+++ trunk/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp 2012-03-27 02:29:41 UTC (rev 112195)
@@ -163,25 +163,36 @@
class FilePickerContextObject : public QObject {
Q_OBJECT
Q_PROPERTY(QStringList fileList READ fileList CONSTANT)
+ Q_PROPERTY(bool allowMultipleFiles READ allowMultipleFiles CONSTANT)
public:
- FilePickerContextObject(const QStringList& selectedFiles)
+ FilePickerContextObject(const QStringList& selectedFiles, bool allowMultiple)
: QObject()
+ , m_allowMultiple(allowMultiple)
, m_fileList(selectedFiles)
{
}
QStringList fileList() const { return m_fileList; }
+ bool allowMultipleFiles() const { return m_allowMultiple;}
public slots:
void reject() { emit rejected();}
- void accept(const QVariant& path) { emit fileSelected(path.toStringList()); }
+ void accept(const QVariant& path)
+ {
+ QStringList filesPath = path.toStringList();
+ // 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);
+ }
signals:
void rejected();
void fileSelected(const QStringList&);
private:
+ bool m_allowMultiple;
QStringList m_fileList;
};
@@ -312,9 +323,9 @@
return true;
}
-bool QtDialogRunner::initForFilePicker(QDeclarativeComponent* component, QQuickItem* dialogParent, const QStringList& selectedFiles)
+bool QtDialogRunner::initForFilePicker(QDeclarativeComponent* component, QQuickItem* dialogParent, const QStringList& selectedFiles, bool allowMultiple)
{
- FilePickerContextObject* contextObject = new FilePickerContextObject(selectedFiles);
+ FilePickerContextObject* contextObject = new FilePickerContextObject(selectedFiles, allowMultiple);
if (!createDialog(component, dialogParent, contextObject))
return false;
Modified: trunk/Source/WebKit2/UIProcess/qt/QtDialogRunner.h (112194 => 112195)
--- trunk/Source/WebKit2/UIProcess/qt/QtDialogRunner.h 2012-03-27 02:17:23 UTC (rev 112194)
+++ trunk/Source/WebKit2/UIProcess/qt/QtDialogRunner.h 2012-03-27 02:29:41 UTC (rev 112195)
@@ -43,7 +43,7 @@
bool initForAuthentication(QDeclarativeComponent*, QQuickItem* dialogParent, const QString& hostname, const QString& realm, const QString& prefilledUsername);
bool initForCertificateVerification(QDeclarativeComponent*, QQuickItem*, const QString& hostname);
bool initForProxyAuthentication(QDeclarativeComponent*, QQuickItem*, const QString& hostname, uint16_t port, const QString& prefilledUsername);
- bool initForFilePicker(QDeclarativeComponent*, QQuickItem*, const QStringList& selectedFiles);
+ bool initForFilePicker(QDeclarativeComponent*, QQuickItem*, const QStringList& selectedFiles, bool allowMultiple);
bool initForDatabaseQuotaDialog(QDeclarativeComponent*, QQuickItem*, const QString& databaseName, const QString& displayName, WKSecurityOriginRef, quint64 currentQuota, quint64 currentOriginUsage, quint64 currentDatabaseUsage, quint64 expectedUsage);
QQuickItem* dialog() const { return m_dialog.get(); }
Modified: trunk/Tools/ChangeLog (112194 => 112195)
--- trunk/Tools/ChangeLog 2012-03-27 02:17:23 UTC (rev 112194)
+++ trunk/Tools/ChangeLog 2012-03-27 02:29:41 UTC (rev 112195)
@@ -1,3 +1,22 @@
+2012-03-26 Dinu Jacob <[email protected]>
+
+ [Qt][WK2] Support multi-file upload
+ https://bugs.webkit.org/show_bug.cgi?id=81589
+
+ Reviewed by Simon Hausmann.
+
+ Modified filePicker to support multi-file upload.
+
+ * MiniBrowser/qt/MiniBrowser.qrc:
+ * MiniBrowser/qt/icons/checkbox_checked.png: Added.
+ * MiniBrowser/qt/icons/checkbox_unchecked.png: Added.
+ * MiniBrowser/qt/js/MultiSelect.js: Added.
+ (values):
+ (isSelected):
+ (removeValue):
+ * MiniBrowser/qt/qml/CheckBox.qml: Added.
+ * MiniBrowser/qt/qml/FilePicker.qml:
+
2012-03-26 Mark Hahnenberg <[email protected]>
Retry crashing tests serially at the end of NRWT on Apple Mac
Modified: trunk/Tools/MiniBrowser/qt/MiniBrowser.qrc (112194 => 112195)
--- trunk/Tools/MiniBrowser/qt/MiniBrowser.qrc 2012-03-27 02:17:23 UTC (rev 112194)
+++ trunk/Tools/MiniBrowser/qt/MiniBrowser.qrc 2012-03-27 02:29:41 UTC (rev 112195)
@@ -1,5 +1,7 @@
<RCC>
<qresource prefix="/">
+ <file>icons/checkbox_checked.png</file>
+ <file>icons/checkbox_unchecked.png</file>
<file>icons/favicon.png</file>
<file>icons/folder.png</file>
<file>icons/info.png</file>
@@ -12,9 +14,11 @@
<file>icons/touch.png</file>
<file>icons/touchpoint.png</file>
<file>icons/up.png</file>
+ <file>js/MultiSelect.js</file>
<file>qml/AlertDialog.qml</file>
<file>qml/AuthenticationDialog.qml</file>
<file>qml/BrowserWindow.qml</file>
+ <file>qml/CheckBox.qml</file>
<file>qml/ConfirmDialog.qml</file>
<file>qml/Dialog.qml</file>
<file>qml/DialogButton.qml</file>
Added: trunk/Tools/MiniBrowser/qt/icons/checkbox_checked.png (0 => 112195)
--- trunk/Tools/MiniBrowser/qt/icons/checkbox_checked.png (rev 0)
+++ trunk/Tools/MiniBrowser/qt/icons/checkbox_checked.png 2012-03-27 02:29:41 UTC (rev 112195)
@@ -0,0 +1,6 @@
+\x89PNG
+
+
+IHDR
+
+ \xD8\xE2,\xF7 sBITU\xECF tEXtSoftware www.inkscape.org\x9B\xEE< \x9BIDAT\xD3ch\xACh\xFC\x81V04\xFE\xC7\xC1R\xF7&\xBF\xECA\x86\xF7&å>t\xFCo\x80\xC1s\xF3\xA6\xDC=\xB5\x8B\xD4\xED\xE9\xAD?\xFFo܉$umP\xA2\xF3\xD5ڞ\xEF\x8D\xFF\xA7\xDC{\xD3\x97Z\xBF\xBB\xF1\xFF\x8A{_O\xFA\xD2\xF8\xBF\xF7\xC5\xC7\xF6p\xA9㋛\xFE6\xFE\xEF\xEA\xE8\xF8\xF8\xBC\xF7\x92ԇ\x8EM;@t돛\xD3@6\xA2H\xFDoXx\xAA\xED\xCB\xE9\xC7 IA\xFC\xF5\xBC\x8B\xBFp\x85\xCE0 \x95\xDE\xF8\xD0`e9 IEND\xAEB`\x82
\ No newline at end of file
Added: trunk/Tools/MiniBrowser/qt/icons/checkbox_unchecked.png (0 => 112195)
--- trunk/Tools/MiniBrowser/qt/icons/checkbox_unchecked.png (rev 0)
+++ trunk/Tools/MiniBrowser/qt/icons/checkbox_unchecked.png 2012-03-27 02:29:41 UTC (rev 112195)
@@ -0,0 +1,8 @@
+\x89PNG
+
+
+IHDR
+
+ \xD8\xE2,\xF7 sBITU\xECF tEXtSoftware www.inkscape.org\x9B\xEE< 3IDAT\xD3ch\xACh\xFC\x81V04\xFE\xC7\xC1R\xF7&\xBF\xECA\x86\xF7&å>t\xFCo@\x86:\x86\x90\xE1
+
+\x9Ca \xF5\x8F\xF9T\xCD\xDF IEND\xAEB`\x82
\ No newline at end of file
Added: trunk/Tools/MiniBrowser/qt/js/MultiSelect.js (0 => 112195)
--- trunk/Tools/MiniBrowser/qt/js/MultiSelect.js (rev 0)
+++ trunk/Tools/MiniBrowser/qt/js/MultiSelect.js 2012-03-27 02:29:41 UTC (rev 112195)
@@ -0,0 +1,44 @@
+/*
+ * 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 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.
+ *
+ */
+
+
+var values = []
+
+function selectedValues() {
+ return values
+}
+
+function isSelected(value) {
+ return (values.indexOf(value) != -1)
+}
+
+function addValue(value) {
+ if (values.indexOf(value) != -1)
+ return
+ values.push(value)
+}
+
+function removeValue(value) {
+ var index = values.indexOf(value)
+
+ if (index == -1)
+ return
+ values.splice(index, 1)
+}
Added: trunk/Tools/MiniBrowser/qt/qml/CheckBox.qml (0 => 112195)
--- trunk/Tools/MiniBrowser/qt/qml/CheckBox.qml (rev 0)
+++ trunk/Tools/MiniBrowser/qt/qml/CheckBox.qml 2012-03-27 02:29:41 UTC (rev 112195)
@@ -0,0 +1,35 @@
+/*
+ * 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 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.
+ *
+ */
+
+import QtQuick 2.0
+
+Item {
+ id: checkbox
+ width: 50
+ height: parent.height
+ property bool checked
+
+ Image {
+ width: 24
+ height: 24
+ source: parent.checked ? '../icons/checkbox_checked.png' : '../icons/checkbox_unchecked.png'
+ anchors.verticalCenter: parent.verticalCenter
+ }
+}
Modified: trunk/Tools/MiniBrowser/qt/qml/FilePicker.qml (112194 => 112195)
--- trunk/Tools/MiniBrowser/qt/qml/FilePicker.qml 2012-03-27 02:17:23 UTC (rev 112194)
+++ trunk/Tools/MiniBrowser/qt/qml/FilePicker.qml 2012-03-27 02:29:41 UTC (rev 112195)
@@ -20,6 +20,7 @@
import QtQuick 2.0
import Qt.labs.folderlistmodel 1.0
+import "../js/MultiSelect.js" as MultiSelect
Rectangle {
id: filePicker
@@ -109,8 +110,19 @@
function selected() {
if (folders.isFolder(index))
openFolder(filePath);
- else
- fileModel.accept(filePath);
+ else {
+
+ if (fileModel.allowMultipleFiles) {
+ checkbox.checked = !checkbox.checked
+
+ if (checkbox.checked)
+ MultiSelect.addValue(filePath)
+ else
+ MultiSelect.removeValue(filePath)
+ }
+ else
+ fileModel.accept(filePath)
+ }
}
height: 50
@@ -118,7 +130,7 @@
color: folders.isFolder(index) ? "lightgray": "darkgray"
Item {
- width: 48;
+ width: 50
height: 48
Image {
source: "../icons/folder.png"
@@ -128,11 +140,24 @@
}
Text {
+ id: fileNameText
anchors.centerIn: parent
- anchors.leftMargin: 50
+ anchors.leftMargin: 20
+ width: 300
text: fileName
+ elide: Text.ElideLeft;
}
+ CheckBox {
+ id: checkbox
+
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+
+ checked: MultiSelect.isSelected(filePath)
+ visible: fileModel.allowMultipleFiles && !folders.isFolder(index)
+ }
+
MouseArea {
anchors.fill: parent
onClicked: selected();
@@ -160,15 +185,25 @@
right: parent.right
}
- DialogButton {
- id: cancel
- text: "Cancel"
- anchors {
- horizontalCenter: parent.horizontalCenter;
- verticalCenter: parent.verticalCenter
+ Row {
+ id: buttonRow
+ spacing: 10
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+
+ DialogButton {
+ id: cancel
+ text: "Cancel"
+ onClicked: fileModel.reject()
}
- onClicked: fileModel.reject()
+ DialogButton {
+ id: accept
+ text: "Ok"
+ visible: fileModel.allowMultipleFiles
+ onClicked:
+ fileModel.accept(MultiSelect.selectedValues());
+ }
}
}