Temporary implementation of Canvas.MeasureText

This commit is contained in:
Paul Rouget 2019-09-21 09:36:53 +02:00
parent 748fa72320
commit 3695fb1eb4
11 changed files with 207 additions and 125 deletions

View file

@ -23,6 +23,7 @@ use crate::dom::globalscope::GlobalScope;
use crate::dom::htmlcanvaselement::HTMLCanvasElement;
use crate::dom::imagedata::ImageData;
use crate::dom::offscreencanvas::OffscreenCanvas;
use crate::dom::textmetrics::TextMetrics;
use dom_struct::dom_struct;
use euclid::default::Size2D;
@ -244,6 +245,11 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
self.canvas_state.borrow().FillText(text, x, y, max_width)
}
// https://html.spec.whatwg.org/multipage/#textmetrics
fn MeasureText(&self, text: DOMString) -> DomRoot<TextMetrics> {
self.canvas_state.borrow().MeasureText(&self.global(), text)
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linewidth
fn LineWidth(&self) -> f64 {
self.canvas_state.borrow().LineWidth()