[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

oliver at apple.com oliver at apple.com
Thu Apr 8 01:23:19 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit cebc1867eb0a1fa04d7e1cee2a645ea11c5df04a
Author: oliver at apple.com <oliver at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Jan 24 07:44:05 2010 +0000

    2010-01-23  Oliver Hunt  <oliver at apple.com>
    
            Reviewed by Maciej Stachowiak.
    
            Implement support for FileList cloning in postMessage
            https://bugs.webkit.org/show_bug.cgi?id=34048
    
            Add test for passing a FileList through postMessage, and
            correct testing already present to test what it was meant
            to be.
    
            * fast/dom/Window/window-postmessage-clone-expected.txt:
            * fast/dom/Window/window-postmessage-clone.html:
    2010-01-23  Oliver Hunt  <oliver at apple.com>
    
            Reviewed by Maciej Stachowiak.
    
            Implement support for FileList cloning in postMessage
            https://bugs.webkit.org/show_bug.cgi?id=34048
    
            Support passing FileList through postMessage APIs.  Basically
            mechanical task in line with other terminals in the object
            graph.
    
            * bindings/js/SerializedScriptValue.cpp:
            (WebCore::SerializedFileList::create):
            (WebCore::SerializedFileList::length):
            (WebCore::SerializedFileList::item):
            (WebCore::SerializedFileList::SerializedFileList):
            (WebCore::SerializedScriptValueData::SerializedScriptValueData):
            (WebCore::SharedSerializedData::asFileList):
            (WebCore::SerializingTreeWalker::convertIfTerminal):
            (WebCore::DeserializingTreeWalker::convertIfTerminal):
            (WebCore::TeardownTreeWalker::convertIfTerminal):
                Rearrange these functions to not use 'default:' handling
                so that the compiler will actually tell us when we're
                not handling cases.
            * bindings/js/SerializedScriptValue.h:
            (WebCore::SerializedScriptValueData::):
            (WebCore::SerializedScriptValueData::asFileList):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53774 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 3c2aa84..306bb2e 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-01-23  Oliver Hunt  <oliver at apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        Implement support for FileList cloning in postMessage
+        https://bugs.webkit.org/show_bug.cgi?id=34048
+
+        Add test for passing a FileList through postMessage, and 
+        correct testing already present to test what it was meant
+        to be.
+
+        * fast/dom/Window/window-postmessage-clone-expected.txt:
+        * fast/dom/Window/window-postmessage-clone.html:
+
 2010-01-23  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by Maciej Stachowiak.
diff --git a/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt b/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt
index 2353f19..aa7d220 100644
--- a/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt
+++ b/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt
@@ -17,5 +17,6 @@ PASS: eventData is null of type object
 PASS: eventData is 2009-02-13T23:31:30.000Z of type object
 PASS: eventData is [object Array](default toString threw RangeError: Maximum call stack size exceeded.) of type object
 PASS: eventData is [object File] of type object
+PASS: eventData is [object FileList] of type object
 PASS: eventData is done of type string
 
diff --git a/LayoutTests/fast/dom/Window/window-postmessage-clone.html b/LayoutTests/fast/dom/Window/window-postmessage-clone.html
index 31f9c9a..bc8d9e2 100644
--- a/LayoutTests/fast/dom/Window/window-postmessage-clone.html
+++ b/LayoutTests/fast/dom/Window/window-postmessage-clone.html
@@ -38,12 +38,15 @@ function equal(actual, expected)
         }
         return true;
     }
+    if (actual.constructor !== expected.constructor)
+        return false;
     var keys = Object.keys(actual);
     if (!equal(keys, Object.keys(expected)))
         return false;
-    for (var i = 0; i < keys.length; i++)
-        if (!equal(actual[i], expected[i]))
+    for (var i = 0; i < keys.length; i++) {
+        if (!equal(actual[keys[i]], expected[keys[i]]))
             return false;
+    }
     return true;
 }
 
@@ -131,8 +134,8 @@ var targetY = fileRect.top + fileRect.height / 2;
 eventSender.beginDragWithFiles(['get-file-upload.html']);
 eventSender.mouseMoveTo(targetX, targetY);
 eventSender.mouseUp();
-
 tryPostMessage('fileInput.files[0]', false, fileInput.files[0]);
+tryPostMessage('fileInput.files', false, fileInput.files);
 
 tryPostMessage('"done"');
 </script>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 061e0d9..a37371f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,31 @@
+2010-01-23  Oliver Hunt  <oliver at apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        Implement support for FileList cloning in postMessage
+        https://bugs.webkit.org/show_bug.cgi?id=34048
+
+        Support passing FileList through postMessage APIs.  Basically
+        mechanical task in line with other terminals in the object
+        graph.
+
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::SerializedFileList::create):
+        (WebCore::SerializedFileList::length):
+        (WebCore::SerializedFileList::item):
+        (WebCore::SerializedFileList::SerializedFileList):
+        (WebCore::SerializedScriptValueData::SerializedScriptValueData):
+        (WebCore::SharedSerializedData::asFileList):
+        (WebCore::SerializingTreeWalker::convertIfTerminal):
+        (WebCore::DeserializingTreeWalker::convertIfTerminal):
+        (WebCore::TeardownTreeWalker::convertIfTerminal):
+            Rearrange these functions to not use 'default:' handling
+            so that the compiler will actually tell us when we're
+            not handling cases.
+        * bindings/js/SerializedScriptValue.h:
+        (WebCore::SerializedScriptValueData::):
+        (WebCore::SerializedScriptValueData::asFileList):
+
 2010-01-23  Yury Semikhatsky  <yurys at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/bindings/js/SerializedScriptValue.cpp b/WebCore/bindings/js/SerializedScriptValue.cpp
index f0e7b6e..b38a009 100644
--- a/WebCore/bindings/js/SerializedScriptValue.cpp
+++ b/WebCore/bindings/js/SerializedScriptValue.cpp
@@ -28,6 +28,7 @@
 #include "SerializedScriptValue.h"
 
 #include "File.h"
+#include "FileList.h"
 #include "JSDOMGlobalObject.h"
 #include "JSFile.h"
 #include "JSFileList.h"
@@ -142,6 +143,28 @@ private:
     unsigned m_length;
 };
 
+class SerializedFileList : public SharedSerializedData {
+public:
+    static PassRefPtr<SerializedFileList> create(const FileList* list)
+    {
+        return adoptRef(new SerializedFileList(list));
+    }
+
+    unsigned length() const { return m_files.size(); }
+    const String& item(unsigned idx) { return m_files[idx]; }
+
+private:
+    SerializedFileList(const FileList* list)
+    {
+        unsigned length = list->length();
+        m_files.reserveCapacity(length);
+        for (unsigned i = 0; i < length; i++)
+            m_files.append(list->item(i)->path().crossThreadString());
+    }
+
+    Vector<String> m_files;
+};
+
 SerializedScriptValueData::SerializedScriptValueData(RefPtr<SerializedObject> data)
     : m_type(ObjectType)
     , m_sharedData(data)
@@ -154,6 +177,12 @@ SerializedScriptValueData::SerializedScriptValueData(RefPtr<SerializedArray> dat
 {
 }
 
+SerializedScriptValueData::SerializedScriptValueData(const FileList* fileList)
+    : m_type(FileListType)
+    , m_sharedData(SerializedFileList::create(fileList))
+{
+}
+
 SerializedScriptValueData::SerializedScriptValueData(const File* file)
     : m_type(FileType)
     , m_string(file->path().crossThreadString())
@@ -170,6 +199,11 @@ SerializedObject* SharedSerializedData::asObject()
     return static_cast<SerializedObject*>(this);
 }
 
+SerializedFileList* SharedSerializedData::asFileList()
+{
+    return static_cast<SerializedFileList*>(this);
+}
+
 static const unsigned maximumFilterRecursion = 40000;
 enum WalkerState { StateUnknown, ArrayStartState, ArrayStartVisitMember, ArrayEndVisitMember,
     ObjectStartState, ObjectStartVisitMember, ObjectEndVisitMember };
@@ -497,6 +531,8 @@ struct SerializingTreeWalker : public BaseWalker {
             JSObject* obj = asObject(value);
             if (obj->inherits(&JSFile::s_info))
                 return SerializedScriptValueData(toFile(obj));
+            if (obj->inherits(&JSFileList::s_info))
+                return SerializedScriptValueData(toFileList(obj));
                 
             CallData unusedData;
             if (value.getCallData(unusedData) == CallTypeNone)
@@ -659,10 +695,20 @@ struct DeserializingTreeWalker : public BaseWalker {
                 return new (m_exec) DateInstance(m_exec, value.asDouble());
             case SerializedScriptValueData::FileType:
                 return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject()), File::create(value.asString().crossThreadString()));
-            default:
+            case SerializedScriptValueData::FileListType: {
+                RefPtr<FileList> result = FileList::create();
+                SerializedFileList* serializedFileList = value.asFileList();
+                unsigned length = serializedFileList->length();
+                for (unsigned i = 0; i < length; i++)
+                    result->append(File::create(serializedFileList->item(i)));
+                return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject()), result.get());
+            }
+            case SerializedScriptValueData::EmptyType:
                 ASSERT_NOT_REACHED();
-                return JSValue();
+                return jsNull();
         }
+        ASSERT_NOT_REACHED();
+        return jsNull();
     }
 
     void getPropertyNames(RefPtr<SerializedObject> object, Vector<SerializedObject::PropertyNameList, 16>& properties)
@@ -810,11 +856,14 @@ struct TeardownTreeWalker {
             case SerializedScriptValueData::StringType:
             case SerializedScriptValueData::ImmediateType:
             case SerializedScriptValueData::NumberType:
+            case SerializedScriptValueData::DateType:
+            case SerializedScriptValueData::EmptyType:
+            case SerializedScriptValueData::FileType:
+            case SerializedScriptValueData::FileListType:
                 return true;
-            default:
-                ASSERT_NOT_REACHED();
-                return JSValue();
         }
+        ASSERT_NOT_REACHED();
+        return true;
     }
 
     void getPropertyNames(RefPtr<SerializedObject> object, Vector<SerializedObject::PropertyNameList, 16>& properties)
diff --git a/WebCore/bindings/js/SerializedScriptValue.h b/WebCore/bindings/js/SerializedScriptValue.h
index 57a4a66..d3159fc 100644
--- a/WebCore/bindings/js/SerializedScriptValue.h
+++ b/WebCore/bindings/js/SerializedScriptValue.h
@@ -34,14 +34,17 @@ typedef const struct OpaqueJSValue* JSValueRef;
 
 namespace WebCore {
     class File;
-    class SerializedObject;
+    class FileList;
     class SerializedArray;
+    class SerializedFileList;
+    class SerializedObject;
 
     class SharedSerializedData : public RefCounted<SharedSerializedData> {
     public:
         virtual ~SharedSerializedData() { }
         SerializedArray* asArray();
         SerializedObject* asObject();
+        SerializedFileList* asFileList();
     };
 
     class SerializedScriptValue;
@@ -56,7 +59,8 @@ namespace WebCore {
             ObjectType,
             ArrayType,
             StringType,
-            FileType
+            FileType,
+            FileListType
         };
 
         SerializedType type() const { return m_type; }
@@ -81,6 +85,7 @@ namespace WebCore {
         }
         
         explicit SerializedScriptValueData(const File*);
+        explicit SerializedScriptValueData(const FileList*);
 
         explicit SerializedScriptValueData(JSC::JSValue value)
             : m_type(ImmediateType)
@@ -130,6 +135,13 @@ namespace WebCore {
             return m_sharedData->asArray();
         }
 
+        SerializedFileList* asFileList() const
+        {
+            ASSERT(m_type == FileListType);
+            ASSERT(m_sharedData);
+            return m_sharedData->asFileList();
+        }
+
         operator bool() const { return m_type != EmptyType; }
 
         SerializedScriptValueData release()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list