Replace uses of spidermonkey-specific JS_GetArrayBufferViewType with ArrayBufferView impl's method get_array_type()

This commit is contained in:
Sam Liu 2017-02-20 19:26:23 -08:00
parent ccc1df2dfe
commit 4fc3e7e75d
3 changed files with 11 additions and 12 deletions

View file

@ -37,7 +37,7 @@ use dom::window::Window;
use euclid::size::Size2D;
use ipc_channel::ipc::{self, IpcSender};
use js::conversions::ConversionBehavior;
use js::jsapi::{JSContext, JSObject, JS_GetArrayBufferViewType, Type, Rooted};
use js::jsapi::{JSContext, JSObject, Type, Rooted};
use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, NullValue, UndefinedValue};
use js::typedarray::{TypedArray, TypedArrayElement, Float32, Int32};
use net_traits::image::base::PixelFormat;
@ -2080,8 +2080,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
typedarray!(in(cx) let mut pixels_data: ArrayBufferView = pixels);
let mut data = match { pixels_data.as_mut() } {
Ok(data) => data.as_mut_slice(),
let (array_type, mut 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())),
};
@ -2089,7 +2089,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
return Ok(());
}
match { JS_GetArrayBufferViewType(pixels) } {
match array_type {
Type::Uint8 => (),
_ => return Ok(self.webgl_error(InvalidOperation)),
}