aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/webglrenderingcontext.rs50
1 files changed, 29 insertions, 21 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index 0145d84ffd8..c6443ecfd29 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -1342,31 +1342,39 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
#[allow(unsafe_code)]
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
unsafe fn GetTexParameter(&self, _cx: *mut JSContext, target: u32, pname: u32) -> JSVal {
- let texture = match target {
+ let target_matches = match target {
constants::TEXTURE_2D |
- constants::TEXTURE_CUBE_MAP => self.bound_texture(target),
+ constants::TEXTURE_CUBE_MAP => true,
+ _ => false,
+ };
+
+ let pname_matches = match pname {
+ constants::TEXTURE_MAG_FILTER |
+ constants::TEXTURE_MIN_FILTER |
+ constants::TEXTURE_WRAP_S |
+ constants::TEXTURE_WRAP_T => true,
+ _ => false,
+ };
+
+ if !target_matches || !pname_matches {
+ self.webgl_error(InvalidEnum);
+ return NullValue();
+ }
+
+ if self.bound_texture(target).is_none() {
+ self.webgl_error(InvalidOperation);
+ return NullValue();
+ }
+
+ let (sender, receiver) = webgl_channel().unwrap();
+ self.send_command(WebGLCommand::GetTexParameter(target, pname, sender));
+
+ match receiver.recv().unwrap() {
+ value if value != 0 => Int32Value(value),
_ => {
self.webgl_error(InvalidEnum);
- return NullValue();
- }
- };
- if texture.is_some() {
- let (sender, receiver) = webgl_channel().unwrap();
- self.send_command(WebGLCommand::GetTexParameter(target, pname, sender));
- match handle_potential_webgl_error!(self, receiver.recv().unwrap(), WebGLParameter::Invalid) {
- WebGLParameter::Int(val) => Int32Value(val),
- WebGLParameter::Bool(_) => panic!("Texture parameter should not be bool"),
- WebGLParameter::Float(_) => panic!("Texture parameter should not be float"),
- WebGLParameter::FloatArray(_) => panic!("Texture parameter should not be float array"),
- WebGLParameter::String(_) => panic!("Texture parameter should not be string"),
- WebGLParameter::Invalid => {
- self.webgl_error(InvalidEnum);
- NullValue()
- }
+ NullValue()
}
- } else {
- self.webgl_error(InvalidOperation);
- NullValue()
}
}