mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
removed comments
This commit is contained in:
parent
854ba8d514
commit
cbff66928f
2 changed files with 9 additions and 56 deletions
|
@ -62,8 +62,6 @@ enum CanvasFillOrStrokeStyle {
|
|||
#[dom_struct]
|
||||
pub struct CanvasRenderingContext2D {
|
||||
reflector_: Reflector,
|
||||
//#[ignore_malloc_size_of = "Defined in ipc-channel"]
|
||||
//ipc_renderer: IpcSender<CanvasMsg>,
|
||||
/// For rendering contexts created by an HTML canvas element, this is Some,
|
||||
/// for ones created by a paint worklet, this is None.
|
||||
canvas: Option<Dom<HTMLCanvasElement>>,
|
||||
|
@ -77,7 +75,6 @@ pub struct CanvasRenderingContext2D {
|
|||
state: DomRefCell<CanvasContextState>,
|
||||
saved_states: DomRefCell<Vec<CanvasContextState>>,
|
||||
origin_clean: Cell<bool>,
|
||||
//canvas_id: CanvasId,
|
||||
canvas_state: DomRefCell<CanvasState>,
|
||||
}
|
||||
|
||||
|
@ -122,10 +119,8 @@ impl CanvasContextState {
|
|||
}
|
||||
}
|
||||
|
||||
#[must_root]
|
||||
#[derive(Clone, JSTraceable, MallocSizeOf)]
|
||||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
pub struct CanvasState {
|
||||
//reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "Defined in ipc-channel"]
|
||||
ipc_renderer: IpcSender<CanvasMsg>,
|
||||
canvas_id: CanvasId,
|
||||
|
@ -148,18 +143,6 @@ impl CanvasState {
|
|||
canvas_id: canvas_id,
|
||||
}
|
||||
}
|
||||
/*pub fn new(
|
||||
global: &GlobalScope,
|
||||
size: Size2D<u32>,
|
||||
) -> CanvasState {
|
||||
|
||||
/*let boxed = Box::new(CanvasState::new_inherited(
|
||||
global,
|
||||
size,
|
||||
));
|
||||
|
||||
reflect_dom_object(boxed, global, CanvasState)*/
|
||||
}*/
|
||||
|
||||
pub fn get_canvas_id(&self) -> CanvasId {
|
||||
self.canvas_id.clone()
|
||||
|
@ -216,27 +199,15 @@ impl CanvasRenderingContext2D {
|
|||
base_url: ServoUrl,
|
||||
size: Size2D<u32>,
|
||||
) -> CanvasRenderingContext2D {
|
||||
/*debug!("Creating new canvas rendering context.");
|
||||
let (sender, receiver) =
|
||||
profiled_ipc::channel(global.time_profiler_chan().clone()).unwrap();
|
||||
let script_to_constellation_chan = global.script_to_constellation_chan();
|
||||
debug!("Asking constellation to create new canvas thread.");
|
||||
script_to_constellation_chan
|
||||
.send(ScriptMsg::CreateCanvasPaintThread(size, sender))
|
||||
.unwrap();
|
||||
//let (canvas_state.ipc_renderer, canvas_id) = receiver.recv().unwrap();
|
||||
debug!("Done.");*/
|
||||
CanvasRenderingContext2D {
|
||||
reflector_: Reflector::new(),
|
||||
canvas: canvas.map(Dom::from_ref),
|
||||
//ipc_renderer: ipc_renderer,
|
||||
image_cache: image_cache,
|
||||
missing_image_urls: DomRefCell::new(Vec::new()),
|
||||
base_url: base_url,
|
||||
state: DomRefCell::new(CanvasContextState::new()),
|
||||
saved_states: DomRefCell::new(Vec::new()),
|
||||
origin_clean: Cell::new(true),
|
||||
//canvas_id: canvas_id,
|
||||
canvas_state: DomRefCell::new(CanvasState::new(
|
||||
global,
|
||||
Size2D::new(size.width as u64, size.height as u64),
|
||||
|
@ -571,21 +542,6 @@ impl CanvasRenderingContext2D {
|
|||
mem::replace(&mut self.missing_image_urls.borrow_mut(), vec![])
|
||||
}
|
||||
|
||||
/*fn create_drawable_rect(&self, x: f64, y: f64, w: f64, h: f64) -> Option<Rect<f32>> {
|
||||
if !([x, y, w, h].iter().all(|val| val.is_finite())) {
|
||||
return None;
|
||||
}
|
||||
|
||||
if w == 0.0 && h == 0.0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(Rect::new(
|
||||
Point2D::new(x as f32, y as f32),
|
||||
Size2D::new(w as f32, h as f32),
|
||||
))
|
||||
}*/
|
||||
|
||||
fn parse_color(&self, string: &str) -> Result<RGBA, ()> {
|
||||
let mut input = ParserInput::new(string);
|
||||
let mut parser = Parser::new(&mut input);
|
||||
|
|
|
@ -22,30 +22,30 @@ pub struct OffscreenCanvasRenderingContext2D {
|
|||
|
||||
impl OffscreenCanvasRenderingContext2D {
|
||||
pub fn new_inherited(
|
||||
_global: &GlobalScope,
|
||||
global: &GlobalScope,
|
||||
canvas: Option<&OffscreenCanvas>,
|
||||
_size: Size2D<u64>,
|
||||
size: Size2D<u64>,
|
||||
) -> OffscreenCanvasRenderingContext2D {
|
||||
OffscreenCanvasRenderingContext2D {
|
||||
reflector_: Reflector::new(),
|
||||
canvas: canvas.map(Dom::from_ref),
|
||||
canvas_state: DomRefCell::new(CanvasState::new(_global, _size)),
|
||||
canvas_state: DomRefCell::new(CanvasState::new(global, size)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(
|
||||
_global: &GlobalScope,
|
||||
global: &GlobalScope,
|
||||
canvas: &OffscreenCanvas,
|
||||
_size: Size2D<u64>,
|
||||
size: Size2D<u64>,
|
||||
) -> DomRoot<OffscreenCanvasRenderingContext2D> {
|
||||
let boxed = Box::new(OffscreenCanvasRenderingContext2D::new_inherited(
|
||||
_global,
|
||||
global,
|
||||
Some(canvas),
|
||||
_size,
|
||||
size,
|
||||
));
|
||||
reflect_dom_object(
|
||||
boxed,
|
||||
_global,
|
||||
global,
|
||||
OffscreenCanvasRenderingContext2DBinding::Wrap,
|
||||
)
|
||||
}
|
||||
|
@ -60,18 +60,15 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
|||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-fillrect
|
||||
fn FillRect(&self, x: f64, y: f64, width: f64, height: f64) {
|
||||
self.canvas_state.borrow().FillRect(x, y, width, height);
|
||||
//self.mark_as_dirty();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-clearrect
|
||||
fn ClearRect(&self, x: f64, y: f64, width: f64, height: f64) {
|
||||
self.canvas_state.borrow().ClearRect(x, y, width, height);
|
||||
//self.mark_as_dirty();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokerect
|
||||
fn StrokeRect(&self, x: f64, y: f64, width: f64, height: f64) {
|
||||
self.canvas_state.borrow().StrokeRect(x, y, width, height);
|
||||
//self.mark_as_dirty();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue