aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/paintrenderingcontext2d.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-09-19 17:47:27 -0400
committerGitHub <noreply@github.com>2018-09-19 17:47:27 -0400
commitdf2adebefdfa3da49f173e480fa1e56450f9bda2 (patch)
tree1f05b49bac02318455a59d5b143c186fd872bdb9 /components/script/dom/paintrenderingcontext2d.rs
parent2ca7a134736bb4759ff209c1bc0b6dc3cc1984c9 (diff)
parentc37a345dc9f4dda6ea29c42f96f6c7201c42cbac (diff)
downloadservo-df2adebefdfa3da49f173e480fa1e56450f9bda2.tar.gz
servo-df2adebefdfa3da49f173e480fa1e56450f9bda2.zip
Auto merge of #21737 - chansuke:format_script, r=jdm
Format script component --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix part of #21373. - [x] These changes do not require tests because they format code only. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21737) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/paintrenderingcontext2d.rs')
-rw-r--r--components/script/dom/paintrenderingcontext2d.rs89
1 files changed, 55 insertions, 34 deletions
diff --git a/components/script/dom/paintrenderingcontext2d.rs b/components/script/dom/paintrenderingcontext2d.rs
index 49bf0da6024..43124e30c76 100644
--- a/components/script/dom/paintrenderingcontext2d.rs
+++ b/components/script/dom/paintrenderingcontext2d.rs
@@ -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)
}
-
}