mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Format script component
This commit is contained in:
parent
2ca7a13473
commit
c37a345dc9
357 changed files with 25485 additions and 18076 deletions
|
@ -47,19 +47,30 @@ impl PaintRenderingContext2D {
|
|||
let image_cache = global.image_cache();
|
||||
let base_url = global.upcast::<WorkletGlobalScope>().base_url();
|
||||
PaintRenderingContext2D {
|
||||
context: CanvasRenderingContext2D::new_inherited(global.upcast(), None, image_cache, base_url, size),
|
||||
context: CanvasRenderingContext2D::new_inherited(
|
||||
global.upcast(),
|
||||
None,
|
||||
image_cache,
|
||||
base_url,
|
||||
size,
|
||||
),
|
||||
device_pixel_ratio: Cell::new(TypedScale::new(1.0)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: &PaintWorkletGlobalScope) -> DomRoot<PaintRenderingContext2D> {
|
||||
reflect_dom_object(Box::new(PaintRenderingContext2D::new_inherited(global)),
|
||||
global,
|
||||
PaintRenderingContext2DBinding::Wrap)
|
||||
reflect_dom_object(
|
||||
Box::new(PaintRenderingContext2D::new_inherited(global)),
|
||||
global,
|
||||
PaintRenderingContext2DBinding::Wrap,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn send_data(&self, sender: IpcSender<CanvasImageData>) {
|
||||
let msg = CanvasMsg::FromLayout(FromLayoutMsg::SendData(sender), self.context.get_canvas_id());
|
||||
let msg = CanvasMsg::FromLayout(
|
||||
FromLayoutMsg::SendData(sender),
|
||||
self.context.get_canvas_id(),
|
||||
);
|
||||
let _ = self.context.get_ipc_renderer().send(msg);
|
||||
}
|
||||
|
||||
|
@ -67,13 +78,15 @@ impl PaintRenderingContext2D {
|
|||
self.context.take_missing_image_urls()
|
||||
}
|
||||
|
||||
pub fn set_bitmap_dimensions(&self,
|
||||
size: TypedSize2D<f32, CSSPixel>,
|
||||
device_pixel_ratio: TypedScale<f32, CSSPixel, DevicePixel>)
|
||||
{
|
||||
pub fn set_bitmap_dimensions(
|
||||
&self,
|
||||
size: TypedSize2D<f32, CSSPixel>,
|
||||
device_pixel_ratio: TypedScale<f32, CSSPixel, DevicePixel>,
|
||||
) {
|
||||
let size = size * device_pixel_ratio;
|
||||
self.device_pixel_ratio.set(device_pixel_ratio);
|
||||
self.context.set_bitmap_dimensions(size.to_untyped().to_i32());
|
||||
self.context
|
||||
.set_bitmap_dimensions(size.to_untyped().to_i32());
|
||||
self.scale_by_device_pixel_ratio();
|
||||
}
|
||||
|
||||
|
@ -194,12 +207,7 @@ impl PaintRenderingContext2DMethods for PaintRenderingContext2D {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
|
||||
fn DrawImage(
|
||||
&self,
|
||||
image: CanvasImageSource,
|
||||
dx: f64,
|
||||
dy: f64,
|
||||
) -> ErrorResult {
|
||||
fn DrawImage(&self, image: CanvasImageSource, dx: f64, dy: f64) -> ErrorResult {
|
||||
self.context.DrawImage(image, dx, dy)
|
||||
}
|
||||
|
||||
|
@ -228,7 +236,8 @@ impl PaintRenderingContext2DMethods for PaintRenderingContext2D {
|
|||
dw: f64,
|
||||
dh: f64,
|
||||
) -> ErrorResult {
|
||||
self.context.DrawImage__(image, sx, sy, sw, sh, dx, dy, dw, dh)
|
||||
self.context
|
||||
.DrawImage__(image, sx, sy, sw, sh, dx, dy, dw, dh)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-moveto
|
||||
|
@ -267,8 +276,19 @@ impl PaintRenderingContext2DMethods for PaintRenderingContext2D {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-ellipse
|
||||
fn Ellipse(&self, x: f64, y: f64, rx: f64, ry: f64, rotation: f64, start: f64, end: f64, ccw: bool) -> ErrorResult {
|
||||
self.context.Ellipse(x, y, rx, ry, rotation, start, end, ccw)
|
||||
fn Ellipse(
|
||||
&self,
|
||||
x: f64,
|
||||
y: f64,
|
||||
rx: f64,
|
||||
ry: f64,
|
||||
rotation: f64,
|
||||
start: f64,
|
||||
end: f64,
|
||||
ccw: bool,
|
||||
) -> ErrorResult {
|
||||
self.context
|
||||
.Ellipse(x, y, rx, ry, rotation, start, end, ccw)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-imagesmoothingenabled
|
||||
|
@ -302,24 +322,26 @@ impl PaintRenderingContext2DMethods for PaintRenderingContext2D {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createlineargradient
|
||||
fn CreateLinearGradient(&self,
|
||||
x0: Finite<f64>,
|
||||
y0: Finite<f64>,
|
||||
x1: Finite<f64>,
|
||||
y1: Finite<f64>)
|
||||
-> DomRoot<CanvasGradient> {
|
||||
fn CreateLinearGradient(
|
||||
&self,
|
||||
x0: Finite<f64>,
|
||||
y0: Finite<f64>,
|
||||
x1: Finite<f64>,
|
||||
y1: Finite<f64>,
|
||||
) -> DomRoot<CanvasGradient> {
|
||||
self.context.CreateLinearGradient(x0, y0, x1, y1)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createradialgradient
|
||||
fn CreateRadialGradient(&self,
|
||||
x0: Finite<f64>,
|
||||
y0: Finite<f64>,
|
||||
r0: Finite<f64>,
|
||||
x1: Finite<f64>,
|
||||
y1: Finite<f64>,
|
||||
r1: Finite<f64>)
|
||||
-> Fallible<DomRoot<CanvasGradient>> {
|
||||
fn CreateRadialGradient(
|
||||
&self,
|
||||
x0: Finite<f64>,
|
||||
y0: Finite<f64>,
|
||||
r0: Finite<f64>,
|
||||
x1: Finite<f64>,
|
||||
y1: Finite<f64>,
|
||||
r1: Finite<f64>,
|
||||
) -> Fallible<DomRoot<CanvasGradient>> {
|
||||
self.context.CreateRadialGradient(x0, y0, r0, x1, y1, r1)
|
||||
}
|
||||
|
||||
|
@ -411,5 +433,4 @@ impl PaintRenderingContext2DMethods for PaintRenderingContext2D {
|
|||
fn SetShadowColor(&self, value: DOMString) {
|
||||
self.context.SetShadowColor(value)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue