Commit 3cbb559a authored by jianli@chromium.org's avatar jianli@chromium.org

Implement DataView interface from Typed Array specification

https://bugs.webkit.org/show_bug.cgi?id=46541

Reviewed by Kenneth Russell.

WebCore:

Test: fast/canvas/webgl/data-view-test.html

* CMakeLists.txt:
* DerivedSources.make:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pri:
* WebCore.pro:
* WebCore.xcodeproj/project.pbxproj:
* bindings/generic/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::dataViewEnabled):
* bindings/js/JSArrayBufferViewHelper.h:
(WebCore::constructArrayBufferViewWithArrayBufferArgument):
(WebCore::constructArrayBufferView):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::dataView):
* bindings/js/JSDataViewCustom.cpp: Added.
* bindings/js/JSFloat32ArrayCustom.cpp:
(WebCore::JSFloat32ArrayConstructor::constructJSFloat32Array):
* bindings/js/JSInt16ArrayCustom.cpp:
(WebCore::JSInt16ArrayConstructor::constructJSInt16Array):
* bindings/js/JSInt32ArrayCustom.cpp:
(WebCore::JSInt32ArrayConstructor::constructJSInt32Array):
* bindings/js/JSInt8ArrayCustom.cpp:
(WebCore::JSInt8ArrayConstructor::constructJSInt8Array):
* bindings/js/JSUint16ArrayCustom.cpp:
(WebCore::JSUint16ArrayConstructor::constructJSUint16Array):
* bindings/js/JSUint32ArrayCustom.cpp:
(WebCore::JSUint32ArrayConstructor::constructJSUint32Array):
* bindings/js/JSUint8ArrayCustom.cpp:
(WebCore::JSUint8ArrayConstructor::constructJSUint8Array):
* bindings/v8/custom/V8ArrayBufferViewCustom.h:
(WebCore::constructWebGLArrayWithArrayBufferArgument):
(WebCore::constructWebGLArray):
* bindings/v8/custom/V8DataViewCustom.cpp: Added.
* html/canvas/ArrayBufferView.h:
(WebCore::ArrayBufferView::isDataView):
* html/canvas/DataView.cpp: Added.
* html/canvas/DataView.h: Added.
* html/canvas/DataView.idl: Added.
* page/DOMWindow.idl:

LayoutTests:

Add a new test for testing DataView interface. Also update some tests
to exclude DataView property from being tested because it is not
exposed to all platforms.

* fast/canvas/webgl/data-view-test-expected.txt: Added.
* fast/canvas/webgl/data-view-test.html: Added.
* fast/dom/Window/script-tests/window-property-descriptors.js:
* fast/dom/Window/window-properties.html:
* fast/dom/script-tests/prototype-inheritance-2.js:
(constructorNamesForWindow):
* fast/dom/script-tests/prototype-inheritance.js:
* fast/js/script-tests/global-constructors.js:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 804d65e6
2010-11-24 Jian Li <jianli@chromium.org>
Reviewed by Kenneth Russell.
Implement DataView interface from Typed Array specification
https://bugs.webkit.org/show_bug.cgi?id=46541
Add a new test for testing DataView interface. Also update some tests
to exclude DataView property from being tested because it is not
exposed to all platforms.
* fast/canvas/webgl/data-view-test-expected.txt: Added.
* fast/canvas/webgl/data-view-test.html: Added.
* fast/dom/Window/script-tests/window-property-descriptors.js:
* fast/dom/Window/window-properties.html:
* fast/dom/script-tests/prototype-inheritance-2.js:
(constructorNamesForWindow):
* fast/dom/script-tests/prototype-inheritance.js:
* fast/js/script-tests/global-constructors.js:
2010-11-24 Eric Uhrhane <ericu@chromium.org>
Reviewed by Tony Chang.
This diff is collapsed.
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Test DataView.");
var intArray1 = [0, 1, 2, 3, 100, 101, 102, 103, 128, 129, 130, 131, 252, 253, 254, 255];
var intArray2 = [31, 32, 33, 0, 1, 2, 3, 100, 101, 102, 103, 128, 129, 130, 131, 252, 253, 254, 255];
var emptyArray = [204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204];
var arayBuffer = null;
var view = null;
var viewStart = 0;
var viewLength = 0;
function getElementSize(func)
{
switch (func) {
case "Int8":
case "Uint8":
return 1;
case "Int16":
case "Uint16":
return 2;
case "Int32":
case "Uint32":
case "Float32":
return 4;
case "Float64":
return 8;
default:
debug("Should not reached");
}
}
function checkGet(func, index, expected, littleEndian)
{
var expr = "view.get" + func + "(" + index;
if (littleEndian != undefined) {
expr += ", ";
expr += littleEndian ? "true" : "false";
}
expr += ")";
if (index + getElementSize(func) - 1 < view.byteLength)
shouldBe(expr, expected);
else
shouldThrow(expr);
}
function checkSet(func, index, value, littleEndian)
{
var expr = "view.set" + func + "(" + index + ", " + value;
if (littleEndian != undefined) {
expr += ", ";
expr += littleEndian ? "true" : "false";
}
expr += ")";
if (index + getElementSize(func) - 1 < view.byteLength) {
shouldBeUndefined(expr);
checkGet(func, index, value, littleEndian);
} else
shouldThrow(expr);
}
function test(isTestingGet, func, index, value, littleEndian)
{
if (isTestingGet)
checkGet(func, index, value, littleEndian);
else
checkSet(func, index, value, littleEndian);
}
function createDataView(array, frontPaddingNum, littleEndian, start, length)
{
if (!littleEndian)
array.reverse();
var paddingArray = new Array(frontPaddingNum);
arrayBuffer = (new Uint8Array(paddingArray.concat(array))).buffer;
viewStart = (start != undefined) ? start : 0;
viewLength = (length != undefined) ? length : arrayBuffer.byteLength - viewStart;
view = new DataView(arrayBuffer, viewStart, viewLength);
if (!littleEndian)
array.reverse(); // restore the array.
}
function runIntegerTestCases(isTestingGet, array, start, length)
{
createDataView(array, 0, true, start, length);
test(isTestingGet, "Int8", 0, "0");
test(isTestingGet, "Int8", 8, "-128");
test(isTestingGet, "Int8", 15, "-1");
test(isTestingGet, "Uint8", 0, "0");
test(isTestingGet, "Uint8", 8, "128");
test(isTestingGet, "Uint8", 15, "255");
// Little endian.
test(isTestingGet, "Int16", 0, "256", true);
test(isTestingGet, "Int16", 5, "26213", true);
test(isTestingGet, "Int16", 9, "-32127", true);
test(isTestingGet, "Int16", 14, "-2", true);
// Big endian.
test(isTestingGet, "Int16", 0, "1");
test(isTestingGet, "Int16", 5, "25958");
test(isTestingGet, "Int16", 9, "-32382");
test(isTestingGet, "Int16", 14, "-257");
// Little endian.
test(isTestingGet, "Uint16", 0, "256", true);
test(isTestingGet, "Uint16", 5, "26213", true);
test(isTestingGet, "Uint16", 9, "33409", true);
test(isTestingGet, "Uint16", 14, "65534", true);
// Big endian.
test(isTestingGet, "Uint16", 0, "1");
test(isTestingGet, "Uint16", 5, "25958");
test(isTestingGet, "Uint16", 9, "33154");
test(isTestingGet, "Uint16", 14, "65279");
// Little endian.
test(isTestingGet, "Int32", 0, "50462976", true);
test(isTestingGet, "Int32", 3, "1717920771", true);
test(isTestingGet, "Int32", 6, "-2122291354", true);
test(isTestingGet, "Int32", 9, "-58490239", true);
test(isTestingGet, "Int32", 12, "-66052", true);
// Big endian.
test(isTestingGet, "Int32", 0, "66051");
test(isTestingGet, "Int32", 3, "56911206");
test(isTestingGet, "Int32", 6, "1718059137");
test(isTestingGet, "Int32", 9, "-2122152964");
test(isTestingGet, "Int32", 12, "-50462977");
// Little endian.
test(isTestingGet, "Uint32", 0, "50462976", true);
test(isTestingGet, "Uint32", 3, "1717920771", true);
test(isTestingGet, "Uint32", 6, "2172675942", true);
test(isTestingGet, "Uint32", 9, "4236477057", true);
test(isTestingGet, "Uint32", 12, "4294901244", true);
// Big endian.
test(isTestingGet, "Uint32", 0, "66051");
test(isTestingGet, "Uint32", 3, "56911206");
test(isTestingGet, "Uint32", 6, "1718059137");
test(isTestingGet, "Uint32", 9, "2172814332");
test(isTestingGet, "Uint32", 12, "4244504319");
}
function testFloat(isTestingGet, func, array, start, expected)
{
// Little endian.
createDataView(array, 0, true, start);
test(isTestingGet, func, 0, expected, true);
createDataView(array, 3, true, start);
test(isTestingGet, func, 3, expected, true);
createDataView(array, 7, true, start);
test(isTestingGet, func, 7, expected, true);
createDataView(array, 10, true, start);
test(isTestingGet, func, 10, expected, true);
// Big endian.
createDataView(array, 0, false);
test(isTestingGet, func, 0, expected, false);
createDataView(array, 3, false);
test(isTestingGet, func, 3, expected, false);
createDataView(array, 7, false);
test(isTestingGet, func, 7, expected, false);
createDataView(array, 10, false);
test(isTestingGet, func, 10, expected, false);
}
function runFloatTestCases(isTestingGet, start)
{
testFloat(isTestingGet, "Float32", isTestingGet ? [0, 0, 32, 65] : emptyArray, start, "10");
testFloat(isTestingGet, "Float32", isTestingGet ? [164, 112, 157, 63] : emptyArray, start, "1.2300000190734863");
testFloat(isTestingGet, "Float32", isTestingGet ? [95, 53, 50, 199] : emptyArray, start, "-45621.37109375");
testFloat(isTestingGet, "Float32", isTestingGet ? [255, 255, 255, 127] : emptyArray, start, "NaN");
testFloat(isTestingGet, "Float32", isTestingGet ? [255, 255, 255, 255] : emptyArray, start, "-NaN");
testFloat(isTestingGet, "Float64", isTestingGet ? [0, 0, 0, 0, 0, 0, 36, 64] : emptyArray, start, "10");
testFloat(isTestingGet, "Float64", isTestingGet ? [174, 71, 225, 122, 20, 174, 243, 63] : emptyArray, start, "1.23");
testFloat(isTestingGet, "Float64", isTestingGet ? [181, 55, 248, 30, 242, 179, 87, 193] : emptyArray, start, "-6213576.4839");
testFloat(isTestingGet, "Float64", isTestingGet ? [255, 255, 255, 255, 255, 255, 255, 127] : emptyArray, start, "NaN");
testFloat(isTestingGet, "Float64", isTestingGet ? [255, 255, 255, 255, 255, 255, 255, 255] : emptyArray, start, "-NaN");
}
function runConstructorTests()
{
arayBuffer = (new Uint8Array([1, 2])).buffer;
debug("");
debug("Test for constructor taking 1 argument");
shouldBeDefined("view = new DataView(arayBuffer)");
shouldBe("view.byteOffset", "0");
shouldBe("view.byteLength", "2");
debug("");
debug("Test for constructor taking 2 arguments");
shouldBeDefined("view = new DataView(arayBuffer, 1)");
shouldBe("view.byteOffset", "1");
shouldBe("view.byteLength", "1");
debug("");
debug("Test for constructor taking 3 arguments");
shouldBeDefined("view = new DataView(arayBuffer, 0, 1)");
shouldBe("view.byteOffset", "0");
shouldBe("view.byteLength", "1");
debug("");
debug("Test for constructor throwing exception");
shouldThrow("view = new DataView(arayBuffer, 0, 3)");
shouldThrow("view = new DataView(arayBuffer, 1, 2)");
shouldThrow("view = new DataView(arayBuffer, 2, 1)");
}
function runGetTests()
{
debug("");
debug("Test for get methods that work");
runIntegerTestCases(true, intArray1, 0, 16);
runFloatTestCases(true, 0);
debug("");
debug("Test for get methods that might read beyound range");
runIntegerTestCases(true, intArray2, 3, 2);
runFloatTestCases(true, 3);
debug("");
debug("Test for wrong arguments passed to get methods");
view = new DataView((new Uint8Array([1, 2])).buffer);
shouldThrow("view.getInt8()");
shouldThrow("view.getUint8()");
shouldThrow("view.getInt16()");
shouldThrow("view.getUint16()");
shouldThrow("view.getInt32()");
shouldThrow("view.getUint32()");
shouldThrow("view.getFloat32()");
shouldThrow("view.getFloat64()");
}
function runSetTests()
{
debug("");
debug("Test for set methods that work");
runIntegerTestCases(false, emptyArray, 0, 16);
runFloatTestCases(false);
debug("");
debug("Test for set methods that might write beyond the range");
runIntegerTestCases(false, emptyArray, 3, 2);
runFloatTestCases(false, 7);
debug("");
debug("Test for wrong arguments passed to get methods");
view = new DataView((new Uint8Array([1, 2])).buffer);
shouldThrow("view.setInt8()");
shouldThrow("view.setUint8()");
shouldThrow("view.setInt16()");
shouldThrow("view.setUint16()");
shouldThrow("view.setInt32()");
shouldThrow("view.setUint32()");
shouldThrow("view.setFloat32()");
shouldThrow("view.setFloat64()");
shouldThrow("view.setInt8(1)");
shouldThrow("view.setUint8(1)");
shouldThrow("view.setInt16(1)");
shouldThrow("view.setUint16(1)");
shouldThrow("view.setInt32(1)");
shouldThrow("view.setUint32(1)");
shouldThrow("view.setFloat32(1)");
shouldThrow("view.setFloat64(1)");
}
function runIndexingTests()
{
debug("");
debug("Test for indexing that should not work");
view = new DataView((new Uint8Array([1, 2])).buffer);
shouldBeUndefined("view[0]");
shouldBeDefined("view[0] = 3");
shouldBe("view.getUint8(0)", "1");
}
runConstructorTests();
runGetTests();
runSetTests();
runIndexingTests();
successfullyParsed = true;
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
......@@ -21,6 +21,7 @@ var __skip__ = {
// Ignore these properties because they do not exist in all implementations. They will be tested separately
"WebGLRenderingContext" : 1,
"ArrayBuffer" : 1,
"DataView" : 1,
"Int8Array" : 1,
"Uint8Array" : 1,
"Int16Array" : 1,
......
......@@ -63,6 +63,7 @@ var __skip__ = {
// Ignore these properties because they do not exist in all implementations. They will be tested separately
"window.WebGLRenderingContext" : 1,
"window.ArrayBuffer" : 1,
"window.DataView" : 1,
"window.Int8Array" : 1,
"window.Uint8Array" : 1,
"window.Int16Array" : 1,
......
......@@ -61,6 +61,7 @@ function constructorNamesForWindow(globalObject)
// Ignore these properties because they do not exist in all implementations. They will be tested separately
if (type == "WebGLRenderingContextConstructor" ||
type == "ArrayBufferConstructor" ||
type == "DataViewConstructor" ||
type =="Float32ArrayConstructor" ||
type =="Int8ArrayConstructor" ||
type =="Int16ArrayConstructor" ||
......
......@@ -17,7 +17,7 @@ var skippedProperties = [
"webkitPerformance",
"WebGLRenderingContext",
"ArrayBuffer",
"Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array",
"DataView", "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array",
"FileError", "FileReader", "requestFileSystem",
"indexedDB", "IDBKeyRange", "IDBCursor", "IDBDatabase", "IDBDatabaseError", "IDBDatabaseException", "IDBErrorEvent", "IDBEvent", "IDBFactory", "IDBIndex", "IDBObjectStore", "IDBRequest", "IDBSuccessEvent", "IDBTransaction",
"showModalDialog",
......
......@@ -19,6 +19,7 @@ for (var x in constructorNames) {
// Ignore these properties because they do not exist in all implementations. They will be tested separately
if (name == "WebGLRenderingContext" ||
name == "ArrayBuffer" ||
name == "DataView" ||
name == "Int8Array" ||
name == "Uint8Array" ||
name == "Int16Array" ||
......
......@@ -293,6 +293,7 @@ SET(WebCore_IDL_FILES
html/canvas/CanvasPattern.idl
html/canvas/CanvasRenderingContext2D.idl
html/canvas/CanvasRenderingContext.idl
html/canvas/DataView.idl
html/canvas/Float32Array.idl
html/canvas/Int16Array.idl
html/canvas/Int32Array.idl
......
2010-11-24 Jian Li <jianli@chromium.org>
Reviewed by Kenneth Russell.
Implement DataView interface from Typed Array specification
https://bugs.webkit.org/show_bug.cgi?id=46541
Test: fast/canvas/webgl/data-view-test.html
* CMakeLists.txt:
* DerivedSources.make:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pri:
* WebCore.pro:
* WebCore.xcodeproj/project.pbxproj:
* bindings/generic/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::dataViewEnabled):
* bindings/js/JSArrayBufferViewHelper.h:
(WebCore::constructArrayBufferViewWithArrayBufferArgument):
(WebCore::constructArrayBufferView):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::dataView):
* bindings/js/JSDataViewCustom.cpp: Added.
* bindings/js/JSFloat32ArrayCustom.cpp:
(WebCore::JSFloat32ArrayConstructor::constructJSFloat32Array):
* bindings/js/JSInt16ArrayCustom.cpp:
(WebCore::JSInt16ArrayConstructor::constructJSInt16Array):
* bindings/js/JSInt32ArrayCustom.cpp:
(WebCore::JSInt32ArrayConstructor::constructJSInt32Array):
* bindings/js/JSInt8ArrayCustom.cpp:
(WebCore::JSInt8ArrayConstructor::constructJSInt8Array):
* bindings/js/JSUint16ArrayCustom.cpp:
(WebCore::JSUint16ArrayConstructor::constructJSUint16Array):
* bindings/js/JSUint32ArrayCustom.cpp:
(WebCore::JSUint32ArrayConstructor::constructJSUint32Array):
* bindings/js/JSUint8ArrayCustom.cpp:
(WebCore::JSUint8ArrayConstructor::constructJSUint8Array):
* bindings/v8/custom/V8ArrayBufferViewCustom.h:
(WebCore::constructWebGLArrayWithArrayBufferArgument):
(WebCore::constructWebGLArray):
* bindings/v8/custom/V8DataViewCustom.cpp: Added.
* html/canvas/ArrayBufferView.h:
(WebCore::ArrayBufferView::isDataView):
* html/canvas/DataView.cpp: Added.
* html/canvas/DataView.h: Added.
* html/canvas/DataView.idl: Added.
* page/DOMWindow.idl:
2010-11-24 Nicolas Dufresne <nicolas.dufresne@collabora.co.uk>
Reviewed by Martin Robinson.
......@@ -76,6 +76,7 @@ DOM_CLASSES = \
WebGLActiveInfo \
ArrayBufferView \
ArrayBuffer \
DataView \
WebGLBuffer \
Int8Array \
WebGLContextAttributes \
......
......@@ -186,6 +186,8 @@ webcore_built_sources += \
DerivedSources/WebCore/JSDataGridColumn.h \
DerivedSources/WebCore/JSDataGridColumnList.cpp \
DerivedSources/WebCore/JSDataGridColumnList.h \
DerivedSources/WebCore/JSDataView.cpp \
DerivedSources/WebCore/JSDataView.h \
DerivedSources/WebCore/JSDedicatedWorkerContext.cpp \
DerivedSources/WebCore/JSDedicatedWorkerContext.h \
DerivedSources/WebCore/JSDeviceMotionEvent.cpp \
......
......@@ -207,6 +207,7 @@
'html/canvas/CanvasPixelArray.idl',
'html/canvas/CanvasRenderingContext.idl',
'html/canvas/CanvasRenderingContext2D.idl',
'html/canvas/DataView.idl',
'html/canvas/Float32Array.idl',
'html/canvas/Int16Array.idl',
'html/canvas/Int32Array.idl',
......@@ -747,6 +748,8 @@
'bindings/v8/custom/V8CanvasPixelArrayCustom.cpp',
'bindings/v8/custom/V8ArrayBufferViewCustom.h',
'bindings/v8/custom/V8ArrayBufferCustom.cpp',
'bindings/v8/custom/V8DataViewCustom.cpp',
'bindings/v8/custom/V8DataViewCustom.h',
'bindings/v8/custom/V8Int8ArrayCustom.cpp',
'bindings/v8/custom/V8Int32ArrayCustom.cpp',
'bindings/v8/custom/V8FileReaderCustom.cpp',
......@@ -1865,6 +1868,8 @@
'html/canvas/CanvasStyle.cpp',
'html/canvas/CanvasStyle.h',
'html/canvas/CheckedInt.h',
'html/canvas/DataView.cpp',
'html/canvas/DataView.h',
'html/canvas/Float32Array.cpp',
'html/canvas/Float32Array.h',
'html/canvas/Int16Array.cpp',
......
......@@ -182,6 +182,7 @@ IDL_BINDINGS += \
fileapi/MetadataCallback.idl \
html/canvas/ArrayBufferView.idl \
html/canvas/ArrayBuffer.idl \
html/canvas/DataView.idl \
html/canvas/Int8Array.idl \
html/canvas/Float32Array.idl \
html/canvas/CanvasGradient.idl \
......
......@@ -3700,6 +3700,7 @@ HEADERS += \
html/canvas/WebGLActiveInfo.h \
html/canvas/ArrayBuffer.h \
html/canvas/ArrayBufferView.h \
html/canvas/DataView.h \
html/canvas/WebGLBuffer.h \
html/canvas/Int8Array.h \
html/canvas/WebGLContextAttributes.h \
......@@ -3724,6 +3725,7 @@ HEADERS += \
!v8 {
SOURCES += \
bindings/js/JSArrayBufferCustom.cpp \
bindings/js/JSDataViewCustom.cpp \
bindings/js/JSInt8ArrayCustom.cpp \
bindings/js/JSFloat32ArrayCustom.cpp \
bindings/js/JSInt32ArrayCustom.cpp \
......@@ -3738,6 +3740,7 @@ SOURCES += \
html/canvas/WebGLObject.cpp \
html/canvas/ArrayBuffer.cpp \
html/canvas/ArrayBufferView.cpp \
html/canvas/DataView.cpp \
html/canvas/WebGLBuffer.cpp \
html/canvas/Int8Array.cpp \
html/canvas/WebGLContextAttributes.cpp \
......
......@@ -767,6 +767,11 @@
2E75841F12779ADA0062628B /* FileReaderLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E75841C12779ADA0062628B /* FileReaderLoaderClient.h */; };
2E94F43B119207DA00B7F75D /* JSFileReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E94F439119207DA00B7F75D /* JSFileReader.cpp */; };
2E94F43C119207DA00B7F75D /* JSFileReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E94F43A119207DA00B7F75D /* JSFileReader.h */; };
2E97CCEA12939CB800C5C8FF /* DataView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E97CCE712939CB800C5C8FF /* DataView.cpp */; };
2E97CCEB12939CB800C5C8FF /* DataView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E97CCE812939CB800C5C8FF /* DataView.h */; };
2E97CCF71293A43A00C5C8FF /* JSDataViewCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E97CCF61293A43A00C5C8FF /* JSDataViewCustom.cpp */; };
2E97CE6F1293AD6B00C5C8FF /* JSDataView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E97CE6D1293AD6B00C5C8FF /* JSDataView.cpp */; };
2E97CE701293AD6B00C5C8FF /* JSDataView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E97CE6E1293AD6B00C5C8FF /* JSDataView.h */; };
2EA768040FE7126400AB9C8A /* WorkerScriptLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EA768030FE7126400AB9C8A /* WorkerScriptLoaderClient.h */; };
2EB4BCD2121F03E300EC4885 /* BlobResourceHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2EB4BCD0121F03E300EC4885 /* BlobResourceHandle.cpp */; };
2EB4BCD3121F03E300EC4885 /* BlobResourceHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EB4BCD1121F03E300EC4885 /* BlobResourceHandle.h */; };
......@@ -6857,6 +6862,12 @@
2E75841C12779ADA0062628B /* FileReaderLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileReaderLoaderClient.h; path = fileapi/FileReaderLoaderClient.h; sourceTree = "<group>"; };
2E94F439119207DA00B7F75D /* JSFileReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFileReader.cpp; sourceTree = "<group>"; };
2E94F43A119207DA00B7F75D /* JSFileReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFileReader.h; sourceTree = "<group>"; };
2E97CCE712939CB800C5C8FF /* DataView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataView.cpp; path = canvas/DataView.cpp; sourceTree = "<group>"; };
2E97CCE812939CB800C5C8FF /* DataView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataView.h; path = canvas/DataView.h; sourceTree = "<group>"; };
2E97CCE912939CB800C5C8FF /* DataView.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DataView.idl; path = canvas/DataView.idl; sourceTree = "<group>"; };
2E97CCF61293A43A00C5C8FF /* JSDataViewCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDataViewCustom.cpp; sourceTree = "<group>"; };
2E97CE6D1293AD6B00C5C8FF /* JSDataView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDataView.cpp; sourceTree = "<group>"; };
2E97CE6E1293AD6B00C5C8FF /* JSDataView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDataView.h; sourceTree = "<group>"; };
2EA768030FE7126400AB9C8A /* WorkerScriptLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WorkerScriptLoaderClient.h; path = workers/WorkerScriptLoaderClient.h; sourceTree = "<group>"; };
2EB4BCD0121F03E300EC4885 /* BlobResourceHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BlobResourceHandle.cpp; sourceTree = "<group>"; };
2EB4BCD1121F03E300EC4885 /* BlobResourceHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlobResourceHandle.h; sourceTree = "<group>"; };
......@@ -12631,6 +12642,9 @@
49484FBF102CF23C00187DD3 /* CanvasStyle.cpp */,
49484FC0102CF23C00187DD3 /* CanvasStyle.h */,
A00B721911DE6427008AB9FF /* CheckedInt.h */,
2E97CCE712939CB800C5C8FF /* DataView.cpp */,
2E97CCE812939CB800C5C8FF /* DataView.h */,
2E97CCE912939CB800C5C8FF /* DataView.idl */,
49EECDCD10503C2300099FAB /* Float32Array.cpp */,
49EECDCE10503C2300099FAB /* Float32Array.h */,
49EECDCF10503C2300099FAB /* Float32Array.idl */,
......@@ -15321,6 +15335,8 @@
BC77D1660FF19F550070887B /* JSDataGridColumn.h */,
BC77D1670FF19F550070887B /* JSDataGridColumnList.cpp */,
BC77D1680FF19F550070887B /* JSDataGridColumnList.h */,
2E97CE6D1293AD6B00C5C8FF /* JSDataView.cpp */,
2E97CE6E1293AD6B00C5C8FF /* JSDataView.h */,
2E0888D21148848A00AF4265 /* JSDOMFormData.cpp */,
2E0888D31148848A00AF4265 /* JSDOMFormData.h */,
4ACBC0C812713D0A0094F9B2 /* JSDOMSettableTokenList.cpp */,
......@@ -17100,6 +17116,7 @@
E1AD14E71297377400ACA989 /* JSCSSStyleRuleCustom.cpp */,
BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */,
BC77D1510FF19C730070887B /* JSDataGridColumnListCustom.cpp */,
2E97CCF61293A43A00C5C8FF /* JSDataViewCustom.cpp */,
4162A453101145E300DFF3ED /* JSDedicatedWorkerContextCustom.cpp */,
33503CBF10179C1A003B47E1 /* JSDesktopNotificationsCustom.cpp */,
31FB1A6B120A5D6900DC02A0 /* JSDeviceMotionEventCustom.cpp */,
......@@ -21403,6 +21420,8 @@
75415D56129AB2D2003AD669 /* JSSpeechInputEvent.h in Headers */,
75415D58129AB2D2003AD669 /* JSSpeechInputResult.h in Headers */,
75415D5A129AB2D2003AD669 /* JSSpeechInputResultList.h in Headers */,
2E97CCEB12939CB800C5C8FF /* DataView.h in Headers */,
2E97CE701293AD6B00C5C8FF /* JSDataView.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -23978,6 +23997,9 @@
75415D57129AB2D2003AD669 /* JSSpeechInputResult.cpp in Sources */,
75415D59129AB2D2003AD669 /* JSSpeechInputResultList.cpp in Sources */,
46BC724E129B104C0071C07E /* FileWriterBase.cpp in Sources */,
2E97CCEA12939CB800C5C8FF /* DataView.cpp in Sources */,
2E97CCF71293A43A00C5C8FF /* JSDataViewCustom.cpp in Sources */,
2E97CE6F1293AD6B00C5C8FF /* JSDataView.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -102,6 +102,7 @@ public:
static bool int32ArrayEnabled() { return isWebGLEnabled; }
static bool uint32ArrayEnabled() { return isWebGLEnabled; }
static bool float32ArrayEnabled() { return isWebGLEnabled; }
static bool dataViewEnabled() { return isWebGLEnabled; }
static bool webGLRenderingContextEnabled() { return isWebGLEnabled; }
static bool webGLArrayBufferEnabled() { return isWebGLEnabled; }
static bool webGLByteArrayEnabled() { return isWebGLEnabled; }
......
......@@ -86,16 +86,33 @@ JSC::JSValue setWebGLArrayHelper(JSC::ExecState* exec, T* impl, T* (*conversionF
// Template function used by XXXArrayConstructors.
// If this returns 0, it will already have thrown a JavaScript exception.
template<class C, typename T>
PassRefPtr<ArrayBufferView> constructArrayBufferView(JSC::ExecState* exec)
PassRefPtr<C> constructArrayBufferViewWithArrayBufferArgument(JSC::ExecState* exec)
{
RefPtr<ArrayBuffer> buffer = toArrayBuffer(exec->argument(0));
if (!buffer)
return 0;
unsigned offset = (exec->argumentCount() > 1) ? exec->argument(1).toUInt32(exec) : 0;
if ((buffer->byteLength() - offset) % sizeof(T))
throwError(exec, createRangeError(exec, "ArrayBuffer length minus the byteOffset is not a multiple of the element size."));
unsigned int length = (buffer->byteLength() - offset) / sizeof(T);
if (exec->argumentCount() > 2)
length = exec->argument(2).toUInt32(exec);