Skip to content

Truly independent web browser

LibWeb: Implement text-orientation

Andreas Klingada0e2bb1d8d
diff --git a/Libraries/LibWeb/CSS/ComputedValues.h b/Libraries/LibWeb/CSS/ComputedValues.h
index 454f73ceb24..6cb4deeadd3 100644
--- a/Libraries/LibWeb/CSS/ComputedValues.h
+++ b/Libraries/LibWeb/CSS/ComputedValues.h
@@ -819,7 +819,8 @@ public:
&& direction == other.direction
&& writing_mode == other.writing_mode
&& content_visibility == other.content_visibility
- && image_rendering == other.image_rendering;
+ && image_rendering == other.image_rendering
+ && text_orientation == other.text_orientation;
}
};
diff --git a/Libraries/LibWeb/CSS/Enums.json b/Libraries/LibWeb/CSS/Enums.json
index b4921454046..805d8717ea1 100644
--- a/Libraries/LibWeb/CSS/Enums.json
+++ b/Libraries/LibWeb/CSS/Enums.json
@@ -1169,6 +1169,11 @@
"inter-word",
"inter-character"
],
+ "text-orientation": [
+ "mixed",
+ "upright",
+ "sideways"
+ ],
"text-overflow": [
"clip",
"ellipsis"
diff --git a/Libraries/LibWeb/CSS/Keywords.json b/Libraries/LibWeb/CSS/Keywords.json
index db19183f652..b79379ae7da 100644
--- a/Libraries/LibWeb/CSS/Keywords.json
+++ b/Libraries/LibWeb/CSS/Keywords.json
@@ -463,6 +463,7 @@
"min-content",
"minimal-ui",
"miter",
+ "mixed",
"mongolian",
"monospace",
"more",
@@ -659,6 +660,7 @@
"show",
"sidama",
"sides",
+ "sideways",
"sideways-lr",
"sideways-rl",
"silti",
diff --git a/Libraries/LibWeb/CSS/Properties.json b/Libraries/LibWeb/CSS/Properties.json
index 94c588b2827..5b9f483ba44 100644
--- a/Libraries/LibWeb/CSS/Properties.json
+++ b/Libraries/LibWeb/CSS/Properties.json
@@ -5291,6 +5291,16 @@
"distribute>inter-character"
]
},
+ "text-orientation": {
+ "style-group": "InheritedBoxValues",
+ "animation-type": "none",
+ "inherited": true,
+ "initial": "mixed",
+ "requires-computation": "never",
+ "valid-types": [
+ "text-orientation"
+ ]
+ },
"text-overflow": {
"style-group": "BoxValues",
"affects-layout": false,
diff --git a/Libraries/LibWeb/Rust/src/css/computed_value_views.rs b/Libraries/LibWeb/Rust/src/css/computed_value_views.rs
index 275b3fd0ad0..a3577b370a4 100644
--- a/Libraries/LibWeb/Rust/src/css/computed_value_views.rs
+++ b/Libraries/LibWeb/Rust/src/css/computed_value_views.rs
@@ -473,6 +473,7 @@ scalar_accessors! {
}
inherited_box: {
writing_mode: u8 => writing_mode,
+ text_orientation: u8 => text_orientation,
direction: u8 => direction,
visibility: u8 => visibility,
}
diff --git a/Libraries/LibWeb/Rust/src/css/computed_values.rs b/Libraries/LibWeb/Rust/src/css/computed_values.rs
index 4b5b60343a6..51c1ea4679c 100644
--- a/Libraries/LibWeb/Rust/src/css/computed_values.rs
+++ b/Libraries/LibWeb/Rust/src/css/computed_values.rs
@@ -68,6 +68,7 @@ pub struct InheritedBoxValues {
pub writing_mode: u8,
pub content_visibility: u8,
pub image_rendering: u8,
+ pub text_orientation: u8,
}
impl ComputedStyleValueHandle {
@@ -333,6 +334,7 @@ impl_content_hash_by_field!(InheritedBoxValues {
writing_mode,
content_visibility,
image_rendering,
+ text_orientation,
});
// The anchor-inset wrappers are pure derivatives of the anchor-inset fields, so payload equality
// excludes them and the hash follows it field for field.
@@ -2667,7 +2669,7 @@ pub(crate) fn build_group_payload_with_rust_fill<T: StyleGroupPayload>(
share_equal_group_payload(scratch.as_ref(), parent).unwrap_or_else(|| scratch.publish())
}
-/// Builds an inherited box group payload from the five computed keyword
+/// Builds an inherited box group payload from the six computed keyword
/// values, sharing instead of allocating whenever it can: the parent's
/// payload when every field matches it, or the immortal default payload when
/// every field holds its initial value. Every input is a canonical computed
@@ -2676,6 +2678,7 @@ pub(crate) fn build_group_payload_with_rust_fill<T: StyleGroupPayload>(
/// The returned payload carries one reference for the caller; fresh payloads
/// start at one, shared payloads are retained, and default payloads are
/// intentionally leaked and never counted.
+#[allow(clippy::too_many_arguments)]
pub(crate) fn build_inherited_box_group(
group_index: usize,
visibility: &RetainedStyleValueData,
@@ -2683,6 +2686,7 @@ pub(crate) fn build_inherited_box_group(
writing_mode: &RetainedStyleValueData,
content_visibility: &RetainedStyleValueData,
image_rendering: &RetainedStyleValueData,
+ text_orientation: &RetainedStyleValueData,
parent: Option<GroupPayloadRef<'_>>,
) -> *const c_void {
use crate::css::style_value::StyleValueData;
@@ -2702,6 +2706,7 @@ pub(crate) fn build_inherited_box_group(
crate::css::style_compute::keyword_to_content_visibility,
),
image_rendering: keyword_code(image_rendering, crate::css::style_compute::keyword_to_image_rendering),
+ text_orientation: keyword_code(text_orientation, crate::css::style_compute::keyword_to_text_orientation),
};
share_or_publish_group_payload::<InheritedBoxValues>(group_index, built, parent)
@@ -4081,7 +4086,9 @@ impl InheritedTableValues {
impl InheritedBoxValues {
fn initial() -> Self {
- use crate::css::css_enums::{content_visibility, direction, image_rendering, visibility, writing_mode};
+ use crate::css::css_enums::{
+ content_visibility, direction, image_rendering, text_orientation, visibility, writing_mode,
+ };
Self {
visibility: visibility::VISIBLE,
@@ -4089,6 +4096,7 @@ impl InheritedBoxValues {
writing_mode: writing_mode::HORIZONTAL_TB,
content_visibility: content_visibility::VISIBLE,
image_rendering: image_rendering::AUTO,
+ text_orientation: text_orientation::MIXED,
}
}
}
diff --git a/Libraries/LibWeb/Rust/src/css/table_group_builder.rs b/Libraries/LibWeb/Rust/src/css/table_group_builder.rs
index 0edfe48a060..d533896da64 100644
--- a/Libraries/LibWeb/Rust/src/css/table_group_builder.rs
+++ b/Libraries/LibWeb/Rust/src/css/table_group_builder.rs
@@ -3342,6 +3342,7 @@ pub(crate) fn rebuild_group_from_table(
values.handle(property_id::WRITING_MODE),
values.handle(property_id::CONTENT_VISIBILITY),
values.handle(property_id::IMAGE_RENDERING),
+ values.handle(property_id::TEXT_ORIENTATION),
parent,
),
group_index::SIZING => build_sizing_group(
@@ -3425,6 +3426,7 @@ pub(crate) unsafe fn build_group_payloads_from_table(
values.handle(property_id::WRITING_MODE),
values.handle(property_id::CONTENT_VISIBILITY),
values.handle(property_id::IMAGE_RENDERING),
+ values.handle(property_id::TEXT_ORIENTATION),
parent,
),
group_index::SIZING => build_sizing_group(
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_content.rs b/Libraries/LibWeb/Rust/src/layout/inline_content.rs
index 393ad3c7d73..2cde5a349d4 100644
--- a/Libraries/LibWeb/Rust/src/layout/inline_content.rs
+++ b/Libraries/LibWeb/Rust/src/layout/inline_content.rs
@@ -38,7 +38,7 @@ pub enum InlineItem {
impl PartialEq for GlyphRunRecord {
fn eq(&self, other: &Self) -> bool {
- self.font == other.font && self.glyphs == other.glyphs
+ self.font == other.font && self.glyphs == other.glyphs && self.is_upright == other.is_upright
}
}
@@ -86,6 +86,8 @@ impl LineRecord {
pub struct GlyphRunRecord {
pub glyphs: libgfx_rust::text_layout::GlyphBuffer,
pub font: libgfx_rust::font::FontHandle,
+ /// Whether the glyphs are set upright in vertical text.
+ pub is_upright: bool,
// Conservative painted bounds in CSS pixels, relative to the run's baseline origin.
pub bounding_box: libgfx_rust::FloatRect,
}
@@ -183,6 +185,7 @@ impl InlineContent {
std::sync::Arc::new(GlyphRunRecord {
glyphs: glyph_data.glyphs,
font: glyph_data.font,
+ is_upright: glyph_data.is_upright,
bounding_box,
})
});
@@ -430,13 +433,42 @@ impl InlineContent {
),
content_size,
);
+ fragment.relpos_delta = delta_to_physical(fragment.relpos_delta);
+ if fragment.glyph_run.as_ref().is_some_and(|run| run.is_upright) {
+ // NB: Upright glyphs are painted unturned, stacked downwards one em apart and centered within the
+ // line, so the fragment is painted as horizontal text whose glyphs sit at those positions.
+ let run = fragment.glyph_run.as_ref().unwrap();
+ let ascent = fragment.baseline.to_double() as f32;
+ let line_width = rect.width.to_double() as f32;
+ let mut glyphs = run.glyphs.clone();
+ for glyph in glyphs.to_mut().iter_mut() {
+ let inline_position = glyph.x;
+ glyph.x = (line_width - glyph.glyph_width) / 2.0;
+ glyph.y += inline_position;
+ }
+ let bounding_box = libgfx_rust::FloatRect::from_array(
+ libgfx_rust::text_layout::glyph_run_bounding_box(&run.font, &glyphs, 1.0),
+ );
+ fragment.glyph_run = Some(std::sync::Arc::new(GlyphRunRecord {
+ glyphs,
+ font: run.font.clone(),
+ is_upright: true,
+ bounding_box,
+ }));
+ fragment.baseline = CssPixels::nearest_value_for_f32(ascent);
+ fragment.writing_mode = crate::css::css_enums::writing_mode::HORIZONTAL_TB;
+ fragment.inline_offset = rect.x;
+ fragment.block_offset = rect.y;
+ fragment.inline_length = rect.width;
+ fragment.block_length = rect.height;
+ continue;
+ }
// NB: A vertical fragment keeps its inline offset and length along the physical vertical axis.
fragment.writing_mode = writing_mode;
fragment.inline_offset = rect.y;
fragment.block_offset = rect.x;
fragment.inline_length = rect.height;
fragment.block_length = rect.width;
- fragment.relpos_delta = delta_to_physical(fragment.relpos_delta);
}
for piece in &mut content.inline_box_pieces {
let mut rect = piece.border_box_rect;
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
index 52609b30081..b1e69854d92 100644
--- a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
@@ -302,6 +302,7 @@ fn apply_block_ellipsis(
font,
text_type: line_box_fragment::GLYPH_TEXT_TYPE_COMMON,
width: ellipsis_width,
+ is_upright: false,
}),
line_box_fragment::FragmentBuildFacts {
style_source,
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
index 2976899afd7..dcbe84d055b 100644
--- a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
+++ b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
@@ -65,10 +65,54 @@ fn shape_glyph_data(
glyphs: shaped.into_glyphs(),
font,
text_type,
+ is_upright: false,
};
(glyph_data, trailing_whitespace)
}
+/// Whether text in the given writing mode and text orientation that starts with `code_point` is set with its glyphs
+/// upright, stacked along the vertical inline axis, rather than turned sideways like a horizontal line of text.
+/// https://drafts.csswg.org/css-writing-modes-4/#text-orientation
+pub(crate) fn text_is_set_upright(writing_mode: u8, text_orientation: u8, code_point: u32) -> bool {
+ // NB: The sideways writing modes set all text sideways, whatever its text orientation.
+ if !matches!(writing_mode, writing_mode::VERTICAL_RL | writing_mode::VERTICAL_LR) {
+ return false;
+ }
+ match text_orientation {
+ // upright: Typographic character units from horizontal-only scripts are typeset upright, i.e. in their
+ // standard horizontal orientation. Typographic character units from vertical scripts are typeset with their
+ // intrinsic orientation and shaped normally.
+ // FIXME: This value causes the used value of 'direction' to be 'ltr', and for the purposes of bidi
+ // reordering, causes all characters to be treated as strong LTR.
+ text_orientation::UPRIGHT => true,
+ // mixed: Typographic character units from horizontal-only scripts are typeset sideways, i.e. 90° clockwise
+ // from their standard orientation in horizontal text. Typographic character units from vertical scripts are
+ // typeset with their intrinsic orientation.
+ text_orientation::MIXED => text_chunker::code_point_is_upright_in_mixed_orientation(code_point),
+ _ => false,
+ }
+}
+
+/// Sets shaped glyphs upright: each of them takes one em along the inline axis, which runs downwards in the frame of
+/// a vertical writing mode, while keeping its own horizontal width, which painting centers it within.
+// FIXME: Use the vertical metrics of the font, where it has them.
+fn set_glyphs_upright(glyph_data: &mut line_box_fragment::GlyphData, inline_offset: f32, advance: f32) {
+ let glyphs = glyph_data.glyphs.to_mut();
+ let mut pen = inline_offset;
+ let mut count = 0usize;
+ for glyph in glyphs.iter_mut() {
+ if glyph.length_in_code_units != 0 {
+ if count > 0 {
+ pen += advance;
+ }
+ count += 1;
+ }
+ glyph.x = pen;
+ }
+ glyph_data.width = advance * count as f32;
+ glyph_data.is_upright = true;
+}
+
impl Item {
fn new(type_: ItemType, node: Node) -> Self {
Self {
@@ -211,6 +255,7 @@ impl Item {
font: glyph_data.font.clone(),
text_type: glyph_data.text_type,
width: glyph_data.width - split_x,
+ is_upright: glyph_data.is_upright,
})
}
@@ -292,6 +337,7 @@ impl Item {
font: prefix.font.clone(),
text_type: prefix.text_type,
width: prefix.width - split_x,
+ is_upright: prefix.is_upright,
};
prefix.width = split_x;
@@ -762,7 +808,7 @@ impl<'iterator, 'context> InlineLevelIteratorGenerator<'iterator, 'context> {
inline_offset = tab_stop_distance.to_double() as f32;
}
let shaped_text = &full_text[shaped_start..shaped_start + shaped_length];
- let (glyphs, shaped_trailing_whitespace) = shape_glyph_data(
+ let (mut glyphs, shaped_trailing_whitespace) = shape_glyph_data(
shaped_text,
chunk.font.clone(),
text_type,
@@ -770,6 +816,20 @@ impl<'iterator, 'context> InlineLevelIteratorGenerator<'iterator, 'context> {
style.letter_spacing().to_double() as f32,
word_spacing.to_double() as f32,
);
+ if !shaped_text.is_empty()
+ && text_is_set_upright(
+ style.writing_mode(),
+ style.text_orientation(),
+ text_chunker::code_point_at(shaped_text, 0),
+ )
+ {
+ // NB: The font's own size takes any font-size-adjust into account.
+ set_glyphs_upright(
+ &mut glyphs,
+ inline_offset,
+ chunk.font.facts().pixel_size + style.letter_spacing().to_double() as f32,
+ );
+ }
let chunk_inline_size = CssPixels::nearest_value_for_f32(glyphs.width + inline_offset);
let generated_empty = synthesize_zero_length_chunk
|| (self.context().facts(text_node).is_generated_for_pseudo_element() && chunk.length == 0);
diff --git a/Libraries/LibWeb/Rust/src/layout/line_box.rs b/Libraries/LibWeb/Rust/src/layout/line_box.rs
index efb8c6aa934..9202711a013 100644
--- a/Libraries/LibWeb/Rust/src/layout/line_box.rs
+++ b/Libraries/LibWeb/Rust/src/layout/line_box.rs
@@ -132,10 +132,9 @@ impl LineBoxData {
&& self.fragments.last().is_some_and(|last| {
!last.has_soft_wrap_opportunity_after
&& last.layout_node == layout_node
- && last
- .glyphs
- .as_ref()
- .is_some_and(|last_glyphs| last_glyphs.font == glyphs.font)
+ && last.glyphs.as_ref().is_some_and(|last_glyphs| {
+ last_glyphs.font == glyphs.font && last_glyphs.is_upright == glyphs.is_upright
+ })
&& last.start + last.length_in_code_units == start
})
});
diff --git a/Libraries/LibWeb/Rust/src/layout/line_box_fragment.rs b/Libraries/LibWeb/Rust/src/layout/line_box_fragment.rs
index ebdb410d40d..1c91b5d4691 100644
--- a/Libraries/LibWeb/Rust/src/layout/line_box_fragment.rs
+++ b/Libraries/LibWeb/Rust/src/layout/line_box_fragment.rs
@@ -23,6 +23,8 @@ pub(crate) struct GlyphData {
pub(crate) text_type: u8,
// GlyphRun::width is not updated by the C++ fragment merge machine.
pub(crate) width: f32,
+ /// Whether the glyphs are set upright in vertical text, one em apart along the inline axis.
+ pub(crate) is_upright: bool,
}
// The advance of a run's trailing whitespace, recorded at shaping time so that trimming it subtracts exactly what
diff --git a/Libraries/LibWeb/Rust/src/layout/rendered_text.rs b/Libraries/LibWeb/Rust/src/layout/rendered_text.rs
index 3ed94e65ca8..2e5f7888f06 100644
--- a/Libraries/LibWeb/Rust/src/layout/rendered_text.rs
+++ b/Libraries/LibWeb/Rust/src/layout/rendered_text.rs
@@ -146,6 +146,7 @@ pub(crate) struct TextChunkCacheKey {
pub(crate) word_break: u8,
pub(crate) font_variant_emoji: u8,
pub(crate) frozen_font_list: std::sync::Arc<libgfx_rust::font::FrozenFontList>,
+ pub(crate) splits_at_orientation_changes: bool,
}
impl PartialEq for TextChunkCacheKey {
@@ -156,6 +157,7 @@ impl PartialEq for TextChunkCacheKey {
&& self.white_space_collapse == other.white_space_collapse
&& self.word_break == other.word_break
&& self.font_variant_emoji == other.font_variant_emoji
+ && self.splits_at_orientation_changes == other.splits_at_orientation_changes
// A frozen cascade is immutable, so naming the same one is the whole of equality.
&& std::sync::Arc::ptr_eq(&self.frozen_font_list, &other.frozen_font_list)
}
@@ -441,6 +443,7 @@ mod tests {
word_break: 0,
font_variant_emoji: 0,
frozen_font_list: std::sync::Arc::new(libgfx_rust::font::FrozenFontList::empty()),
+ splits_at_orientation_changes: false,
};
let chunk = TextChunk {
start: 0,
diff --git a/Libraries/LibWeb/Rust/src/layout/text_chunker.rs b/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
index 82b46e819cb..2559ab3f46f 100644
--- a/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
+++ b/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
@@ -163,6 +163,9 @@ pub(crate) struct TextChunkInputs<'text> {
pub should_wrap_lines: bool,
pub should_respect_linebreaks: bool,
pub unidirectional_ltr: bool,
+ /// Whether the text is vertical text in mixed orientation, where some characters are typeset upright and others
+ /// sideways.
+ pub splits_at_orientation_changes: bool,
}
pub(crate) fn chunk_text(inputs: TextChunkInputs<'_>) -> Vec<TextChunk> {
@@ -370,9 +373,33 @@ fn is_utf16_low_surrogate(code_unit: u16) -> bool {
(0xdc00..=0xdfff).contains(&code_unit)
}
+/// Whether a code point is typeset upright in vertical text whose text orientation is 'mixed'.
+// FIXME: Use the Vertical_Orientation property of Unicode (UAX #50) instead of these blocks of characters, which are
+// mostly upright.
+pub(crate) fn code_point_is_upright_in_mixed_orientation(code_point: u32) -> bool {
+ matches!(
+ code_point,
+ 0x1100..=0x11FF
+ | 0x2E80..=0x303F
+ | 0x3040..=0x31FF
+ | 0x3200..=0x4DBF
+ | 0x4E00..=0x9FFF
+ | 0xA960..=0xA97F
+ | 0xAC00..=0xD7FF
+ | 0xF900..=0xFAFF
+ | 0xFE10..=0xFE1F
+ | 0xFE30..=0xFE4F
+ | 0xFF01..=0xFF0C
+ | 0xFF0E..=0xFF1B
+ | 0xFF1F..=0xFF60
+ | 0xFFE0..=0xFFE6
+ | 0x20000..=0x3FFFF
+ )
+}
+
/// Mirrors AK::Utf16View::code_point_at, including its lone-surrogate
/// pass-through behavior.
-pub(super) fn code_point_at(text: &[u16], index: usize) -> u32 {
+pub(crate) fn code_point_at(text: &[u16], index: usize) -> u32 {
let code_unit = text[index];
let code_point = u32::from(code_unit);
if !is_utf16_high_surrogate(code_unit) && !is_utf16_low_surrogate(code_unit) {
@@ -453,6 +480,7 @@ struct PendingChunk {
start: usize,
font: FontHandle,
text_type: u8,
+ is_upright: bool,
broken_on_tab: bool,
}
@@ -474,6 +502,7 @@ struct TextChunker<'text> {
should_wrap_lines: bool,
should_respect_linebreaks: bool,
unidirectional_ltr: bool,
+ splits_at_orientation_changes: bool,
current_index: usize,
last_non_whitespace_font: Option<FontHandle>,
}
@@ -494,6 +523,7 @@ impl<'text> TextChunker<'text> {
should_wrap_lines: inputs.should_wrap_lines,
should_respect_linebreaks: inputs.should_respect_linebreaks,
unidirectional_ltr: inputs.unidirectional_ltr,
+ splits_at_orientation_changes: inputs.splits_at_orientation_changes,
current_index: 0,
last_non_whitespace_font: None,
}
@@ -510,6 +540,10 @@ impl<'text> TextChunker<'text> {
text_type_for_code_point(self.current_code_point())
}
+ fn current_code_point_is_upright(&self) -> bool {
+ self.splits_at_orientation_changes && code_point_is_upright_in_mixed_orientation(self.current_code_point())
+ }
+
fn next_grapheme_boundary(&self) -> usize {
self.grapheme_segmenter
.next_boundary(self.current_index, false)
@@ -731,6 +765,7 @@ impl<'text> TextChunker<'text> {
start: self.current_index,
font: self.expected_font_for(code_point),
text_type: self.current_text_type(),
+ is_upright: self.current_code_point_is_upright(),
broken_on_tab: false,
};
@@ -810,6 +845,14 @@ impl<'text> TextChunker<'text> {
return Some(chunk);
}
+ // NB: Each chunk is typeset either upright or sideways as a whole, so split it where that changes.
+ if self.current_index < self.text.len()
+ && pending.is_upright != self.current_code_point_is_upright()
+ && let Some(chunk) = self.try_commit_chunk_at_cursor(&pending, can_break_at_current_position)
+ {
+ return Some(chunk);
+ }
+
if self.should_wrap_lines {
if code_point_is_ascii_space(code_point) {
// Whitespace encountered, and we're allowed to break on whitespace.
@@ -897,6 +940,10 @@ pub(crate) fn text_chunks(
word_break: parent_style.word_break(),
font_variant_emoji: parent_style.font_variant_emoji(),
frozen_font_list: parent_style.frozen_font_list_ref(),
+ splits_at_orientation_changes: matches!(
+ parent_style.writing_mode(),
+ writing_mode::VERTICAL_RL | writing_mode::VERTICAL_LR
+ ) && parent_style.text_orientation() == text_orientation::MIXED,
};
let text = &callbacks.text_content(node).text;
callbacks.text_content(node).text_chunks(&key, || {
@@ -909,6 +956,7 @@ pub(crate) fn text_chunks(
should_wrap_lines,
should_respect_linebreaks,
unidirectional_ltr,
+ splits_at_orientation_changes: key.splits_at_orientation_changes,
})
})
}
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-writing-modes/text-orientation-016-ref.xht b/Tests/LibWeb/Ref/expected/wpt-import/css/css-writing-modes/text-orientation-016-ref.xht
new file mode 100644
index 00000000000..0010955e405
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-writing-modes/text-orientation-016-ref.xht
@@ -0,0 +1,48 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+ <title>CSS Reftest Reference</title>
+
+ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+ <meta content="image" name="flags" />
+
+ <style type="text/css"><![CDATA[
+ div
+ {
+ border-bottom: blue solid 15px;
+ border-top: blue solid 15px;
+ margin-top: 8px;
+ width: 200px;
+ }
+
+ img
+ {
+ vertical-align: top;
+ }
+ ]]></style>
+
+ </head>
+
+ <body>
+
+ <p>Test passes if both blue-and-yellow rectangles are <strong>identical</strong>.</p>
+
+ <div><img src="support/swatch-blue.png" width="14" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="8" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="58" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="16" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="104" height="40" alt="Image download support must be enabled" />
+
+<img src="support/swatch-blue.png" width="14" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="16" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="50" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="16" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="104" height="40" alt="Image download support must be enabled" />
+
+<img src="support/swatch-blue.png" width="14" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="16" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="58" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="8" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="104" height="40" alt="Image download support must be enabled" /></div>
+
+
+ <div><img src="support/swatch-blue.png" width="14" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="8" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="58" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="16" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="104" height="40" alt="Image download support must be enabled" />
+
+<img src="support/swatch-blue.png" width="14" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="16" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="50" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="16" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="104" height="40" alt="Image download support must be enabled" />
+
+<img src="support/swatch-blue.png" width="14" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="16" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="58" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="8" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="104" height="40" alt="Image download support must be enabled" /></div>
+
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-writing-modes/text-orientation-016.xht b/Tests/LibWeb/Ref/input/wpt-import/css/css-writing-modes/text-orientation-016.xht
new file mode 100644
index 00000000000..3d7216c03ac
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-writing-modes/text-orientation-016.xht
@@ -0,0 +1,81 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+ <title>CSS Writing Modes Test: text-orientation - sideways</title>
+
+ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+ <link rel="help" title="5.1. Orienting Text: the 'text-orientation' property" href="http://www.w3.org/TR/css-writing-modes-3/#text-orientation" />
+ <link rel="match" href="../../../../expected/wpt-import/css/css-writing-modes/text-orientation-016-ref.xht" />
+
+ <meta content="ahem image" name="flags" />
+ <meta content="This test checks that sideways-oriented latin text is baseline-aligned alphabetically within the line box and not baseline-aligned centrally. This test uses exclusively 'p' and 'É' glyphs to verify this." name="assert" />
+
+ <link rel="stylesheet" type="text/css" href="../../fonts/ahem.css" />
+ <style type="text/css"><![CDATA[
+ div
+ {
+ border-bottom: blue solid 15px;
+ border-top: blue solid 15px;
+ }
+
+ div#test
+ {
+ background-color: blue;
+ color: yellow;
+ font-family: Ahem;
+ font-size: 20px;
+ line-height: 2;
+ text-orientation: sideways;
+ writing-mode: vertical-rl;
+ }
+
+ span#p80
+ {
+ font-size: 4em; /* computes to 80px */
+ }
+
+ span#p40
+ {
+ font-size: 2em; /* computes to 40px */
+ }
+
+ span#E10
+ {
+ font-size: 0.5em; /* computes to 10px */
+ }
+
+ span#E20
+ {
+ font-size: 1em; /* computes to 20px */
+ }
+
+ div#reference
+ {
+ margin-top: 8px;
+ width: 200px;
+ }
+
+ img
+ {
+ vertical-align: top;
+ }
+ ]]></style>
+ </head>
+
+ <body>
+
+ <p>Test passes if both blue-and-yellow rectangles are <strong>identical</strong>.</p>
+
+ <div id="test"><span id="p80">p</span><span id="p40">p</span><br /><span id="E10">ÉÉÉÉ</span><span id="E20">ÉÉÉÉ</span></div>
+
+ <div id="reference"><img src="support/swatch-blue.png" width="14" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="8" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="58" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="16" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="104" height="40" alt="Image download support must be enabled" />
+
+<img src="support/swatch-blue.png" width="14" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="16" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="50" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="16" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="104" height="40" alt="Image download support must be enabled" />
+
+<img src="support/swatch-blue.png" width="14" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="16" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="58" height="40" alt="Image download support must be enabled" /><img src="support/swatch-yellow.png" width="8" height="40" alt="Image download support must be enabled" /><img src="support/swatch-blue.png" width="104" height="40" alt="Image download support must be enabled" /></div>
+
+ </body>
+</html>
diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt b/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt
index 1f22805ba46..b64752c5a33 100644
--- a/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt
+++ b/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt
@@ -75,6 +75,7 @@ All properties associated with getComputedStyle(document.body):
"text-decoration-skip-ink",
"text-indent",
"text-justify",
+ "text-orientation",
"text-rendering",
"text-shadow",
"text-transform",
diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt
index fc4a942f726..cc67634e554 100644
--- a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt
+++ b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt
@@ -977,6 +977,8 @@ All supported properties and their default values exposed from CSSStylePropertie
'text-indent': '0px'
'textJustify': 'auto'
'text-justify': 'auto'
+'textOrientation': 'mixed'
+'text-orientation': 'mixed'
'textOverflow': 'clip'
'text-overflow': 'clip'
'textRendering': 'auto'
diff --git a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt
index e5bfcfb6be2..d7fa1ea6e38 100644
--- a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt
+++ b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt
@@ -73,6 +73,7 @@ text-anchor: start
text-decoration-skip-ink: auto
text-indent: 0px
text-justify: auto
+text-orientation: mixed
text-rendering: auto
text-shadow: none
text-transform: none
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt
index 9169339bb7a..eae6917cde2 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt
@@ -1,8 +1,8 @@
Harness status: OK
-Found 342 tests
+Found 343 tests
-338 Pass
+339 Pass
4 Fail
Pass accent-color
Pass border-collapse
@@ -70,6 +70,7 @@ Pass text-anchor
Pass text-decoration-skip-ink
Pass text-indent
Pass text-justify
+Pass text-orientation
Pass text-rendering
Pass text-shadow
Pass text-transform
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/text-orientation.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/text-orientation.txt
index 8f402e349eb..398c82406ed 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/text-orientation.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/text-orientation.txt
@@ -2,16 +2,15 @@ Harness status: OK
Found 34 tests
-26 Pass
-8 Fail
-Fail Can set 'text-orientation' to CSS-wide keywords: initial
-Fail Can set 'text-orientation' to CSS-wide keywords: inherit
-Fail Can set 'text-orientation' to CSS-wide keywords: unset
-Fail Can set 'text-orientation' to CSS-wide keywords: revert
-Fail Can set 'text-orientation' to var() references: var(--A)
-Fail Can set 'text-orientation' to the 'mixed' keyword: mixed
-Fail Can set 'text-orientation' to the 'upright' keyword: upright
-Fail Can set 'text-orientation' to the 'sideways' keyword: sideways
+34 Pass
+Pass Can set 'text-orientation' to CSS-wide keywords: initial
+Pass Can set 'text-orientation' to CSS-wide keywords: inherit
+Pass Can set 'text-orientation' to CSS-wide keywords: unset
+Pass Can set 'text-orientation' to CSS-wide keywords: revert
+Pass Can set 'text-orientation' to var() references: var(--A)
+Pass Can set 'text-orientation' to the 'mixed' keyword: mixed
+Pass Can set 'text-orientation' to the 'upright' keyword: upright
+Pass Can set 'text-orientation' to the 'sideways' keyword: sideways
Pass Setting 'text-orientation' to a length: 0px throws TypeError
Pass Setting 'text-orientation' to a length: -3.14em throws TypeError
Pass Setting 'text-orientation' to a length: 3.14cm throws TypeError
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-writing-modes/parsing/text-orientation-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-writing-modes/parsing/text-orientation-computed.txt
index 6abfdfe849f..dbf8ae9bfe3 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-writing-modes/parsing/text-orientation-computed.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-writing-modes/parsing/text-orientation-computed.txt
@@ -2,7 +2,7 @@ Harness status: OK
Found 3 tests
-3 Fail
-Fail Property text-orientation value 'mixed'
-Fail Property text-orientation value 'upright'
-Fail Property text-orientation value 'sideways'
\ No newline at end of file
+3 Pass
+Pass Property text-orientation value 'mixed'
+Pass Property text-orientation value 'upright'
+Pass Property text-orientation value 'sideways'
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-writing-modes/parsing/text-orientation-valid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-writing-modes/parsing/text-orientation-valid.txt
index 190f4d7ae0b..0c2615e66fd 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-writing-modes/parsing/text-orientation-valid.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-writing-modes/parsing/text-orientation-valid.txt
@@ -2,7 +2,7 @@ Harness status: OK
Found 3 tests
-3 Fail
-Fail e.style['text-orientation'] = "mixed" should set the property value
-Fail e.style['text-orientation'] = "upright" should set the property value
-Fail e.style['text-orientation'] = "sideways" should set the property value
\ No newline at end of file
+3 Pass
+Pass e.style['text-orientation'] = "mixed" should set the property value
+Pass e.style['text-orientation'] = "upright" should set the property value
+Pass e.style['text-orientation'] = "sideways" should set the property value
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-writing-modes/text-orientation-parsing-001.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-writing-modes/text-orientation-parsing-001.txt
index 9bc61d8fd9f..c28ae5ed2f9 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-writing-modes/text-orientation-parsing-001.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-writing-modes/text-orientation-parsing-001.txt
@@ -2,12 +2,12 @@ Harness status: OK
Found 8 tests
-8 Fail
-Fail text-orientation initial value
-Fail text-orientation: upright
-Fail text-orientation: sideways
-Fail text-orientation should inherit
-Fail text-orientation: mixed
-Fail text-orientation: initial
-Fail text-orientation: inherit
-Fail text-orientation: foo
\ No newline at end of file
+8 Pass
+Pass text-orientation initial value
+Pass text-orientation: upright
+Pass text-orientation: sideways
+Pass text-orientation should inherit
+Pass text-orientation: mixed
+Pass text-orientation: initial
+Pass text-orientation: inherit
+Pass text-orientation: foo
\ No newline at end of file