Skip to content

Truly independent web browser

LibWeb: Honor text direction and alignment in canvas text and metrics

Andreas Kling4ee8852cbd01
diff --git a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/canvas.rs b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/canvas.rs
index 03b59040189..c28eb774d17 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/canvas.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/canvas.rs
@@ -34,6 +34,7 @@ unsafe extern "C" {
fn web_canvas_2d_canvas_wrapper(canvas: *mut c_void, canvas_is_offscreen: bool, realm: *mut c_void) -> *mut c_void;
fn web_canvas_2d_canvas_relevant_realm(canvas_host: *mut c_void) -> *mut c_void;
fn web_canvas_2d_canvas_font_environment_generation(canvas_host: *mut c_void) -> u64;
+ fn web_canvas_2d_canvas_directionality_is_rtl(canvas: *mut c_void, canvas_is_offscreen: bool) -> bool;
fn web_canvas_2d_canvas_resolve_font(
canvas: *mut c_void,
canvas_is_offscreen: bool,
@@ -295,6 +296,11 @@ impl Canvas {
unsafe { web_canvas_2d_canvas_font_environment_generation(self.host.as_ptr()) }
}
+ /// Whether the directionality of a canvas element, or the inherited direction of an OffscreenCanvas, is 'rtl'.
+ pub(crate) fn directionality_is_rtl(self) -> bool {
+ unsafe { web_canvas_2d_canvas_directionality_is_rtl(self.cell.as_ptr(), self.is_offscreen) }
+ }
+
/// The font that a value of the font attribute describes, resolved against the canvas, unless the value is not a
/// CSS font.
pub(crate) fn resolve_font(self, font: &Utf16String, font_selection: FontSelection) -> Option<ResolvedFont> {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/context.rs b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/context.rs
index 4433823206b..b838f5b614d 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/context.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/context.rs
@@ -24,6 +24,7 @@ use super::canvas::{Canvas, FontMetricsSource, FontSelection, ResolvedFont, Styl
use super::drawing_state::{CanvasColor, DrawingState, FillOrStrokeStyle};
use super::host::{Bitmap, CppTransport, LentImageFrame};
use crate::bindings::interface::Wrappable;
+use crate::html::canvas_rendering_context2d::CanvasDirection;
use crate::html::canvas_rendering_context2d_settings::CanvasRenderingContext2DSettings;
use crate::html::predefined_color_space::PredefinedColorSpace;
@@ -632,6 +633,24 @@ impl ContextState {
}
}
+ /// Whether the direction of text is 'rtl', as step 7 of the text preparation algorithm determines it,
+ /// https://html.spec.whatwg.org/multipage/canvas.html#text-preparation-algorithm
+ pub(crate) fn direction_is_rtl(&self) -> bool {
+ match self.drawing_state().direction {
+ // If the target object's direction attribute has the value "ltr": Let direction be 'ltr'.
+ CanvasDirection::Ltr => false,
+ // If the target object's direction attribute has the value "rtl": Let direction be 'rtl'.
+ CanvasDirection::Rtl => true,
+ // If the target object's direction attribute has the value "inherit":
+ // 1. Let sourceObject be object's font style source object.
+ // 2. If sourceObject is a canvas element, then let direction be sourceObject's directionality.
+ // 3. Otherwise:
+ // 1. Assert: sourceObject is an OffscreenCanvas object.
+ // 2. Let direction be sourceObject's inherited direction.
+ CanvasDirection::Inherit => self.canvas.directionality_is_rtl(),
+ }
+ }
+
/// Resolves the font of the current drawing state again, after a change to the text drawing styles that select
/// its fonts.
pub(crate) fn font_selection_did_change(&self) {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/text.rs b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/text.rs
index dadb0117a77..d03543e0a0f 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/text.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/text.rs
@@ -14,7 +14,7 @@ use libgfx_rust::{AffineTransform, FloatPoint};
use super::context::multiply_transforms;
use super::drawing_state::DrawingState;
-use crate::html::canvas_rendering_context2d::{CanvasDirection, CanvasTextAlign, CanvasTextBaseline};
+use crate::html::canvas_rendering_context2d::{CanvasTextAlign, CanvasTextBaseline};
/// A run of the text that one font of the cascade shapes.
pub(crate) struct ShapedRun {
@@ -124,6 +124,25 @@ fn translation(x: f32, y: f32) -> AffineTransform {
AffineTransform::new(1.0, 0.0, 0.0, 1.0, x, y)
}
+/// How far the left edge of an inline box of the width is to the right of the anchor point, which textAlign and
+/// the direction of the text determine, https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-textalign
+pub(crate) fn horizontal_alignment_offset(text_align: CanvasTextAlign, is_rtl: bool, text_width: f32) -> f32 {
+ // The direction affects how "start" and "end" are interpreted:
+ // - "ltr": start=left, end=right
+ // - "rtl": start=right, end=left
+ match text_align {
+ // Center alignment is the same regardless of direction.
+ CanvasTextAlign::Center => -text_width / 2.0,
+ // In RTL, "start" means right-aligned. In LTR, it means left-aligned, which needs no translation.
+ CanvasTextAlign::Start if is_rtl => -text_width,
+ // In LTR, "end" means right-aligned. In RTL, it means left-aligned, which needs no translation.
+ CanvasTextAlign::End if !is_rtl => -text_width,
+ // Explicit "left" and "right" alignments ignore direction.
+ CanvasTextAlign::Right => -text_width,
+ CanvasTextAlign::Start | CanvasTextAlign::End | CanvasTextAlign::Left => 0.0,
+ }
+}
+
/// Where text of the width goes relative to the point that it is drawn at, and how much it is condensed to fit in the
/// maximum width. The text starts at x, around which it is condensed.
#[allow(
@@ -132,6 +151,7 @@ fn translation(x: f32, y: f32) -> AffineTransform {
)]
pub(crate) fn text_transform(
state: &DrawingState,
+ is_rtl: bool,
first_font: &FontHandle,
x: f32,
mut text_width: f32,
@@ -153,24 +173,9 @@ pub(crate) fn text_transform(
}
// Apply text align
- // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-textalign
- // The direction property affects how "start" and "end" are interpreted:
- // - "ltr" or "inherit" (default): start=left, end=right
- // - "rtl": start=right, end=left
- let is_rtl = state.direction == CanvasDirection::Rtl;
- let alignment_offset = match state.text_align {
- // Center alignment is the same regardless of direction.
- CanvasTextAlign::Center => Some(-text_width / 2.0),
- // In RTL, "start" means right-aligned. In LTR, it means left-aligned, which needs no translation.
- CanvasTextAlign::Start => is_rtl.then_some(-text_width),
- // In LTR, "end" means right-aligned. In RTL, it means left-aligned, which needs no translation.
- CanvasTextAlign::End => (!is_rtl).then_some(-text_width),
- // Explicit "left" and "right" alignments ignore direction.
- CanvasTextAlign::Right => Some(-text_width),
- CanvasTextAlign::Left => None,
- };
- if let Some(offset) = alignment_offset {
- transform = multiply_transforms(translation(offset, 0.0), transform);
+ let alignment_offset = horizontal_alignment_offset(state.text_align, is_rtl, text_width);
+ if alignment_offset != 0.0 {
+ transform = multiply_transforms(translation(alignment_offset, 0.0), transform);
}
// Apply text baseline
diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_text.rs b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_text.rs
index 7dcad48df42..f51551e762e 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_text.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_text.rs
@@ -19,7 +19,9 @@ use crate::bindings::{CallContext, WebIdlResult};
use crate::canvas_2d::context::{CanvasKind, ContextState, RenderingContext2D, paint_of};
use crate::canvas_2d::float;
use crate::canvas_2d::host::LentFont;
-use crate::canvas_2d::text::{baseline_offset, path_of_runs, replace_ascii_whitespace, shape_text, text_transform};
+use crate::canvas_2d::text::{
+ baseline_offset, horizontal_alignment_offset, path_of_runs, replace_ascii_whitespace, shape_text, text_transform,
+};
use crate::html::canvas_rendering_context2d::CanvasTextBaseline;
impl ContextState {
@@ -35,7 +37,15 @@ impl ContextState {
let runs = shape_text(&font.cascade, text, FloatPoint { x, y }, letter_spacing, word_spacing);
let path = path_of_runs(&runs);
let text_width: f32 = runs.iter().map(|run| run.width).sum();
- let transform = text_transform(&self.drawing_state(), &font.cascade.first(), x, text_width, max_width);
+ let is_rtl = self.direction_is_rtl();
+ let transform = text_transform(
+ &self.drawing_state(),
+ is_rtl,
+ &font.cascade.first(),
+ x,
+ text_width,
+ max_width,
+ );
path.copy_transformed(transform.values)
}
}
@@ -115,7 +125,8 @@ impl<K: CanvasKind> RenderingContext2D<K> {
.collect();
let first_font = font.cascade.first();
let state = self.drawing_state();
- let translation = text_transform(&state, &first_font, x, run.width, None).map_point(FloatPoint { x, y });
+ let translation = text_transform(&state, self.direction_is_rtl(), &first_font, x, run.width, None)
+ .map_point(FloatPoint { x, y });
let lent_font = LentFont(NonNull::new(run.font.as_raw().cast_mut()).expect("a font has a font"));
self.record(|recorder| {
let paint = paint_of(recorder, &state.fill_style, self.context_attributes.color_space);
@@ -178,7 +189,8 @@ impl<K: CanvasKind> RenderingContext2D<K> {
// FIXME: 4. Let language be the target's language.
// FIXME: 5. If language is "inherit": ...
// FIXME: 6. If language is the empty string, then set language to explicitly unknown.
- // FIXME: 7. Apply the appropriate step from the following list to determine the value of direction: ...
+ // 7. Apply the appropriate step from the following list to determine the value of direction: ...
+ let is_rtl = self.direction_is_rtl();
// 8. Form a hypothetical infinitely-wide CSS line box containing a single inline box containing the text text,
// with the CSS content language set to language, and with its CSS properties set as follows: ...
@@ -193,14 +205,17 @@ impl<K: CanvasKind> RenderingContext2D<K> {
// greater than maxWidth CSS pixels, then change font to have a more condensed font (if one is available or
// if a reasonably readable one can be synthesized by applying a horizontal scale factor to the font) or a
// smaller font, and return to the previous step.
- // FIXME: 10. The anchor point is a point on the inline box, and the physical alignment is one of the values
- // left, right, and center. These variables are determined by the textAlign and textBaseline values.
+ // 10. The anchor point is a point on the inline box, and the physical alignment is one of the values left,
+ // right, and center. These variables are determined by the textAlign and textBaseline values.
+ // NB: The horizontal position of the anchor point places the inline box below, and its vertical position is
+ // the baseline offset below.
+ let alignment_offset = horizontal_alignment_offset(self.drawing_state().text_align, is_rtl, width);
// 11. Let result be an array constructed by iterating over each glyph in the inline box from left to right (if
// any), adding to the array, for each glyph, the shape of the glyph as it is in the inline box, positioned
// on a coordinate space using CSS pixels with its origin at the anchor point.
// 12. Return result, physical alignment, and the inline box.
- // NB: The inline box is at the origin, as wide as the text.
- let (box_left, box_right) = (0.0_f32, width);
+ // NB: The inline box is as wide as the text, with the anchor point at the origin.
+ let (box_left, box_right) = (alignment_offset, alignment_offset + width);
// FIXME: Use the font that was used to create the glyphs of the runs.
let first_font = font.cascade.first();
diff --git a/Libraries/LibWeb/HTML/Canvas/Canvas2DContextBase.cpp b/Libraries/LibWeb/HTML/Canvas/Canvas2DContextBase.cpp
index 06a26cff61a..0ac0a1a6673 100644
--- a/Libraries/LibWeb/HTML/Canvas/Canvas2DContextBase.cpp
+++ b/Libraries/LibWeb/HTML/Canvas/Canvas2DContextBase.cpp
@@ -161,6 +161,7 @@ void* web_canvas_2d_canvas_create_transport(void* canvas_host);
void* web_canvas_2d_canvas_wrapper(void* canvas, bool canvas_is_offscreen, void* realm);
void* web_canvas_2d_canvas_relevant_realm(void* canvas_host);
u64 web_canvas_2d_canvas_font_environment_generation(void* canvas_host);
+bool web_canvas_2d_canvas_directionality_is_rtl(void* canvas, bool canvas_is_offscreen);
bool web_canvas_2d_canvas_resolve_font(void* canvas, bool canvas_is_offscreen, FlatPtr font, CanvasFontSelection, ResolvedFont* out_font);
void web_canvas_2d_canvas_resolve_color(void* canvas_host, CSS::StyleValue const* color, FontMetricsSource, u8 color_space, Gfx::Color* out_color, Gfx::Color* out_color_in_color_space);
float web_canvas_2d_canvas_resolve_length(void* canvas_host, CSS::StyleValue const* length, FontMetricsSource);
@@ -369,6 +370,16 @@ u64 web_canvas_2d_canvas_font_environment_generation(void* canvas_host)
return host_from(canvas_host).canvas_font_computer().environment_generation();
}
+bool web_canvas_2d_canvas_directionality_is_rtl(void* canvas, bool canvas_is_offscreen)
+{
+ // FIXME: Return the inherited direction of an OffscreenCanvas, which OffscreenCanvas does not keep yet. It is
+ // 'ltr' unless transferControlToOffscreen() or a transfer set it.
+ if (canvas_is_offscreen)
+ return false;
+ auto& canvas_element = *static_cast<HTMLCanvasElement*>(static_cast<GC::Cell*>(canvas));
+ return canvas_element.directionality() == DOM::Element::Directionality::Rtl;
+}
+
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-font
template<typename CanvasType>
static bool resolve_font(CanvasType& canvas_element, Utf16View font, CanvasFontSelection font_selection, ResolvedFont& out_font)
diff --git a/Tests/LibWeb/Text/expected/canvas/2d-measure-text.txt b/Tests/LibWeb/Text/expected/canvas/2d-measure-text.txt
index 06afbc3a388..9a872cc5acc 100644
--- a/Tests/LibWeb/Text/expected/canvas/2d-measure-text.txt
+++ b/Tests/LibWeb/Text/expected/canvas/2d-measure-text.txt
@@ -48,13 +48,13 @@ A canvas:
textAlign start
"Aligned": 53.28125, 0, 53.28125, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
textAlign end
- "Aligned": 53.28125, 0, 53.28125, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
+ "Aligned": 53.28125, 53.28125, 0, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
textAlign left
"Aligned": 53.28125, 0, 53.28125, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
textAlign right
- "Aligned": 53.28125, 0, 53.28125, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
+ "Aligned": 53.28125, 53.28125, 0, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
textAlign center
- "Aligned": 53.28125, 0, 53.28125, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
+ "Aligned": 53.28125, 26.640625, 26.640625, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
An OffscreenCanvas:
10px sans-serif
"": 0, 0, 0, 7.998046875, 2.001953125, 7.998046875, 2.001953125, 7.998046875, 2.001953125, 6.3984375, 0, -2.001953125
@@ -105,10 +105,10 @@ An OffscreenCanvas:
textAlign start
"Aligned": 53.28125, 0, 53.28125, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
textAlign end
- "Aligned": 53.28125, 0, 53.28125, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
+ "Aligned": 53.28125, 53.28125, 0, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
textAlign left
"Aligned": 53.28125, 0, 53.28125, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
textAlign right
- "Aligned": 53.28125, 0, 53.28125, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
+ "Aligned": 53.28125, 53.28125, 0, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
textAlign center
- "Aligned": 53.28125, 0, 53.28125, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
+ "Aligned": 53.28125, 26.640625, 26.640625, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 11.9970703125, 3.0029296875, 9.59765625, 0, -3.0029296875
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.draw.align.end.rtl.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.draw.align.end.rtl.txt
index 20a6fd9f1ec..49da037a7b7 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.draw.align.end.rtl.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.draw.align.end.rtl.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail textAlign end with rtl is the left edge
\ No newline at end of file
+1 Pass
+Pass textAlign end with rtl is the left edge
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.draw.align.start.rtl.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.draw.align.start.rtl.txt
index 8864a153292..490a6734f79 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.draw.align.start.rtl.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.draw.align.start.rtl.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail textAlign start with rtl is the right edge
\ No newline at end of file
+1 Pass
+Pass textAlign start with rtl is the right edge
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.drawing.style.measure.direction.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.drawing.style.measure.direction.txt
index f61b331699a..9628b47dec1 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.drawing.style.measure.direction.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.drawing.style.measure.direction.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Measurement should follow text direction
\ No newline at end of file
+1 Pass
+Pass Measurement should follow text direction
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.drawing.style.measure.textAlign.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.drawing.style.measure.textAlign.txt
index cb69aa664ab..4a372bdd954 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.drawing.style.measure.textAlign.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/text/2d.text.drawing.style.measure.textAlign.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Measurement should be related to textAlignment
\ No newline at end of file
+1 Pass
+Pass Measurement should be related to textAlignment
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.direction.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.direction.txt
index f61b331699a..9628b47dec1 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.direction.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.direction.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Measurement should follow text direction
\ No newline at end of file
+1 Pass
+Pass Measurement should follow text direction
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.direction.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.direction.worker.txt
index f61b331699a..9628b47dec1 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.direction.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.direction.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Measurement should follow text direction
\ No newline at end of file
+1 Pass
+Pass Measurement should follow text direction
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.textAlign.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.textAlign.txt
index cb69aa664ab..4a372bdd954 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.textAlign.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.textAlign.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Measurement should be related to textAlignment
\ No newline at end of file
+1 Pass
+Pass Measurement should be related to textAlignment
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.textAlign.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.textAlign.worker.txt
index cb69aa664ab..4a372bdd954 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.textAlign.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.drawing.style.measure.textAlign.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Measurement should be related to textAlignment
\ No newline at end of file
+1 Pass
+Pass Measurement should be related to textAlignment
\ No newline at end of file