Update GPUObjectBase webidl and cleanup valid flags

This commit is contained in:
Kunal Mohan 2020-07-20 20:10:41 +05:30
parent 3216209506
commit cdc0a75fe4
20 changed files with 229 additions and 251 deletions

View file

@ -6,28 +6,25 @@ use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GPUBindGroupBinding::GPUBindGroupMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::bindings::str::DOMString;
use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::gpubindgrouplayout::GPUBindGroupLayout;
use dom_struct::dom_struct;
use std::cell::Cell;
use webgpu::{WebGPUBindGroup, WebGPUDevice};
#[dom_struct]
pub struct GPUBindGroup {
reflector_: Reflector,
label: DomRefCell<Option<DOMString>>,
label: DomRefCell<Option<USVString>>,
bind_group: WebGPUBindGroup,
device: WebGPUDevice,
layout: Dom<GPUBindGroupLayout>,
valid: Cell<bool>,
}
impl GPUBindGroup {
fn new_inherited(
bind_group: WebGPUBindGroup,
device: WebGPUDevice,
valid: bool,
layout: &GPUBindGroupLayout,
) -> Self {
Self {
@ -35,7 +32,6 @@ impl GPUBindGroup {
label: DomRefCell::new(None),
bind_group,
device,
valid: Cell::new(valid),
layout: Dom::from_ref(layout),
}
}
@ -44,13 +40,10 @@ impl GPUBindGroup {
global: &GlobalScope,
bind_group: WebGPUBindGroup,
device: WebGPUDevice,
valid: bool,
layout: &GPUBindGroupLayout,
) -> DomRoot<Self> {
reflect_dom_object(
Box::new(GPUBindGroup::new_inherited(
bind_group, device, valid, layout,
)),
Box::new(GPUBindGroup::new_inherited(bind_group, device, layout)),
global,
)
}
@ -64,12 +57,12 @@ impl GPUBindGroup {
impl GPUBindGroupMethods for GPUBindGroup {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
fn GetLabel(&self) -> Option<DOMString> {
fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
fn SetLabel(&self, value: Option<DOMString>) {
fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
}