Commit 761e3037 authored by kbr@google.com's avatar kbr@google.com

2011-01-27 Kenneth Russell <kbr@google.com>

        Reviewed by James Robinson.

        Rename Typed Array slice() to subset()
        https://bugs.webkit.org/show_bug.cgi?id=53273

        * bindings/js/JSArrayBufferViewHelper.h:
        (WebCore::constructArrayBufferView):
        * bindings/v8/custom/V8ArrayBufferViewCustom.h:
        (WebCore::constructWebGLArray):
        * html/canvas/Float32Array.cpp:
        (WebCore::Float32Array::subset):
        * html/canvas/Float32Array.h:
        * html/canvas/Float32Array.idl:
        * html/canvas/Int16Array.cpp:
        (WebCore::Int16Array::subset):
        * html/canvas/Int16Array.h:
        * html/canvas/Int16Array.idl:
        * html/canvas/Int32Array.cpp:
        (WebCore::Int32Array::subset):
        * html/canvas/Int32Array.h:
        * html/canvas/Int32Array.idl:
        * html/canvas/Int8Array.cpp:
        (WebCore::Int8Array::subset):
        * html/canvas/Int8Array.h:
        * html/canvas/Int8Array.idl:
        * html/canvas/TypedArrayBase.h:
        (WebCore::TypedArrayBase::subsetImpl):
        * html/canvas/Uint16Array.cpp:
        (WebCore::Uint16Array::subset):
        * html/canvas/Uint16Array.h:
        * html/canvas/Uint16Array.idl:
        * html/canvas/Uint32Array.cpp:
        (WebCore::Uint32Array::subset):
        * html/canvas/Uint32Array.h:
        * html/canvas/Uint32Array.idl:
        * html/canvas/Uint8Array.cpp:
        (WebCore::Uint8Array::subset):
        * html/canvas/Uint8Array.h:
        * html/canvas/Uint8Array.idl:
2011-01-27  Kenneth Russell  <kbr@google.com>

        Reviewed by James Robinson.

        Rename Typed Array slice() to subset()
        https://bugs.webkit.org/show_bug.cgi?id=53273

        * fast/canvas/webgl/array-setters.html:
        * fast/canvas/webgl/array-unit-tests-expected.txt:
        * fast/canvas/webgl/array-unit-tests.html:
        * fast/canvas/webgl/draw-elements-out-of-bounds-expected.txt:
        * fast/canvas/webgl/draw-elements-out-of-bounds.html:
        * fast/canvas/webgl/webgl-array-invalid-ranges-expected.txt:
        * fast/canvas/webgl/webgl-array-invalid-ranges.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76892 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 13561637
2011-01-27 Kenneth Russell <kbr@google.com>
Reviewed by James Robinson.
Rename Typed Array slice() to subset()
https://bugs.webkit.org/show_bug.cgi?id=53273
* fast/canvas/webgl/array-setters.html:
* fast/canvas/webgl/array-unit-tests-expected.txt:
* fast/canvas/webgl/array-unit-tests.html:
* fast/canvas/webgl/draw-elements-out-of-bounds-expected.txt:
* fast/canvas/webgl/draw-elements-out-of-bounds.html:
* fast/canvas/webgl/webgl-array-invalid-ranges-expected.txt:
* fast/canvas/webgl/webgl-array-invalid-ranges.html:
2011-01-27 Leo Yang <leo.yang@torchmobile.com.cn>
Reviewed by Dirk Schulze.
......@@ -38,7 +38,7 @@ function testSetters(typeName, low, high) {
array = [0, 1, 2, 3, 4, 5];
webGLArray = new type(6);
webGLArray.set(array);
array = webGLArray.slice(2, 4);
array = webGLArray.subset(2, 4);
array[0] = 88;
array[1] = 99;
shouldBe("webGLArray[2]", "88");
......
......@@ -14,8 +14,8 @@ PASS test Float32Array SetFromTypedArray
PASS negativeTest Float32Array SetFromTypedArray
PASS test Float32Array SetFromArray
PASS negativeTest Float32Array SetFromArray
PASS test Float32Array Slice
PASS negativeTest Float32Array Slice
PASS test Float32Array Subset
PASS negativeTest Float32Array Subset
PASS test Float32Array BoundaryConditions(-500.5, -500.5, 500.5, 500.5)
PASS Construction of Float32Array with null buffer threw exception
PASS Construction of Float32Array with (null buffer, 0) threw exception
......@@ -28,17 +28,17 @@ PASS Construction of Float32Array with unaligned offset threw an exception
PASS Construction of Float32Array with unaligned length threw an exception
PASS Construction of huge Float32Array threw exception
PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
Testing slicing of Float32Array
Testing subsetting of Float32Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
PASS array.length is 0
Testing slicing with default inputs of Float32Array
Testing subsetting with default inputs of Float32Array
PASS array.length is 32 / typeSize
PASS array.slice(0).length is (32 / typeSize)
PASS array.slice(2).length is (32 / typeSize) - 2
PASS array.slice(-2).length is 2
PASS array.slice(-2147483648).length is (32 / typeSize)
PASS array.subset(0).length is (32 / typeSize)
PASS array.subset(2).length is (32 / typeSize) - 2
PASS array.subset(-2).length is 2
PASS array.subset(-2147483648).length is (32 / typeSize)
PASS Setting Float32Array from array with out-of-range offset was caught
PASS Setting Float32Array from fake array with invalid length was caught
PASS Setting Float32Array from Float32Array with out-of-range offset was caught
......@@ -57,8 +57,8 @@ PASS test Int8Array SetFromTypedArray
PASS negativeTest Int8Array SetFromTypedArray
PASS test Int8Array SetFromArray
PASS negativeTest Int8Array SetFromArray
PASS test Int8Array Slice
PASS negativeTest Int8Array Slice
PASS test Int8Array Subset
PASS negativeTest Int8Array Subset
PASS test Int8Array BoundaryConditions(-128, -128, 127, 127)
PASS Construction of Int8Array with null buffer threw exception
PASS Construction of Int8Array with (null buffer, 0) threw exception
......@@ -68,16 +68,16 @@ PASS Construction of ArrayBuffer with negative size threw exception
PASS Construction of Int8Array with negative size threw exception
PASS Construction of Int8Array with negative out-of-range values threw an exception
PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
Testing slicing of Int8Array
Testing subsetting of Int8Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
Testing slicing with default inputs of Int8Array
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
Testing subsetting with default inputs of Int8Array
PASS array.length is 32 / typeSize
PASS array.slice(0).length is (32 / typeSize)
PASS array.slice(2).length is (32 / typeSize) - 2
PASS array.slice(-2).length is 2
PASS array.slice(-2147483648).length is (32 / typeSize)
PASS array.subset(0).length is (32 / typeSize)
PASS array.subset(2).length is (32 / typeSize) - 2
PASS array.subset(-2).length is 2
PASS array.subset(-2147483648).length is (32 / typeSize)
PASS Setting Int8Array from array with out-of-range offset was caught
PASS Setting Int8Array from fake array with invalid length was caught
PASS Setting Int8Array from Int8Array with out-of-range offset was caught
......@@ -96,8 +96,8 @@ PASS test Int16Array SetFromTypedArray
PASS negativeTest Int16Array SetFromTypedArray
PASS test Int16Array SetFromArray
PASS negativeTest Int16Array SetFromArray
PASS test Int16Array Slice
PASS negativeTest Int16Array Slice
PASS test Int16Array Subset
PASS negativeTest Int16Array Subset
PASS test Int16Array BoundaryConditions(-32768, -32768, 32767, 32767)
PASS Construction of Int16Array with null buffer threw exception
PASS Construction of Int16Array with (null buffer, 0) threw exception
......@@ -110,17 +110,17 @@ PASS Construction of Int16Array with unaligned offset threw an exception
PASS Construction of Int16Array with unaligned length threw an exception
PASS Construction of huge Int16Array threw exception
PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
Testing slicing of Int16Array
Testing subsetting of Int16Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
PASS array.length is 0
Testing slicing with default inputs of Int16Array
Testing subsetting with default inputs of Int16Array
PASS array.length is 32 / typeSize
PASS array.slice(0).length is (32 / typeSize)
PASS array.slice(2).length is (32 / typeSize) - 2
PASS array.slice(-2).length is 2
PASS array.slice(-2147483648).length is (32 / typeSize)
PASS array.subset(0).length is (32 / typeSize)
PASS array.subset(2).length is (32 / typeSize) - 2
PASS array.subset(-2).length is 2
PASS array.subset(-2147483648).length is (32 / typeSize)
PASS Setting Int16Array from array with out-of-range offset was caught
PASS Setting Int16Array from fake array with invalid length was caught
PASS Setting Int16Array from Int16Array with out-of-range offset was caught
......@@ -139,8 +139,8 @@ PASS test Int32Array SetFromTypedArray
PASS negativeTest Int32Array SetFromTypedArray
PASS test Int32Array SetFromArray
PASS negativeTest Int32Array SetFromArray
PASS test Int32Array Slice
PASS negativeTest Int32Array Slice
PASS test Int32Array Subset
PASS negativeTest Int32Array Subset
PASS test Int32Array BoundaryConditions(-2147483648, -2147483648, 2147483647, 2147483647)
PASS Construction of Int32Array with null buffer threw exception
PASS Construction of Int32Array with (null buffer, 0) threw exception
......@@ -153,17 +153,17 @@ PASS Construction of Int32Array with unaligned offset threw an exception
PASS Construction of Int32Array with unaligned length threw an exception
PASS Construction of huge Int32Array threw exception
PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
Testing slicing of Int32Array
Testing subsetting of Int32Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
PASS array.length is 0
Testing slicing with default inputs of Int32Array
Testing subsetting with default inputs of Int32Array
PASS array.length is 32 / typeSize
PASS array.slice(0).length is (32 / typeSize)
PASS array.slice(2).length is (32 / typeSize) - 2
PASS array.slice(-2).length is 2
PASS array.slice(-2147483648).length is (32 / typeSize)
PASS array.subset(0).length is (32 / typeSize)
PASS array.subset(2).length is (32 / typeSize) - 2
PASS array.subset(-2).length is 2
PASS array.subset(-2147483648).length is (32 / typeSize)
PASS Setting Int32Array from array with out-of-range offset was caught
PASS Setting Int32Array from fake array with invalid length was caught
PASS Setting Int32Array from Int32Array with out-of-range offset was caught
......@@ -182,8 +182,8 @@ PASS test Uint8Array SetFromTypedArray
PASS negativeTest Uint8Array SetFromTypedArray
PASS test Uint8Array SetFromArray
PASS negativeTest Uint8Array SetFromArray
PASS test Uint8Array Slice
PASS negativeTest Uint8Array Slice
PASS test Uint8Array Subset
PASS negativeTest Uint8Array Subset
PASS test Uint8Array BoundaryConditions(0, 0, 255, 255)
PASS Construction of Uint8Array with null buffer threw exception
PASS Construction of Uint8Array with (null buffer, 0) threw exception
......@@ -193,16 +193,16 @@ PASS Construction of ArrayBuffer with negative size threw exception
PASS Construction of Uint8Array with negative size threw exception
PASS Construction of Uint8Array with negative out-of-range values threw an exception
PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
Testing slicing of Uint8Array
Testing subsetting of Uint8Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
Testing slicing with default inputs of Uint8Array
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
Testing subsetting with default inputs of Uint8Array
PASS array.length is 32 / typeSize
PASS array.slice(0).length is (32 / typeSize)
PASS array.slice(2).length is (32 / typeSize) - 2
PASS array.slice(-2).length is 2
PASS array.slice(-2147483648).length is (32 / typeSize)
PASS array.subset(0).length is (32 / typeSize)
PASS array.subset(2).length is (32 / typeSize) - 2
PASS array.subset(-2).length is 2
PASS array.subset(-2147483648).length is (32 / typeSize)
PASS Setting Uint8Array from array with out-of-range offset was caught
PASS Setting Uint8Array from fake array with invalid length was caught
PASS Setting Uint8Array from Uint8Array with out-of-range offset was caught
......@@ -221,8 +221,8 @@ PASS test Uint16Array SetFromTypedArray
PASS negativeTest Uint16Array SetFromTypedArray
PASS test Uint16Array SetFromArray
PASS negativeTest Uint16Array SetFromArray
PASS test Uint16Array Slice
PASS negativeTest Uint16Array Slice
PASS test Uint16Array Subset
PASS negativeTest Uint16Array Subset
PASS test Uint16Array BoundaryConditions(0, 0, 65535, 65535)
PASS Construction of Uint16Array with null buffer threw exception
PASS Construction of Uint16Array with (null buffer, 0) threw exception
......@@ -235,17 +235,17 @@ PASS Construction of Uint16Array with unaligned offset threw an exception
PASS Construction of Uint16Array with unaligned length threw an exception
PASS Construction of huge Uint16Array threw exception
PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
Testing slicing of Uint16Array
Testing subsetting of Uint16Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
PASS array.length is 0
Testing slicing with default inputs of Uint16Array
Testing subsetting with default inputs of Uint16Array
PASS array.length is 32 / typeSize
PASS array.slice(0).length is (32 / typeSize)
PASS array.slice(2).length is (32 / typeSize) - 2
PASS array.slice(-2).length is 2
PASS array.slice(-2147483648).length is (32 / typeSize)
PASS array.subset(0).length is (32 / typeSize)
PASS array.subset(2).length is (32 / typeSize) - 2
PASS array.subset(-2).length is 2
PASS array.subset(-2147483648).length is (32 / typeSize)
PASS Setting Uint16Array from array with out-of-range offset was caught
PASS Setting Uint16Array from fake array with invalid length was caught
PASS Setting Uint16Array from Uint16Array with out-of-range offset was caught
......@@ -264,8 +264,8 @@ PASS test Uint32Array SetFromTypedArray
PASS negativeTest Uint32Array SetFromTypedArray
PASS test Uint32Array SetFromArray
PASS negativeTest Uint32Array SetFromArray
PASS test Uint32Array Slice
PASS negativeTest Uint32Array Slice
PASS test Uint32Array Subset
PASS negativeTest Uint32Array Subset
PASS test Uint32Array BoundaryConditions(0, 0, 4294967295, 4294967295)
PASS Construction of Uint32Array with null buffer threw exception
PASS Construction of Uint32Array with (null buffer, 0) threw exception
......@@ -278,17 +278,17 @@ PASS Construction of Uint32Array with unaligned offset threw an exception
PASS Construction of Uint32Array with unaligned length threw an exception
PASS Construction of huge Uint32Array threw exception
PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
Testing slicing of Uint32Array
Testing subsetting of Uint32Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
PASS array.length is 0
Testing slicing with default inputs of Uint32Array
Testing subsetting with default inputs of Uint32Array
PASS array.length is 32 / typeSize
PASS array.slice(0).length is (32 / typeSize)
PASS array.slice(2).length is (32 / typeSize) - 2
PASS array.slice(-2).length is 2
PASS array.slice(-2147483648).length is (32 / typeSize)
PASS array.subset(0).length is (32 / typeSize)
PASS array.subset(2).length is (32 / typeSize) - 2
PASS array.subset(-2).length is 2
PASS array.subset(-2147483648).length is (32 / typeSize)
PASS Setting Uint32Array from array with out-of-range offset was caught
PASS Setting Uint32Array from fake array with invalid length was caught
PASS Setting Uint32Array from Uint32Array with out-of-range offset was caught
......
......@@ -284,19 +284,19 @@ function negativeTestSetFromArray(type, name) {
}
}
function testSlice(type, name) {
running('test ' + name + ' Slice');
function testSubset(type, name) {
running('test ' + name + ' Subset');
try {
var array = new type([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
var slice = array.slice(0, 5);
assertEq('slice.length', 5, slice.length);
var subset = array.subset(0, 5);
assertEq('subset.length', 5, subset.length);
for (var i = 0; i < 5; i++) {
assertEq('Element ' + i, i, slice[i]);
assertEq('Element ' + i, i, subset[i]);
}
slice = array.slice(4, 10);
assertEq('slice.length', 6, slice.length);
subset = array.subset(4, 10);
assertEq('subset.length', 6, subset.length);
for (var i = 0; i < 6; i++) {
assertEq('Element ' + i, 4 + i, slice[i]);
assertEq('Element ' + i, 4 + i, subset[i]);
}
pass();
} catch (e) {
......@@ -304,17 +304,17 @@ function testSlice(type, name) {
}
}
function negativeTestSlice(type, name) {
running('negativeTest ' + name + ' Slice');
function negativeTestSubset(type, name) {
running('negativeTest ' + name + ' Subset');
try {
var array = new type([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
slice = array.slice(5, 11);
if (slice.length != 5) {
subset = array.subset(5, 11);
if (subset.length != 5) {
fail();
return;
}
slice = array.slice(10, 10);
if (slice.length != 0) {
subset = array.subset(10, 10);
if (subset.length != 0) {
fail();
return;
}
......@@ -446,48 +446,48 @@ function testConstructionWithBothArrayBufferAndLength(type, name, elementSizeInB
var array;
var typeSize;
function testSlicingWithOutOfRangeValues(type, name, sz) {
debug("Testing slicing of " + name);
function testSubsettingWithOutOfRangeValues(type, name, sz) {
debug("Testing subsetting of " + name);
try {
var buffer = new ArrayBuffer(32);
array = new type(buffer);
typeSize = sz;
shouldBe("array.length", "32 / typeSize");
try {
shouldBe("array.slice(4, 0x3FFFFFFF).length", "(32 / typeSize) - 4");
shouldBe("array.slice(4, -2147483648).length", "0");
// Test slice() against overflows.
array = array.slice(2);
shouldBe("array.subset(4, 0x3FFFFFFF).length", "(32 / typeSize) - 4");
shouldBe("array.subset(4, -2147483648).length", "0");
// Test subset() against overflows.
array = array.subset(2);
if (sz > 1) {
// Full byte offset is +1 larger than the maximum unsigned long int.
// Make sure slice() still handles it correctly. Otherwise overflow would happen and
// Make sure subset() still handles it correctly. Otherwise overflow would happen and
// offset would be 0, and array.length array.length would incorrectly be 1.
var start = 4294967296 / sz - 2;
array = array.slice(start, start + 1);
array = array.subset(start, start + 1);
shouldBe("array.length", "0");
}
} catch (e) {
testFailed("Slicing of " + name + " threw exception");
testFailed("Subsetting of " + name + " threw exception");
}
} catch (e) {
testFailed("Exception: " + e);
}
}
function testSlicingWithDefaultValues(type, name, sz) {
debug("Testing slicing with default inputs of " + name);
function testSubsettingWithDefaultValues(type, name, sz) {
debug("Testing subsetting with default inputs of " + name);
try {
var buffer = new ArrayBuffer(32);
array = new type(buffer);
typeSize = sz;
shouldBe("array.length", "32 / typeSize");
try {
shouldBe("array.slice(0).length", "(32 / typeSize)");
shouldBe("array.slice(2).length", "(32 / typeSize) - 2");
shouldBe("array.slice(-2).length", "2");
shouldBe("array.slice(-2147483648).length", "(32 / typeSize)");
shouldBe("array.subset(0).length", "(32 / typeSize)");
shouldBe("array.subset(2).length", "(32 / typeSize) - 2");
shouldBe("array.subset(-2).length", "2");
shouldBe("array.subset(-2147483648).length", "(32 / typeSize)");
} catch (e) {
testFailed("Slicing of " + name + " threw exception");
testFailed("Subsetting of " + name + " threw exception");
}
} catch (e) {
testFailed("Exception: " + e);
......@@ -713,8 +713,8 @@ function runTests() {
negativeTestSetFromTypedArray(type, name);
testSetFromArray(type, name);
negativeTestSetFromArray(type, name);
testSlice(type, name);
negativeTestSlice(type, name);
testSubset(type, name);
negativeTestSubset(type, name);
testBoundaryConditions(type,
name,
testCase.low,
......@@ -728,8 +728,8 @@ function runTests() {
testConstructionWithUnalignedLength(type, name, testCase.elementSizeInBytes);
testConstructionOfHugeArray(type, name, testCase.elementSizeInBytes);
testConstructionWithBothArrayBufferAndLength(type, name, testCase.elementSizeInBytes);
testSlicingWithOutOfRangeValues(type, name, testCase.elementSizeInBytes);
testSlicingWithDefaultValues(type, name, testCase.elementSizeInBytes);
testSubsettingWithOutOfRangeValues(type, name, testCase.elementSizeInBytes);
testSubsettingWithDefaultValues(type, name, testCase.elementSizeInBytes);
testSettingFromArrayWithOutOfRangeOffset(type, name);
testSettingFromFakeArrayWithOutOfRangeLength(type, name);
testSettingFromTypedArrayWithOutOfRangeOffset(type, name);
......
......@@ -28,11 +28,11 @@ PASS context.drawElements(context.TRIANGLES, 0, context.UNSIGNED_BYTE, 4) genera
PASS context.drawElements(context.TRIANGLES, 0xffffffff, context.UNSIGNED_BYTE, 0) generated expected GL error: INVALID_VALUE.
PASS context.drawElements(context.TRIANGLES, 0x7fffffff, context.UNSIGNED_BYTE, 0) generated expected GL error: INVALID_OPERATION.
PASS context.drawElements(context.TRIANGLES, 0x7fffffff, context.UNSIGNED_BYTE, 0x7fffffff) generated expected GL error: INVALID_OPERATION.
PASS context.bufferData(context.ELEMENT_ARRAY_BUFFER, (new Uint8Array([ 3, 0, 1, 2 ])).slice(1), context.STATIC_DRAW) generated expected GL error: NO_ERROR.
PASS context.bufferData(context.ELEMENT_ARRAY_BUFFER, (new Uint8Array([ 3, 0, 1, 2 ])).subset(1), context.STATIC_DRAW) generated expected GL error: NO_ERROR.
PASS context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0) generated expected GL error: NO_ERROR.
PASS context.bufferSubData(context.ELEMENT_ARRAY_BUFFER, 0, new Uint8Array([ 3, 0, 1])) generated expected GL error: NO_ERROR.
PASS context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0) generated expected GL error: INVALID_OPERATION.
PASS context.bufferSubData(context.ELEMENT_ARRAY_BUFFER, 0, (new Uint8Array([ 3, 0, 1, 2 ])).slice(1)) generated expected GL error: NO_ERROR.
PASS context.bufferSubData(context.ELEMENT_ARRAY_BUFFER, 0, (new Uint8Array([ 3, 0, 1, 2 ])).subset(1)) generated expected GL error: NO_ERROR.
PASS context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0) generated expected GL error: NO_ERROR.
PASS context.drawElements(context.TRIANGLES, 0, context.UNSIGNED_BYTE, 0) generated expected GL error: NO_ERROR.
......
......@@ -55,11 +55,11 @@ shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont
shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLES, 0x7fffffff, context.UNSIGNED_BYTE, 0)");
shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLES, 0x7fffffff, context.UNSIGNED_BYTE, 0x7fffffff)");
shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ELEMENT_ARRAY_BUFFER, (new Uint8Array([ 3, 0, 1, 2 ])).slice(1), context.STATIC_DRAW)");
shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ELEMENT_ARRAY_BUFFER, (new Uint8Array([ 3, 0, 1, 2 ])).subset(1), context.STATIC_DRAW)");
shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0)");
shouldGenerateGLError(context, context.NO_ERROR, "context.bufferSubData(context.ELEMENT_ARRAY_BUFFER, 0, new Uint8Array([ 3, 0, 1]))");
shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0)");
shouldGenerateGLError(context, context.NO_ERROR, "context.bufferSubData(context.ELEMENT_ARRAY_BUFFER, 0, (new Uint8Array([ 3, 0, 1, 2 ])).slice(1))");
shouldGenerateGLError(context, context.NO_ERROR, "context.bufferSubData(context.ELEMENT_ARRAY_BUFFER, 0, (new Uint8Array([ 3, 0, 1, 2 ])).subset(1))");
shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0)");
shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 0, context.UNSIGNED_BYTE, 0)");
......
......@@ -7,8 +7,8 @@ PASS Construction of Int8Array with out-of-range values threw exception
PASS Construction of Int8Array with negative out-of-range values threw exception
Testing slicing of Int8Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
PASS Setting Int8Array from array with out-of-range offset was caught
PASS Setting Int8Array from fake array with invalid length was caught
PASS Setting Int8Array from Int8Array with out-of-range offset was caught
......@@ -17,8 +17,8 @@ PASS Construction of Uint8Array with out-of-range values threw exception
PASS Construction of Uint8Array with negative out-of-range values threw exception
Testing slicing of Uint8Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
PASS Setting Uint8Array from array with out-of-range offset was caught
PASS Setting Uint8Array from fake array with invalid length was caught
PASS Setting Uint8Array from Uint8Array with out-of-range offset was caught
......@@ -28,8 +28,8 @@ PASS Construction of Int16Array with negative out-of-range values threw exceptio
PASS Construction of huge Int16Array threw exception
Testing slicing of Int16Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
PASS Setting Int16Array from array with out-of-range offset was caught
PASS Setting Int16Array from fake array with invalid length was caught
PASS Setting Int16Array from Int16Array with out-of-range offset was caught
......@@ -39,8 +39,8 @@ PASS Construction of Uint16Array with negative out-of-range values threw excepti
PASS Construction of huge Uint16Array threw exception
Testing slicing of Uint16Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
PASS Setting Uint16Array from array with out-of-range offset was caught
PASS Setting Uint16Array from fake array with invalid length was caught
PASS Setting Uint16Array from Uint16Array with out-of-range offset was caught
......@@ -50,8 +50,8 @@ PASS Construction of Int32Array with negative out-of-range values threw exceptio
PASS Construction of huge Int32Array threw exception
Testing slicing of Int32Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
PASS Setting Int32Array from array with out-of-range offset was caught
PASS Setting Int32Array from fake array with invalid length was caught
PASS Setting Int32Array from Int32Array with out-of-range offset was caught
......@@ -61,8 +61,8 @@ PASS Construction of Uint32Array with negative out-of-range values threw excepti
PASS Construction of huge Uint32Array threw exception
Testing slicing of Uint32Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
PASS Setting Uint32Array from array with out-of-range offset was caught
PASS Setting Uint32Array from fake array with invalid length was caught
PASS Setting Uint32Array from Uint32Array with out-of-range offset was caught
......@@ -72,8 +72,8 @@ PASS Construction of Float32Array with negative out-of-range values threw except
PASS Construction of huge Float32Array threw exception
Testing slicing of Float32Array
PASS array.length is 32 / typeSize
PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.slice(4, -2147483648).length is 0
PASS array.subset(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
PASS array.subset(4, -2147483648).length is 0
PASS Setting Float32Array from array with out-of-range offset was caught
PASS Setting Float32Array from fake array with invalid length was caught
PASS Setting Float32Array from Float32Array with out-of-range offset was caught
......
......@@ -70,8 +70,8 @@ function testSlicingWithOutOfRangeValues(type, name, sz) {
typeSize = sz;
shouldBe("array.length", "32 / typeSize");
try {
shouldBe("array.slice(4, 0x3FFFFFFF).length", "(32 / typeSize) - 4");
shouldBe("array.slice(4, -2147483648).length", "0");
shouldBe("array.subset(4, 0x3FFFFFFF).length", "(32 / typeSize) - 4");
shouldBe("array.subset(4, -2147483648).length", "0");
} catch (e) {
testFailed("Slicing of " + name + " threw exception");
}
......
2011-01-27 Kenneth Russell <kbr@google.com>
Reviewed by James Robinson.
Rename Typed Array slice() to subset()
https://bugs.webkit.org/show_bug.cgi?id=53273
* bindings/js/JSArrayBufferViewHelper.h:
(WebCore::constructArrayBufferView):
* bindings/v8/custom/V8ArrayBufferViewCustom.h:
(WebCore::constructWebGLArray):
* html/canvas/Float32Array.cpp:
(WebCore::Float32Array::subset):
* html/canvas/Float32Array.h:
* html/canvas/Float32Array.idl:
* html/canvas/Int16Array.cpp:
(WebCore::Int16Array::subset):
* html/canvas/Int16Array.h:
* html/canvas/Int16Array.idl:
* html/canvas/Int32Array.cpp:
(WebCore::Int32Array::subset):
* html/canvas/Int32Array.h:
* html/canvas/Int32Array.idl:
* html/canvas/Int8Array.cpp:
(WebCore::Int8Array::subset):
* html/canvas/Int8Array.h:
* html/canvas/Int8Array.idl:
* html/canvas/TypedArrayBase.h:
(WebCore::TypedArrayBase::subsetImpl):
* html/canvas/Uint16Array.cpp:
(WebCore::Uint16Array::subset):
* html/canvas/Uint16Array.h:
* html/canvas/Uint16Array.idl:
* html/canvas/Uint32Array.cpp:
(WebCore::Uint32Array::subset):
* html/canvas/Uint32Array.h:
* html/canvas/Uint32Array.idl:
* html/canvas/Uint8Array.cpp:
(WebCore::Uint8Array::subset):
* html/canvas/Uint8Array.h:
* html/canvas/Uint8Array.idl:
2011-01-27 Darin Adler <darin@apple.com>
Reviewed by Dan Bernstein.
......@@ -137,7 +137,7 @@ PassRefPtr<C> constructArrayBufferView(JSC::ExecState* exec)
// JavaScript DOM bindings can distinguish between "new
// <Type>Array()" and what occurs when a previously-constructed
// ArrayBufferView is returned to JavaScript; e.g., from
// "array.slice()".
// "array.subset()".
if (exec->argumentCount() < 1)
return C::create(0);
......
......@@ -87,7 +87,7 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType
int argLen = args.Length();
if (!argLen) {
// This happens when we return a previously constructed
// ArrayBufferView, e.g. from the call to <Type>Array.slice().
// ArrayBufferView, e.g. from the call to <Type>Array.subset().
// The V8DOMWrapper will set the internal pointer in the
// created object. Unfortunately it doesn't look like it's
// possible to distinguish between this case and that where
......@@ -99,7 +99,7 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType
V8DOMWrapper::setDOMWrapper(args.Holder(), type, array.get());
// Do not call SetIndexedPropertiesToExternalArrayData on this
// object. Not only is there no point from a performance
// perspective, but doing so causes errors in the slice() case.
// perspective, but doing so causes errors in the subset() case.
return toV8(array.release(), args.Holder());
}
......
......@@ -52,14 +52,14 @@ Float32Array::Float32Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset,
{
}
PassRefPtr<Float32Array> Float32Array::slice(int start) const
PassRefPtr<Float32Array> Float32Array::subset(