aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py15
-rw-r--r--components/script/dom/bindings/reflector.rs3
-rw-r--r--components/script/dom/bindings/trace.rs14
-rw-r--r--components/script/dom/customelementregistry.rs3
-rw-r--r--components/script/dom/gamepadbuttonlist.rs6
-rw-r--r--components/script/dom/testbinding.rs3
-rw-r--r--components/script/dom/webgl2renderingcontext.rs321
-rw-r--r--components/script/dom/webglrenderingcontext.rs582
-rw-r--r--components/script/dom/webidls/TestBinding.webidl3
-rw-r--r--components/script/dom/webidls/WebGLRenderingContext.webidl162
10 files changed, 527 insertions, 585 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 24054de8e95..de991f35ed9 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -422,7 +422,8 @@ class CGMethodCall(CGThing):
template,
{"val": distinguishingArg},
declType,
- "arg%d" % distinguishingIndex)
+ "arg%d" % distinguishingIndex,
+ needsAutoRoot=type_needs_auto_root(type))
# Indent by 4, since we need to indent further than our "do" statement
caseBody.append(CGIndenter(testCode, 4))
@@ -1211,7 +1212,8 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
def instantiateJSToNativeConversionTemplate(templateBody, replacements,
- declType, declName):
+ declType, declName,
+ needsAutoRoot=False):
"""
Take the templateBody and declType as returned by
getJSToNativeConversionInfo, a set of replacements as required by the
@@ -1236,6 +1238,8 @@ def instantiateJSToNativeConversionTemplate(templateBody, replacements,
else:
result.append(conversion)
+ if needsAutoRoot:
+ result.append(CGGeneric("auto_root!(in(cx) let %s = %s);" % (declName, declName)))
# Add an empty CGGeneric to get an extra newline after the argument
# conversion.
result.append(CGGeneric(""))
@@ -1318,11 +1322,8 @@ class CGArgumentConverter(CGThing):
arg = "arg%d" % index
self.converter = instantiateJSToNativeConversionTemplate(
- template, replacementVariables, declType, arg)
-
- # The auto rooting is done only after the conversion is performed
- if type_needs_auto_root(argument.type):
- self.converter.append(CGGeneric("auto_root!(in(cx) let %s = %s);" % (arg, arg)))
+ template, replacementVariables, declType, arg,
+ needsAutoRoot=type_needs_auto_root(argument.type))
else:
assert argument.optional
diff --git a/components/script/dom/bindings/reflector.rs b/components/script/dom/bindings/reflector.rs
index 0fef0a30678..97d88cb4357 100644
--- a/components/script/dom/bindings/reflector.rs
+++ b/components/script/dom/bindings/reflector.rs
@@ -46,7 +46,8 @@ impl Reflector {
/// Get the reflector.
#[inline]
pub fn get_jsobject(&self) -> HandleObject {
- self.object.handle()
+ // We're rooted, so it's safe to hand out a handle to object in Heap
+ unsafe { self.object.handle() }
}
/// Initialize the reflector. (May be called only once.)
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index 423b053cbbf..be38b14a540 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -59,9 +59,9 @@ use hyper::mime::Mime;
use hyper::status::StatusCode;
use ipc_channel::ipc::{IpcReceiver, IpcSender};
use js::glue::{CallObjectTracer, CallValueTracer};
-use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSTracer, TraceKind};
+use js::jsapi::{GCTraceKindToAscii, Heap, Handle, JSObject, JSTracer, TraceKind};
use js::jsval::JSVal;
-use js::rust::Runtime;
+use js::rust::{GCMethods, Runtime};
use js::typedarray::TypedArray;
use js::typedarray::TypedArrayElement;
use metrics::{InteractiveMetrics, InteractiveWindow};
@@ -788,6 +788,16 @@ impl<T: JSTraceable + 'static> RootedTraceableBox<T> {
}
}
+impl<T> RootedTraceableBox<Heap<T>>
+ where
+ Heap<T>: JSTraceable + 'static,
+ T: GCMethods + Copy,
+{
+ pub fn handle(&self) -> Handle<T> {
+ unsafe { (*self.ptr).handle() }
+ }
+}
+
impl<T: JSTraceable + Default> Default for RootedTraceableBox<T> {
fn default() -> RootedTraceableBox<T> {
RootedTraceableBox::new(T::default())
diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs
index a208f99def6..123b0bef2cb 100644
--- a/components/script/dom/customelementregistry.rs
+++ b/components/script/dom/customelementregistry.rs
@@ -604,7 +604,8 @@ impl CustomElementReaction {
match *self {
CustomElementReaction::Upgrade(ref definition) => upgrade_element(definition.clone(), element),
CustomElementReaction::Callback(ref callback, ref arguments) => {
- let arguments = arguments.iter().map(|arg| arg.handle()).collect();
+ // We're rooted, so it's safe to hand out a handle to objects in Heap
+ let arguments = arguments.iter().map(|arg| unsafe { arg.handle() }).collect();
let _ = callback.Call_(&*element, arguments, ExceptionHandling::Report);
}
}
diff --git a/components/script/dom/gamepadbuttonlist.rs b/components/script/dom/gamepadbuttonlist.rs
index 46f69fb97ad..24afa3b1bfe 100644
--- a/components/script/dom/gamepadbuttonlist.rs
+++ b/components/script/dom/gamepadbuttonlist.rs
@@ -37,10 +37,8 @@ impl GamepadButtonList {
}
pub fn sync_from_vr(&self, vr_buttons: &[WebVRGamepadButton]) {
- let mut index = 0;
- for btn in vr_buttons {
- self.list.get(index).as_ref().unwrap().update(btn.pressed, btn.touched);
- index += 1;
+ for (gp_btn, btn) in self.list.iter().zip(vr_buttons.iter()) {
+ gp_btn.update(btn.pressed, btn.touched);
}
}
}
diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs
index a5bb29a7e76..2beaa4d8897 100644
--- a/components/script/dom/testbinding.rs
+++ b/components/script/dom/testbinding.rs
@@ -472,6 +472,9 @@ impl TestBindingMethods for TestBinding {
fn PassStringSequence(&self, _: Vec<DOMString>) {}
fn PassInterfaceSequence(&self, _: Vec<DomRoot<Blob>>) {}
+ fn PassOverloaded(&self, _: CustomAutoRooterGuard<typedarray::ArrayBuffer>) {}
+ fn PassOverloaded_(&self, _: DOMString) {}
+
fn PassNullableBoolean(&self, _: Option<bool>) {}
fn PassNullableByte(&self, _: Option<i8>) {}
fn PassNullableOctet(&self, _: Option<u8>) {}
diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs
index 71ec9388d87..dd0701ace99 100644
--- a/components/script/dom/webgl2renderingcontext.rs
+++ b/components/script/dom/webgl2renderingcontext.rs
@@ -8,6 +8,7 @@ use dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding;
use dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextMethods;
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLContextAttributes;
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods;
+use dom::bindings::codegen::UnionTypes::ArrayBufferOrArrayBufferView;
use dom::bindings::codegen::UnionTypes::ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement;
use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::reflector::{reflect_dom_object, Reflector};
@@ -30,6 +31,8 @@ use dom_struct::dom_struct;
use euclid::Size2D;
use js::jsapi::{JSContext, JSObject};
use js::jsval::JSVal;
+use js::rust::CustomAutoRooterGuard;
+use js::typedarray::{ArrayBufferView, Float32Array, Int32Array};
use offscreen_gl_context::GLContextAttributes;
use script_layout_interface::HTMLCanvasDataSource;
use std::ptr::NonNull;
@@ -235,25 +238,23 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
self.base.BufferData_(target, size, usage)
}
- #[allow(unsafe_code)]
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
- unsafe fn BufferSubData(&self, cx: *mut JSContext, target: u32, offset: i64, data: *mut JSObject) -> Fallible<()> {
- self.base.BufferSubData(cx, target, offset, data)
+ fn BufferSubData(&self, target: u32, offset: i64, data: Option<ArrayBufferOrArrayBufferView>) {
+ self.base.BufferSubData(target, offset, data)
}
- #[allow(unsafe_code)]
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
- unsafe fn CompressedTexImage2D(&self, cx: *mut JSContext, target: u32, level: i32, internal_format: u32,
- width: i32, height: i32, border: i32, pixels: *mut JSObject) -> Fallible<()> {
- self.base.CompressedTexImage2D(cx, target, level, internal_format, width, height, border, pixels)
+ fn CompressedTexImage2D(&self, target: u32, level: i32, internal_format: u32,
+ width: i32, height: i32, border: i32,
+ pixels: CustomAutoRooterGuard<ArrayBufferView>) {
+ self.base.CompressedTexImage2D(target, level, internal_format, width, height, border, pixels)
}
- #[allow(unsafe_code)]
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
- unsafe fn CompressedTexSubImage2D(&self, cx: *mut JSContext, target: u32, level: i32,
- xoffset: i32, yoffset: i32, width: i32, height: i32,
- format: u32, pixels: *mut JSObject) -> Fallible<()> {
- self.base.CompressedTexSubImage2D(cx, target, level, xoffset, yoffset, width, height, format, pixels)
+ fn CompressedTexSubImage2D(&self, target: u32, level: i32, xoffset: i32,
+ yoffset: i32, width: i32, height: i32, format: u32,
+ pixels: CustomAutoRooterGuard<ArrayBufferView>) {
+ self.base.CompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, pixels)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
@@ -533,11 +534,10 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
self.base.PolygonOffset(factor, units)
}
- #[allow(unsafe_code)]
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.12
- unsafe fn ReadPixels(&self, cx: *mut JSContext, x: i32, y: i32, width: i32, height: i32,
- format: u32, pixel_type: u32, pixels: *mut JSObject) -> Fallible<()> {
- self.base.ReadPixels(cx, x, y, width, height, format, pixel_type, pixels)
+ fn ReadPixels(&self, x: i32, y: i32, width: i32, height: i32, format: u32, pixel_type: u32,
+ pixels: CustomAutoRooterGuard<Option<ArrayBufferView>>) {
+ self.base.ReadPixels(x, y, width, height, format, pixel_type, pixels)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
@@ -597,161 +597,198 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform1f(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
val: f32) {
- self.base.Uniform1f(uniform, val)
+ self.base.Uniform1f(location, val)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform1i(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
val: i32) {
- self.base.Uniform1i(uniform, val)
+ self.base.Uniform1i(location, val)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform1iv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- self.base.Uniform1iv(cx, uniform, data)
+ fn Uniform1iv(&self,
+ location: Option<&WebGLUniformLocation>,
+ v: CustomAutoRooterGuard<Int32Array>) {
+ self.base.Uniform1iv(location, v)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform1fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- self.base.Uniform1fv(cx, uniform, data)
+ fn Uniform1iv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<i32>) {
+ self.base.Uniform1iv_(location, v);
+ }
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform1fv(&self,
+ location: Option<&WebGLUniformLocation>,
+ v: CustomAutoRooterGuard<Float32Array>) {
+ self.base.Uniform1fv(location, v);
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform1fv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<f32>) {
+ self.base.Uniform1fv_(location, v);
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform2f(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
x: f32, y: f32) {
- self.base.Uniform2f(uniform, x, y)
+ self.base.Uniform2f(location, x, y)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform2fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- self.base.Uniform2fv(cx, uniform, data)
+ fn Uniform2fv(&self,
+ location: Option<&WebGLUniformLocation>,
+ v: CustomAutoRooterGuard<Float32Array>) {
+ self.base.Uniform2fv(location, v)
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform2fv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<f32>) {
+ self.base.Uniform2fv_(location, v);
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform2i(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
x: i32, y: i32) {
- self.base.Uniform2i(uniform, x, y)
+ self.base.Uniform2i(location, x, y)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform2iv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- self.base.Uniform2iv(cx, uniform, data)
+ fn Uniform2iv(&self,
+ location: Option<&WebGLUniformLocation>,
+ v: CustomAutoRooterGuard<Int32Array>) {
+ self.base.Uniform2iv(location, v)
+ }
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform2iv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<i32>) {
+ self.base.Uniform2iv_(location, v);
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform3f(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
x: f32, y: f32, z: f32) {
- self.base.Uniform3f(uniform, x, y, z)
+ self.base.Uniform3f(location, x, y, z)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform3fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- self.base.Uniform3fv(cx, uniform, data)
+ fn Uniform3fv(&self,
+ location: Option<&WebGLUniformLocation>,
+ v: CustomAutoRooterGuard<Float32Array>) {
+ self.base.Uniform3fv(location, v)
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform3fv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<f32>) {
+ self.base.Uniform3fv_(location, v);
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform3i(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
x: i32, y: i32, z: i32) {
- self.base.Uniform3i(uniform, x, y, z)
+ self.base.Uniform3i(location, x, y, z)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform3iv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- self.base.Uniform3iv(cx, uniform, data)
+ fn Uniform3iv(&self,
+ location: Option<&WebGLUniformLocation>,
+ v: CustomAutoRooterGuard<Int32Array>) {
+ self.base.Uniform3iv(location, v)
+ }
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform3iv_(&self,
+ location: Option<&WebGLUniformLocation>,
+ v: Vec<i32>) {
+ self.base.Uniform3iv_(location, v)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform4i(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
x: i32, y: i32, z: i32, w: i32) {
- self.base.Uniform4i(uniform, x, y, z, w)
+ self.base.Uniform4i(location, x, y, z, w)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform4iv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- self.base.Uniform4iv(cx, uniform, data)
+ fn Uniform4iv(&self,
+ location: Option<&WebGLUniformLocation>,
+ v: CustomAutoRooterGuard<Int32Array>) {
+ self.base.Uniform4iv(location, v)
+ }
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform4iv_(&self,
+ location: Option<&WebGLUniformLocation>,
+ v: Vec<i32>) {
+ self.base.Uniform4iv_(location, v)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform4f(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
x: f32, y: f32, z: f32, w: f32) {
- self.base.Uniform4f(uniform, x, y, z, w)
+ self.base.Uniform4f(location, x, y, z, w)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform4fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- self.base.Uniform4fv(cx, uniform, data)
+ fn Uniform4fv(&self,
+ location: Option<&WebGLUniformLocation>,
+ v: CustomAutoRooterGuard<Float32Array>) {
+ self.base.Uniform4fv(location, v)
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform4fv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<f32>) {
+ self.base.Uniform4fv_(location, v);
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn UniformMatrix2fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
+ fn UniformMatrix2fv(&self,
+ location: Option<&WebGLUniformLocation>,
transpose: bool,
- data: *mut JSObject) -> Fallible<()> {
- self.base.UniformMatrix2fv(cx, uniform, transpose, data)
+ v: CustomAutoRooterGuard<Float32Array>) {
+ self.base.UniformMatrix2fv(location, transpose, v)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn UniformMatrix3fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
+ fn UniformMatrix2fv_(&self, location: Option<&WebGLUniformLocation>, transpose: bool, value: Vec<f32>) {
+ self.base.UniformMatrix2fv_(location, transpose, value);
+ }
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn UniformMatrix3fv(&self,
+ location: Option<&WebGLUniformLocation>,
transpose: bool,
- data: *mut JSObject) -> Fallible<()> {
- self.base.UniformMatrix3fv(cx, uniform, transpose, data)
+ v: CustomAutoRooterGuard<Float32Array>) {
+ self.base.UniformMatrix3fv(location, transpose, v)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn UniformMatrix4fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
+ fn UniformMatrix3fv_(&self, location: Option<&WebGLUniformLocation>, transpose: bool, value: Vec<f32>) {
+ self.base.UniformMatrix3fv_(location, transpose, value);
+ }
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn UniformMatrix4fv(&self,
+ location: Option<&WebGLUniformLocation>,
transpose: bool,
- data: *mut JSObject) -> Fallible<()> {
- self.base.UniformMatrix4fv(cx, uniform, transpose, data)
+ v: CustomAutoRooterGuard<Float32Array>) {
+ self.base.UniformMatrix4fv(location, transpose, v)
+ }
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn UniformMatrix4fv_(&self, location: Option<&WebGLUniformLocation>, transpose: bool, value: Vec<f32>) {
+ self.base.UniformMatrix4fv_(location, transpose, value);
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
@@ -770,9 +807,13 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn VertexAttrib1fv(&self, cx: *mut JSContext, indx: u32, data: *mut JSObject) -> Fallible<()> {
- self.base.VertexAttrib1fv(cx, indx, data)
+ fn VertexAttrib1fv(&self, indx: u32, v: CustomAutoRooterGuard<Float32Array>) {
+ self.base.VertexAttrib1fv(indx, v)
+ }
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn VertexAttrib1fv_(&self, indx: u32, v: Vec<f32>) {
+ self.base.VertexAttrib1fv_(indx, v)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
@@ -781,9 +822,13 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn VertexAttrib2fv(&self, cx: *mut JSContext, indx: u32, data: *mut JSObject) -> Fallible<()> {
- self.base.VertexAttrib2fv(cx, indx, data)
+ fn VertexAttrib2fv(&self, indx: u32, v: CustomAutoRooterGuard<Float32Array>) {
+ self.base.VertexAttrib2fv(indx, v)
+ }
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn VertexAttrib2fv_(&self, indx: u32, v: Vec<f32>) {
+ self.base.VertexAttrib2fv_(indx, v)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
@@ -792,9 +837,13 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn VertexAttrib3fv(&self, cx: *mut JSContext, indx: u32, data: *mut JSObject) -> Fallible<()> {
- self.base.VertexAttrib3fv(cx, indx, data)
+ fn VertexAttrib3fv(&self, indx: u32, v: CustomAutoRooterGuard<Float32Array>) {
+ self.base.VertexAttrib3fv(indx, v)
+ }
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn VertexAttrib3fv_(&self, indx: u32, v: Vec<f32>) {
+ self.base.VertexAttrib3fv_(indx, v)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
@@ -803,9 +852,13 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn VertexAttrib4fv(&self, cx: *mut JSContext, indx: u32, data: *mut JSObject) -> Fallible<()> {
- self.base.VertexAttrib4fv(cx, indx, data)
+ fn VertexAttrib4fv(&self, indx: u32, v: CustomAutoRooterGuard<Float32Array>) {
+ self.base.VertexAttrib4fv(indx, v)
+ }
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn VertexAttrib4fv_(&self, indx: u32, v: Vec<f32>) {
+ self.base.VertexAttrib4fv_(indx, v)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
@@ -820,19 +873,17 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
- #[allow(unsafe_code)]
- unsafe fn TexImage2D(&self,
- cx: *mut JSContext,
- target: u32,
- level: i32,
- internal_format: u32,
- width: i32,
- height: i32,
- border: i32,
- format: u32,
- data_type: u32,
- data_ptr: *mut JSObject) -> Fallible<()> {
- self.base.TexImage2D(cx, target, level, internal_format, width, height, border, format, data_type, data_ptr)
+ fn TexImage2D(&self,
+ target: u32,
+ level: i32,
+ internal_format: u32,
+ width: i32,
+ height: i32,
+ border: i32,
+ format: u32,
+ data_type: u32,
+ pixels: CustomAutoRooterGuard<Option<ArrayBufferView>>) -> Fallible<()> {
+ self.base.TexImage2D(target, level, internal_format, width, height, border, format, data_type, pixels)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
@@ -862,19 +913,17 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
- #[allow(unsafe_code)]
- unsafe fn TexSubImage2D(&self,
- cx: *mut JSContext,
- target: u32,
- level: i32,
- xoffset: i32,
- yoffset: i32,
- width: i32,
- height: i32,
- format: u32,
- data_type: u32,
- data_ptr: *mut JSObject) -> Fallible<()> {
- self.base.TexSubImage2D(cx, target, level, xoffset, yoffset, width, height, format, data_type, data_ptr)
+ fn TexSubImage2D(&self,
+ target: u32,
+ level: i32,
+ xoffset: i32,
+ yoffset: i32,
+ width: i32,
+ height: i32,
+ format: u32,
+ data_type: u32,
+ pixels: CustomAutoRooterGuard<Option<ArrayBufferView>>) -> Fallible<()> {
+ self.base.TexSubImage2D(target, level, xoffset, yoffset, width, height, format, data_type, pixels)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index 8d3801c36e3..204426f8063 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -14,8 +14,9 @@ use dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2Rende
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::{self, WebGLContextAttributes};
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods;
+use dom::bindings::codegen::UnionTypes::ArrayBufferOrArrayBufferView;
use dom::bindings::codegen::UnionTypes::ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement;
-use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible};
+use dom::bindings::conversions::ToJSValConvertible;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
@@ -46,10 +47,10 @@ use dom_struct::dom_struct;
use euclid::Size2D;
use fnv::FnvHashMap;
use half::f16;
-use js::conversions::ConversionBehavior;
use js::jsapi::{JSContext, JSObject, Type};
use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, NullValue, UndefinedValue};
-use js::typedarray::{TypedArray, TypedArrayElement, Float32, Int32};
+use js::rust::CustomAutoRooterGuard;
+use js::typedarray::{ArrayBufferView, Float32Array, Int32Array};
use net_traits::image::base::PixelFormat;
use net_traits::image_cache::ImageResponse;
use offscreen_gl_context::{GLContextAttributes, GLLimits};
@@ -824,15 +825,13 @@ impl WebGLRenderingContext {
}
// TODO(emilio): Move this logic to a validator.
- #[allow(unsafe_code)]
- unsafe fn validate_tex_image_2d_data(&self,
- width: u32,
- height: u32,
- format: TexFormat,
- data_type: TexDataType,
- unpacking_alignment: u32,
- data: *mut JSObject,
- cx: *mut JSContext)
+ fn validate_tex_image_2d_data(&self,
+ width: u32,
+ height: u32,
+ format: TexFormat,
+ data_type: TexDataType,
+ unpacking_alignment: u32,
+ data: &Option<ArrayBufferView>)
-> Result<u32, ()> {
let element_size = data_type.element_size();
let components_per_element = data_type.components_per_element();
@@ -845,21 +844,16 @@ impl WebGLRenderingContext {
// or UNSIGNED_SHORT_5_5_5_1, a Uint16Array must be supplied.
// or FLOAT, a Float32Array must be supplied.
// If the types do not match, an INVALID_OPERATION error is generated.
- typedarray!(in(cx) let typedarray_u8: Uint8Array = data);
- typedarray!(in(cx) let typedarray_u16: Uint16Array = data);
- typedarray!(in(cx) let typedarray_f32: Float32Array = data);
- let received_size = if data.is_null() {
- element_size
- } else {
- if typedarray_u16.is_ok() {
- 2
- } else if typedarray_u8.is_ok() {
- 1
- } else if typedarray_f32.is_ok() {
- 4
- } else {
- self.webgl_error(InvalidOperation);
- return Err(());
+ let received_size = match *data {
+ None => element_size,
+ Some(ref buffer) => match buffer.get_array_type() {
+ Type::Uint8 => 1,
+ Type::Uint16 => 2,
+ Type::Float32 => 4,
+ _ => {
+ self.webgl_error(InvalidOperation);
+ return Err(());
+ }
}
};
@@ -1198,45 +1192,13 @@ impl Drop for WebGLRenderingContext {
}
}
-// FIXME: After [1] lands and the relevant Servo and codegen PR too, we should
-// convert all our raw JSObject pointers to proper types.
-//
-// [1]: https://github.com/servo/rust-mozjs/pull/304
-#[allow(unsafe_code)]
-unsafe fn typed_array_or_sequence_to_vec<T>(cx: *mut JSContext,
- sequence_or_abv: *mut JSObject,
- config: <T::Element as FromJSValConvertible>::Config)
- -> Result<Vec<T::Element>, Error>
- where T: TypedArrayElement,
- T::Element: FromJSValConvertible + Clone,
- <T::Element as FromJSValConvertible>::Config: Clone,
-{
- // TODO(servo/rust-mozjs#330): replace this with a macro that supports generic types.
- let typed_array: Option<TypedArray<T, *mut JSObject>> =
- TypedArray::from(sequence_or_abv).ok();
- if let Some(mut typed_array) = typed_array {
- return Ok(typed_array.as_slice().to_vec());
- }
- assert!(!sequence_or_abv.is_null());
- rooted!(in(cx) let mut val = UndefinedValue());
- sequence_or_abv.to_jsval(cx, val.handle_mut());
-
- match Vec::<T::Element>::from_jsval(cx, val.handle(), config) {
- Ok(ConversionResult::Success(v)) => Ok(v),
- Ok(ConversionResult::Failure(error)) => Err(Error::Type(error.into_owned())),
- // FIXME: What to do here? Generated code only aborts the execution of
- // the script.
- Err(err) => panic!("unexpected conversion error: {:?}", err),
- }
-}
-
#[allow(unsafe_code)]
unsafe fn fallible_array_buffer_view_to_vec(cx: *mut JSContext, abv: *mut JSObject) -> Result<Vec<u8>, Error>
{
assert!(!abv.is_null());
typedarray!(in(cx) let array_buffer_view: ArrayBufferView = abv);
match array_buffer_view {
- Ok(mut v) => Ok(v.as_slice().to_vec()),
+ Ok(mut v) => Ok(v.to_vec()),
Err(_) => Err(Error::Type("Not an ArrayBufferView".to_owned())),
}
}
@@ -1680,7 +1642,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
typedarray!(in(cx) let array_buffer: ArrayBuffer = data);
let data_vec = match array_buffer {
- Ok(mut data) => data.as_slice().to_vec(),
+ Ok(mut data) => data.to_vec(),
Err(_) => fallible_array_buffer_view_to_vec(cx, data)?,
};
@@ -1739,64 +1701,53 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
Ok(())
}
- #[allow(unsafe_code)]
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
- unsafe fn BufferSubData(&self, cx: *mut JSContext, target: u32, offset: i64, data: *mut JSObject) -> Fallible<()> {
- if data.is_null() {
- return Ok(self.webgl_error(InvalidValue));
- }
-
- typedarray!(in(cx) let array_buffer: ArrayBuffer = data);
- let data_vec = match array_buffer {
- Ok(mut data) => data.as_slice().to_vec(),
- Err(_) => fallible_array_buffer_view_to_vec(cx, data)?,
+ fn BufferSubData(&self, target: u32, offset: i64, data: Option<ArrayBufferOrArrayBufferView>) {
+ let data_vec = match data {
+ // Typed array is rooted, so we can safely temporarily retrieve its slice
+ Some(ArrayBufferOrArrayBufferView::ArrayBuffer(mut inner)) => inner.to_vec(),
+ Some(ArrayBufferOrArrayBufferView::ArrayBufferView(mut inner)) => inner.to_vec(),
+ // Spec: If data is null then an INVALID_VALUE error is generated.
+ None => return self.webgl_error(InvalidValue),
};
let bound_buffer = match target {
constants::ARRAY_BUFFER => self.bound_buffer_array.get(),
constants::ELEMENT_ARRAY_BUFFER => self.bound_buffer_element_array.get(),
- _ => return Ok(self.webgl_error(InvalidEnum)),
+ _ => return self.webgl_error(InvalidEnum),
};
let bound_buffer = match bound_buffer {
Some(bound_buffer) => bound_buffer,
- None => return Ok(self.webgl_error(InvalidOperation)),
+ None => return self.webgl_error(InvalidOperation),
};
if offset < 0 {
- return Ok(self.webgl_error(InvalidValue));
+ return self.webgl_error(InvalidValue);
}
if (offset as usize) + data_vec.len() > bound_buffer.capacity() {
- return Ok(self.webgl_error(InvalidValue));
+ return self.webgl_error(InvalidValue);
}
self.send_command(WebGLCommand::BufferSubData(target, offset as isize, data_vec));
-
- Ok(())
}
- #[allow(unsafe_code)]
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
- unsafe fn CompressedTexImage2D(&self, cx: *mut JSContext, _target: u32, _level: i32, _internal_format: u32,
- _width: i32, _height: i32, _border: i32, pixels: *mut JSObject) -> Fallible<()> {
- let _data = fallible_array_buffer_view_to_vec(cx, pixels)?;
+ fn CompressedTexImage2D(&self, _target: u32, _level: i32, _internal_format: u32,
+ _width: i32, _height: i32, _border: i32,
+ _data: CustomAutoRooterGuard<ArrayBufferView>) {
// FIXME: No compressed texture format is currently supported, so error out as per
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#COMPRESSED_TEXTURE_SUPPORT
self.webgl_error(InvalidEnum);
- Ok(())
}
- #[allow(unsafe_code)]
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
- unsafe fn CompressedTexSubImage2D(&self, cx: *mut JSContext, _target: u32, _level: i32,
- _xoffset: i32, _yoffset: i32, _width: i32, _height: i32,
- _format: u32, pixels: *mut JSObject) -> Fallible<()> {
- let _data = fallible_array_buffer_view_to_vec(cx, pixels)?;
+ fn CompressedTexSubImage2D(&self, _target: u32, _level: i32, _xoffset: i32,
+ _yoffset: i32, _width: i32, _height: i32, _format: u32,
+ _data: CustomAutoRooterGuard<ArrayBufferView>) {
// FIXME: No compressed texture format is currently supported, so error out as per
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#COMPRESSED_TEXTURE_SUPPORT
self.webgl_error(InvalidEnum);
-
- Ok(())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
@@ -2642,27 +2593,25 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
self.send_command(WebGLCommand::PolygonOffset(factor, units))
}
- #[allow(unsafe_code)]
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.12
- unsafe fn ReadPixels(&self, cx: *mut JSContext, x: i32, y: i32, width: i32, height: i32,
- format: u32, pixel_type: u32, pixels: *mut JSObject) -> Fallible<()> {
- if pixels.is_null() {
- return Ok(self.webgl_error(InvalidValue));
- }
-
- typedarray!(in(cx) let mut pixels_data: ArrayBufferView = pixels);
- let (array_type, data) = match { pixels_data.as_mut() } {
- Ok(data) => (data.get_array_type(), data.as_mut_slice()),
- Err(_) => return Err(Error::Type("Not an ArrayBufferView".to_owned())),
+ #[allow(unsafe_code)]
+ fn ReadPixels(&self, x: i32, y: i32, width: i32, height: i32, format: u32, pixel_type: u32,
+ mut pixels: CustomAutoRooterGuard<Option<ArrayBufferView>>) {
+ let (array_type, data) = match *pixels {
+ // Spec: If data is null then an INVALID_VALUE error is generated.
+ None => return self.webgl_error(InvalidValue),
+ // The typed array is rooted and we should have a unique reference to it,
+ // so retrieving its mutable slice is safe here
+ Some(ref mut data) => (data.get_array_type(), unsafe { data.as_mut_slice() }),
};
if !self.validate_framebuffer_complete() {
- return Ok(());
+ return;
}
match array_type {
Type::Uint8 => (),
- _ => return Ok(self.webgl_error(InvalidOperation)),
+ _ => return self.webgl_error(InvalidOperation),
}
// From the WebGL specification, 5.14.12 Reading back pixels
@@ -2683,7 +2632,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// always report RGBA/UNSIGNED_BYTE as our only supported
// format.
if format != constants::RGBA || pixel_type != constants::UNSIGNED_BYTE {
- return Ok(self.webgl_error(InvalidOperation));
+ return self.webgl_error(InvalidOperation);
}
let cpp = 4;
@@ -2693,12 +2642,12 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// INVALID_OPERATION error is generated."
let stride = match width.checked_mul(cpp) {
Some(stride) => stride,
- _ => return Ok(self.webgl_error(InvalidOperation)),
+ _ => return self.webgl_error(InvalidOperation),
};
match height.checked_mul(stride) {
Some(size) if size <= data.len() as i32 => {}
- _ => return Ok(self.webgl_error(InvalidOperation)),
+ _ => return self.webgl_error(InvalidOperation),
}
// "For any pixel lying outside the frame buffer, the
@@ -2724,7 +2673,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
if width < 0 || height < 0 {
- return Ok(self.webgl_error(InvalidValue));
+ return self.webgl_error(InvalidValue);
}
match self.get_current_framebuffer_size() {
@@ -2736,7 +2685,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
height = fb_height - y;
}
}
- _ => return Ok(self.webgl_error(InvalidOperation)),
+ _ => return self.webgl_error(InvalidOperation),
};
let (sender, receiver) = webgl_channel().unwrap();
@@ -2750,8 +2699,6 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
result[(i * width * cpp + j) as usize];
}
}
-
- Ok(())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
@@ -2854,279 +2801,269 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform1f(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
val: f32) {
- if self.validate_uniform_parameters(uniform, UniformSetterType::Float, &[val]) {
- self.send_command(WebGLCommand::Uniform1f(uniform.unwrap().id(), val))
+ if self.validate_uniform_parameters(location, UniformSetterType::Float, &[val]) {
+ self.send_command(WebGLCommand::Uniform1f(location.unwrap().id(), val))
}
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform1i(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
val: i32) {
- if self.validate_uniform_parameters(uniform, UniformSetterType::Int, &[val]) {
- self.send_command(WebGLCommand::Uniform1i(uniform.unwrap().id(), val))
+ if self.validate_uniform_parameters(location, UniformSetterType::Int, &[val]) {
+ self.send_command(WebGLCommand::Uniform1i(location.unwrap().id(), val))
}
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform1iv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Int32>(cx, data, ConversionBehavior::Default)?;
+ fn Uniform1iv(&self,
+ location: Option<&WebGLUniformLocation>,
+ mut v: CustomAutoRooterGuard<Int32Array>) {
+ self.Uniform1iv_(location, v.to_vec());
+ }
- if self.validate_uniform_parameters(uniform, UniformSetterType::Int, &data_vec) {
- self.send_command(WebGLCommand::Uniform1iv(uniform.unwrap().id(), data_vec))
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform1iv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<i32>) {
+ if self.validate_uniform_parameters(location, UniformSetterType::Int, &v) {
+ self.send_command(WebGLCommand::Uniform1iv(location.unwrap().id(), v))
}
-
- Ok(())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform1fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Float32>(cx, data, ())?;
+ fn Uniform1fv(&self,
+ location: Option<&WebGLUniformLocation>,
+ mut v: CustomAutoRooterGuard<Float32Array>) {
+ self.Uniform1fv_(location, v.to_vec());
+ }
- if self.validate_uniform_parameters(uniform, UniformSetterType::Float, &data_vec) {
- self.send_command(WebGLCommand::Uniform1fv(uniform.unwrap().id(), data_vec));
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform1fv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<f32>) {
+ if self.validate_uniform_parameters(location, UniformSetterType::Float, &v) {
+ self.send_command(WebGLCommand::Uniform1fv(location.unwrap().id(), v));
}
-
- Ok(())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform2f(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
x: f32, y: f32) {
- if self.validate_uniform_parameters(uniform, UniformSetterType::FloatVec2, &[x, y]) {
- self.send_command(WebGLCommand::Uniform2f(uniform.unwrap().id(), x, y));
+ if self.validate_uniform_parameters(location, UniformSetterType::FloatVec2, &[x, y]) {
+ self.send_command(WebGLCommand::Uniform2f(location.unwrap().id(), x, y));
}
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform2fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Float32>(cx, data, ())?;
-
- if self.validate_uniform_parameters(uniform,
+ fn Uniform2fv(&self,
+ location: Option<&WebGLUniformLocation>,
+ mut v: CustomAutoRooterGuard<Float32Array>) {
+ self.Uniform2fv_(location, v.to_vec());
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform2fv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<f32>) {
+ if self.validate_uniform_parameters(location,
UniformSetterType::FloatVec2,
- &data_vec) {
- self.send_command(WebGLCommand::Uniform2fv(uniform.unwrap().id(), data_vec));
+ &v) {
+ self.send_command(WebGLCommand::Uniform2fv(location.unwrap().id(), v));
}
-
- Ok(())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform2i(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
x: i32, y: i32) {
- if self.validate_uniform_parameters(uniform,
+ if self.validate_uniform_parameters(location,
UniformSetterType::IntVec2,
&[x, y]) {
- self.send_command(WebGLCommand::Uniform2i(uniform.unwrap().id(), x, y));
+ self.send_command(WebGLCommand::Uniform2i(location.unwrap().id(), x, y));
}
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform2iv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Int32>(cx, data, ConversionBehavior::Default)?;
-
- if self.validate_uniform_parameters(uniform,
+ fn Uniform2iv(&self,
+ location: Option<&WebGLUniformLocation>,
+ mut v: CustomAutoRooterGuard<Int32Array>) {
+ self.Uniform2iv_(location, v.to_vec());
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform2iv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<i32>) {
+ if self.validate_uniform_parameters(location,
UniformSetterType::IntVec2,
- &data_vec) {
- self.send_command(WebGLCommand::Uniform2iv(uniform.unwrap().id(), data_vec));
+ &v) {
+ self.send_command(WebGLCommand::Uniform2iv(location.unwrap().id(), v));
}
-
- Ok(())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform3f(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
x: f32, y: f32, z: f32) {
- if self.validate_uniform_parameters(uniform,
+ if self.validate_uniform_parameters(location,
UniformSetterType::FloatVec3,
&[x, y, z]) {
- self.send_command(WebGLCommand::Uniform3f(uniform.unwrap().id(), x, y, z));
+ self.send_command(WebGLCommand::Uniform3f(location.unwrap().id(), x, y, z));
}
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform3fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Float32>(cx, data, ())?;
-
- if self.validate_uniform_parameters(uniform,
+ fn Uniform3fv(&self,
+ location: Option<&WebGLUniformLocation>,
+ mut v: CustomAutoRooterGuard<Float32Array>) {
+ self.Uniform3fv_(location, v.to_vec());
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform3fv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<f32>) {
+ if self.validate_uniform_parameters(location,
UniformSetterType::FloatVec3,
- &data_vec) {
- self.send_command(WebGLCommand::Uniform3fv(uniform.unwrap().id(), data_vec))
+ &v) {
+ self.send_command(WebGLCommand::Uniform3fv(location.unwrap().id(), v))
}
-
- Ok(())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform3i(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
x: i32, y: i32, z: i32) {
- if self.validate_uniform_parameters(uniform,
+ if self.validate_uniform_parameters(location,
UniformSetterType::IntVec3,
&[x, y, z]) {
- self.send_command(WebGLCommand::Uniform3i(uniform.unwrap().id(), x, y, z))
+ self.send_command(WebGLCommand::Uniform3i(location.unwrap().id(), x, y, z))
}
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform3iv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Int32>(cx, data, ConversionBehavior::Default)?;
-
- if self.validate_uniform_parameters(uniform,
+ fn Uniform3iv(&self,
+ location: Option<&WebGLUniformLocation>,
+ mut v: CustomAutoRooterGuard<Int32Array>) {
+ self.Uniform3iv_(location, v.to_vec());
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform3iv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<i32>) {
+ if self.validate_uniform_parameters(location,
UniformSetterType::IntVec3,
- &data_vec) {
- self.send_command(WebGLCommand::Uniform3iv(uniform.unwrap().id(), data_vec))
+ &v) {
+ self.send_command(WebGLCommand::Uniform3iv(location.unwrap().id(), v))
}
-
- Ok(())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform4i(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
x: i32, y: i32, z: i32, w: i32) {
- if self.validate_uniform_parameters(uniform,
+ if self.validate_uniform_parameters(location,
UniformSetterType::IntVec4,
&[x, y, z, w]) {
- self.send_command(WebGLCommand::Uniform4i(uniform.unwrap().id(), x, y, z, w))
+ self.send_command(WebGLCommand::Uniform4i(location.unwrap().id(), x, y, z, w))
}
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform4iv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Int32>(cx, data, ConversionBehavior::Default)?;
-
- if self.validate_uniform_parameters(uniform,
+ fn Uniform4iv(&self,
+ location: Option<&WebGLUniformLocation>,
+ mut v: CustomAutoRooterGuard<Int32Array>) {
+ self.Uniform4iv_(location, v.to_vec());
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform4iv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<i32>) {
+ if self.validate_uniform_parameters(location,
UniformSetterType::IntVec4,
- &data_vec) {
- self.send_command(WebGLCommand::Uniform4iv(uniform.unwrap().id(), data_vec))
+ &v) {
+ self.send_command(WebGLCommand::Uniform4iv(location.unwrap().id(), v))
}
-
- Ok(())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform4f(&self,
- uniform: Option<&WebGLUniformLocation>,
+ location: Option<&WebGLUniformLocation>,
x: f32, y: f32, z: f32, w: f32) {
- if self.validate_uniform_parameters(uniform,
+ if self.validate_uniform_parameters(location,
UniformSetterType::FloatVec4,
&[x, y, z, w]) {
- self.send_command(WebGLCommand::Uniform4f(uniform.unwrap().id(), x, y, z, w))
+ self.send_command(WebGLCommand::Uniform4f(location.unwrap().id(), x, y, z, w))
}
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn Uniform4fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
- data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Float32>(cx, data, ())?;
-
- if self.validate_uniform_parameters(uniform,
+ fn Uniform4fv(&self,
+ location: Option<&WebGLUniformLocation>,
+ mut v: CustomAutoRooterGuard<Float32Array>) {
+ self.Uniform4fv_(location, v.to_vec());
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform4fv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<f32>) {
+ if self.validate_uniform_parameters(location,
UniformSetterType::FloatVec4,
- &data_vec) {
- self.send_command(WebGLCommand::Uniform4fv(uniform.unwrap().id(), data_vec))
+ &v) {
+ self.send_command(WebGLCommand::Uniform4fv(location.unwrap().id(), v))
}
-
- Ok(())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn UniformMatrix2fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
+ fn UniformMatrix2fv(&self,
+ location: Option<&WebGLUniformLocation>,
transpose: bool,
- data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Float32>(cx, data, ())?;
- if self.validate_uniform_parameters(uniform,
+ mut v: CustomAutoRooterGuard<Float32Array>) {
+ self.UniformMatrix2fv_(location, transpose, v.to_vec());
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn UniformMatrix2fv_(&self,
+ location: Option<&WebGLUniformLocation>,
+ transpose: bool,
+ value: Vec<f32>) {
+ if self.validate_uniform_parameters(location,
UniformSetterType::FloatMat2,
- &data_vec) {
- self.send_command(WebGLCommand::UniformMatrix2fv(uniform.unwrap().id(), transpose, data_vec));
+ &value) {
+ self.send_command(WebGLCommand::UniformMatrix2fv(location.unwrap().id(), transpose, value));
}
-
- Ok(())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn UniformMatrix3fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
+ fn UniformMatrix3fv(&self,
+ location: Option<&WebGLUniformLocation>,
transpose: bool,
- data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Float32>(cx, data, ())?;
- if self.validate_uniform_parameters(uniform,
+ mut v: CustomAutoRooterGuard<Float32Array>) {
+ self.UniformMatrix3fv_(location, transpose, v.to_vec());
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn UniformMatrix3fv_(&self,
+ location: Option<&WebGLUniformLocation>,
+ transpose: bool,
+ value: Vec<f32>) {
+ if self.validate_uniform_parameters(location,
UniformSetterType::FloatMat3,
- &data_vec) {
- self.send_command(WebGLCommand::UniformMatrix3fv(uniform.unwrap().id(), transpose, data_vec));
+ &value) {
+ self.send_command(WebGLCommand::UniformMatrix3fv(location.unwrap().id(), transpose, value));
}
-
- Ok(())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn UniformMatrix4fv(&self,
- cx: *mut JSContext,
- uniform: Option<&WebGLUniformLocation>,
+ fn UniformMatrix4fv(&self,
+ location: Option<&WebGLUniformLocation>,
transpose: bool,
- data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Float32>(cx, data, ())?;
- if self.validate_uniform_parameters(uniform,
+ mut v: CustomAutoRooterGuard<Float32Array>) {
+ self.UniformMatrix4fv_(location, transpose, v.to_vec());
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn UniformMatrix4fv_(&self,
+ location: Option<&WebGLUniformLocation>,
+ transpose: bool,
+ value: Vec<f32>) {
+ if self.validate_uniform_parameters(location,
UniformSetterType::FloatMat4,
- &data_vec) {
- self.send_command(WebGLCommand::UniformMatrix4fv(uniform.unwrap().id(), transpose, data_vec));
+ &value) {
+ self.send_command(WebGLCommand::UniformMatrix4fv(location.unwrap().id(), transpose, value));
}
-
- Ok(())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
@@ -3152,15 +3089,17 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn VertexAttrib1fv(&self, cx: *mut JSContext, indx: u32, data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Float32>(cx, data, ())?;
- if data_vec.len() < 1 {
- return Ok(self.webgl_error(InvalidOperation));
+ fn VertexAttrib1fv(&self, indx: u32, mut v: CustomAutoRooterGuard<Float32Array>) {
+ self.VertexAttrib1fv_(indx, v.to_vec());
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn VertexAttrib1fv_(&self, indx: u32, values: Vec<f32>) {
+ if values.len() < 1 {
+ return self.webgl_error(InvalidOperation);
}
- self.vertex_attrib(indx, data_vec[0], 0f32, 0f32, 1f32);
- Ok(())
+
+ self.vertex_attrib(indx, values[0], 0f32, 0f32, 1f32);
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
@@ -3169,15 +3108,17 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn VertexAttrib2fv(&self, cx: *mut JSContext, indx: u32, data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Float32>(cx, data, ())?;
- if data_vec.len() < 2 {
- return Ok(self.webgl_error(InvalidOperation));
+ fn VertexAttrib2fv(&self, indx: u32, mut v: CustomAutoRooterGuard<Float32Array>) {
+ self.VertexAttrib2fv_(indx, v.to_vec());
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn VertexAttrib2fv_(&self, indx: u32, values: Vec<f32>) {
+ if values.len() < 2 {
+ return self.webgl_error(InvalidOperation);
}
- self.vertex_attrib(indx, data_vec[0], data_vec[1], 0f32, 1f32);
- Ok(())
+
+ self.vertex_attrib(indx, values[0], values[1], 0f32, 1f32);
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
@@ -3186,15 +3127,17 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn VertexAttrib3fv(&self, cx: *mut JSContext, indx: u32, data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Float32>(cx, data, ())?;
- if data_vec.len() < 3 {
- return Ok(self.webgl_error(InvalidOperation));
+ fn VertexAttrib3fv(&self, indx: u32, mut v: CustomAutoRooterGuard<Float32Array>) {
+ self.VertexAttrib3fv_(indx, v.to_vec());
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn VertexAttrib3fv_(&self, indx: u32, values: Vec<f32>) {
+ if values.len() < 3 {
+ return self.webgl_error(InvalidOperation);
}
- self.vertex_attrib(indx, data_vec[0], data_vec[1], data_vec[2], 1f32);
- Ok(())
+
+ self.vertex_attrib(indx, values[0], values[1], values[2], 1f32);
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
@@ -3203,16 +3146,17 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
- #[allow(unsafe_code)]
- unsafe fn VertexAttrib4fv(&self, cx: *mut JSContext, indx: u32, data: *mut JSObject) -> Fallible<()> {
- assert!(!data.is_null());
- let data_vec = typed_array_or_sequence_to_vec::<Float32>(cx, data, ())?;
- if data_vec.len() < 4 {
- return Ok(self.webgl_error(InvalidOperation));
+ fn VertexAttrib4fv(&self, indx: u32, mut v: CustomAutoRooterGuard<Float32Array>) {
+ self.VertexAttrib4fv_(indx, v.to_vec());
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn VertexAttrib4fv_(&self, indx: u32, values: Vec<f32>) {
+ if values.len() < 4 {
+ return self.webgl_error(InvalidOperation);
}
- self.vertex_attrib(indx, data_vec[0], data_vec[1], data_vec[2], data_vec[3]);
- Ok(())
+ self.vertex_attrib(indx, values[0], values[1], values[2], values[3]);
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
@@ -3271,9 +3215,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
- #[allow(unsafe_code)]
- unsafe fn TexImage2D(&self,
- cx: *mut JSContext,
+ fn TexImage2D(&self,
target: u32,
level: i32,
internal_format: u32,
@@ -3282,17 +3224,11 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
border: i32,
format: u32,
data_type: u32,
- data_ptr: *mut JSObject) -> Fallible<()> {
+ mut pixels: CustomAutoRooterGuard<Option<ArrayBufferView>>) -> Fallible<()> {
if !self.extension_manager.is_tex_type_enabled(data_type) {
return Ok(self.webgl_error(InvalidEnum));
}
- let data = if data_ptr.is_null() {
- None
- } else {
- Some(fallible_array_buffer_view_to_vec(cx, data_ptr)?)
- };
-
let validator = TexImage2DValidator::new(self, target, level,
internal_format, width, height,
border, format, data_type);
@@ -3316,16 +3252,16 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
let expected_byte_length =
match { self.validate_tex_image_2d_data(width, height,
format, data_type,
- unpacking_alignment, data_ptr, cx) } {
+ unpacking_alignment, &*pixels) } {
Ok(byte_length) => byte_length,
Err(()) => return Ok(()),
};
// If data is null, a buffer of sufficient size
// initialized to 0 is passed.
- let buff = match data {
+ let buff = match *pixels {
None => vec![0u8; expected_byte_length as usize],
- Some(data) => data,
+ Some(ref mut data) => data.to_vec(),
};
// From the WebGL spec:
@@ -3443,9 +3379,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
- #[allow(unsafe_code)]
- unsafe fn TexSubImage2D(&self,
- cx: *mut JSContext,
+ fn TexSubImage2D(&self,
target: u32,
level: i32,
xoffset: i32,
@@ -3454,13 +3388,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
height: i32,
format: u32,
data_type: u32,
- data_ptr: *mut JSObject) -> Fallible<()> {
- let data = if data_ptr.is_null() {
- None
- } else {
- Some(fallible_array_buffer_view_to_vec(cx, data_ptr)?)
- };
-
+ mut pixels: CustomAutoRooterGuard<Option<ArrayBufferView>>) -> Fallible<()> {
let validator = TexImage2DValidator::new(self, target, level,
format, width, height,
0, format, data_type);
@@ -3483,16 +3411,16 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
let expected_byte_length =
match { self.validate_tex_image_2d_data(width, height,
format, data_type,
- unpacking_alignment, data_ptr, cx) } {
+ unpacking_alignment, &*pixels) } {
Ok(byte_length) => byte_length,
Err(()) => return Ok(()),
};
// If data is null, a buffer of sufficient size
// initialized to 0 is passed.
- let buff = match data {
+ let buff = match *pixels {
None => vec![0u8; expected_byte_length as usize],
- Some(data) => data,
+ Some(ref mut data) => data.to_vec(),
};
// From the WebGL spec:
diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl
index 1a1c86293cb..f95f4505ffb 100644
--- a/components/script/dom/webidls/TestBinding.webidl
+++ b/components/script/dom/webidls/TestBinding.webidl
@@ -275,6 +275,9 @@ interface TestBinding {
void passStringSequence(sequence<DOMString> seq);
void passInterfaceSequence(sequence<Blob> seq);
+ void passOverloaded(ArrayBuffer arg);
+ void passOverloaded(DOMString arg);
+
void passNullableBoolean(boolean? arg);
void passNullableByte(byte? arg);
void passNullableOctet(octet? arg);
diff --git a/components/script/dom/webidls/WebGLRenderingContext.webidl b/components/script/dom/webidls/WebGLRenderingContext.webidl
index 819e0d82179..9921adf2504 100644
--- a/components/script/dom/webidls/WebGLRenderingContext.webidl
+++ b/components/script/dom/webidls/WebGLRenderingContext.webidl
@@ -28,6 +28,7 @@ typedef (ImageData or
HTMLImageElement or
HTMLCanvasElement or
HTMLVideoElement) TexImageSource;
+typedef (ArrayBuffer or ArrayBufferView) BufferDataSource;
dictionary WebGLContextAttributes {
@@ -488,21 +489,15 @@ interface WebGLRenderingContextBase
void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
GLenum srcAlpha, GLenum dstAlpha);
- // typedef (ArrayBuffer or ArrayBufferView) BufferDataSource;
- // FIXME(dmarcos) The function below is the original function in the webIdl:
+ // FIXME(xanewok) from CodegenRust.py:
+ // 'No support for unions as distinguishing arguments yet' for below
+ // original WebIDL function definition
// void bufferData(GLenum target, BufferDataSource? data, GLenum usage);
- // The Code generator doesn't handle BufferDataSource so we're using 'object?'
- // in the meantime, and marking the function as [Throws], so we can handle
- // the type error from inside.
[Throws]
void bufferData(GLenum target, object? data, GLenum usage);
- // FIXME: Codegen requires that this have [Throws] to match the other one.
[Throws]
void bufferData(GLenum target, GLsizeiptr size, GLenum usage);
-
- //void bufferSubData(GLenum target, GLintptr offset, BufferDataSource? data);
- [Throws]
- void bufferSubData(GLenum target, GLintptr offset, object? data);
+ void bufferSubData(GLenum target, GLintptr offset, BufferDataSource? data);
[WebGLHandlesContextLoss] GLenum checkFramebufferStatus(GLenum target);
void clear(GLbitfield mask);
@@ -512,25 +507,13 @@ interface WebGLRenderingContextBase
void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
void compileShader(WebGLShader shader);
- // FIXME(simartin) The Code generator doesn't handle ArrayBufferView so we're
- // using 'object' in the meantime, and marking the function as Throws to
- // handle the type error from inside.
- // void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
- // GLsizei width, GLsizei height, GLint border,
- // ArrayBufferView data);
- [Throws]
void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLint border,
- object data);
- // void compressedTexSubImage2D(GLenum target, GLint level,
- // GLint xoffset, GLint yoffset,
- // GLsizei width, GLsizei height, GLenum format,
- // ArrayBufferView data);
- [Throws]
+ ArrayBufferView data);
void compressedTexSubImage2D(GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLenum format,
- object data);
+ ArrayBufferView data);
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
void copyTexImage2D(GLenum target, GLint level, GLenum internalformat,
@@ -623,11 +606,8 @@ interface WebGLRenderingContextBase
void pixelStorei(GLenum pname, GLint param);
void polygonOffset(GLfloat factor, GLfloat units);
- //void readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
- // GLenum format, GLenum type, ArrayBufferView? pixels);
- [Throws]
void readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type, object? pixels);
+ GLenum format, GLenum type, ArrayBufferView? pixels);
void renderbufferStorage(GLenum target, GLenum internalformat,
GLsizei width, GLsizei height);
@@ -643,14 +623,11 @@ interface WebGLRenderingContextBase
void stencilOp(GLenum fail, GLenum zfail, GLenum zpass);
void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
- //void texImage2D(GLenum target, GLint level, GLenum internalformat,
- // GLsizei width, GLsizei height, GLint border, GLenum format,
- // GLenum type, ArrayBufferView? pixels);
- // FIXME: SM interface arguments
+ // FIXME: Codegen requires that this have [Throws] to match the other one.
[Throws]
void texImage2D(GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLint border, GLenum format,
- GLenum type, object? data);
+ GLenum type, ArrayBufferView? pixels);
[Throws]
void texImage2D(GLenum target, GLint level, GLenum internalformat,
GLenum format, GLenum type, TexImageSource source); // May throw DOMException
@@ -661,107 +638,78 @@ interface WebGLRenderingContextBase
void texParameterf(GLenum target, GLenum pname, GLfloat param);
void texParameteri(GLenum target, GLenum pname, GLint param);
+ // FIXME: Codegen requires that this have [Throws] to match the other one.
[Throws]
void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
- GLenum format, GLenum type, object? data);
+ GLenum format, GLenum type, ArrayBufferView? pixels);
[Throws]
void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLenum format, GLenum type, TexImageSource source); // May throw DOMException
void uniform1f(WebGLUniformLocation? location, GLfloat x);
- //void uniform1fv(WebGLUniformLocation? location, Float32Array v);
- //void uniform1fv(WebGLUniformLocation? location, sequence<GLfloat> v);
- [Throws]
- void uniform1fv(WebGLUniformLocation? location, object v);
+ void uniform1fv(WebGLUniformLocation? location, Float32Array v);
+ void uniform1fv(WebGLUniformLocation? location, sequence<GLfloat> v);
+
void uniform1i(WebGLUniformLocation? location, GLint x);
- //void uniform1iv(WebGLUniformLocation? location, Int32Array v);
- //void uniform1iv(WebGLUniformLocation? location, sequence<long> v);
- [Throws]
- void uniform1iv(WebGLUniformLocation? location, object v);
+ void uniform1iv(WebGLUniformLocation? location, Int32Array v);
+ void uniform1iv(WebGLUniformLocation? location, sequence<long> v);
+
void uniform2f(WebGLUniformLocation? location, GLfloat x, GLfloat y);
- //void uniform2fv(WebGLUniformLocation? location, Float32Array v);
- //void uniform2fv(WebGLUniformLocation? location, sequence<GLfloat> v);
- [Throws]
- void uniform2fv(WebGLUniformLocation? location, object v);
- //void uniform2i(WebGLUniformLocation? location, GLint x, GLint y);
+ void uniform2fv(WebGLUniformLocation? location, Float32Array v);
+ void uniform2fv(WebGLUniformLocation? location, sequence<GLfloat> v);
+
void uniform2i(WebGLUniformLocation? location, GLint x, GLint y);
- //void uniform2iv(WebGLUniformLocation? location, Int32Array v);
- //void uniform2iv(WebGLUniformLocation? location, sequence<long> v);
- [Throws]
- void uniform2iv(WebGLUniformLocation? location, object v);
+ void uniform2iv(WebGLUniformLocation? location, Int32Array v);
+ void uniform2iv(WebGLUniformLocation? location, sequence<long> v);
+
void uniform3f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z);
- [Throws]
- void uniform3fv(WebGLUniformLocation? location, object v);
- //void uniform3fv(WebGLUniformLocation? location, Float32Array v);
- //void uniform3fv(WebGLUniformLocation? location, sequence<GLfloat> v);
+ void uniform3fv(WebGLUniformLocation? location, Float32Array v);
+ void uniform3fv(WebGLUniformLocation? location, sequence<GLfloat> v);
+
void uniform3i(WebGLUniformLocation? location, GLint x, GLint y, GLint z);
- //void uniform3iv(WebGLUniformLocation? location, Int32Array v);
- //void uniform3iv(WebGLUniformLocation? location, sequence<long> v);
- [Throws]
- void uniform3iv(WebGLUniformLocation? location, object v);
+ void uniform3iv(WebGLUniformLocation? location, Int32Array v);
+ void uniform3iv(WebGLUniformLocation? location, sequence<long> v);
+
void uniform4f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
- // FIXME(dmarcos) The function below is the original function in the webIdl:
- //void uniform4fv(WebGLUniformLocation? location, Float32Array v);
- // The Code genearator doesn't handle typed arrays, so we use object
- // instead, and handle the type error ourselves.
- [Throws]
- void uniform4fv(WebGLUniformLocation? location, object v);
- //void uniform4fv(WebGLUniformLocation? location, sequence<GLfloat> v);
+ void uniform4fv(WebGLUniformLocation? location, Float32Array v);
+ void uniform4fv(WebGLUniformLocation? location, sequence<GLfloat> v);
+
void uniform4i(WebGLUniformLocation? location, GLint x, GLint y, GLint z, GLint w);
- //void uniform4iv(WebGLUniformLocation? location, Int32Array v);
- //void uniform4iv(WebGLUniformLocation? location, sequence<long> v);
- // See FIXME above
- [Throws]
- void uniform4iv(WebGLUniformLocation? location, object v);
+ void uniform4iv(WebGLUniformLocation? location, Int32Array v);
+ void uniform4iv(WebGLUniformLocation? location, sequence<long> v);
- //void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose,
- // Float32Array value);
- //void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose,
- // sequence<GLfloat> value);
- [Throws]
void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose,
- object v);
- //void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose,
- // Float32Array value);
- //void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose,
- // sequence<GLfloat> value);
- [Throws]
+ Float32Array value);
+ void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose,
+ sequence<GLfloat> value);
void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose,
- object v);
- //void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose,
- // Float32Array value);
- //void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose,
- // sequence<GLfloat> value);
- [Throws]
+ Float32Array value);
+ void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose,
+ sequence<GLfloat> value);
+ void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose,
+ Float32Array value);
void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose,
- object v);
+ sequence<GLfloat> value);
void useProgram(WebGLProgram? program);
void validateProgram(WebGLProgram program);
- // FIXME(dmarcos)
- // The code generator doesn't handle Float32Array so we're using 'object'
void vertexAttrib1f(GLuint indx, GLfloat x);
- //void vertexAttrib1fv(GLuint indx, Float32Array values);
- [Throws]
- void vertexAttrib1fv(GLuint indx, object values);
- //void vertexAttrib1fv(GLuint indx, sequence<GLfloat> values);
+ void vertexAttrib1fv(GLuint indx, Float32Array values);
+ void vertexAttrib1fv(GLuint indx, sequence<GLfloat> values);
+
void vertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
- //void vertexAttrib2fv(GLuint indx, Float32Array values);
- [Throws]
- void vertexAttrib2fv(GLuint indx, object values);
- //void vertexAttrib2fv(GLuint indx, sequence<GLfloat> values);
+ void vertexAttrib2fv(GLuint indx, Float32Array values);
+ void vertexAttrib2fv(GLuint indx, sequence<GLfloat> values);
+
void vertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
- //void vertexAttrib3fv(GLuint indx, Float32Array values);
- [Throws]
- void vertexAttrib3fv(GLuint indx, object values);
- //void vertexAttrib3fv(GLuint indx, sequence<GLfloat> values);
+ void vertexAttrib3fv(GLuint indx, Float32Array values);
+ void vertexAttrib3fv(GLuint indx, sequence<GLfloat> values);
+
void vertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
- //void vertexAttrib4fv(GLuint indx, Float32Array values);
- [Throws]
- void vertexAttrib4fv(GLuint indx, object values);
- //void vertexAttrib4fv(GLuint indx, sequence<GLfloat> values);
+ void vertexAttrib4fv(GLuint indx, Float32Array values);
+ void vertexAttrib4fv(GLuint indx, sequence<GLfloat> values);
void vertexAttribPointer(GLuint indx, GLint size, GLenum type,
GLboolean normalized, GLsizei stride, GLintptr offset);