script/dom/webgl/
webglobject.rs1use dom_struct::dom_struct;
7
8use crate::dom::bindings::cell::DomRefCell;
9use crate::dom::bindings::codegen::Bindings::WebGLObjectBinding::WebGLObjectMethods;
10use crate::dom::bindings::reflector::Reflector;
11use crate::dom::bindings::root::Dom;
12use crate::dom::bindings::str::USVString;
13use crate::dom::webgl::webglrenderingcontext::WebGLRenderingContext;
14
15#[dom_struct]
16pub(crate) struct WebGLObject {
17 reflector_: Reflector,
18 context: Dom<WebGLRenderingContext>,
19 label: DomRefCell<USVString>,
20}
21
22impl WebGLObject {
23 pub(crate) fn new_inherited(context: &WebGLRenderingContext) -> WebGLObject {
24 WebGLObject {
25 reflector_: Reflector::new(),
26 context: Dom::from_ref(context),
27 label: DomRefCell::new(USVString::default()),
28 }
29 }
30
31 pub(crate) fn context(&self) -> &WebGLRenderingContext {
32 &self.context
33 }
34}
35
36impl WebGLObjectMethods<crate::DomTypeHolder> for WebGLObject {
37 fn Label(&self) -> USVString {
39 self.label.borrow().clone()
40 }
41
42 fn SetLabel(&self, value: USVString) {
44 *self.label.borrow_mut() = value;
45 }
46}