Advertisement
Guest User

Untitled

a guest
Nov 9th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.25 KB | None | 0 0
  1.     pub fn new_inherited(height: u64, width: u64, placeholder: Option<&HTMLCanvasElement>) -> OffscreenCanvas {
  2.         OffscreenCanvas {
  3.             reflector_: Reflector::new(),
  4.             height: height,
  5.             width: width,
  6.             context: DomRefCell::new(None),
  7.             placeholder: placeholder,
  8.         }
  9.     }
  10.  
  11.     pub fn new(global: &GlobalScope, height: u64, width: u64, placeholder: Option<&HTMLCanvasElement>) -> DomRoot<OffscreenCanvas> {
  12.         reflect_dom_object(Box::OffscreenCanvas::new_inherited(), global, OffscreenCanvas::Bindings::Wrap)
  13.     }
  14.  
  15.     pub fn Constructor (global: &GlobalScope, height: u64, width: u64) -> Fallible<DomRoot<OffscreenCanvas>> {
  16.         //step 1
  17.         let offscreencanvas = OffscreenCanvas::new(global,height,width);
  18.         //step 2
  19.  
  20.         if(offscreencanvas.context.is_some()){
  21.             return Err(Error::InvalidState);
  22.         }
  23.  
  24.         //offscreencanvas.height = height;
  25.         //offscreencanvas.width = width;
  26.  
  27.         if(offscreencanvas.placeholder.is_null()) {
  28.             offscreencanvas.placeholder = ptr::null();
  29.         }
  30.         else {
  31.             //offscreencanvas.placeholder = &self.placeholder;
  32.         }
  33.  
  34.         //step 3
  35.         Ok(offscreencanvas);
  36.     }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement