mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
Created CanvasRect fro OffscreenCanvas and Updated Testcases
This commit is contained in:
parent
85ed1812ee
commit
6c6fb676b7
188 changed files with 496 additions and 34 deletions
|
@ -2,10 +2,12 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::OffscreenCanvasRenderingContext2DBinding;
|
||||
use crate::dom::bindings::codegen::Bindings::OffscreenCanvasRenderingContext2DBinding::OffscreenCanvasRenderingContext2DMethods;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::canvasrenderingcontext2d::CanvasState;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::offscreencanvas::OffscreenCanvas;
|
||||
use dom_struct::dom_struct;
|
||||
|
@ -15,6 +17,7 @@ use euclid::Size2D;
|
|||
pub struct OffscreenCanvasRenderingContext2D {
|
||||
reflector_: Reflector,
|
||||
canvas: Option<Dom<OffscreenCanvas>>,
|
||||
canvas_state: DomRefCell<CanvasState>,
|
||||
}
|
||||
|
||||
impl OffscreenCanvasRenderingContext2D {
|
||||
|
@ -26,6 +29,7 @@ impl OffscreenCanvasRenderingContext2D {
|
|||
OffscreenCanvasRenderingContext2D {
|
||||
reflector_: Reflector::new(),
|
||||
canvas: canvas.map(Dom::from_ref),
|
||||
canvas_state: DomRefCell::new(CanvasState::new(_global)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,4 +56,22 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
|||
fn Canvas(&self) -> DomRoot<OffscreenCanvas> {
|
||||
DomRoot::from_ref(self.canvas.as_ref().expect("No canvas."))
|
||||
}
|
||||
|
||||
// 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