Auto merge of #26289 - he4d:master, r=jdm

Replaced failible boolean with an enum

<!-- Please describe your changes on the following line: -->
Replaced the boolean `fallible` argument of some WebGL object methods with the new `enum Operation { Fallible, Infallible }` that was added to the `webglrenderingcontext`. This improves the readability of that methods.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #26047 (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because the issue says so

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
bors-servo 2020-04-24 02:04:07 -04:00 committed by GitHub
commit 25220049d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 106 additions and 111 deletions

View file

@ -155,6 +155,12 @@ pub enum VertexAttrib {
Uint(u32, u32, u32, u32),
}
#[derive(Clone, Copy, Debug)]
pub enum Operation {
Fallible,
Infallible,
}
#[dom_struct]
pub struct WebGLRenderingContext {
reflector_: Reflector,
@ -1142,7 +1148,7 @@ impl WebGLRenderingContext {
self.current_vao.set(None);
self.send_command(WebGLCommand::BindVertexArray(None));
}
vao.delete(false);
vao.delete(Operation::Infallible);
}
}
@ -1160,7 +1166,7 @@ impl WebGLRenderingContext {
self.current_vao_webgl2.set(None);
self.send_command(WebGLCommand::BindVertexArray(None));
}
vao.delete(false);
vao.delete(Operation::Infallible);
}
}
@ -1335,7 +1341,7 @@ impl WebGLRenderingContext {
self.send_command(WebGLCommand::BindBuffer(target, buffer.map(|b| b.id())));
if let Some(old) = slot.get() {
old.decrement_attached_counter(false);
old.decrement_attached_counter(Operation::Infallible);
}
slot.set(buffer);
@ -2839,9 +2845,9 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
.map_or(false, |b| buffer == &*b)
{
self.bound_buffer_array.set(None);
buffer.decrement_attached_counter(false);
buffer.decrement_attached_counter(Operation::Infallible);
}
buffer.mark_for_deletion(false);
buffer.mark_for_deletion(Operation::Infallible);
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
@ -2861,7 +2867,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
WebGLFramebufferBindingRequest::Default
))
);
framebuffer.delete(false)
framebuffer.delete(Operation::Infallible)
}
}
@ -2878,7 +2884,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
None
))
);
renderbuffer.delete(false)
renderbuffer.delete(Operation::Infallible)
}
}
@ -2913,7 +2919,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
));
}
texture.delete(false)
texture.delete(Operation::Infallible)
}
}
@ -2921,7 +2927,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
fn DeleteProgram(&self, program: Option<&WebGLProgram>) {
if let Some(program) = program {
handle_potential_webgl_error!(self, self.validate_ownership(program), return);
program.mark_for_deletion(false)
program.mark_for_deletion(Operation::Infallible)
}
}
@ -2929,7 +2935,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
fn DeleteShader(&self, shader: Option<&WebGLShader>) {
if let Some(shader) = shader {
handle_potential_webgl_error!(self, self.validate_ownership(shader), return);
shader.mark_for_deletion(false)
shader.mark_for_deletion(Operation::Infallible)
}
}