diff options
author | David Zbarsky <dzbarsky@gmail.com> | 2015-11-28 20:03:17 -0800 |
---|---|---|
committer | David Zbarsky <dzbarsky@gmail.com> | 2015-12-05 17:49:49 -0800 |
commit | 789a90a82f7d0c89bf2b1065acbf218626a66a41 (patch) | |
tree | 321fbc8845716b9a9c037a49da66197a16866be0 /components/script/dom | |
parent | 2af23dc06151475b053bd76976fd9da899f27b8b (diff) | |
download | servo-789a90a82f7d0c89bf2b1065acbf218626a66a41.tar.gz servo-789a90a82f7d0c89bf2b1065acbf218626a66a41.zip |
Implement IsPointInPath
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/canvasrenderingcontext2d.rs | 15 | ||||
-rw-r--r-- | components/script/dom/webidls/CanvasRenderingContext2D.webidl | 9 |
2 files changed, 18 insertions, 6 deletions
diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 5fed20daae7..119f819cf8e 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -5,7 +5,7 @@ use canvas::canvas_paint_task::RectToi32; use canvas_traits::{Canvas2dMsg, CanvasCommonMsg, CanvasMsg}; use canvas_traits::{CompositionOrBlending, LineCapStyle, LineJoinStyle}; -use canvas_traits::{FillOrStrokeStyle, LinearGradientStyle, RadialGradientStyle, RepetitionStyle}; +use canvas_traits::{FillOrStrokeStyle, FillRule, LinearGradientStyle, RadialGradientStyle, RepetitionStyle}; use cssparser::Color as CSSColor; use cssparser::{Parser, RGBA}; use dom::bindings::cell::DOMRefCell; @@ -695,6 +695,19 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D { self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::Clip)).unwrap(); } + // https://html.spec.whatwg.org/multipage/#dom-context-2d-ispointinpath + fn IsPointInPath(&self, x: f64, y: f64, fill_rule: CanvasFillRule) -> bool { + let fill_rule = match fill_rule { + CanvasFillRule::Nonzero => FillRule::Nonzero, + CanvasFillRule::Evenodd => FillRule::Evenodd, + }; + let (sender, receiver) = ipc::channel::<bool>().unwrap(); + self.ipc_renderer + .send(CanvasMsg::Canvas2d(Canvas2dMsg::IsPointInPath(x, y, fill_rule, sender))) + .unwrap(); + receiver.recv().unwrap() + } + // https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage fn DrawImage(&self, image: HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D, diff --git a/components/script/dom/webidls/CanvasRenderingContext2D.webidl b/components/script/dom/webidls/CanvasRenderingContext2D.webidl index 1fa82ba0e1a..a0e7614a1a2 100644 --- a/components/script/dom/webidls/CanvasRenderingContext2D.webidl +++ b/components/script/dom/webidls/CanvasRenderingContext2D.webidl @@ -94,13 +94,12 @@ interface CanvasRenderingContext2D { void clip(optional CanvasFillRule fillRule = "nonzero"); //void clip(Path2D path, optional CanvasFillRule fillRule = "nonzero"); //void resetClip(); - //boolean isPointInPath(unrestricted double x, unrestricted double y, + boolean isPointInPath(unrestricted double x, unrestricted double y, + optional CanvasFillRule fillRule = "nonzero"); + //boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y, // optional CanvasFillRule fillRule = "nonzero"); - //boolean isPointInPath(Path2D path, unrestricted double x, unrestricted - // double y, optional CanvasFillRule fillRule = "nonzero"); //boolean isPointInStroke(unrestricted double x, unrestricted double y); - // boolean isPointInStroke(Path2D path, unrestricted double x, - // unrestricted double y); + //boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y); // text (see also the CanvasDrawingStyles interface) //void fillText(DOMString text, unrestricted double x, unrestricted double y, |