mirror of
https://github.com/servo/servo.git
synced 2025-06-12 02:14:41 +00:00
canvas: Implement line dash setters and getters (#36257)
Implement `setLineDash`, `getLineDash`, and `lineDashOffset` from `CanvasPathDrawingStyles` mixin, according to the spec https://html.spec.whatwg.org/multipage/canvas.html#canvaspathdrawingstyles. Testing: Existing WPT. --------- Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
This commit is contained in:
parent
bc6926d1fe
commit
a77592e281
21 changed files with 144 additions and 92 deletions
|
@ -642,6 +642,26 @@ impl CanvasRenderingContext2DMethods<crate::DomTypeHolder> for CanvasRenderingCo
|
|||
self.canvas_state.set_miter_limit(limit)
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-setlinedash>
|
||||
fn SetLineDash(&self, segments: Vec<f64>) {
|
||||
self.canvas_state.set_line_dash(segments);
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-getlinedash>
|
||||
fn GetLineDash(&self) -> Vec<f64> {
|
||||
self.canvas_state.line_dash()
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-linedashoffset>
|
||||
fn LineDashOffset(&self) -> f64 {
|
||||
self.canvas_state.line_dash_offset()
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-linedashoffset>
|
||||
fn SetLineDashOffset(&self, offset: f64) {
|
||||
self.canvas_state.set_line_dash_offset(offset);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsetx
|
||||
fn ShadowOffsetX(&self) -> f64 {
|
||||
self.canvas_state.shadow_offset_x()
|
||||
|
|
|
@ -340,6 +340,26 @@ impl OffscreenCanvasRenderingContext2DMethods<crate::DomTypeHolder>
|
|||
self.context.SetMiterLimit(limit)
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-setlinedash>
|
||||
fn SetLineDash(&self, segments: Vec<f64>) {
|
||||
self.context.SetLineDash(segments)
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-getlinedash>
|
||||
fn GetLineDash(&self) -> Vec<f64> {
|
||||
self.context.GetLineDash()
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-linedashoffset>
|
||||
fn LineDashOffset(&self) -> f64 {
|
||||
self.context.LineDashOffset()
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-linedashoffset>
|
||||
fn SetLineDashOffset(&self, offset: f64) {
|
||||
self.context.SetLineDashOffset(offset)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
||||
fn CreateImageData(&self, sw: i32, sh: i32, can_gc: CanGc) -> Fallible<DomRoot<ImageData>> {
|
||||
self.context.CreateImageData(sw, sh, can_gc)
|
||||
|
|
|
@ -430,6 +430,26 @@ impl PaintRenderingContext2DMethods<crate::DomTypeHolder> for PaintRenderingCont
|
|||
self.canvas_state.set_miter_limit(limit)
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-setlinedash>
|
||||
fn SetLineDash(&self, segments: Vec<f64>) {
|
||||
self.canvas_state.set_line_dash(segments);
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-getlinedash>
|
||||
fn GetLineDash(&self) -> Vec<f64> {
|
||||
self.canvas_state.line_dash()
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-linedashoffset>
|
||||
fn LineDashOffset(&self) -> f64 {
|
||||
self.canvas_state.line_dash_offset()
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-linedashoffset>
|
||||
fn SetLineDashOffset(&self, offset: f64) {
|
||||
self.canvas_state.set_line_dash_offset(offset);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsetx
|
||||
fn ShadowOffsetX(&self) -> f64 {
|
||||
self.canvas_state.shadow_offset_x()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue