aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/offscreencanvasrenderingcontext2d.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/offscreencanvasrenderingcontext2d.rs')
-rw-r--r--components/script/dom/offscreencanvasrenderingcontext2d.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/components/script/dom/offscreencanvasrenderingcontext2d.rs b/components/script/dom/offscreencanvasrenderingcontext2d.rs
index a02d2d4a85b..bf1e8058f3e 100644
--- a/components/script/dom/offscreencanvasrenderingcontext2d.rs
+++ b/components/script/dom/offscreencanvasrenderingcontext2d.rs
@@ -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();
+ }
}