mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implementing canvas drawImage API for HTML Canvas elements as image source
This commit is contained in:
parent
2a9f29f382
commit
e3f5a76baa
44 changed files with 1567 additions and 118 deletions
|
@ -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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue