mirror of
https://github.com/servo/servo.git
synced 2025-07-21 22:33:41 +01:00
Enable textAlign, textBaseline and direction attributes for canvas
This commit is contained in:
parent
c21fde3751
commit
34d0c313dc
15 changed files with 486 additions and 64 deletions
|
@ -3,10 +3,13 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::canvas_state::CanvasState;
|
||||
use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasDirection;
|
||||
use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasFillRule;
|
||||
use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasImageSource;
|
||||
use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineCap;
|
||||
use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineJoin;
|
||||
use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasTextAlign;
|
||||
use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasTextBaseline;
|
||||
use crate::dom::bindings::codegen::Bindings::OffscreenCanvasRenderingContext2DBinding::OffscreenCanvasRenderingContext2DMethods;
|
||||
use crate::dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern;
|
||||
use crate::dom::bindings::error::ErrorResult;
|
||||
|
@ -269,6 +272,36 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
|||
.set_font(self.htmlcanvas.as_ref().map(|c| &**c), value)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-textalign
|
||||
fn TextAlign(&self) -> CanvasTextAlign {
|
||||
self.canvas_state.text_align()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-textalign
|
||||
fn SetTextAlign(&self, value: CanvasTextAlign) {
|
||||
self.canvas_state.set_text_align(value)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-textbaseline
|
||||
fn TextBaseline(&self) -> CanvasTextBaseline {
|
||||
self.canvas_state.text_baseline()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-textbaseline
|
||||
fn SetTextBaseline(&self, value: CanvasTextBaseline) {
|
||||
self.canvas_state.set_text_baseline(value)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-direction
|
||||
fn Direction(&self) -> CanvasDirection {
|
||||
self.canvas_state.direction()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-direction
|
||||
fn SetDirection(&self, value: CanvasDirection) {
|
||||
self.canvas_state.set_direction(value)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linewidth
|
||||
fn LineWidth(&self) -> f64 {
|
||||
self.canvas_state.line_width()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue