<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[166246] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/166246">166246</a></dd>
<dt>Author</dt> <dd>krit@webkit.org</dd>
<dt>Date</dt> <dd>2014-03-25 13:24:14 -0700 (Tue, 25 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Implement ImageData constructors and WebWorkers exposure
https://bugs.webkit.org/show_bug.cgi?id=130668
Reviewed by Dean Jackson.
Source/WebCore:
Add new constructors for ImageData.
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#pixel-manipulation
Test: fast/canvas/canvas-imageData.html
* html/ImageData.cpp:
(WebCore::ImageData::create):
* html/ImageData.h:
* html/ImageData.idl:
LayoutTests:
Tests for ImageData constructors. Remove a false tests for constructors
from Philip's test suite.
* fast/canvas/canvas-imageData-expected.txt: Added.
* fast/canvas/canvas-imageData.html: Added.
* fast/canvas/script-tests/canvas-imageData.js: Added.
(testTransparentBlack):
* LayoutTests/canvas/philip/tests/2d.imageData.object.ctor.html: Removed.
* LayoutTests/canvas/philip/tests/2d.imageData.object.ctor-expected.txt: Removed.
* LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt
* LayoutTests/js/dom/global-constructors-attributes-shared-worker-expected.txt</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsdomglobalconstructorsattributesdedicatedworkerexpectedtxt">trunk/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsdomglobalconstructorsattributessharedworkerexpectedtxt">trunk/LayoutTests/js/dom/global-constructors-attributes-shared-worker-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlImageDatacpp">trunk/Source/WebCore/html/ImageData.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlImageDatah">trunk/Source/WebCore/html/ImageData.h</a></li>
<li><a href="#trunkSourceWebCorehtmlImageDataidl">trunk/Source/WebCore/html/ImageData.idl</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcanvascanvasimageDataexpectedtxt">trunk/LayoutTests/fast/canvas/canvas-imageData-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcanvascanvasimageDatahtml">trunk/LayoutTests/fast/canvas/canvas-imageData.html</a></li>
<li><a href="#trunkLayoutTestsfastcanvasscripttestscanvasimageDatajs">trunk/LayoutTests/fast/canvas/script-tests/canvas-imageData.js</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscanvasphiliptests2dimageDataobjectctorexpectedtxt">trunk/LayoutTests/canvas/philip/tests/2d.imageData.object.ctor-expected.txt</a></li>
<li><a href="#trunkLayoutTestscanvasphiliptests2dimageDataobjectctorhtml">trunk/LayoutTests/canvas/philip/tests/2d.imageData.object.ctor.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (166245 => 166246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-03-25 20:15:14 UTC (rev 166245)
+++ trunk/LayoutTests/ChangeLog        2014-03-25 20:24:14 UTC (rev 166246)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2014-03-25 Dirk Schulze <krit@webkit.org>
+
+ Implement ImageData constructors and WebWorkers exposure
+ https://bugs.webkit.org/show_bug.cgi?id=130668
+
+ Reviewed by Dean Jackson.
+
+ Tests for ImageData constructors. Remove a false tests for constructors
+ from Philip's test suite.
+
+ * fast/canvas/canvas-imageData-expected.txt: Added.
+ * fast/canvas/canvas-imageData.html: Added.
+ * fast/canvas/script-tests/canvas-imageData.js: Added.
+ (testTransparentBlack):
+ * LayoutTests/canvas/philip/tests/2d.imageData.object.ctor.html: Removed.
+ * LayoutTests/canvas/philip/tests/2d.imageData.object.ctor-expected.txt: Removed.
+ * LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt
+ * LayoutTests/js/dom/global-constructors-attributes-shared-worker-expected.txt
+
</ins><span class="cx"> 2014-03-25 Myles C. Maxfield <mmaxfield@apple.com>
</span><span class="cx">
</span><span class="cx"> InlineIterator position (unsigned int) variable can wrap around
</span></span></pre></div>
<a id="trunkLayoutTestscanvasphiliptests2dimageDataobjectctorexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/canvas/philip/tests/2d.imageData.object.ctor-expected.txt (166245 => 166246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/canvas/philip/tests/2d.imageData.object.ctor-expected.txt        2014-03-25 20:15:14 UTC (rev 166245)
+++ trunk/LayoutTests/canvas/philip/tests/2d.imageData.object.ctor-expected.txt        2014-03-25 20:24:14 UTC (rev 166246)
</span><span class="lines">@@ -1 +0,0 @@
</span><del>-Passed
</del></span></pre></div>
<a id="trunkLayoutTestscanvasphiliptests2dimageDataobjectctorhtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/canvas/philip/tests/2d.imageData.object.ctor.html (166245 => 166246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/canvas/philip/tests/2d.imageData.object.ctor.html        2014-03-25 20:15:14 UTC (rev 166245)
+++ trunk/LayoutTests/canvas/philip/tests/2d.imageData.object.ctor.html        2014-03-25 20:24:14 UTC (rev 166246)
</span><span class="lines">@@ -1,21 +0,0 @@
</span><del>-<!DOCTYPE html>
-<title>Canvas test: 2d.imageData.object.ctor</title>
-<script src="../tests.js"></script>
-<link rel="stylesheet" href="../tests.css">
-<body>
-<p id="passtext">Pass</p>
-<p id="failtext">Fail</p>
-<p class="output">These images should be identical:</p>
-<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
-
-<ul id="d"></ul>
-<script>
-_addTest(function(canvas, ctx) {
-
-_assertDifferent(window.ImageData, undefined, "window.ImageData", "undefined");
-try { var _thrown = false; new window.ImageData(1,1); } catch (e) { _thrown = true; } finally { _assert(_thrown, "should throw exception: new window.ImageData(1,1)"); }
-
-
-});
-</script>
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastcanvascanvasimageDataexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/canvas-imageData-expected.txt (0 => 166246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/canvas/canvas-imageData-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-imageData-expected.txt        2014-03-25 20:24:14 UTC (rev 166246)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+Test constructors of ImageData.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Test invalid ImageData constructor arguments.
+PASS new ImageData() threw exception TypeError: Not enough arguments.
+PASS new ImageData(1) threw exception TypeError: Not enough arguments.
+PASS new ImageData(new Uint8ClampedArray([1,2,3,4])); threw exception TypeError: Not enough arguments.
+PASS new ImageData(0, 0) threw exception Error: IndexSizeError: DOM Exception 1.
+PASS new ImageData(20, 0) threw exception Error: IndexSizeError: DOM Exception 1.
+PASS new ImageData(0, 20) threw exception Error: IndexSizeError: DOM Exception 1.
+PASS new ImageData(-20, 20) threw exception TypeError: Type error.
+PASS new ImageData(20, -20) threw exception TypeError: Type error.
+PASS new ImageData(null, 20) threw exception Error: IndexSizeError: DOM Exception 1.
+PASS new ImageData(32768, 32768) threw exception TypeError: Type error.
+PASS new ImageData(null, 20, 20) threw exception TypeError: Type error.
+PASS new ImageData(imageData, 20, 20) threw exception TypeError: Type error.
+PASS new ImageData(imageData, 0) threw exception Error: IndexSizeError: DOM Exception 1.
+PASS new ImageData(imageData, 20, 0) threw exception TypeError: Type error.
+PASS new ImageData(imageData, 0, 20) threw exception TypeError: Type error.
+PASS new ImageData(imageData, 10, 5) threw exception TypeError: Type error.
+PASS new ImageData(imageData.data, 10, 5) threw exception Error: IndexSizeError: DOM Exception 1.
+PASS new ImageData(imageData.data, -10, 5) threw exception Error: InvalidStateError: DOM Exception 11.
+PASS new ImageData(imageData.data, 10, -10) threw exception Error: IndexSizeError: DOM Exception 1.
+PASS new ImageData(new Uint8ClampedArray([1,2,3,4,5,6,7,8]),536870913,2); threw exception Error: InvalidStateError: DOM Exception 11.
+PASS new ImageData({},2,2); threw exception TypeError: Type error.
+PASS new ImageData(undefined,2,2); threw exception TypeError: Type error.
+PASS new ImageData("none",2,2); threw exception TypeError: Type error.
+PASS new ImageData(0,2,2); threw exception TypeError: Type error.
+PASS new ImageData(imageData.data, 32768, 32768) threw exception Error: InvalidStateError: DOM Exception 11.
+PASS new ImageData(imageData.data, Infinity, Infinity) threw exception Error: IndexSizeError: DOM Exception 1.
+PASS new ImageData(imageData.data, NaN, NaN) threw exception Error: IndexSizeError: DOM Exception 1.
+
+Test valid ImageData constructors.
+Test that we got the pixel array from imageData.
+PASS imageData.data[1] is 128
+
+Test that we got a reference rather than a copy.
+PASS imageData.data[1] is 100
+
+PASS testTransparentBlack(imageData2.data) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcanvascanvasimageDatahtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/canvas-imageData.html (0 => 166246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/canvas/canvas-imageData.html         (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-imageData.html        2014-03-25 20:24:14 UTC (rev 166246)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/canvas-imageData.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcanvasscripttestscanvasimageDatajs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/script-tests/canvas-imageData.js (0 => 166246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/canvas/script-tests/canvas-imageData.js         (rev 0)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-imageData.js        2014-03-25 20:24:14 UTC (rev 166246)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+description('Test constructors of ImageData.');
+
+ctx = document.createElement('canvas').getContext('2d');
+ctx.fillStyle = 'green';
+ctx.fillRect(0,0,10,10);
+var imageData = ctx.getImageData(0,0,10,10);
+
+debug('Test invalid ImageData constructor arguments.')
+shouldThrow('new ImageData()', '"TypeError: Not enough arguments"');
+shouldThrow('new ImageData(1)', '"TypeError: Not enough arguments"');
+shouldThrow('new ImageData(new Uint8ClampedArray([1,2,3,4]));', '"TypeError: Not enough arguments"');
+shouldThrow('new ImageData(0, 0)', '"Error: IndexSizeError: DOM Exception 1"');
+shouldThrow('new ImageData(20, 0)', '"Error: IndexSizeError: DOM Exception 1"');
+shouldThrow('new ImageData(0, 20)', '"Error: IndexSizeError: DOM Exception 1"');
+shouldThrow('new ImageData(-20, 20)', '"TypeError: Type error"');
+shouldThrow('new ImageData(20, -20)', '"TypeError: Type error"');
+shouldThrow('new ImageData(null, 20)', '"Error: IndexSizeError: DOM Exception 1"');
+shouldThrow('new ImageData(32768, 32768)', '"TypeError: Type error"');
+shouldThrow('new ImageData(null, 20, 20)', '"TypeError: Type error"');
+shouldThrow('new ImageData(imageData, 20, 20)', '"TypeError: Type error"');
+shouldThrow('new ImageData(imageData, 0)', '"Error: IndexSizeError: DOM Exception 1"');
+shouldThrow('new ImageData(imageData, 20, 0)', '"TypeError: Type error"');
+shouldThrow('new ImageData(imageData, 0, 20)', '"TypeError: Type error"');
+shouldThrow('new ImageData(imageData, 10, 5)', '"TypeError: Type error"');
+shouldThrow('new ImageData(imageData.data, 10, 5)', '"Error: IndexSizeError: DOM Exception 1"');
+shouldThrow('new ImageData(imageData.data, -10, 5)', '"Error: InvalidStateError: DOM Exception 11"');
+shouldThrow('new ImageData(imageData.data, 10, -10)', '"Error: IndexSizeError: DOM Exception 1"');
+shouldThrow('new ImageData(new Uint8ClampedArray([1,2,3,4,5,6,7,8]),536870913,2);', '"Error: InvalidStateError: DOM Exception 11"');
+shouldThrow('new ImageData({},2,2);', '"TypeError: Type error"');
+shouldThrow('new ImageData(undefined,2,2);', '"TypeError: Type error"');
+shouldThrow('new ImageData("none",2,2);', '"TypeError: Type error"');
+shouldThrow('new ImageData(0,2,2);', '"TypeError: Type error"');
+shouldThrow('new ImageData(imageData.data, 32768, 32768)', '"Error: InvalidStateError: DOM Exception 11"');
+shouldThrow('new ImageData(imageData.data, Infinity, Infinity)', '"Error: IndexSizeError: DOM Exception 1"');
+shouldThrow('new ImageData(imageData.data, NaN, NaN)', '"Error: IndexSizeError: DOM Exception 1"');
+debug('');
+
+debug('Test valid ImageData constructors.')
+new ImageData(10, 10);
+new ImageData(imageData.data, 10, 10);
+new ImageData(imageData.data, 10);
+// This should throw but doesn't because of a CodeGeneratorJS bug.
+new ImageData(imageData.data, 10, 0);
+
+debug('Test that we got the pixel array from imageData.');
+var newImageData = new ImageData(imageData.data, 10, 10);
+shouldBe('imageData.data[1]', '128');
+debug('');
+
+debug('Test that we got a reference rather than a copy.')
+newImageData.data[1] = 100;
+shouldBe('imageData.data[1]','100');
+debug('');
+
+function testTransparentBlack(data) {
+ for (var i = 0; i < data.length; ++i) {
+ if (data[i] != 0)
+ return false;
+ }
+ return true;
+}
+
+var imageData2 = new ImageData(100,100);
+shouldBeTrue('testTransparentBlack(imageData2.data)');
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomglobalconstructorsattributesdedicatedworkerexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt (166245 => 166246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt        2014-03-25 20:15:14 UTC (rev 166245)
+++ trunk/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt        2014-03-25 20:24:14 UTC (rev 166246)
</span><span class="lines">@@ -84,6 +84,11 @@
</span><span class="cx"> PASS [Worker] Object.getOwnPropertyDescriptor(global, 'IDBVersionChangeEvent').hasOwnProperty('set') is false
</span><span class="cx"> PASS [Worker] Object.getOwnPropertyDescriptor(global, 'IDBVersionChangeEvent').enumerable is false
</span><span class="cx"> PASS [Worker] Object.getOwnPropertyDescriptor(global, 'IDBVersionChangeEvent').configurable is true
</span><ins>+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').enumerable is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').configurable is true
</ins><span class="cx"> PASS [Worker] Object.getOwnPropertyDescriptor(global, 'MessageChannel').value is MessageChannel
</span><span class="cx"> PASS [Worker] Object.getOwnPropertyDescriptor(global, 'MessageChannel').hasOwnProperty('get') is false
</span><span class="cx"> PASS [Worker] Object.getOwnPropertyDescriptor(global, 'MessageChannel').hasOwnProperty('set') is false
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomglobalconstructorsattributessharedworkerexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/global-constructors-attributes-shared-worker-expected.txt (166245 => 166246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/global-constructors-attributes-shared-worker-expected.txt        2014-03-25 20:15:14 UTC (rev 166245)
+++ trunk/LayoutTests/js/dom/global-constructors-attributes-shared-worker-expected.txt        2014-03-25 20:24:14 UTC (rev 166246)
</span><span class="lines">@@ -79,6 +79,11 @@
</span><span class="cx"> PASS [Worker] Object.getOwnPropertyDescriptor(global, 'IDBVersionChangeEvent').hasOwnProperty('set') is false
</span><span class="cx"> PASS [Worker] Object.getOwnPropertyDescriptor(global, 'IDBVersionChangeEvent').enumerable is false
</span><span class="cx"> PASS [Worker] Object.getOwnPropertyDescriptor(global, 'IDBVersionChangeEvent').configurable is true
</span><ins>+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').enumerable is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').configurable is true
</ins><span class="cx"> PASS [Worker] Object.getOwnPropertyDescriptor(global, 'MessageChannel').value is MessageChannel
</span><span class="cx"> PASS [Worker] Object.getOwnPropertyDescriptor(global, 'MessageChannel').hasOwnProperty('get') is false
</span><span class="cx"> PASS [Worker] Object.getOwnPropertyDescriptor(global, 'MessageChannel').hasOwnProperty('set') is false
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166245 => 166246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-25 20:15:14 UTC (rev 166245)
+++ trunk/Source/WebCore/ChangeLog        2014-03-25 20:24:14 UTC (rev 166246)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2014-03-25 Dirk Schulze <krit@webkit.org>
+
+ Implement ImageData constructors and WebWorkers exposure
+ https://bugs.webkit.org/show_bug.cgi?id=130668
+
+ Reviewed by Dean Jackson.
+
+ Add new constructors for ImageData.
+
+ http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#pixel-manipulation
+
+ Test: fast/canvas/canvas-imageData.html
+
+ * html/ImageData.cpp:
+ (WebCore::ImageData::create):
+ * html/ImageData.h:
+ * html/ImageData.idl:
+
</ins><span class="cx"> 2014-03-25 Myles C. Maxfield <mmaxfield@apple.com>
</span><span class="cx">
</span><span class="cx"> InlineIterator position (unsigned int) variable can wrap around
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlImageDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/ImageData.cpp (166245 => 166246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/ImageData.cpp        2014-03-25 20:15:14 UTC (rev 166245)
+++ trunk/Source/WebCore/html/ImageData.cpp        2014-03-25 20:24:14 UTC (rev 166246)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * Copyright (C) 2008 Apple Inc. All rights reserved.
</span><ins>+ * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -29,8 +30,31 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "ImageData.h"
</span><span class="cx">
</span><ins>+#include "ExceptionCode.h"
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+PassRefPtr<ImageData> ImageData::create(unsigned sw, unsigned sh, ExceptionCode& ec)
+{
+ if (!sw || !sh) {
+ ec = INDEX_SIZE_ERR;
+ return nullptr;
+ }
+
+ Checked<int, RecordOverflow> dataSize = 4;
+ dataSize *= sw;
+ dataSize *= sh;
+ if (dataSize.hasOverflowed()) {
+ ec = TypeError;
+ return nullptr;
+ }
+
+ IntSize size(sw, sh);
+ RefPtr<ImageData> data = adoptRef(new ImageData(size));
+ data->data()->zeroFill();
+ return data.release();
+}
+
</ins><span class="cx"> PassRefPtr<ImageData> ImageData::create(const IntSize& size)
</span><span class="cx"> {
</span><span class="cx"> Checked<int, RecordOverflow> dataSize = 4;
</span><span class="lines">@@ -57,6 +81,34 @@
</span><span class="cx"> return adoptRef(new ImageData(size, byteArray));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+PassRefPtr<ImageData> ImageData::create(PassRefPtr<Uint8ClampedArray> byteArray, unsigned sw, unsigned sh, ExceptionCode& ec)
+{
+ unsigned length = byteArray->length();
+ if (!length || length % 4 != 0) {
+ ec = INVALID_STATE_ERR;
+ return nullptr;
+ }
+
+ if (!sw) {
+ ec = INDEX_SIZE_ERR;
+ return nullptr;
+ }
+
+ length /= 4;
+ if (length % sw != 0) {
+ ec = INVALID_STATE_ERR;
+ return nullptr;
+ }
+
+ unsigned height = length / sw;
+ if (sh && sh != height) {
+ ec = INDEX_SIZE_ERR;
+ return nullptr;
+ }
+
+ return create(IntSize(sw, height), byteArray);
+}
+
</ins><span class="cx"> ImageData::ImageData(const IntSize& size)
</span><span class="cx"> : m_size(size)
</span><span class="cx"> , m_data(Uint8ClampedArray::createUninitialized(size.width() * size.height() * 4))
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlImageDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/ImageData.h (166245 => 166246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/ImageData.h        2014-03-25 20:15:14 UTC (rev 166245)
+++ trunk/Source/WebCore/html/ImageData.h        2014-03-25 20:24:14 UTC (rev 166246)
</span><span class="lines">@@ -36,10 +36,14 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+typedef int ExceptionCode;
+
</ins><span class="cx"> class ImageData : public RefCounted<ImageData> {
</span><span class="cx"> public:
</span><ins>+ static PassRefPtr<ImageData> create(unsigned sw, unsigned sh, ExceptionCode&);
</ins><span class="cx"> static PassRefPtr<ImageData> create(const IntSize&);
</span><span class="cx"> static PassRefPtr<ImageData> create(const IntSize&, PassRefPtr<Uint8ClampedArray>);
</span><ins>+ static PassRefPtr<ImageData> create(PassRefPtr<Uint8ClampedArray>, unsigned sw, unsigned sh, ExceptionCode&);
</ins><span class="cx">
</span><span class="cx"> IntSize size() const { return m_size; }
</span><span class="cx"> int width() const { return m_size.width(); }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlImageDataidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/ImageData.idl (166245 => 166246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/ImageData.idl        2014-03-25 20:15:14 UTC (rev 166245)
+++ trunk/Source/WebCore/html/ImageData.idl        2014-03-25 20:24:14 UTC (rev 166246)
</span><span class="lines">@@ -27,7 +27,14 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> [
</span><ins>+ GlobalContext=DOMWindow&WorkerGlobalScope,
</ins><span class="cx"> CustomToJSObject,
</span><ins>+ // FIXME: Without [Default=Undefined] CodeGeneratorJS can't generate JSImageData. But with
+ // the extended attribute we accept a value of 0 for sh and don't throw.
+ // https://bugs.webkit.org/show_bug.cgi?id=130667
+ Constructor(Uint8ClampedArray data, unsigned long sw, [Default=Undefined] optional unsigned long sh),
+ Constructor(unsigned long sw, unsigned long sh),
+ ConstructorRaisesException,
</ins><span class="cx"> ImplementationLacksVTable
</span><span class="cx"> ] interface ImageData {
</span><span class="cx"> readonly attribute long width;
</span></span></pre>
</div>
</div>
</body>
</html>