Skip to content
Permalink
Browse files
fixed build issues related to DomRefCell and Cell type. Build passes …
…successfully for HtmlCanvas and OffScreenCanvas.
  • Loading branch information
ramyananth committed Apr 24, 2020
1 parent 9c3cbbe commit 6ff3333e78cfc41228b3b797511d5e9f94cc1d42
Showing 3 changed files with 25 additions and 40 deletions.
@@ -25,30 +25,31 @@ pub struct ImageBitmap {
}

impl ImageBitmap {
fn new_inherited(width_arg: u32, height_arg: u32, origin_clean_arg: Cell<bool>) -> ImageBitmap {
fn new_inherited(width_arg: u32, height_arg: u32) -> ImageBitmap {
ImageBitmap {
reflector_: Reflector::new(),
width: width_arg,
height: height_arg,
bitmap_data: DomRefCell::new(vec![]),
origin_clean: origin_clean_arg
origin_clean: Cell::new(true)
//origin_clean: origin_clean_arg
}
}

#[allow(dead_code)]
pub fn new(global: &GlobalScope, width: u32, height: u32, origin_clean: Cell<bool>) -> Fallible<DomRoot<ImageBitmap>> {
pub fn new(global: &GlobalScope, width: u32, height: u32) -> Fallible<DomRoot<ImageBitmap>> {
//assigning to a variable the return object of new_inherited
let imagebitmap = Box::new(ImageBitmap::new_inherited(width, height, origin_clean));
let imagebitmap = Box::new(ImageBitmap::new_inherited(width, height));

Ok(reflect_dom_object(imagebitmap, global))
}

pub fn set_bitmap_data(&mut self, data: DomRefCell<Vec<u8>>) {
self.bitmap_data = data;
pub fn set_bitmap_data(&self, data: DomRefCell<Vec<u8>>) {
*self.bitmap_data.borrow_mut() = data.borrow_mut().to_vec();
}

pub fn set_origin_clean(&mut self, origin_is_clean: Cell<bool>) {
self.origin_clean = origin_is_clean;
pub fn set_origin_clean(&self, origin_is_clean: bool) {
self.origin_clean.set(origin_is_clean);
}
}

@@ -904,13 +904,8 @@ impl WindowMethods for Window {
p.reject_error(Error::InvalidState)
}

let imageBitmap = ImageBitmap::new(&global,0,0,Cell::new(true)).unwrap();
// global: &global,
// width: 0,
// height: 0,
// origin_clean: Cell::new(true),
// );

let image_bitmap = ImageBitmap::new(&global,0,0).unwrap();

let promise = match image {
ImageBitmapSource::HTMLCanvasElement(ref canvas) => {
// https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument
@@ -923,10 +918,9 @@ impl WindowMethods for Window {
.map(|data| data.to_vec())
.unwrap_or_else(|| vec![0; size.area() as usize * 4]));

let origin_is_clean = Cell::new(canvas.origin_is_clean());
imageBitmap.set_bitmap_data(data);
imageBitmap.set_origin_clean(origin_is_clean);
p.resolve_native(&(imageBitmap));
image_bitmap.set_bitmap_data(data);
image_bitmap.set_origin_clean(canvas.origin_is_clean());
p.resolve_native(&(image_bitmap));
}
p
}
@@ -941,10 +935,9 @@ impl WindowMethods for Window {
.map(|data| data.to_vec())
.unwrap_or_else(|| vec![0; size.area() as usize * 4]));

let origin_is_clean = Cell::new(canvas.origin_is_clean());
imageBitmap.set_bitmap_data(data);
imageBitmap.set_origin_clean(origin_is_clean);
p.resolve_native(&(imageBitmap));
image_bitmap.set_bitmap_data(data);
image_bitmap.set_origin_clean(canvas.origin_is_clean());
p.resolve_native(&(image_bitmap));
}
p
}
@@ -60,7 +60,6 @@ use time::precise_time_ns;
use uuid::Uuid;
use crate::dom::bindings::codegen::Bindings::ImageBitmapBinding::{ImageBitmapSource, ImageBitmapOptions};
use crate::dom::imagebitmap::ImageBitmap;
use std::cell::Cell;

pub fn prepare_workerscope_init(
global: &GlobalScope,
@@ -392,13 +391,8 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
p.reject_error(Error::InvalidState)
}

let imageBitmap = ImageBitmap::new(&global,0,0,Cell::new(true)).unwrap();
// global: &global,
// width: 0,
// height: 0,
// origin_clean: Cell::new(true),
// );

let image_bitmap = ImageBitmap::new(&global,0,0).unwrap();

let promise = match image {
ImageBitmapSource::HTMLCanvasElement(ref canvas) => {
// https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument
@@ -411,10 +405,9 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
.map(|data| data.to_vec())
.unwrap_or_else(|| vec![0; size.area() as usize * 4]));

let origin_is_clean = Cell::new(canvas.origin_is_clean());
imageBitmap.set_bitmap_data(data);
imageBitmap.set_origin_clean(origin_is_clean);
p.resolve_native(&(imageBitmap));
image_bitmap.set_bitmap_data(data);
image_bitmap.set_origin_clean(canvas.origin_is_clean());
p.resolve_native(&(image_bitmap));
}
p
}
@@ -429,10 +422,9 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
.map(|data| data.to_vec())
.unwrap_or_else(|| vec![0; size.area() as usize * 4]));

let origin_is_clean = Cell::new(canvas.origin_is_clean());
imageBitmap.set_bitmap_data(data);
imageBitmap.set_origin_clean(origin_is_clean);
p.resolve_native(&(imageBitmap));
image_bitmap.set_bitmap_data(data);
image_bitmap.set_origin_clean(canvas.origin_is_clean());
p.resolve_native(&(image_bitmap));
}
p
}
@@ -442,7 +434,6 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
};
promise
}

}

impl WorkerGlobalScope {

0 comments on commit 6ff3333

Please sign in to comment.