Skip to content

Commit 022f1d9

Browse files
committed
[web] Avoid deprecated web_sys functions.
1 parent 020d13e commit 022f1d9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tx2-web/rust/src/io/keyboard.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ impl HtmlCanvas2DPainter {
563563

564564
fn set_up_context_defaults(context: &CanvasRenderingContext2d) {
565565
context.set_line_cap("round");
566-
context.set_stroke_style(&("black".into()));
566+
context.set_stroke_style_str("black");
567567
}
568568

569569
fn fill_multiline_text(
@@ -646,7 +646,7 @@ impl HtmlCanvas2DPainter {
646646

647647
// This calculation for x assumes Left-to-Right text.
648648
let text_x: f64 = f64::from(x_midline) - metrics.actual_bounding_box_right() / 2.0;
649-
self.context.set_fill_style(&JsValue::from(colour));
649+
self.context.set_fill_style_str(colour);
650650
if let Err(e) = self.context.fill_text(s, text_x, text_y) {
651651
return Err(KeyPaintError::Failed(format!("fill_text failed: {e:?}")));
652652
}
@@ -673,8 +673,7 @@ impl KeyPainter for HtmlCanvas2DPainter {
673673
if self.hits_only {
674674
// We fill the background with a colour which never maps back
675675
// to a key code.
676-
self.context
677-
.set_fill_style(&JsValue::from(HIT_DETECTION_BACKGROUND));
676+
self.context.set_fill_style_str(HIT_DETECTION_BACKGROUND);
678677
self.context
679678
.fill_rect(0.0_f64, 0.0_f64, self.width().into(), self.height().into());
680679
}
@@ -691,7 +690,8 @@ impl KeyPainter for HtmlCanvas2DPainter {
691690
let hit_detection_colour: String = keycode.hit_detection_colour();
692691

693692
if self.hits_only {
694-
self.context.set_fill_style(&(&hit_detection_colour).into());
693+
self.context
694+
.set_fill_style_str(hit_detection_colour.as_str());
695695
self.context.fill_rect(
696696
keybox.left().into(),
697697
keybox.top().into(),
@@ -702,8 +702,8 @@ impl KeyPainter for HtmlCanvas2DPainter {
702702
return Ok(());
703703
}
704704

705-
self.context.set_fill_style(&colour.key_css_colour().into());
706-
self.context.set_stroke_style(&("black".into()));
705+
self.context.set_fill_style_str(colour.key_css_colour());
706+
self.context.set_stroke_style_str("black");
707707
let label_css_color = colour.label_css_colour();
708708

709709
self.draw_filled_stroked_rect(

0 commit comments

Comments
 (0)