aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlcanvaselement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/htmlcanvaselement.rs')
-rw-r--r--components/script/dom/htmlcanvaselement.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs
index 9c3c11d5dbc..e4fc68565a3 100644
--- a/components/script/dom/htmlcanvaselement.rs
+++ b/components/script/dom/htmlcanvaselement.rs
@@ -91,12 +91,22 @@ impl LayoutHTMLCanvasElementHelpers for LayoutJS<HTMLCanvasElement> {
pub trait HTMLCanvasElementHelpers {
fn get_size(&self) -> Size2D<i32>;
+ fn get_2d_context(self) -> Temporary<CanvasRenderingContext2D>;
+ fn is_valid(self) -> bool;
}
impl<'a> HTMLCanvasElementHelpers for JSRef<'a, HTMLCanvasElement> {
fn get_size(&self) -> Size2D<i32> {
Size2D(self.Width() as i32, self.Height() as i32)
}
+
+ fn get_2d_context(self) -> Temporary<CanvasRenderingContext2D> {
+ self.GetContext(String::from_str("2d")).unwrap()
+ }
+
+ fn is_valid(self) -> bool {
+ self.height.get() != 0 && self.width.get() != 0
+ }
}
impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {