[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

oliver at apple.com oliver at apple.com
Fri Feb 26 22:17:35 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit afaa3621048ab623bc12840b0ec26681bcbbf1f6
Author: oliver at apple.com <oliver at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Feb 11 08:30:34 2010 +0000

    2010-02-10  Oliver Hunt  <oliver at apple.com>
    
            Reviewed by Gavin Barraclough.
    
            postMessage does not send ImageData
            https://bugs.webkit.org/show_bug.cgi?id=34825
    
            Add test for postMessage passing ImageData
    
            Update a few other tests to cover the fact that ImageData's constructor
            is now available on the window object.
    
            * fast/dom/Window/window-postmessage-clone-expected.txt:
            * fast/dom/Window/window-postmessage-clone.html:
            * fast/dom/Window/window-properties-expected.txt:
            * fast/dom/Window/window-property-descriptors-expected.txt:
            * fast/dom/prototype-inheritance-2-expected.txt:
            * fast/dom/prototype-inheritance-expected.txt:
            * fast/js/global-constructors-expected.txt:
    2010-02-10  Oliver Hunt  <oliver at apple.com>
    
            Reviewed by Gavin Barraclough.
    
            postMessage does not send ImageData
            https://bugs.webkit.org/show_bug.cgi?id=34825
    
            Implement serialisation of ImageData, and for testing reasons
            expose the ImageData constructor (which should already have
            been exposed).
    
            * bindings/js/SerializedScriptValue.cpp:
            (WebCore::SerializedImageData::create):
            (WebCore::SerializedImageData::width):
            (WebCore::SerializedImageData::height):
            (WebCore::SerializedImageData::data):
            (WebCore::SerializedImageData::SerializedImageData):
            (WebCore::SerializedScriptValueData::SerializedScriptValueData):
            (WebCore::SharedSerializedData::asImageData):
            (WebCore::SerializingTreeWalker::convertIfTerminal):
            (WebCore::DeserializingTreeWalker::convertIfTerminal):
            (WebCore::TeardownTreeWalker::convertIfTerminal):
            * bindings/js/SerializedScriptValue.h:
            (WebCore::SerializedScriptValueData::):
            (WebCore::SerializedScriptValueData::asImageData):
            * html/canvas/CanvasPixelArray.h:
            (WebCore::CanvasPixelArray::data):
            * page/DOMWindow.idl:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54646 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 7b5323c..7c4668a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,23 @@
+2010-02-10  Oliver Hunt  <oliver at apple.com>
+
+        Reviewed by Gavin Barraclough.
+
+        postMessage does not send ImageData
+        https://bugs.webkit.org/show_bug.cgi?id=34825
+
+        Add test for postMessage passing ImageData
+
+        Update a few other tests to cover the fact that ImageData's constructor
+        is now available on the window object.
+
+        * fast/dom/Window/window-postmessage-clone-expected.txt:
+        * fast/dom/Window/window-postmessage-clone.html:
+        * fast/dom/Window/window-properties-expected.txt:
+        * fast/dom/Window/window-property-descriptors-expected.txt:
+        * fast/dom/prototype-inheritance-2-expected.txt:
+        * fast/dom/prototype-inheritance-expected.txt:
+        * fast/js/global-constructors-expected.txt:
+
 2010-02-10  Beth Dakin  <bdakin at apple.com>
 
         Reviewed by Simon Fraser and Darin Adler.
diff --git a/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt b/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt
index aa7d220..e72ab20 100644
--- a/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt
+++ b/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt
@@ -18,5 +18,7 @@ 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 [object ImageData] of type object
+PASS: eventData is [object ImageData] 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 29cc421..9cb6e8d 100644
--- a/LayoutTests/fast/dom/Window/window-postmessage-clone.html
+++ b/LayoutTests/fast/dom/Window/window-postmessage-clone.html
@@ -16,10 +16,10 @@ var messages = [];
 
 function equal(actual, expected)
 {
-    if (typeof actual !== typeof expected)
-        return false;
     if (actual === expected)
         return true;
+    if (typeof actual !== typeof expected)
+        return false;
     if ((actual instanceof Date) || (expected instanceof Date)) {
         if ((actual instanceof Date) && (expected instanceof Date))
             return (expected instanceof Date) && actual.getTime() == expected.getTime();
@@ -40,9 +40,17 @@ function equal(actual, expected)
     }
     if (actual.constructor !== expected.constructor)
         return false;
-    var keys = Object.keys(actual);
+    try {
+        var keys = Object.keys(actual);
+    } catch(e) {
+        return false;
+    }
+    try {
     if (!equal(keys, Object.keys(expected)))
         return false;
+    } catch(e) {
+        return false;
+    }
     for (var i = 0; i < keys.length; i++) {
         if (!equal(actual[keys[i]], expected[keys[i]]))
             return false;
@@ -75,7 +83,7 @@ function shouldBe(actual, expected)
 function onmessage(evt) {
     eventData = evt.data;
     if (evt.data !== evt.data)
-        console.innerHTML += "MessageEvent.data does not produce the same value on multiple queries.";
+        console.innerHTML += "MessageEvent.data does not produce the same value on multiple queries.<br>";
     shouldBe("eventData", messages.shift());
 
     if (safeToString(evt.data) == 'done' && window.layoutTestController)
@@ -129,15 +137,27 @@ for (var i = 0; i < 100000; i++)
 tryPostMessage('reallyDeepArray', true);
 tryPostMessage('window', true);
 
-var fileInput = document.getElementById("fileInput");
-var fileRect = fileInput.getClientRects()[0];
-var targetX = fileRect.left + fileRect.width / 2;
-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);
+if (window.eventSender) {
+    var fileInput = document.getElementById("fileInput");
+    var fileRect = fileInput.getClientRects()[0];
+    var targetX = fileRect.left + fileRect.width / 2;
+    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);
+}
+var imageData = document.createElement("canvas").getContext("2d").createImageData(10,10);
+for (var i = 0; i < imageData.data.length * 4; i++)
+    imageData.data[i] = i % 256;
+var mutatedImageData = document.createElement("canvas").getContext("2d").createImageData(10,10);
+for (var i = 0; i < imageData.data.length * 4; i++)
+    mutatedImageData.data[i] = i % 256;
+tryPostMessage('imageData', false, imageData);
+tryPostMessage('mutatedImageData', false, imageData);
+for (var i = 0; i < imageData.data.length * 4; i++)
+    mutatedImageData.data[i] = 0;
 
 tryPostMessage('"done"');
 </script>
diff --git a/LayoutTests/fast/dom/Window/window-properties-expected.txt b/LayoutTests/fast/dom/Window/window-properties-expected.txt
index de53c27..836d367 100644
--- a/LayoutTests/fast/dom/Window/window-properties-expected.txt
+++ b/LayoutTests/fast/dom/Window/window-properties-expected.txt
@@ -1044,6 +1044,8 @@ window.HTMLVideoElement [object HTMLVideoElementConstructor]
 window.HTMLVideoElement.prototype [printed above as window.Element.prototype]
 window.Image [object ImageConstructor]
 window.Image.prototype [printed above as window.Element.prototype]
+window.ImageData [object ImageDataConstructor]
+window.ImageData.prototype [object ImageDataPrototype]
 window.KeyboardEvent [object KeyboardEventConstructor]
 window.KeyboardEvent.prototype [printed above as window.Event.prototype]
 window.MediaError [object MediaErrorConstructor]
diff --git a/LayoutTests/fast/dom/Window/window-property-descriptors-expected.txt b/LayoutTests/fast/dom/Window/window-property-descriptors-expected.txt
index 4847a4e..e869549 100644
--- a/LayoutTests/fast/dom/Window/window-property-descriptors-expected.txt
+++ b/LayoutTests/fast/dom/Window/window-property-descriptors-expected.txt
@@ -114,6 +114,7 @@ PASS typeof Object.getOwnPropertyDescriptor(window, 'HTMLTitleElement') is 'obje
 PASS typeof Object.getOwnPropertyDescriptor(window, 'HTMLUListElement') is 'object'
 PASS typeof Object.getOwnPropertyDescriptor(window, 'HTMLVideoElement') is 'object'
 PASS typeof Object.getOwnPropertyDescriptor(window, 'Image') is 'object'
+PASS typeof Object.getOwnPropertyDescriptor(window, 'ImageData') is 'object'
 PASS typeof Object.getOwnPropertyDescriptor(window, 'Infinity') is 'object'
 PASS typeof Object.getOwnPropertyDescriptor(window, 'JSON') is 'object'
 PASS typeof Object.getOwnPropertyDescriptor(window, 'KeyboardEvent') is 'object'
diff --git a/LayoutTests/fast/dom/prototype-inheritance-2-expected.txt b/LayoutTests/fast/dom/prototype-inheritance-2-expected.txt
index dc349aa..583d865 100644
--- a/LayoutTests/fast/dom/prototype-inheritance-2-expected.txt
+++ b/LayoutTests/fast/dom/prototype-inheritance-2-expected.txt
@@ -264,6 +264,7 @@ Never found HTMLTableElement
 Never found HTMLTableRowElement
 Never found HTMLTableSectionElement
 Never found Image
+Never found ImageData
 Never found MessageChannel
 Never found MessagePort
 Never found Node
diff --git a/LayoutTests/fast/dom/prototype-inheritance-expected.txt b/LayoutTests/fast/dom/prototype-inheritance-expected.txt
index e4d4d17..4faa715 100644
--- a/LayoutTests/fast/dom/prototype-inheritance-expected.txt
+++ b/LayoutTests/fast/dom/prototype-inheritance-expected.txt
@@ -215,6 +215,8 @@ PASS inner.HTMLVideoElement.isInner is true
 PASS inner.HTMLVideoElement.constructor.isInner is true
 PASS inner.Image.isInner is true
 PASS inner.Image.constructor.isInner is true
+PASS inner.ImageData.isInner is true
+PASS inner.ImageData.constructor.isInner is true
 PASS inner.KeyboardEvent.isInner is true
 PASS inner.KeyboardEvent.constructor.isInner is true
 PASS inner.MediaError.isInner is true
diff --git a/LayoutTests/fast/js/global-constructors-expected.txt b/LayoutTests/fast/js/global-constructors-expected.txt
index 87b5cac..1d1c2dc 100644
--- a/LayoutTests/fast/js/global-constructors-expected.txt
+++ b/LayoutTests/fast/js/global-constructors-expected.txt
@@ -107,6 +107,7 @@ PASS HTMLTitleElement.toString() is '[object HTMLTitleElementConstructor]'
 PASS HTMLUListElement.toString() is '[object HTMLUListElementConstructor]'
 PASS HTMLVideoElement.toString() is '[object HTMLVideoElementConstructor]'
 PASS Image.toString() is '[object ImageConstructor]'
+PASS ImageData.toString() is '[object ImageDataConstructor]'
 PASS KeyboardEvent.toString() is '[object KeyboardEventConstructor]'
 PASS MediaError.toString() is '[object MediaErrorConstructor]'
 PASS MediaList.toString() is '[object MediaListConstructor]'
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e57d842..396efe8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2010-02-10  Oliver Hunt  <oliver at apple.com>
+
+        Reviewed by Gavin Barraclough.
+
+        postMessage does not send ImageData
+        https://bugs.webkit.org/show_bug.cgi?id=34825
+
+        Implement serialisation of ImageData, and for testing reasons
+        expose the ImageData constructor (which should already have
+        been exposed).
+
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::SerializedImageData::create):
+        (WebCore::SerializedImageData::width):
+        (WebCore::SerializedImageData::height):
+        (WebCore::SerializedImageData::data):
+        (WebCore::SerializedImageData::SerializedImageData):
+        (WebCore::SerializedScriptValueData::SerializedScriptValueData):
+        (WebCore::SharedSerializedData::asImageData):
+        (WebCore::SerializingTreeWalker::convertIfTerminal):
+        (WebCore::DeserializingTreeWalker::convertIfTerminal):
+        (WebCore::TeardownTreeWalker::convertIfTerminal):
+        * bindings/js/SerializedScriptValue.h:
+        (WebCore::SerializedScriptValueData::):
+        (WebCore::SerializedScriptValueData::asImageData):
+        * html/canvas/CanvasPixelArray.h:
+        (WebCore::CanvasPixelArray::data):
+        * page/DOMWindow.idl:
+
 2010-02-10  Adam Barth  <abarth at webkit.org>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/bindings/js/SerializedScriptValue.cpp b/WebCore/bindings/js/SerializedScriptValue.cpp
index fd9cb59..fbf8899 100644
--- a/WebCore/bindings/js/SerializedScriptValue.cpp
+++ b/WebCore/bindings/js/SerializedScriptValue.cpp
@@ -29,14 +29,17 @@
 
 #include "File.h"
 #include "FileList.h"
+#include "ImageData.h"
 #include "JSDOMGlobalObject.h"
 #include "JSFile.h"
 #include "JSFileList.h"
+#include "JSImageData.h"
 #include <JavaScriptCore/APICast.h>
 #include <runtime/DateInstance.h>
 #include <runtime/ExceptionHelpers.h>
 #include <runtime/JSLock.h>
 #include <runtime/PropertyNameArray.h>
+#include <wtf/ByteArray.h>
 #include <wtf/HashTraits.h>
 #include <wtf/Vector.h>
 
@@ -165,6 +168,30 @@ private:
     Vector<String> m_files;
 };
 
+class SerializedImageData : public SharedSerializedData {
+public:
+    static PassRefPtr<SerializedImageData> create(const ImageData* imageData)
+    {
+        return adoptRef(new SerializedImageData(imageData));
+    }
+    
+    unsigned width() const { return m_width; }
+    unsigned height() const { return m_height; }
+    WTF::ByteArray* data() const { return m_storage.get(); }
+private:
+    SerializedImageData(const ImageData* imageData)
+        : m_width(imageData->width())
+        , m_height(imageData->height())
+    {
+        WTF::ByteArray* array = imageData->data()->data();
+        m_storage = WTF::ByteArray::create(array->length());
+        memcpy(m_storage->data(), array->data(), array->length());
+    }
+    unsigned m_width;
+    unsigned m_height;
+    RefPtr<WTF::ByteArray> m_storage;
+};
+
 SerializedScriptValueData::SerializedScriptValueData(RefPtr<SerializedObject> data)
     : m_type(ObjectType)
     , m_sharedData(data)
@@ -183,6 +210,12 @@ SerializedScriptValueData::SerializedScriptValueData(const FileList* fileList)
 {
 }
 
+SerializedScriptValueData::SerializedScriptValueData(const ImageData* imageData)
+    : m_type(ImageDataType)
+    , m_sharedData(SerializedImageData::create(imageData))
+{
+}
+
 SerializedScriptValueData::SerializedScriptValueData(const File* file)
     : m_type(FileType)
     , m_string(file->path().crossThreadString())
@@ -204,6 +237,11 @@ SerializedFileList* SharedSerializedData::asFileList()
     return static_cast<SerializedFileList*>(this);
 }
 
+SerializedImageData* SharedSerializedData::asImageData()
+{
+    return static_cast<SerializedImageData*>(this);
+}
+
 static const unsigned maximumFilterRecursion = 40000;
 enum WalkerState { StateUnknown, ArrayStartState, ArrayStartVisitMember, ArrayEndVisitMember,
     ObjectStartState, ObjectStartVisitMember, ObjectEndVisitMember };
@@ -533,6 +571,8 @@ struct SerializingTreeWalker : public BaseWalker {
                 return SerializedScriptValueData(toFile(obj));
             if (obj->inherits(&JSFileList::s_info))
                 return SerializedScriptValueData(toFileList(obj));
+            if (obj->inherits(&JSImageData::s_info))
+                return SerializedScriptValueData(toImageData(obj));
                 
             CallData unusedData;
             if (value.getCallData(unusedData) == CallTypeNone)
@@ -709,6 +749,14 @@ struct DeserializingTreeWalker : public BaseWalker {
                     result->append(File::create(serializedFileList->item(i)));
                 return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_globalObject), result.get());
             }
+            case SerializedScriptValueData::ImageDataType: {
+                if (!m_isDOMGlobalObject)
+                    return jsNull();
+                SerializedImageData* serializedImageData = value.asImageData();
+                RefPtr<ImageData> result = ImageData::create(serializedImageData->width(), serializedImageData->height());
+                memcpy(result->data()->data()->data(), serializedImageData->data()->data(), serializedImageData->data()->length());
+                return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_globalObject), result.get());
+            }
             case SerializedScriptValueData::EmptyType:
                 ASSERT_NOT_REACHED();
                 return jsNull();
@@ -868,6 +916,7 @@ struct TeardownTreeWalker {
             case SerializedScriptValueData::EmptyType:
             case SerializedScriptValueData::FileType:
             case SerializedScriptValueData::FileListType:
+            case SerializedScriptValueData::ImageDataType:
                 return true;
         }
         ASSERT_NOT_REACHED();
diff --git a/WebCore/bindings/js/SerializedScriptValue.h b/WebCore/bindings/js/SerializedScriptValue.h
index 347d8f2..93bd0de 100644
--- a/WebCore/bindings/js/SerializedScriptValue.h
+++ b/WebCore/bindings/js/SerializedScriptValue.h
@@ -35,8 +35,10 @@ typedef const struct OpaqueJSValue* JSValueRef;
 namespace WebCore {
     class File;
     class FileList;
+    class ImageData;
     class SerializedArray;
     class SerializedFileList;
+    class SerializedImageData;
     class SerializedObject;
 
     class SharedSerializedData : public RefCounted<SharedSerializedData> {
@@ -45,6 +47,7 @@ namespace WebCore {
         SerializedArray* asArray();
         SerializedObject* asObject();
         SerializedFileList* asFileList();
+        SerializedImageData* asImageData();
     };
 
     class SerializedScriptValue;
@@ -60,7 +63,8 @@ namespace WebCore {
             ArrayType,
             StringType,
             FileType,
-            FileListType
+            FileListType,
+            ImageDataType
         };
 
         SerializedType type() const { return m_type; }
@@ -86,6 +90,7 @@ namespace WebCore {
         
         explicit SerializedScriptValueData(const File*);
         explicit SerializedScriptValueData(const FileList*);
+        explicit SerializedScriptValueData(const ImageData*);
 
         explicit SerializedScriptValueData(JSC::JSValue value)
             : m_type(ImmediateType)
@@ -141,6 +146,13 @@ namespace WebCore {
             ASSERT(m_sharedData);
             return m_sharedData->asFileList();
         }
+        
+        SerializedImageData* asImageData() const
+        {
+            ASSERT(m_type == ImageDataType);
+            ASSERT(m_sharedData);
+            return m_sharedData->asImageData();
+        }
 
         operator bool() const { return m_type != EmptyType; }
 
diff --git a/WebCore/html/canvas/CanvasPixelArray.h b/WebCore/html/canvas/CanvasPixelArray.h
index 8ac5163..25eb92a 100644
--- a/WebCore/html/canvas/CanvasPixelArray.h
+++ b/WebCore/html/canvas/CanvasPixelArray.h
@@ -42,6 +42,7 @@ namespace WebCore {
         static PassRefPtr<CanvasPixelArray> create(unsigned length);
         
         WTF::ByteArray* data() { return m_data.get(); }
+        const WTF::ByteArray* data() const { return m_data.get(); }
         unsigned length() const { return m_data->length(); }
         
         void set(unsigned index, double value)
diff --git a/WebCore/page/DOMWindow.idl b/WebCore/page/DOMWindow.idl
index f17f594..89de452 100644
--- a/WebCore/page/DOMWindow.idl
+++ b/WebCore/page/DOMWindow.idl
@@ -441,6 +441,7 @@ module window {
         attribute [CustomGetter] HTMLOptionElementConstructor Option; // Usable with new operator
 
         attribute CanvasRenderingContext2DConstructor CanvasRenderingContext2D;
+        attribute ImageDataConstructor ImageData;
         attribute [Conditional=3D_CANVAS] WebGLRenderingContextConstructor WebGLRenderingContext;
         attribute TextMetricsConstructor TextMetrics;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list