Truly independent web browser
LibWeb: Draw a hyphen where a line breaks at a soft hyphen
sideshowbarker41eb886ca20e
diff --git a/Libraries/LibWeb/CSS/Enums.json b/Libraries/LibWeb/CSS/Enums.jsonindex 52de2e39ae7..9dc8987f30d 100644--- a/Libraries/LibWeb/CSS/Enums.json+++ b/Libraries/LibWeb/CSS/Enums.json@@ -720,6 +720,11 @@"increasing","decreasing"],+ "hyphens": [+ "none",+ "manual",+ "auto"+ ],"image-rendering": ["auto","crisp-edges",diff --git a/Libraries/LibWeb/CSS/Keywords.json b/Libraries/LibWeb/CSS/Keywords.jsonindex ad3be80e75a..bfda33b2ff8 100644--- a/Libraries/LibWeb/CSS/Keywords.json+++ b/Libraries/LibWeb/CSS/Keywords.json@@ -444,6 +444,7 @@"mandatory","manipulation","manipuri",+ "manual","marathi","margin-box","mark",diff --git a/Libraries/LibWeb/CSS/Properties.json b/Libraries/LibWeb/CSS/Properties.jsonindex 8936cd44ce6..587c60f8f7b 100644--- a/Libraries/LibWeb/CSS/Properties.json+++ b/Libraries/LibWeb/CSS/Properties.json@@ -3177,7 +3177,7 @@"needs-layout-for-getcomputedstyle": true},"hyphenate-character": {- "__comment": "FIXME: Use this string when hyphenation is implemented.",+ "__comment": "FIXME: Use this string, not just its auto hyphen, at a hyphenation opportunity.","animation-type": "discrete","inherited": true,"initial": "auto",@@ -3189,6 +3189,15 @@"auto"]},+ "hyphens": {+ "animation-type": "discrete",+ "inherited": true,+ "initial": "manual",+ "requires-computation": "never",+ "valid-types": [+ "hyphens"+ ]+ },"image-rendering": {"style-group": "InheritedUIValues","animation-type": "discrete",diff --git a/Libraries/LibWeb/Rust/src/css/computed_value_types.rs b/Libraries/LibWeb/Rust/src/css/computed_value_types.rsindex 64bafa008a2..18ec62441f3 100644--- a/Libraries/LibWeb/Rust/src/css/computed_value_types.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_value_types.rs@@ -276,6 +276,8 @@ pub const INHERITED_BITS_WORD_BREAK_SHIFT: u32 = 24;pub const INHERITED_BITS_WORD_BREAK_WIDTH: u32 = 2;pub const INHERITED_BITS_TEXT_ALIGN_LAST_SHIFT: u32 = 26;pub const INHERITED_BITS_TEXT_ALIGN_LAST_WIDTH: u32 = 3;+pub const INHERITED_BITS_HYPHENS_SHIFT: u32 = 29;+pub const INHERITED_BITS_HYPHENS_WIDTH: u32 = 2;/// The keywords of few values of properties that do not inherit a style holds as bits in its/// root beside its own groups, in place of fields of its box group: each the code of its keyworddiff --git a/Libraries/LibWeb/Rust/src/css/computed_value_views.rs b/Libraries/LibWeb/Rust/src/css/computed_value_views.rsindex 5501e449fa3..bf4db37025a 100644--- a/Libraries/LibWeb/Rust/src/css/computed_value_views.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_value_views.rs@@ -1080,6 +1080,11 @@ impl<'a> ComputedValuesView<'a> {self.bit(StyleBitField::TextAlignLast)}+ #[inline]+ pub(crate) fn hyphens(self) -> u8 {+ self.bit(StyleBitField::Hyphens)+ }+#[inline]fn bit(self, field: StyleBitField) -> u8 {self.0.0.style_bits().get(field)diff --git a/Libraries/LibWeb/Rust/src/css/computed_values.rs b/Libraries/LibWeb/Rust/src/css/computed_values.rsindex 9607272813f..32066062045 100644--- a/Libraries/LibWeb/Rust/src/css/computed_values.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_values.rs@@ -3302,6 +3302,8 @@ style_bit_fields! {INHERITED_BITS_WORD_BREAK_SHIFT, INHERITED_BITS_WORD_BREAK_WIDTH;Inherited TextAlignLast: TEXT_ALIGN_LAST, text_align_last::AUTO, keyword_to_text_align_last,INHERITED_BITS_TEXT_ALIGN_LAST_SHIFT, INHERITED_BITS_TEXT_ALIGN_LAST_WIDTH;+ Inherited Hyphens: HYPHENS, hyphens::MANUAL, keyword_to_hyphens,+ INHERITED_BITS_HYPHENS_SHIFT, INHERITED_BITS_HYPHENS_WIDTH;Reset Position: POSITION, positioning::STATIC, keyword_to_positioning,RESET_BITS_POSITION_SHIFT, RESET_BITS_POSITION_WIDTH;Reset Float: FLOAT, float::NONE, keyword_to_float,diff --git a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rsindex 061c4ee4676..69628da139d 100644--- a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs@@ -1855,6 +1855,47 @@ impl<'context> InlineFormattingContext<'context> {});}+ /// Splits off the longest prefix of `item` that fits `available` for an overflow break. A prefix that still ends at+ /// the item's soft hyphen ends the line in a hyphen as well, so it has to leave room for `hyphen` too.+ #[allow(clippy::too_many_arguments)]+ fn split_for_overflow_break_before_hyphen(+ &self,+ item: &mut inline_level_iterator::Item,+ prepared: &prepared_inline_content::PreparedInlineContent,+ text: &[u16],+ letter_spacing: f32,+ word_spacing: f32,+ available: CssPixels,+ hyphen: CssPixels,+ line_is_empty: bool,+ ) -> Option<inline_level_iterator::Item> {+ let split = |item: &mut inline_level_iterator::Item, available| {+ self.pass.with_grapheme_segmenter(item.node, |segmenter| {+ item.split_for_overflow_break(+ prepared,+ text,+ segmenter,+ letter_spacing,+ word_spacing,+ available,+ line_is_empty,+ )+ })+ };+ if hyphen > CssPixels::default() {+ let end = item.offset_in_node + item.length_in_node;+ let mut remainder = item.clone();+ if let Some(prefix) = split(&mut remainder, available)+ && prefix.offset_in_node + prefix.length_in_node < end+ {+ *item = remainder;+ return Some(prefix);+ }+ return split(item, available - hyphen);+ }+ split(item, available)+ }+#[allow(clippy::too_many_arguments)]fn break_soft_wrapped_text_item<'builder>(&'builder self,@@ -1867,7 +1908,15 @@ impl<'context> InlineFormattingContext<'context> {state_at_clamp_point: &mut Option<LineBuildingState<'builder, 'context>>,) -> bool {let prepared = iterator.prepared_content();- let following_inline_size = iterator.inline_size_following_text(self, item);+ let mut following_inline_size = iterator.inline_size_following_text(self, item);+ // NB: Where nothing glued follows an item that ends in a soft hyphen, the line ends in that hyphen if the next+ // run doesn't fit after the item.+ if following_inline_size == CssPixels::default()+ && let Some(remaining) = line_builder.remaining_inline_size_for_soft_wrap()+ && inline_level_iterator::inline_extent([&*item]) + iterator.next_line_content_inline_size(self) > remaining+ {+ following_inline_size = inline_level_iterator::hyphen_inline_size_after(self, prepared, item);+ }if line_builder.remaining_inline_size_for_soft_wrap().is_none_or(|remaining| inline_level_iterator::inline_extent([&*item]) + following_inline_size <= remaining)@@ -1906,24 +1955,29 @@ impl<'context> InlineFormattingContext<'context> {word_spacing,remaining,following_inline_size,+ inline_level_iterator::soft_hyphen_hyphenates(style),);- if inline_level_iterator::inline_extent([&prefix]) > remaining {+ let hyphen = if prefix.offset_in_node + prefix.length_in_node == end {+ CssPixels::default()+ } else {+ inline_level_iterator::hyphen_inline_size_after(self, prepared, &prefix)+ };+ if inline_level_iterator::inline_extent([&prefix]) + hyphen > remaining {if overflow_break_allowed {let physical_remaining = line_builder.remaining_inline_size_for_overflow_break().expect("splitting text requires a definite line width");- if prefix.border_box_inline_size() > physical_remaining {- let split = self.pass.with_grapheme_segmenter(item.node, |segmenter| {- prefix.split_for_overflow_break(- prepared,- &text_content.text,- segmenter,- letter_spacing,- word_spacing,- physical_remaining,- line_is_empty,- )- });+ if prefix.border_box_inline_size() + hyphen > physical_remaining {+ let split = self.split_for_overflow_break_before_hyphen(+ &mut prefix,+ prepared,+ &text_content.text,+ letter_spacing,+ word_spacing,+ physical_remaining,+ hyphen,+ line_is_empty,+ );if let Some(split) = split {prefix = split;} else if !line_is_empty {@@ -1994,7 +2048,18 @@ impl<'context> InlineFormattingContext<'context> {let Some(remaining_inline_size) = line_builder.remaining_inline_size_for_overflow_break() else {return false;};- if item.border_box_inline_size() <= remaining_inline_size {+ // NB: An item that ends in a soft hyphen ends the line in a hyphen if the run after it doesn't fit there too.+ let hyphen = match inline_level_iterator::hyphen_inline_size_after(self, prepared, item) {+ hyphen+ if hyphen > CssPixels::default()+ && item.border_box_inline_size() + iterator.next_line_content_inline_size(self)+ > remaining_inline_size =>+ {+ hyphen+ }+ _ => CssPixels::default(),+ };+ if item.border_box_inline_size() + hyphen <= remaining_inline_size {return false;}if !self.overflow_break_applies_to_style(style) {@@ -2006,17 +2071,16 @@ impl<'context> InlineFormattingContext<'context> {line_builder.break_line(line_builder::ForcedBreak::No, None, None);continue;}- let split_item = self.pass.with_grapheme_segmenter(item.node, |grapheme_segmenter| {- item.split_for_overflow_break(- prepared,- &text_content.text,- grapheme_segmenter,- letter_spacing,- word_spacing,- remaining_inline_size,- line_is_empty,- )- });+ let split_item = self.split_for_overflow_break_before_hyphen(+ item,+ prepared,+ &text_content.text,+ letter_spacing,+ word_spacing,+ remaining_inline_size,+ hyphen,+ line_is_empty,+ );let Some(mut prefix) = split_item else {if line_is_empty {return false;@@ -4080,6 +4144,22 @@ impl ContentSizingLines {} else {CssPixels::default()};+ // NB: Min-content breaks at every soft wrap opportunity, so content that ends in a soft hyphen ends+ // its line in a hyphen wherever the content after it can start a line. And min-content breaks+ // before every atomic inline in a container that wraps, as append_atomic_inline() does.+ let next_content = remaining_items.iter().find(|next| {+ !matches!(+ next.type_,+ inline_level_iterator::ItemType::InlineEdge+ | inline_level_iterator::ItemType::AbsolutelyPositionedElement+ | inline_level_iterator::ItemType::FloatingElement+ )+ });+ let breaks_after_item = next_content.is_some_and(|next| match next.type_ {+ inline_level_iterator::ItemType::Text => next.can_break_before,+ inline_level_iterator::ItemType::Element => self.container_wraps,+ _ => false,+ });if style.text_wrap_mode() == text_wrap_mode::WRAP {let is_whitespace = item.is_collapsible_whitespace || item.is_ascii_whitespace(context);let breaks_between_graphemes = !is_whitespace && breaks_between_graphemes(style);@@ -4134,6 +4214,8 @@ impl ContentSizingLines {&text.text,style.letter_spacing().to_double() as f32,style.word_spacing().to_double() as f32,+ inline_level_iterator::soft_hyphen_hyphenates(style),+ breaks_after_item,);let last_index = sizes.len() - 1;for (index, size) in sizes.into_iter().enumerate() {@@ -4160,8 +4242,13 @@ impl ContentSizingLines {{self.lines.finish();}+ let hyphen = if self.measures_min_content() && breaks_after_item {+ inline_level_iterator::hyphen_inline_size_after(context, prepared, item)+ } else {+ CssPixels::default()+ };self.lines.append(- border_box_inline_size,+ border_box_inline_size + hyphen,item.ends_in_ascii_space(context),trailing_whitespace_inline_size,);diff --git a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rsindex 4d0a919778c..87f80945496 100644--- a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs+++ b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs@@ -61,9 +61,9 @@ pub(crate) struct Item {const _: () = assert!(size_of::<Item>() == 96);#[derive(Clone, Debug)]-struct OwnedGlyphRun {- glyphs: libgfx_rust::text_layout::GlyphBuffer,- width: f32,+pub(crate) struct OwnedGlyphRun {+ pub(crate) glyphs: libgfx_rust::text_layout::GlyphBuffer,+ pub(crate) width: f32,is_upright: bool,}@@ -133,6 +133,54 @@ fn reshaped_glyph_run(}}+/// The hyphen that ends a line broken after a soft hyphen: U+2010 HYPHEN where the font has a glyph for it, and U+002D+/// HYPHEN-MINUS otherwise.+// https://drafts.csswg.org/css-text-4/#valdef-hyphenate-character-auto+pub(crate) fn hyphen_glyph_run(+ font: &libgfx_rust::font::FontHandle,+ text_type: u8,+ letter_spacing: f32,+ word_spacing: f32,+) -> OwnedGlyphRun {+ let hyphen = [if font.contains_glyph(0x2010) { 0x2010 } else { 0x2d }];+ reshaped_glyph_run(&hyphen, 0..1, font, text_type, letter_spacing, word_spacing)+}++/// Whether a line that breaks after a soft hyphen in text of this style ends in a hyphen.+pub(crate) fn soft_hyphen_hyphenates(style: StyleValues<'_>) -> bool {+ // https://drafts.csswg.org/css-text-3/#valdef-word-break-break-all+ // Hyphenation is not applied.+ style.hyphens() != hyphens::NONE && style.word_break() != word_break::BREAK_ALL+}++/// The inline size of the hyphen that a line ends in if it breaks right after `item`: none, unless the item's text ends+/// in a soft hyphen that its hyphens lets the line break after.+pub(crate) fn hyphen_inline_size_after(+ context: &inline_formatting_context::InlineFormattingContext<'_>,+ prepared: &PreparedInlineContent,+ item: &Item,+) -> CssPixels {+ if item.type_ != ItemType::Text || item.length_in_node == 0 {+ return CssPixels::default();+ }+ let text_content = context.pass.text_content(item.node);+ if !text_chunker::breaks_at_soft_hyphen(&text_content.text, item.offset_in_node + item.length_in_node) {+ return CssPixels::default();+ }+ let style = context.style(context.style_source(item.node));+ if !soft_hyphen_hyphenates(style) {+ return CssPixels::default();+ }+ let prepared_item = item.prepared_item(prepared);+ let run = hyphen_glyph_run(+ prepared.font_of(prepared_item),+ prepared_item.text_type(),+ style.letter_spacing().to_double() as f32,+ style.word_spacing().to_double() as f32,+ );+ CssPixels::nearest_value_for_f32(run.width)+}+/// 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@@ -425,13 +473,17 @@ impl Item {text: &[u16],letter_spacing: f32,word_spacing: f32,+ hyphenates: bool,+ breaks_after_item: bool,) -> Vec<CssPixels> {+ let item_end = self.offset_in_node + self.length_in_node;let mut start = self.offset_in_node;let item = self.prepared_item(prepared);+ let mut hyphen_width = None;self.soft_wrap_offsets(prepared).chain(std::iter::once(start + self.length_in_node)).map(|end| {- let width = libgfx_rust::text_layout::shaped_text_width(+ let mut width = libgfx_rust::text_layout::shaped_text_width(prepared.font_of(item),&text[start..end],libgfx_rust::text_layout::TextType::try_from(item.text_type())@@ -440,6 +492,17 @@ impl Item {word_spacing,text_chunker::joining_context(text, start..end),);+ // NB: A segment that ends in a soft hyphen ends its line in a hyphen, unless it ends the item and no break+ // follows the item.+ if hyphenates+ && end > start+ && (end < item_end || breaks_after_item)+ && text_chunker::breaks_at_soft_hyphen(text, end)+ {+ width += *hyphen_width.get_or_insert_with(|| {+ hyphen_glyph_run(prepared.font_of(item), item.text_type(), letter_spacing, word_spacing).width+ });+ }start = end;CssPixels::nearest_value_for_f32(width)})@@ -510,9 +573,11 @@ impl Item {word_spacing: f32,available: CssPixels,following_inline_size: CssPixels,+ hyphenates: bool,) -> Item {let end = self.offset_in_node + self.length_in_node;let mut chosen = None;+ let mut hyphen_inline_size = None;for offset in self.soft_wrap_offsets_after(prepared, start).chain(std::iter::once(end))@@ -520,6 +585,18 @@ impl Item {let fragment = self.reshaped_fragment(prepared, text, start..offset, letter_spacing, word_spacing);let following = if offset == end {following_inline_size+ } else if hyphenates && text_chunker::breaks_at_soft_hyphen(text, offset) {+ // NB: A line that breaks after a soft hyphen ends in a hyphen, which has to fit too.+ *hyphen_inline_size.get_or_insert_with(|| {+ let prepared_item = self.prepared_item(prepared);+ let run = hyphen_glyph_run(+ prepared.font_of(prepared_item),+ prepared_item.text_type(),+ letter_spacing,+ word_spacing,+ );+ CssPixels::nearest_value_for_f32(run.width)+ })} else {CssPixels::default()};@@ -1519,6 +1596,9 @@ impl<'pass> InlineContentPreparer<'pass> {} else {text_chunker::LineBreakLanguage::Other};+ // NB: A soft hyphen ending the previous text is a hyphenation opportunity of that text, by its own style.+ let breaks_after_soft_hyphen =+ previous_node.is_none_or(|node| self.style(self.pass.parent(node)).hyphens() != hyphens::NONE);let opportunity_with = |word_break| {text_chunker::soft_wrap_opportunity_between(previous_text,@@ -1528,6 +1608,7 @@ impl<'pass> InlineContentPreparer<'pass> {word_break,style.line_break(),line_break_language,+ breaks_after_soft_hyphen,)};can_break_before = opportunity_with(style.word_break())@@ -2444,6 +2525,32 @@ impl InlineLevelIterator {sequence_inline_size(context, &self.prepared, self.items(), true)}+ /// The inline size of the content that has to fit after the current item for the line not to break there: the+ /// inline box edges up to the next text or atomic inline, past any out-of-flow items, and then the unbreakable run+ /// that text starts, or that atomic inline.+ pub(crate) fn next_line_content_inline_size(+ &self,+ context: &inline_formatting_context::InlineFormattingContext<'_>,+ ) -> CssPixels {+ let items = self.items();+ let start = items+ .iter()+ .position(|item| !sits_between_line_content(item))+ .unwrap_or(items.len());+ let edges = sequence_inline_extent(+ context,+ items[..start].iter().filter(|item| item.type_ == ItemType::InlineEdge),+ );+ let content = match items.get(start) {+ Some(item) if item.type_ == ItemType::Element => inline_extent([item]),+ Some(item) if item.type_ == ItemType::Text => {+ sequence_inline_size(context, &self.prepared, &items[start..], true).unwrap_or_default()+ }+ _ => CssPixels::default(),+ };+ edges + content+ }+pub(crate) fn unbreakable_run_inline_size(&self,context: &inline_formatting_context::InlineFormattingContext<'_>,@@ -2463,9 +2570,26 @@ impl InlineLevelIterator {.clone().nth(length).map(|item| first_breakable_segment(context, &self.prepared, item, end));- return sequence_inline_extent(context, items.take(length).chain(first_grapheme_cluster.as_ref()));+ let hyphen = hyphen_ending_sequence(+ context,+ &self.prepared,+ end,+ first_grapheme_cluster.as_ref(),+ None,+ false,+ );+ return sequence_inline_extent(context, items.take(length).chain(first_grapheme_cluster.as_ref())) + hyphen;}- sequence_inline_extent(context, items.take(length.max(1)))+ let length = length.max(1);+ let hyphen = hyphen_ending_sequence(+ context,+ &self.prepared,+ end,+ None,+ last_line_content(items.clone().take(length)),+ starts_line_content(items.clone().skip(length)),+ );+ sequence_inline_extent(context, items.take(length)) + hyphen}pub(crate) fn inline_size_following_text(@@ -2477,7 +2601,20 @@ impl InlineLevelIterator {let (length, end) = sequence_length(context, &self.prepared, items.clone(), false, true);let prefix = (end == SequenceEnd::SoftWrapInText).then(|| first_breakable_segment(context, &self.prepared, self.items().get(length - 1).unwrap(), end));- sequence_inline_extent(context, items.take(length).chain(prefix.as_ref())) - inline_extent([item])+ // NB: The following text ends in a hyphen where it ends at a soft hyphen that a line can break after.+ let hyphen = if prefix.is_some() || length > 1 {+ hyphen_ending_sequence(+ context,+ &self.prepared,+ end,+ prefix.as_ref(),+ last_line_content(items.clone().take(length)),+ starts_line_content(items.clone().skip(length)),+ )+ } else {+ CssPixels::default()+ };+ sequence_inline_extent(context, items.take(length).chain(prefix.as_ref())) + hyphen - inline_extent([item])}pub(crate) fn next_non_whitespace_text_allows_overflow_break(@@ -2520,7 +2657,15 @@ pub(crate) fn whitespace_and_sequence_inline_size(.chain(&items[..length]).chain(prefix.as_ref()),);- (size > inline_extent([whitespace])).then_some(size)+ let hyphen = hyphen_ending_sequence(+ context,+ prepared,+ end,+ prefix.as_ref(),+ last_line_content(items[..length].iter()),+ starts_line_content(items[length..].iter()),+ );+ (size > inline_extent([whitespace])).then_some(size + hyphen)}pub(crate) fn sequence_inline_size(@@ -2533,7 +2678,63 @@ pub(crate) fn sequence_inline_size(let first_grapheme_cluster = matches!(end, SequenceEnd::OverflowBreakableText | SequenceEnd::SoftWrapInText).then(|| first_breakable_segment(context, prepared, &items[length], end));let size = sequence_inline_extent(context, items[..length].iter().chain(first_grapheme_cluster.as_ref()));- (end == SequenceEnd::ForcedBreak || size > CssPixels::default()).then_some(size)+ let hyphen = hyphen_ending_sequence(+ context,+ prepared,+ end,+ first_grapheme_cluster.as_ref(),+ last_line_content(items[..length].iter()),+ starts_line_content(items[length..].iter()),+ );+ (end == SequenceEnd::ForcedBreak || size > CssPixels::default()).then_some(size + hyphen)+}++/// Whether `item` sits between the text and atomic inlines of a line without being line content of its own: an+/// out-of-flow item or an inline box edge.+fn sits_between_line_content(item: &Item) -> bool {+ matches!(+ item.type_,+ ItemType::InlineEdge | ItemType::AbsolutelyPositionedElement | ItemType::FloatingElement+ )+}++/// The last text or atomic inline of a measured run, which a hyphen after the run follows, past any out-of-flow items+/// and inline box edges after it.+fn last_line_content<'item>(items: impl Iterator<Item = &'item Item>) -> Option<&'item Item> {+ items.filter(|item| !sits_between_line_content(item)).last()+}++/// Whether the content after a measured run can start a line there: Out-of-flow items and inline box edges sit between+/// them without a line of their own, so the next text or atomic inline after them decides.+fn starts_line_content<'item>(mut items: impl Iterator<Item = &'item Item>) -> bool {+ items+ .find(|item| !sits_between_line_content(item))+ .is_some_and(|item| match item.type_ {+ ItemType::Text => item.can_break_before,+ ItemType::Element => true,+ _ => false,+ })+}++/// The inline size of the hyphen that a measured run ends in, where a line can break at its end after a soft hyphen:+/// a soft wrap inside a text item, which ends `segment`, or the start of content that can begin a line, which follows+/// `last_item`.+fn hyphen_ending_sequence(+ context: &inline_formatting_context::InlineFormattingContext<'_>,+ prepared: &PreparedInlineContent,+ end: SequenceEnd,+ segment: Option<&Item>,+ last_item: Option<&Item>,+ next_starts_line: bool,+) -> CssPixels {+ let item = match end {+ SequenceEnd::SoftWrapInText => segment,+ SequenceEnd::Other if next_starts_line => last_item,+ _ => None,+ };+ item.map_or(CssPixels::default(), |item| {+ hyphen_inline_size_after(context, prepared, item)+ })}#[derive(Clone, Copy, PartialEq)]diff --git a/Libraries/LibWeb/Rust/src/layout/line_box.rs b/Libraries/LibWeb/Rust/src/layout/line_box.rsindex 9d9d852dd1f..1bc33f2d98d 100644--- a/Libraries/LibWeb/Rust/src/layout/line_box.rs+++ b/Libraries/LibWeb/Rust/src/layout/line_box.rs@@ -24,6 +24,8 @@ pub(crate) struct StaticPositionMarker {pub(crate) block_offset: CssPixels,pub(crate) writing_mode: u8,pub(crate) preceded_by_in_flow_content: bool,+ /// How many fragments the line held when the marker was added, which places it in the line's logical order.+ pub(crate) fragments_before: usize,}impl StaticPositionMarker {@@ -220,6 +222,7 @@ impl LineBoxData {block_offset: CssPixels::default(),writing_mode: self.writing_mode,preceded_by_in_flow_content: !self.fragments.is_empty() || preceded_by_inline_box_start_edges,+ fragments_before: self.fragments.len(),});}diff --git a/Libraries/LibWeb/Rust/src/layout/line_builder.rs b/Libraries/LibWeb/Rust/src/layout/line_builder.rsindex 6262fdee76e..fe41492c0ad 100644--- a/Libraries/LibWeb/Rust/src/layout/line_builder.rs+++ b/Libraries/LibWeb/Rust/src/layout/line_builder.rs@@ -342,6 +342,9 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {line.has_forced_break = forced == ForcedBreak::Yes;line.forced_break = forced_break;}+ if forced == ForcedBreak::No {+ self.hyphenate_end_of_line(line_index);+ }self.last_line_needs_update = true;self.update_last_line(forced == ForcedBreak::No || next_size.is_some());if forced == ForcedBreak::Yes || !self.line(line_index).fragments.is_empty() {@@ -1193,6 +1196,83 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {(0..line_index).any(|index| !self.line(index).is_empty())}+ // https://drafts.csswg.org/css-text-3/#hyphenation+ // When a word is hyphenated, the UA must insert a hyphen [...] at the end of the line.+ /// Shows a hyphen at the end of a line that breaks after a soft hyphen. The hyphen joins the soft hyphen's own+ /// fragment, in its place, so that it takes the soft hyphen's style.+ fn hyphenate_end_of_line(&mut self, line_index: usize) {+ let (fragment_index, hyphen, font, text_type, is_upright, soft_hyphen_offset) = {+ let line = self.line(line_index);+ // NB: Only the empty edges of inline boxes that end after the soft hyphen can follow its fragment. An atomic+ // inline after it means the line broke after that instead.+ let Some(fragment_index) = line.fragments.iter().rposition(|fragment| {+ fragment.glyphs.is_some() || fragment.length_in_code_units != 0 || fragment.is_atomic_inline+ }) else {+ return;+ };+ let fragment = &line.fragments[fragment_index];+ let Some(glyphs) = fragment.glyphs.as_ref() else {+ return;+ };+ let text_content = self.context().pass.text_content(fragment.layout_node);+ if !text_chunker::breaks_at_soft_hyphen(&text_content.text, fragment.start + fragment.length_in_code_units)+ {+ return;+ }+ let style = self.style(fragment.style_source);+ if !inline_level_iterator::soft_hyphen_hyphenates(style) {+ return;+ }+ // NB: The hyphen goes in the direction of the run that ends the fragment, which runs of either direction can+ // share.+ let text_type = if fragment.current_insert_direction == direction::RTL {+ GLYPH_TEXT_TYPE_RTL+ } else {+ GLYPH_TEXT_TYPE_LTR+ };+ let hyphen = inline_level_iterator::hyphen_glyph_run(+ &glyphs.font,+ text_type,+ style.letter_spacing().to_double() as f32,+ style.word_spacing().to_double() as f32,+ );+ (+ fragment_index,+ hyphen,+ glyphs.font.clone(),+ text_type,+ glyphs.is_upright,+ fragment.length_in_code_units - 1,+ )+ };+ let inline_size = CssPixels::nearest_value_for_f32(hyphen.width);+ let mut line = self.line_mut(line_index);+ for fragment in &mut line.fragments[fragment_index + 1..] {+ fragment.inline_offset += inline_size;+ }+ for marker in &mut line.static_position_markers {+ if marker.fragments_before > fragment_index {+ marker.inline_offset += inline_size;+ }+ }+ let fragment = &mut line.fragments[fragment_index];+ fragment.append_glyph_run(+ &line_box_fragment::ItemGlyphRun {+ glyphs: std::borrow::Cow::Borrowed(&hyphen.glyphs),+ font: &font,+ text_type,+ width: hyphen.width,+ is_upright,+ },+ inline_size,+ soft_hyphen_offset,+ );+ if let Some(glyphs) = fragment.glyphs.as_mut() {+ glyphs.width += hyphen.width;+ }+ line.inline_length += inline_size;+ }+pub(crate) fn set_outside_marker_line(&mut self, marker_line: Option<block_formatting_context::OutsideMarkerLine>) {self.outside_marker_line = marker_line;}diff --git a/Libraries/LibWeb/Rust/src/layout/rendered_text.rs b/Libraries/LibWeb/Rust/src/layout/rendered_text.rsindex 7bc8a41c3be..c87cf7e9ac1 100644--- a/Libraries/LibWeb/Rust/src/layout/rendered_text.rs+++ b/Libraries/LibWeb/Rust/src/layout/rendered_text.rs@@ -159,6 +159,7 @@ pub(crate) struct TextChunkCacheKey {pub(crate) word_break: u8,pub(crate) line_break: u8,pub(crate) line_break_language: super::text_chunker::LineBreakLanguage,+ pub(crate) breaks_after_soft_hyphen: bool,pub(crate) font_variant_emoji: u8,/// A frozen cascade only moves when a load fills one of its faces in. The chunks made against it hold it.pub(crate) frozen_font_list: crate::css::style::pointer_key::PointerLookup,@@ -592,6 +593,7 @@ mod tests {word_break: 0,line_break: crate::css::css_enums::line_break::LOOSE,line_break_language: LineBreakLanguage::Japanese,+ breaks_after_soft_hyphen: true,font_variant_emoji: 0,frozen_font_list: crate::css::style::pointer_key::PointerLookup::new(&frozen_font_list, ()),frozen_font_list_fill_generation: 0,@@ -649,6 +651,7 @@ mod tests {word_break: 0,line_break: crate::css::css_enums::line_break::AUTO,line_break_language: crate::layout::text_chunker::LineBreakLanguage::Other,+ breaks_after_soft_hyphen: true,font_variant_emoji: 0,frozen_font_list: crate::css::style::pointer_key::PointerLookup::new(&frozen_font_list, ()),frozen_font_list_fill_generation: 0,diff --git a/Libraries/LibWeb/Rust/src/layout/text_chunker.rs b/Libraries/LibWeb/Rust/src/layout/text_chunker.rsindex 7a6b288d095..c7f0714b39c 100644--- a/Libraries/LibWeb/Rust/src/layout/text_chunker.rs+++ b/Libraries/LibWeb/Rust/src/layout/text_chunker.rs@@ -194,6 +194,18 @@ fn line_break_class(code_point: u32) -> u8 {unicode_layout_line_break_class(code_point)}+pub(crate) const SOFT_HYPHEN: u16 = 0xad;++/// Whether a line that breaks right after `text[..end]` breaks at a soft hyphen there, and so ends in a hyphen: The+/// text has to end in a soft hyphen that no whitespace follows, since the line breaks at that whitespace instead.+pub(crate) fn breaks_at_soft_hyphen(text: &[u16], end: usize) -> bool {+ end > 0+ && text[end - 1] == SOFT_HYPHEN+ && text+ .get(end)+ .is_none_or(|&code_unit| !(code_unit < 0x80 && code_point_is_ascii_space(u32::from(code_unit))))+}+// LibUnicode's JoiningType, in declaration order.mod joining_type {pub(super) const NON_JOINING: u8 = 0;@@ -398,6 +410,8 @@ pub(crate) struct TextChunkInputs<'text> {pub word_break: u8,pub line_break: u8,pub line_break_language: LineBreakLanguage,+ /// Whether a soft hyphen (U+00AD) gives a soft wrap opportunity after it, which it does unless hyphens is none.+ pub breaks_after_soft_hyphen: bool,pub font_variant_emoji: u8,pub should_wrap_lines: bool,pub should_respect_linebreaks: bool,@@ -862,6 +876,7 @@ pub(crate) fn trailing_regional_indicator_count(text: &[u16]) -> usize {/// of two text nodes that follow each other on a line. `code_unit_before` is the last code unit of the text before/// `before`, if any. `regional_indicators_before` is the number of regional indicators that end `before`, including/// any in text before it.+#[allow(clippy::too_many_arguments)]pub(crate) fn soft_wrap_opportunity_between(before: &[u16],after: &[u16],@@ -870,10 +885,14 @@ pub(crate) fn soft_wrap_opportunity_between(word_break: u8,line_break: u8,line_break_language: LineBreakLanguage,+ breaks_after_soft_hyphen: bool,) -> bool {let (Some(&last), Some(&first)) = (before.last(), after.first()) else {return false;};+ if last == SOFT_HYPHEN && !breaks_after_soft_hyphen {+ return false;+ }// NB: Whitespace gives its own soft wrap opportunities.if (last <= 0x7f && code_point_is_ascii_space(u32::from(last)))|| (first <= 0x7f && code_point_is_ascii_space(u32::from(first)))@@ -919,7 +938,14 @@ pub(crate) fn soft_wrap_opportunity_between(if GraphemeSegmenter::new(&text).next_boundary(boundary, true) != Some(boundary) {return false;}- LineBreaker::new(&text, word_break, line_break, line_break_language).is_at_line_break_opportunity(boundary)+ LineBreaker::new(+ &text,+ word_break,+ line_break,+ line_break_language,+ breaks_after_soft_hyphen,+ )+ .is_at_line_break_opportunity(boundary)}/// Whether there is a soft wrap opportunity between an atomic inline and the text after it.@@ -1001,19 +1027,32 @@ struct LineBreaker<'text> {line_segmenter: LineSegmenter<'text>,word_break: u8,line_break: u8,+ breaks_after_soft_hyphen: bool,}impl<'text> LineBreaker<'text> {- fn new(text: &'text [u16], word_break: u8, line_break: u8, line_break_language: LineBreakLanguage) -> Self {+ fn new(+ text: &'text [u16],+ word_break: u8,+ line_break: u8,+ line_break_language: LineBreakLanguage,+ breaks_after_soft_hyphen: bool,+ ) -> Self {Self {text,line_segmenter: LineSegmenter::new(text, line_break, line_break_language),word_break,line_break,+ breaks_after_soft_hyphen,}}fn is_at_line_break_opportunity(&self, index: usize) -> bool {+ // https://drafts.csswg.org/css-text-3/#valdef-hyphens-none+ // Words are not hyphenated, even if characters inside the word explicitly define hyphenation opportunities.+ if !self.breaks_after_soft_hyphen && index > 0 && self.text.get(index - 1) == Some(&SOFT_HYPHEN) {+ return false;+ }let get_previous_code_point = || -> Option<u32> {if index == 0 {return None;@@ -1126,6 +1165,7 @@ impl<'text> TextChunker<'text> {inputs.word_break,inputs.line_break,inputs.line_break_language,+ inputs.breaks_after_soft_hyphen,),font_variant_emoji: inputs.font_variant_emoji,should_collapse_whitespace: matches!(@@ -1547,6 +1587,7 @@ pub(crate) fn text_chunks(} else {LineBreakLanguage::Other},+ breaks_after_soft_hyphen: parent_style.hyphens() != hyphens::NONE,font_variant_emoji: parent_style.font_variant_emoji(),frozen_font_list: crate::css::style::pointer_key::PointerLookup::new(counted_frozen_font_list, ()),frozen_font_list_fill_generation: frozen_font_list.fill_generation(),@@ -1565,6 +1606,7 @@ pub(crate) fn text_chunks(word_break: key.word_break,line_break: key.line_break,line_break_language: key.line_break_language,+ breaks_after_soft_hyphen: key.breaks_after_soft_hyphen,font_variant_emoji: key.font_variant_emoji,should_wrap_lines,should_respect_linebreaks,diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-auto-010H-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-auto-010H-ref.htmlnew file mode 100644index 00000000000..6d453b9560b--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-auto-010H-ref.html@@ -0,0 +1,29 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Reference Test</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ width: 6ch;+ }+ </style>++ <body lang="en">++ <div>regu‐<br>lation<br>imple‐<br>menta‐<br>tion<br>now</div>++<!--++ Hyphen-minus == - == -++ Hyphen == ‐ == ‐++-->diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-auto-010M-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-auto-010M-ref.htmlnew file mode 100644index 00000000000..27adc3f08f5--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-auto-010M-ref.html@@ -0,0 +1,29 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Reference Test</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ width: 6ch;+ }+ </style>++ <body lang="en">++ <div>regu-<br>lation<br>imple-<br>menta-<br>tion<br>now</div>++<!--++ Hyphen-minus == - == -++ Hyphen == ‐ == ‐++-->diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-010-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-010-ref.htmlnew file mode 100644index 00000000000..f79ce17a4c7--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-010-ref.html@@ -0,0 +1,27 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Reference Test</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ hyphens: none;+ margin-bottom: 0.25em;+ width: 10ch;+ }+ </style>++ <body lang="en">++ <p>Test passes if the characters inside of each black-bordered rectangles are laid out identically. Only "ucleic" should be outside of the black-bordered rectangles.++ <div>Deoxyribonucleic acid</div>++ <div>Deoxyribonucleic acid</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-011H-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-011H-ref.htmlnew file mode 100644index 00000000000..99612206f8e--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-011H-ref.html@@ -0,0 +1,27 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Reference Test</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ width: 10ch;+ }+ </style>++ <div>Deoxyribo‐<br>nucleic acid</div>++<!--++ Hyphen-minus == - == -++ Hyphen == ‐ == ‐++-->diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-011M-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-011M-ref.htmlnew file mode 100644index 00000000000..191095a413b--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-011M-ref.html@@ -0,0 +1,27 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Reference Test</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ width: 10ch;+ }+ </style>++ <div>Deoxyribo-<br>nucleic acid</div>++<!--++ Hyphen-minus == - == -++ Hyphen == ‐ == ‐++-->diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-013H-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-013H-ref.htmlnew file mode 100644index 00000000000..12ad0ed5059--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-013H-ref.html@@ -0,0 +1,27 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Reference Test</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ width: 10ch;+ }+ </style>++ <div>Deoxy‐<br>ribonucleic acid</div>++<!--++ Hyphen-minus == - == -++ Hyphen == ‐ == ‐++-->diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-013M-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-013M-ref.htmlnew file mode 100644index 00000000000..3c7121242b7--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-013M-ref.html@@ -0,0 +1,27 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Reference Test</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ width: 10ch;+ }+ </style>++ <div>Deoxy-<br>ribonucleic acid</div>++<!--++ Hyphen-minus == - == -++ Hyphen == ‐ == ‐++-->diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-010-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-010-ref.htmlnew file mode 100644index 00000000000..a55fe859ff2--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-010-ref.html@@ -0,0 +1,27 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Reference Test</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ hyphens: none;+ margin-bottom: 0.25em;+ width: 10ch;+ }+ </style>++ <body lang="en">++ <p>Test passes if the characters inside of each black-bordered rectangles are laid out identically. Only "ucleic" should be outside of the black-bordered rectangles.++ <div>DNA means Deoxyribonucleic acid.</div>++ <div>DNA means Deoxyribonucleic acid.</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-011H-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-011H-ref.htmlnew file mode 100644index 00000000000..0cd1ef9f9b3--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-011H-ref.html@@ -0,0 +1,27 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Reference Test</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ width: 10ch;+ }+ </style>++ <div>DNA means<br>Deoxyribo‐<br>nucleic<br>acid.</div>++<!--++ Hyphen-minus == - == -++ Hyphen == ‐ == ‐++-->diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-011M-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-011M-ref.htmlnew file mode 100644index 00000000000..836919648e7--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-011M-ref.html@@ -0,0 +1,27 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Reference Test</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ width: 10ch;+ }+ </style>++ <div>DNA means<br>Deoxyribo-<br>nucleic<br>acid.</div>++<!--++ Hyphen-minus == - == -++ Hyphen == ‐ == ‐++-->diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-012H-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-012H-ref.htmlnew file mode 100644index 00000000000..8b2ff04ade5--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-012H-ref.html@@ -0,0 +1,27 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Reference Test</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ width: 8ch;+ }+ </style>++ <div>DNA<br>means<br>Deoxy‐<br>ribonu‐<br>cleic<br>acid.</div>++<!--++ Hyphen-minus == - == -++ Hyphen == ‐ == ‐++-->diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-012M-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-012M-ref.htmlnew file mode 100644index 00000000000..0c8db033c8b--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-012M-ref.html@@ -0,0 +1,27 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Reference Test</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ width: 8ch;+ }+ </style>++ <div>DNA<br>means<br>Deoxy-<br>ribonu-<br>cleic<br>acid.</div>++<!--++ Hyphen-minus == - == -++ Hyphen == ‐ == ‐++-->diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-none-shy-on-2nd-line-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-none-shy-on-2nd-line-001-ref.htmlnew file mode 100644index 00000000000..932330e927a--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-none-shy-on-2nd-line-001-ref.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<style>+.target {+ width: 10ch;+}+</style>+<div class="target">+ 12345678+ Deoxyribonucleic+ Deoxyribonucleic+ 12345678+</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-overflow-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-overflow-001-ref.htmlnew file mode 100644index 00000000000..d9d2f7ac6d6--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-overflow-001-ref.html@@ -0,0 +1,21 @@+<!DOCTYPE html>+<link rel="stylesheet" type="text/css" href="../../../../fonts/ahem.css" />+<style>+div {+ font-size: 10px;+ font-family: Ahem;+ width: 5.1ch;+ border: 1px solid blue;+}+</style>+<body>+ <div>12 4-<br>xx</div>+ <div>12<br>45xx</div>+ <div>12<br>456xx</div>+ <div>1234-<br>xx</div>+ <div>12345-<br>xx</div>+ <div>123456-<br>xx</div>++ <div style="width: 10ch">renfor-<br>cer99999</div>+ <div>00-<br>1222</div>+</body>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-shaping-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-shaping-002-ref.htmlnew file mode 100644index 00000000000..d8e31d71e4b--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-shaping-002-ref.html@@ -0,0 +1,6 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Text level 3 Test reference</title>+<link rel="author" title="Florian Rivoal" href="https://florian.rivoal.net/">++<p>Test passes if there is something below:diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-span-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-span-001-ref.htmlnew file mode 100644index 00000000000..cbe37261375--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-span-001-ref.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Text Test reference</title>+<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">+<style>+div {+ border: solid orange;+ margin: 5px;+ width: 6ch;+ hyphens: manual;+}+</style>++<p>Test passes if the text in all orange boxes below is identical (including the presence and position of a hyphen).++<div>high­way</div>+<div>high­way</div>+<div>high­way</div>+<div>high­way</div>+<div>high­way</div>+<div>high­way</div>+<div>high­way</div>+<div>high­way</div>+<div>high­way</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-span-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-span-002-ref.htmlnew file mode 100644index 00000000000..7b3f8206417--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/hyphens-span-002-ref.html@@ -0,0 +1,22 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Text Test reference</title>+<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">+<style>+div {+ border: solid orange;+ margin: 5px;+ width: 6ch;+ hyphens: auto;+}+</style>++<p>Test passes if the text in all orange boxes below is identical (including the presence and position of a hyphen).++<div lang=en>highway</div>+<div lang=en>highway</div>+<div lang=en>highway</div>+<div lang=en>highway</div>+<div lang=en>highway</div>+<div lang=en>highway</div>+<div lang=en>highway</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/shy-styling-001-alt-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/shy-styling-001-alt-ref.htmlnew file mode 100644index 00000000000..c86cb500286--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/shy-styling-001-alt-ref.html@@ -0,0 +1,15 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>test reference</title>+<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">+<style>+span {+ font-size: 3em;+ color: red;+ text-shadow: 3px 3px 3px black;+}+</style>++<p>Test passes if the word “example” below is hyphenated, and the hyphen is large, red, and has a shadow++<div>ex<span>‐</span><br>ample</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/shy-styling-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/shy-styling-001-ref.htmlnew file mode 100644index 00000000000..ad9df16e35d--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/hyphens/reference/shy-styling-001-ref.html@@ -0,0 +1,15 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>test reference</title>+<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">+<style>+span {+ font-size: 3em;+ color: red;+ text-shadow: 3px 3px 3px black;+}+</style>++<p>Test passes if the word “example” below is hyphenated, and the hyphen is large, red, and has a shadow++<div>ex<span>-</span><br>ample</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/fonts/noto/NotoNaskhArabic-regular.woff2 b/Tests/LibWeb/Ref/expected/wpt-import/fonts/noto/NotoNaskhArabic-regular.woff2new file mode 100644index 00000000000..e24020d46a4Binary files /dev/null and b/Tests/LibWeb/Ref/expected/wpt-import/fonts/noto/NotoNaskhArabic-regular.woff2 differdiff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-010.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-010.htmlnew file mode 100644index 00000000000..26b3ff2dae2--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-010.html@@ -0,0 +1,46 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Text: 'hyphens: manual' with no explicit hyphenation opportunity (basic)</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">+ <link rel="help" href="https://www.w3.org/TR/css-text-3/#hyphenation">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-010-ref.html">++ <meta content="When 'hyphens' is set to 'manual', then words can be hyphenated only if characters inside the words explicitly define hyphenation opportunities. In this test, the characters inside the word 'Deoxyribonucleic' do not explicitly define hyphenation opportunities, so it must not be hyphenated." name="assert">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ margin-bottom: 0.25em;+ width: 10ch;+ }++ div#test+ {+ hyphens: manual;+ }++ div#reference+ {+ hyphens: none;+ }+ </style>++ <body lang="en">++ <p>Test passes if the characters inside of each black-bordered rectangles are laid out identically. Only "ucleic" should be outside of the black-bordered rectangles.++ <div id="test">Deoxyribonucleic acid</div>++ <div id="reference">Deoxyribonucleic acid</div>++ <!--++ Extended form of abreviation DNA++ -->diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-011.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-011.htmlnew file mode 100644index 00000000000..2a4c27a9414--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-011.html@@ -0,0 +1,48 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Text: 'hyphens: manual' with 2 explicit hyphenation opportunities</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">+ <link rel="help" href="https://www.w3.org/TR/css-text-3/#hyphenation">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-011M-ref.html">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-011H-ref.html">++ <!--+ User agents may use U+2010 HYPHEN <https://codepoints.net/U+2010>+ when the font has the glyph, or+ may use U+002D HYPHEN-MINUS <https://codepoints.net/U+002d>+ otherwise. Some fonts will display slightly different glyphs for+ these code points. Therefore these 2 reference files.+ The M-ref.html reference file means the hyphen-Minus character U+002D.+ The H-ref.html reference file means the Hyphen character U+2010.+ -->++ <meta content="When 'hyphens' is set to 'manual', then words can be hyphenated only if characters inside the words explicitly define hyphenation opportunities. In this test, the characters inside the word 'Deoxyribonucleic' explicitly define 2 hyphenation opportunities, so it can be hyphenated. Since 9 characters can all fit inside the line box of the block box, then the word 'Deoxyribonucleic' is hyphenated only after the 2nd soft hyphen." name="assert">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ hyphens: manual;+ width: 10ch;+ }+ </style>++ <div>Deoxy­ribo­nucleic acid</div>++ <!--+ Expected result:+ Deoxyribo-+ nucleic+ acid+ -->++ <!--++ Extended form of abreviation DNA++ -->diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-012.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-012.htmlnew file mode 100644index 00000000000..17e71a12bae--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-012.html@@ -0,0 +1,48 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Text: 'hyphens: manual' with 4 explicit hyphenation opportunities</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">+ <link rel="help" href="https://www.w3.org/TR/css-text-3/#hyphenation">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-011M-ref.html">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-011H-ref.html">++ <!--+ User agents may use U+2010 HYPHEN <https://codepoints.net/U+2010>+ when the font has the glyph, or+ may use U+002D HYPHEN-MINUS <https://codepoints.net/U+002d>+ otherwise. Some fonts will display slightly different glyphs for+ these code points. Therefore these 2 reference files.+ The M-ref.html reference file means the hyphen-Minus character U+002D.+ The H-ref.html reference file means the Hyphen character U+2010.+ -->++ <meta content="When 'hyphens' is set to 'manual', then words can be hyphenated only if characters inside the words explicitly define hyphenation opportunities. In this test, the characters inside the word 'Deoxyribonucleic' explicitly define 4 hyphenation opportunities. Since 9 characters can all fit inside the line box of the block box, then the word 'Deoxyribonucleic' is hyphenated only after the 3rd soft hyphen." name="assert">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ hyphens: manual;+ width: 10ch;+ }+ </style>++ <div>Deo­xy­ribo­nu­cleic acid</div>++ <!--+ Expected result:+ Deoxyribo-+ nucleic+ acid+ -->++ <!--++ Extended form of abreviation DNA++ -->diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-013.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-013.htmlnew file mode 100644index 00000000000..569c492bfe2--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-013.html@@ -0,0 +1,48 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Text: 'hyphens: manual' with 1 explicit hyphenation opportunity</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">+ <link rel="help" href="https://www.w3.org/TR/css-text-3/#hyphenation">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-013M-ref.html">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-013H-ref.html">++ <!--+ User agents may use U+2010 HYPHEN <https://codepoints.net/U+2010>+ when the font has the glyph, or+ may use U+002D HYPHEN-MINUS <https://codepoints.net/U+002d>+ otherwise. Some fonts will display slightly different glyphs for+ these code points. Therefore these 2 reference files.+ The M-ref.html reference file means the hyphen-Minus character U+002D.+ The H-ref.html reference file means the Hyphen character U+2010.+ -->++ <meta content="When 'hyphens' is set to 'manual', then words can be hyphenated only if characters inside the words explicitly define hyphenation opportunities. In this test, the characters inside the word 'Deoxyribonucleic' explicitly define 1 and only 1 hyphenation opportunity, so it can be hyphenated only at such point." name="assert">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ hyphens: manual;+ width: 10ch;+ }+ </style>++ <div>Deoxy­ribonucleic acid</div>++ <!--+ Expected result:+ Deoxy-+ ribonucleic+ acid+ -->++ <!--++ Extended form of abreviation DNA++ -->diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-inline-010.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-inline-010.htmlnew file mode 100644index 00000000000..71a13169ea7--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-inline-010.html@@ -0,0 +1,40 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Text: 'hyphens: manual' with no explicit hyphenation opportunity (basic)</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">+ <link rel="help" href="https://www.w3.org/TR/css-text-3/#hyphenation">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-010-ref.html">++ <meta content="When 'hyphens' is set to 'manual' and applied to an inline element, then words can be hyphenated only if characters inside the words explicitly define hyphenation opportunities. In this test, the characters inside the word 'Deoxyribonucleic' do not explicitly define hyphenation opportunities, so it must not be hyphenated." name="assert">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ margin-bottom: 0.25em;+ width: 10ch;+ }++ span#test+ {+ hyphens: manual;+ }++ div#reference+ {+ hyphens: none;+ }+ </style>++ <body lang="en">++ <p>Test passes if the characters inside of each black-bordered rectangles are laid out identically. Only "ucleic" should be outside of the black-bordered rectangles.++ <div>DNA <span id="test">means Deoxyribonucleic acid</span>.</div>++ <div id="reference">DNA means Deoxyribonucleic acid.</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-inline-011.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-inline-011.htmlnew file mode 100644index 00000000000..1c25a31c364--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-inline-011.html@@ -0,0 +1,47 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Text: 'hyphens: manual' with 2 explicit hyphenation opportunities (inline)</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">+ <link rel="help" href="https://www.w3.org/TR/css-text-3/#hyphenation">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-011M-ref.html">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-011H-ref.html">++ <!--+ User agents may use U+2010 HYPHEN <https://codepoints.net/U+2010>+ when the font has the glyph, or+ may use U+002D HYPHEN-MINUS <https://codepoints.net/U+002d>+ otherwise. Some fonts will display slightly different glyphs for+ these code points. Therefore these 2 reference files.+ The M-ref.html reference file means the hyphen-Minus character U+002D.+ The H-ref.html reference file means the Hyphen character U+2010.+ -->++ <meta content="When 'hyphens' is set to 'manual' and applied to an inline element, then words can be hyphenated only if characters inside the words explicitly define hyphenation opportunities. In this test, the characters inside the word 'Deoxyribonucleic' explicitly define 2 hyphenation opportunities, so it can be hyphenated. Since 9 characters can all fit inside the line box of the block box, then the word 'Deoxyribonucleic' is hyphenated only after the 2nd soft hyphen." name="assert">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ width: 10ch;+ }++ span+ {+ hyphens: manual;+ }+ </style>++ <div>DNA <span>means Deoxy­ribo­nucleic acid</span>.</div>++ <!--+ Expected result:+ DNA means+ Deoxyribo-+ nucleic+ acid.+ -->diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-inline-012.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-inline-012.htmlnew file mode 100644index 00000000000..47c66e05bc5--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-manual-inline-012.html@@ -0,0 +1,49 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Text: 'hyphens: manual' with 4 explicit hyphenation opportunities (inline)</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">+ <link rel="help" href="https://www.w3.org/TR/css-text-3/#hyphenation">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-012M-ref.html">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-inline-012H-ref.html">++ <!--+ User agents may use U+2010 HYPHEN <https://codepoints.net/U+2010>+ when the font has the glyph, or+ may use U+002D HYPHEN-MINUS <https://codepoints.net/U+002d>+ otherwise. Some fonts will display slightly different glyphs for+ these code points. Therefore these 2 reference files.+ The M-ref.html reference file means the hyphen-Minus character U+002D.+ The H-ref.html reference file means the Hyphen character U+2010.+ -->++ <meta content="When 'hyphens' is set to 'manual' and applied to an inline element, then words can be hyphenated only if characters inside the words explicitly define hyphenation opportunities. In this test, the characters inside the word 'Deoxyribonucleic' explicitly define 4 hyphenation opportunities. Since 'Deoxy' has 5 characters and 'Deoxyribo' has 9 characters and since the content width of the block box can take 8 characters, then a soft hyphen will occur after 'Deoxy'. Since 'ribonu' has 6 characters and 'ribonucleic' has 11 characters and since the content width of the block box can take 8 characters, then a soft hyphen will occur after 'ribonu'." name="assert">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ width: 8ch;+ }++ span+ {+ hyphens: manual;+ }+ </style>++ <div>DNA <span>means Deo­xy­ribo­nu­cleic acid</span>.</div>++ <!--+ Expected result:+ DNA+ means+ Deoxy-+ ribonu-+ cleic+ acid.+ -->diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-011.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-011.htmlnew file mode 100644index 00000000000..251684a2516--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-011.html@@ -0,0 +1,41 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Text: 'hyphens: none' with explicit hyphenation opportunities</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">+ <link rel="help" href="https://www.w3.org/TR/css-text-3/#hyphenation">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-manual-010-ref.html">++ <meta content="This test checks that, when 'hyphens' is set to 'none', then long words are not hyphenated, even if characters inside long words explicitly define hyphenation opportunities." name="assert">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ margin-bottom: 0.25em;+ width: 10ch;+ }++ div#test+ {+ hyphens: none;+ }+ </style>++ <body>++ <p>Test passes if the characters inside of each black-bordered rectangles are laid out identically. Only "ucleic" should be outside of the black-bordered rectangles.++ <div id="test">Deoxy­ribo­nucleic acid</div>++ <div id="reference">Deoxyribonucleic acid</div>++ <!--++ Extended form of abreviation DNA++ -->diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-012.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-012.htmlnew file mode 100644index 00000000000..e5924c6e61a--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-012.html@@ -0,0 +1,33 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Text: 'hyphens: none', hyphen-minus character and line wrapping</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">+ <link rel="help" href="https://www.w3.org/TR/css-text-3/#hyphenation">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-auto-010M-ref.html">++ <meta content="This test checks that 'hyphens: none' does not suppress line wrapping after encountering an actual hyphen-minus character (U+002D).">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ hyphens: none;+ width: 6ch;+ }+ </style>++ <div>regu-lation imple-menta-tion now</div>++ <!--+ Expected result:+ regu-+ lation+ imple-+ menta-+ tion+ -->diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-013.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-013.htmlnew file mode 100644index 00000000000..783e28da599--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-013.html@@ -0,0 +1,33 @@+<!DOCTYPE html>++ <meta charset="UTF-8">++ <title>CSS Text: 'hyphens: none', hyphen character and line wrapping</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">+ <link rel="help" href="https://www.w3.org/TR/css-text-3/#hyphenation">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-auto-010H-ref.html">++ <meta content="This test checks that 'hyphens: none' does not suppress line wrapping after encountering an actual hyphen character (U+2010).">++ <style>+ div+ {+ border: black solid 2px;+ font-family: monospace;+ font-size: 32px;+ hyphens: none;+ width: 6ch;+ }+ </style>++ <div>regu‐lation imple‐menta‐tion now</div>++ <!--+ Expected result:+ regu-+ lation+ imple-+ menta-+ tion+ -->diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-014.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-014.htmlnew file mode 100644index 00000000000..29726a0bdb2--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-014.html@@ -0,0 +1,32 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Text level 3 Test: Line breaking with floats and disabled hyphenation </title>+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]"/>+<link rel="help" title="5.4. Hyphenation: the hyphens property" href="https://drafts.csswg.org/css-text-3/#hyphenation">+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-hyphens-none">+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/../../reference/ref-filled-green-100px-square-only.html">+<meta name="assert" content="A span with hypens 'none' is wrapped based on the available space left by a float image.">+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />+<style>+div { font: 20px/1 Ahem; }+img { float:right; }+.test {+ max-width: 100px;+ color: green;+}+span { hyphens: none; }+.ref {+ position: absolute;+ background: green linear-gradient(red, red) 2ch 0/3ch 3ch no-repeat;+ color: red;+ width: 100px;+ height: 100px;+ z-index: -1;+}+</style>+<p>Test passes if there is a filled green square.</p>+<div class="ref">XX<br>X<br></div>+<div class="test">+ <img src="../../../css/support/60x60-green.png" alt="">+ <span>XX X</span>+</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-015.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-015.htmlnew file mode 100644index 00000000000..e2500a6a69d--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-015.html@@ -0,0 +1,32 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Text level 3 Test: Line breaking with floats and disabled hyphenation </title>+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]"/>+<link rel="help" title="5.4. Hyphenation: the hyphens property" href="https://drafts.csswg.org/css-text-3/#hyphenation">+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-hyphens-manual">+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/../../reference/ref-filled-green-200px-square.html">+<meta name="assert" content="A span with hypens 'none' is wrapped in multiple lines based on the available space left by a float image.">+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />+<style>+div { font: 20px/1 Ahem; }+img { float:right; }+.test {+ max-width: 200px;+ color: green;+}+span { hyphens: none; }+.ref {+ position: absolute;+ background: green linear-gradient(red, red) 7ch 0/3ch 3ch no-repeat;+ color: red;+ width: 200px;+ height: 200px;+ z-index: -1;+}+</style>+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>+<div class="ref">XX X<br>XXX<br>XXXX XX<br>XXX</div>+<div class="test">+ <img src="../../../css/support/60x60-green.png" alt="">+ <span>XX X XXX XXXX XX XXX</span>+</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-shy-on-2nd-line-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-shy-on-2nd-line-001.htmlnew file mode 100644index 00000000000..00427e1a0b6--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-none-shy-on-2nd-line-001.html@@ -0,0 +1,16 @@+<!DOCTYPE html>+<title>CSS Text: `hyphens: none` disables soft hyphens on 2nd and later lines</title>+<link rel="help" href="https://drafts.csswg.org/css-text-4/#valdef-hyphens-none">+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-none-shy-on-2nd-line-001-ref.html">+<style>+.target {+ hyphens: none;+ width: 10ch;+}+</style>+<div class="target">+ 12345678+ Deoxy­ribo­nucleic+ Deoxy­ribo­nucleic+ 12345678+</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-out-of-flow-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-out-of-flow-002.htmlnew file mode 100644index 00000000000..5d0a544b110--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-out-of-flow-002.html@@ -0,0 +1,39 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Text Test: auto hyphenation and out-of-flow</title>+<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">+<link rel="help" href="https://drafts.csswg.org/css-text-3/#hyphens-property">+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-span-002-ref.html">+<meta name="assert" content="the presence of an out of flow element has no effect on automatic hyhenation">+<style>+span {+ position: absolute;+ color: transparent;+}+div {+ border: solid orange;+ margin: 5px;+ width: 6ch;+ hyphens: auto;+}+</style>++<p>Test passes if the text in all orange boxes below is identical (including the presence and position of a hyphen).++<div lang=en>highway</div>+<div lang=en><span>abspos</span>highway</div>+<div lang=en>h<span>abspos</span>ighway</div>+<div lang=en>high<span>abspos</span>way</div>+<div lang=en>high<span>abspos</span>way</div>+<div lang=en>highwa<span>abspos</span>y</div>+<div lang=en>highway<span>abspos</span></div>++<!--+This test assumes the presence of "highway"+with a hyphenation point between "high" and "way"+in the hyphenation dictionary for English+in order to be useful,+but that assumption is not necessary for the test to be correct:+if the word doesn't hyphenate,+it will not hyphenate in any of the cases.+-->diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-overflow-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-overflow-001.htmlnew file mode 100644index 00000000000..0f3a9205afd--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-overflow-001.html@@ -0,0 +1,25 @@+<!DOCTYPE html>+<title>CSS Text Test: Test when soft-hyphen overflows</title>+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-overflow-001-ref.html">+<link rel="help" href="https://drafts.csswg.org/css-text-3/#hyphens-property">+<link rel="author" href="mailto:[email protected]">+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />+<style>+div {+ font-size: 10px;+ font-family: Ahem;+ width: 5.1ch;+ border: 1px solid blue;+}+</style>+<body>+ <div>12 4­xx</div>+ <div>12 45­xx</div>+ <div>12 456­xx</div>+ <div>1234­xx</div>+ <div>12345­xx</div>+ <div>123456­xx</div>++ <div style="width: 10ch"><span>ren­for­cer</span>99999</div>+ <div><span>00­1</span>222</div>+</body>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-shaping-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-shaping-002.htmlnew file mode 100644index 00000000000..eea65f171a6--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-shaping-002.html@@ -0,0 +1,31 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Text level 3 Test: hyphenation and text-shaping</title>+<link rel="author" title="Florian Rivoal" href="https://florian.rivoal.net/">+<link rel="help" href="https://drafts.csswg.org/css-text-3/#word-break-shaping">+<link rel="help" href="https://www.w3.org/TR/css-text-3/#hyphens-property">+<link rel="mismatch" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-shaping-002-ref.html">+<meta name="assert" content="Checks that some kind of hyphen does get inserted in Uyghur. (Complement fo hyphens-shaping-001.html)">+<style>+ @font-face {+ font-family: 'csstest_noto';+ src: url('../../../fonts/noto/NotoNaskhArabic-regular.woff2') format('woff2');+ }+ /* The main text is invisible,+ but we want to give the UA a chance to use the right hyphen,+ which may be font dependent.+ */+ div {+ font-family: 'csstest_noto';+ font-size: 4em;+ hyphens: manual;+ margin: auto;+ width: 0;+ }+ #test { color: transparent; }+ span { color: black; }+</style>++<p>Test passes if there is something below:++<div dir=rtl lang=ug id=test>دامي<span>­</span>دى</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-span-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-span-001.htmlnew file mode 100644index 00000000000..d6226e3c900--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-span-001.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Text Test: manual hyphen and span</title>+<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">+<link rel="help" href="https://drafts.csswg.org/css-text-3/#hyphens-property">+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-span-001-ref.html">+<meta name="assert" content="the presence of an unstyled inline element has no effect on text in general and on manual hyhenation in particular">+<style>+div {+ border: solid orange;+ margin: 5px;+ width: 6ch;+ hyphens: manual;+}+</style>++<p>Test passes if the text in all orange boxes below is identical (including the presence and position of a hyphen).++<div>high­way</div>+<div><span>high</span>­way</div>+<div><span>high­</span>way</div>+<div>high<span>­</span>way</div>+<div>high<span>­way</span></div>+<div>high­<span>way</span></div>+<div><span>high</span>­<span>way</span></div>+<div><span>high­wa</span>y</div>+<div><span>hi</span>gh­way</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-span-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-span-002.htmlnew file mode 100644index 00000000000..90a04cf467f--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/hyphens-span-002.html@@ -0,0 +1,35 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Text Test: auto hyphen and span</title>+<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">+<link rel="help" href="https://drafts.csswg.org/css-text-3/#hyphens-property">+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/hyphens-span-002-ref.html">+<meta name="assert" content="the presence of an unstyled inline element has no effect on text in general and on manual hyhenation in particular">+<style>+div {+ border: solid orange;+ margin: 5px;+ width: 6ch;+ hyphens: auto;+}+</style>++<p>Test passes if the text in all orange boxes below is identical (including the presence and position of a hyphen).++<div lang=en>highway</div>+<div lang=en><span>high</span>way</div>+<div lang=en>high<span></span>way</div>+<div lang=en>high<span>way</span></div>+<div lang=en><span>high</span><span>way</span></div>+<div lang=en><span>highwa</span>y</div>+<div lang=en><span>hi</span>ghway</div>++<!--+This test assumes the presence of "highway"+with a hyphenation point between "high" and "way"+in the hyphenation dictionary for English+in order to be useful,+but that assumption is not necessary for the test to be correct:+if the word doesn't hyphenate,+it will not hyphenate in any of the cases.+-->diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/resources/roboto_hyphenation_subset.ttf b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/resources/roboto_hyphenation_subset.ttfnew file mode 100644index 00000000000..38a80ff4b5dBinary files /dev/null and b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/resources/roboto_hyphenation_subset.ttf differdiff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/shy-styling-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/shy-styling-001.htmlnew file mode 100644index 00000000000..d4d8efdbe78--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/hyphens/shy-styling-001.html@@ -0,0 +1,23 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Text Test: soft hyphen styling</title>+<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">+<link rel="help" href="https://drafts.csswg.org/css-text-3/#hyphens-property">+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/shy-styling-001-ref.html">+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/hyphens/reference/shy-styling-001-alt-ref.html">+<meta name="assert" content="hypens inserted where there was a soft-hyphen take on the styles that would have applied to the soft hyphen">+<style>+div {+ width: 0ch;+ hyphens: manual;+}+span {+ font-size: 3em;+ color: red;+ text-shadow: 3px 3px 3px black;+}+</style>++<p>Test passes if the word “example” below is hyphenated, and the hyphen is large, red, and has a shadow++<div>ex<span>­</span>ample</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/support/60x60-green.png b/Tests/LibWeb/Ref/input/wpt-import/css/support/60x60-green.pngnew file mode 100644index 00000000000..b3c8cf3eb4cBinary files /dev/null and b/Tests/LibWeb/Ref/input/wpt-import/css/support/60x60-green.png differdiff --git a/Tests/LibWeb/Ref/input/wpt-import/fonts/noto/NotoNaskhArabic-regular.woff2 b/Tests/LibWeb/Ref/input/wpt-import/fonts/noto/NotoNaskhArabic-regular.woff2new file mode 100644index 00000000000..e24020d46a4Binary files /dev/null and b/Tests/LibWeb/Ref/input/wpt-import/fonts/noto/NotoNaskhArabic-regular.woff2 differdiff --git a/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt b/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txtindex 495758821f3..d8db8abae45 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@@ -47,6 +47,7 @@ All properties associated with getComputedStyle(document.body):"font-width","forced-color-adjust","hyphenate-character",+ "hyphens","image-rendering","interpolate-size","letter-spacing",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.txtindex 7331118921c..07985483112 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@@ -724,6 +724,7 @@ All supported properties and their default values exposed from CSSStylePropertie'height': '134px''hyphenateCharacter': 'auto''hyphenate-character': 'auto'+'hyphens': 'manual''imageRendering': 'auto''image-rendering': 'auto''inlineSize': '284px'diff --git a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txtindex 86c9dbe5d9c..adc3e2429fe 100644--- a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt+++ b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt@@ -45,6 +45,7 @@ font-weight: 400font-width: 100%forced-color-adjust: autohyphenate-character: auto+hyphens: manualimage-rendering: autointerpolate-size: numeric-onlyletter-spacing: normaldiff --git a/Tests/LibWeb/Text/expected/css/soft-hyphen-breaks.txt b/Tests/LibWeb/Text/expected/css/soft-hyphen-breaks.txtnew file mode 100644index 00000000000..50288889f5e--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/soft-hyphen-breaks.txt@@ -0,0 +1,23 @@+min-content: content as wide as "hyphen" + a hyphen, box as wide as "hyphen" + a hyphen, 2 line(s)+min-content-hyphens-none: content as wide as "hyphenation", box as wide as "hyphenation", 1 line(s)+min-content-span-hyphens-none: content as wide as "hyphenation", box as wide as "hyphenation", 1 line(s)+narrow: content as wide as "ab" + a hyphen, 3 line(s)+narrow-hyphens-none: content as wide as "abcdef", 1 line(s)+letter-spacing: content as wide as "ab" + a hyphen, box as wide as "ab" + a hyphen, 2 line(s)+rtl: content as wide as "שלום" + a hyphen, box as wide as "שלום" + a hyphen, 2 line(s)+between-items: content as wide as "ab" + a hyphen, box as wide as "ab" + a hyphen, 2 line(s)+final-soft-hyphen: content as wide as "cdefgh", box as wide as "cdefgh", 2 line(s)+before-word-joiner: content as wide as "abcd", box as wide as "abcd", 1 line(s)+fits-after-break: 2 line(s)+before-inline-box-edge: text as wide as "ab" + a hyphen, 2 line(s)+overflow-wrap-anywhere: fits+overflow-wrap-anywhere-short: first line as wide as "aaa"+item-before-wide-run: fits, 3 line(s)+before-out-of-flow: 1 line(s)+out-of-flow-before-soft-hyphen: box after "ab"+anywhere-before-inline-block: fits+anywhere-before-out-of-flow: fits+space-before-nowrap-out-of-flow: fits, 2 line(s)+before-space: text as wide as "ab", 2 line(s)+before-tiny-inline-block: text fits+before-inline-block: text as wide as "ab"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.txtindex 6142825db3d..6f4ebb436e5 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 354 tests+Found 355 tests-354 Pass+355 PassPass accent-colorPass border-collapsePass border-spacing@@ -45,6 +45,7 @@ Pass font-weightPass font-widthPass forced-color-adjustPass hyphenate-character+Pass hyphensPass image-renderingPass letter-spacingPass line-height@@ -356,4 +357,4 @@ Pass will-changePass xPass yPass z-index-Pass zoom+Pass zoom\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/parsing/marker-supported-properties-in-animation.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/parsing/marker-supported-properties-in-animation.txtindex d1499573cf3..9eda65dd8b9 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/parsing/marker-supported-properties-in-animation.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/parsing/marker-supported-properties-in-animation.txt@@ -2,8 +2,8 @@ Harness status: OKFound 96 tests-70 Pass-26 Fail+72 Pass+24 FailPass Animation of font in ::markerPass Animation of font-family in ::markerPass Animation of font-feature-settings in ::marker@@ -30,7 +30,7 @@ Fail Animation of text-combine-upright in ::markerPass Animation of unicode-bidi in ::markerPass Animation of direction in ::markerPass Animation of content in ::marker-Fail Animation of hyphens in ::marker+Pass Animation of hyphens in ::markerPass Animation of letter-spacing in ::markerFail Animation of line-break in ::markerPass Animation of overflow-wrap in ::marker@@ -78,7 +78,7 @@ Fail Transition of text-combine-upright in ::markerPass Transition of unicode-bidi in ::markerPass Transition of direction in ::markerPass Transition of content in ::marker-Fail Transition of hyphens in ::marker+Pass Transition of hyphens in ::markerPass Transition of letter-spacing in ::markerFail Transition of line-break in ::markerPass Transition of overflow-wrap in ::markerdiff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-text/animations/hyphen-no-interpolation.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/animations/hyphen-no-interpolation.txtindex 4e64398ca1d..9ace5124144 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-text/animations/hyphen-no-interpolation.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/animations/hyphen-no-interpolation.txt@@ -2,8 +2,8 @@ Harness status: OKFound 168 tests-42 Pass-126 Fail+84 Pass+84 FailPass CSS Transitions with transition-behavior:allow-discrete: property <hyphenate-character> from [initial] to ["e"] at (-0.3) should be [initial]Pass CSS Transitions with transition-behavior:allow-discrete: property <hyphenate-character> from [initial] to ["e"] at (0) should be [initial]Pass CSS Transitions with transition-behavior:allow-discrete: property <hyphenate-character> from [initial] to ["e"] at (0.3) should be [initial]@@ -130,45 +130,45 @@ Fail Web Animations: property <hyphenate-limit-lines> from [initial] to [4] at (Fail Web Animations: property <hyphenate-limit-lines> from [initial] to [4] at (0.6) should be [4]Fail Web Animations: property <hyphenate-limit-lines> from [initial] to [4] at (1) should be [4]Fail Web Animations: property <hyphenate-limit-lines> from [initial] to [4] at (1.5) should be [4]-Fail CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (-0.3) should be [initial]-Fail CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (0) should be [initial]-Fail CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (0.3) should be [initial]-Fail CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (0.5) should be [auto]-Fail CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (0.6) should be [auto]-Fail CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (1) should be [auto]-Fail CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (1.5) should be [auto]-Fail CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (-0.3) should be [initial]-Fail CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (0) should be [initial]-Fail CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (0.3) should be [initial]-Fail CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (0.5) should be [auto]-Fail CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (0.6) should be [auto]-Fail CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (1) should be [auto]-Fail CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (1.5) should be [auto]-Fail CSS Transitions: property <hyphens> from [initial] to [auto] at (-0.3) should be [auto]-Fail CSS Transitions: property <hyphens> from [initial] to [auto] at (0) should be [auto]-Fail CSS Transitions: property <hyphens> from [initial] to [auto] at (0.3) should be [auto]-Fail CSS Transitions: property <hyphens> from [initial] to [auto] at (0.5) should be [auto]-Fail CSS Transitions: property <hyphens> from [initial] to [auto] at (0.6) should be [auto]-Fail CSS Transitions: property <hyphens> from [initial] to [auto] at (1) should be [auto]-Fail CSS Transitions: property <hyphens> from [initial] to [auto] at (1.5) should be [auto]-Fail CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (-0.3) should be [auto]-Fail CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (0) should be [auto]-Fail CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (0.3) should be [auto]-Fail CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (0.5) should be [auto]-Fail CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (0.6) should be [auto]-Fail CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (1) should be [auto]-Fail CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (1.5) should be [auto]-Fail CSS Animations: property <hyphens> from [initial] to [auto] at (-0.3) should be [initial]-Fail CSS Animations: property <hyphens> from [initial] to [auto] at (0) should be [initial]-Fail CSS Animations: property <hyphens> from [initial] to [auto] at (0.3) should be [initial]-Fail CSS Animations: property <hyphens> from [initial] to [auto] at (0.5) should be [auto]-Fail CSS Animations: property <hyphens> from [initial] to [auto] at (0.6) should be [auto]-Fail CSS Animations: property <hyphens> from [initial] to [auto] at (1) should be [auto]-Fail CSS Animations: property <hyphens> from [initial] to [auto] at (1.5) should be [auto]-Fail Web Animations: property <hyphens> from [initial] to [auto] at (-0.3) should be [initial]-Fail Web Animations: property <hyphens> from [initial] to [auto] at (0) should be [initial]-Fail Web Animations: property <hyphens> from [initial] to [auto] at (0.3) should be [initial]-Fail Web Animations: property <hyphens> from [initial] to [auto] at (0.5) should be [auto]-Fail Web Animations: property <hyphens> from [initial] to [auto] at (0.6) should be [auto]-Fail Web Animations: property <hyphens> from [initial] to [auto] at (1) should be [auto]-Fail Web Animations: property <hyphens> from [initial] to [auto] at (1.5) should be [auto]\ No newline at end of file+Pass CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (-0.3) should be [initial]+Pass CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (0) should be [initial]+Pass CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (0.3) should be [initial]+Pass CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (0.5) should be [auto]+Pass CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (0.6) should be [auto]+Pass CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (1) should be [auto]+Pass CSS Transitions with transition-behavior:allow-discrete: property <hyphens> from [initial] to [auto] at (1.5) should be [auto]+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (-0.3) should be [initial]+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (0) should be [initial]+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (0.3) should be [initial]+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (0.5) should be [auto]+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (0.6) should be [auto]+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (1) should be [auto]+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <hyphens> from [initial] to [auto] at (1.5) should be [auto]+Pass CSS Transitions: property <hyphens> from [initial] to [auto] at (-0.3) should be [auto]+Pass CSS Transitions: property <hyphens> from [initial] to [auto] at (0) should be [auto]+Pass CSS Transitions: property <hyphens> from [initial] to [auto] at (0.3) should be [auto]+Pass CSS Transitions: property <hyphens> from [initial] to [auto] at (0.5) should be [auto]+Pass CSS Transitions: property <hyphens> from [initial] to [auto] at (0.6) should be [auto]+Pass CSS Transitions: property <hyphens> from [initial] to [auto] at (1) should be [auto]+Pass CSS Transitions: property <hyphens> from [initial] to [auto] at (1.5) should be [auto]+Pass CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (-0.3) should be [auto]+Pass CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (0) should be [auto]+Pass CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (0.3) should be [auto]+Pass CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (0.5) should be [auto]+Pass CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (0.6) should be [auto]+Pass CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (1) should be [auto]+Pass CSS Transitions with transition: all: property <hyphens> from [initial] to [auto] at (1.5) should be [auto]+Pass CSS Animations: property <hyphens> from [initial] to [auto] at (-0.3) should be [initial]+Pass CSS Animations: property <hyphens> from [initial] to [auto] at (0) should be [initial]+Pass CSS Animations: property <hyphens> from [initial] to [auto] at (0.3) should be [initial]+Pass CSS Animations: property <hyphens> from [initial] to [auto] at (0.5) should be [auto]+Pass CSS Animations: property <hyphens> from [initial] to [auto] at (0.6) should be [auto]+Pass CSS Animations: property <hyphens> from [initial] to [auto] at (1) should be [auto]+Pass CSS Animations: property <hyphens> from [initial] to [auto] at (1.5) should be [auto]+Pass Web Animations: property <hyphens> from [initial] to [auto] at (-0.3) should be [initial]+Pass Web Animations: property <hyphens> from [initial] to [auto] at (0) should be [initial]+Pass Web Animations: property <hyphens> from [initial] to [auto] at (0.3) should be [initial]+Pass Web Animations: property <hyphens> from [initial] to [auto] at (0.5) should be [auto]+Pass Web Animations: property <hyphens> from [initial] to [auto] at (0.6) should be [auto]+Pass Web Animations: property <hyphens> from [initial] to [auto] at (1) should be [auto]+Pass Web Animations: property <hyphens> from [initial] to [auto] at (1.5) should be [auto]\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/hyphens.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/hyphens.txtindex a05c8b04355..6e476664449 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/hyphens.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/hyphens.txt@@ -2,16 +2,15 @@ Harness status: OKFound 34 tests-26 Pass-8 Fail-Fail Can set 'hyphens' to CSS-wide keywords: initial-Fail Can set 'hyphens' to CSS-wide keywords: inherit-Fail Can set 'hyphens' to CSS-wide keywords: unset-Fail Can set 'hyphens' to CSS-wide keywords: revert-Fail Can set 'hyphens' to var() references: var(--A)-Fail Can set 'hyphens' to the 'none' keyword: none-Fail Can set 'hyphens' to the 'manual' keyword: manual-Fail Can set 'hyphens' to the 'auto' keyword: auto+34 Pass+Pass Can set 'hyphens' to CSS-wide keywords: initial+Pass Can set 'hyphens' to CSS-wide keywords: inherit+Pass Can set 'hyphens' to CSS-wide keywords: unset+Pass Can set 'hyphens' to CSS-wide keywords: revert+Pass Can set 'hyphens' to var() references: var(--A)+Pass Can set 'hyphens' to the 'none' keyword: none+Pass Can set 'hyphens' to the 'manual' keyword: manual+Pass Can set 'hyphens' to the 'auto' keyword: autoPass Setting 'hyphens' to a length: 0px throws TypeErrorPass Setting 'hyphens' to a length: -3.14em throws TypeErrorPass Setting 'hyphens' to a length: 3.14cm throws TypeErrordiff --git a/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/accumulation-per-property-001.txt b/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/accumulation-per-property-001.txtindex cad3cc145a0..256dd927b64 100644--- a/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/accumulation-per-property-001.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/accumulation-per-property-001.txt@@ -1,8 +1,8 @@Harness status: OK-Found 362 tests+Found 365 tests-343 Pass+346 Pass19 FailPass SetupPass alignment-baseline (type: discrete) has testAccumulation function@@ -365,4 +365,7 @@ Pass grid-template: "none" onto "". . a b" ". . a b""Pass grid-template: "". . a b" ". . a b"" onto "none"Pass grid-template-areas (type: discrete) has testAccumulation functionPass grid-template-areas: "none" onto "". . a b" ". . a b""-Pass grid-template-areas: "". . a b" ". . a b"" onto "none"\ No newline at end of file+Pass grid-template-areas: "". . a b" ". . a b"" onto "none"+Pass hyphens (type: discrete) has testAccumulation function+Pass hyphens: "none" onto "manual"+Pass hyphens: "manual" onto "none"\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/addition-per-property-001.txt b/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/addition-per-property-001.txtindex 258cbcb2c0b..32616456493 100644--- a/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/addition-per-property-001.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/addition-per-property-001.txt@@ -1,8 +1,8 @@Harness status: OK-Found 362 tests+Found 365 tests-343 Pass+346 Pass19 FailPass SetupPass alignment-baseline (type: discrete) has testAddition function@@ -365,4 +365,7 @@ Pass grid-template: "none" onto "". . a b" ". . a b""Pass grid-template: "". . a b" ". . a b"" onto "none"Pass grid-template-areas (type: discrete) has testAddition functionPass grid-template-areas: "none" onto "". . a b" ". . a b""-Pass grid-template-areas: "". . a b" ". . a b"" onto "none"\ No newline at end of file+Pass grid-template-areas: "". . a b" ". . a b"" onto "none"+Pass hyphens (type: discrete) has testAddition function+Pass hyphens: "none" onto "manual"+Pass hyphens: "manual" onto "none"\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/interpolation-per-property-001.txt b/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/interpolation-per-property-001.txtindex 3bcbe5d7b29..742eac3bde4 100644--- a/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/interpolation-per-property-001.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/interpolation-per-property-001.txt@@ -1,8 +1,8 @@Harness status: OK-Found 450 tests+Found 454 tests-440 Pass+444 Pass10 FailPass SetupPass alignment-baseline (type: discrete) has testInterpolation function@@ -453,4 +453,8 @@ Pass grid-template uses discrete animation when animating between "". . a b" ".Pass grid-template-areas (type: discrete) has testInterpolation functionPass grid-template-areas uses discrete animation when animating between "". . a b" ". . a b"" and "none" with linear easingPass grid-template-areas uses discrete animation when animating between "". . a b" ". . a b"" and "none" with effect easing-Pass grid-template-areas uses discrete animation when animating between "". . a b" ". . a b"" and "none" with keyframe easing\ No newline at end of file+Pass grid-template-areas uses discrete animation when animating between "". . a b" ". . a b"" and "none" with keyframe easing+Pass hyphens (type: discrete) has testInterpolation function+Pass hyphens uses discrete animation when animating between "manual" and "none" with linear easing+Pass hyphens uses discrete animation when animating between "manual" and "none" with effect easing+Pass hyphens uses discrete animation when animating between "manual" and "none" with keyframe easing\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/css/soft-hyphen-breaks.html b/Tests/LibWeb/Text/input/css/soft-hyphen-breaks.htmlnew file mode 100644index 00000000000..83f049054e0--- /dev/null+++ b/Tests/LibWeb/Text/input/css/soft-hyphen-breaks.html@@ -0,0 +1,156 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ div {+ font: 20px monospace;+ margin: 4px 0;+ }+ .min {+ width: min-content;+ }+ .narrow {+ width: 0;+ }+ span.reference {+ white-space: pre;+ }+</style>+<div id="one-line">x</div>+<div id="references"></div>+<div id="min-content" class="min">hyphen­ation</div>+<div id="min-content-hyphens-none" class="min" style="hyphens: none">hyphen­ation</div>+<div id="min-content-span-hyphens-none" class="min">hyphen<span style="hyphens: none">­</span>ation</div>+<div id="narrow" class="narrow">ab­cd­ef</div>+<div id="narrow-hyphens-none" class="narrow" style="hyphens: none">ab­cd­ef</div>+<div id="letter-spacing" class="min" style="letter-spacing: 10px">ab­cd</div>+<div id="rtl" class="min" dir="rtl">שלום­עולם</div>+<div id="between-items" class="min">ab­<b>cd</b></div>+<div id="fits-after-break" style="width: 6ch">abc abcd­ef</div>+<div id="before-inline-box-edge" class="min">ab­<span style="padding-right: 10px"></span>cd</div>+<div id="before-word-joiner" class="min">ab­<span>⁠cd</span></div>+<div id="overflow-wrap-anywhere" style="overflow-wrap: anywhere">aaaa­aa</div>+<div id="overflow-wrap-anywhere-short" style="overflow-wrap: anywhere">aaaa­aa</div>+<div id="item-before-wide-run"><span>aa­aa­</span><span>aaaa</span></div>+<div id="before-out-of-flow"><span id="before-out-of-flow-text">x ab­</span><span style="position: absolute"></span></div>+<div id="out-of-flow-before-soft-hyphen">ab<span id="marker" style="position: absolute"></span>­cd</div>+<div id="anywhere-before-inline-block" style="overflow-wrap: anywhere">ab­<span style="display: inline-block; width: 1ch; height: 10px"></span></div>+<div id="anywhere-before-out-of-flow" style="overflow-wrap: anywhere">ab­<span style="position: absolute"></span>cd</div>+<div id="space-before-nowrap-out-of-flow">x ab­<span style="position: absolute; white-space: nowrap"></span>cd</div>+<div id="final-soft-hyphen" class="min">ab­cdefgh­</div>+<div id="before-space">ab­ cd</div>+<div id="before-tiny-inline-block" class="min">ab­<span style="display: inline-block; width: 1px; height: 10px"></span></div>+<div id="before-inline-block" class="min">ab­<span style="display: inline-block; width: 20px"></span>longword</div>+<script>+ // Each block's width, as the text it matches: the widest line's text alone, or with a hyphen after it. And its+ // height in lines.+ function width(text, style = "") {+ const span = document.createElement("span");+ span.className = "reference";+ span.style.cssText = style;+ span.textContent = text;+ document.getElementById("references").append(span);+ const result = span.getBoundingClientRect().width;+ span.remove();+ return result;+ }++ // The candidate nearest to the actual width, if any is within half a pixel of it.+ function describe(actual, candidates) {+ let nearest = null;+ for (const [name, candidate] of candidates) {+ const distance = Math.abs(actual - candidate);+ if (distance < 0.5 && (nearest === null || distance < nearest.distance))+ nearest = { name, distance };+ }+ return nearest ? nearest.name : `none of ${[...new Set(candidates.map(([name]) => name))].join(", ")}`;+ }++ test(() => {+ const lineHeight = document.getElementById("one-line").getBoundingClientRect().height;+ // Either hyphen the UA might draw gets the same label, since a font can give both the same width.+ const withHyphens = (text, style, extra = 0) => [+ [`"${text}"`, width(text, style) + extra],+ [`"${text}" + a hyphen`, width(text + "\u2010", style) + extra],+ [`"${text}" + a hyphen`, width(text + "-", style) + extra],+ ];+ const cases = {+ "min-content": withHyphens("hyphen"),+ "min-content-hyphens-none": withHyphens("hyphenation"),+ "min-content-span-hyphens-none": withHyphens("hyphenation"),+ "narrow": withHyphens("ab"),+ "narrow-hyphens-none": withHyphens("abcdef"),+ "letter-spacing": withHyphens("ab", "letter-spacing: 10px"),+ "rtl": withHyphens("שלום"),+ "between-items": withHyphens("ab"),+ "final-soft-hyphen": withHyphens("cdefgh"),+ "before-word-joiner": withHyphens("abcd"),+ };+ for (const [id, candidates] of Object.entries(cases)) {+ const div = document.getElementById(id);+ const lines = Math.round(div.getBoundingClientRect().height / lineHeight);+ const box = div.classList.contains("min") ? `, box as wide as ${describe(div.getBoundingClientRect().width, candidates)}` : "";+ println(`${id}: content as wide as ${describe(div.scrollWidth, candidates)}${box}, ${lines} line(s)`);+ }+ const fits = document.getElementById("fits-after-break");+ println(`fits-after-break: ${Math.round(fits.getBoundingClientRect().height / lineHeight)} line(s)`);+ // The text before an inline box's edge, as wide as itself and the hyphen its line ends in.+ const edge = document.getElementById("before-inline-box-edge");+ const range = document.createRange();+ range.selectNodeContents(edge.firstChild);+ const edgeLines = Math.round(edge.getBoundingClientRect().height / lineHeight);+ println(`before-inline-box-edge: text as wide as ${describe(range.getBoundingClientRect().width, withHyphens("ab"))}, ${edgeLines} line(s)`);+ const anywhere = document.getElementById("overflow-wrap-anywhere");+ anywhere.style.width = `${width("aaaa")}px`;+ println(`overflow-wrap-anywhere: ${anywhere.scrollWidth > anywhere.clientWidth + 0.5 ? "overflows" : "fits"}`);+ // Room for three letters and half a fourth: Three letters fit with no hyphen, since they don't end at the soft hyphen.+ const short = document.getElementById("overflow-wrap-anywhere-short");+ short.style.width = `${width("aaa") + width("a") / 2}px`;+ const shortRange = document.createRange();+ shortRange.selectNodeContents(short.firstChild);+ const firstLine = [...shortRange.getClientRects()][0].width;+ println(`overflow-wrap-anywhere-short: first line as wide as ${describe(firstLine, [['"aaa"', width("aaa")], ...withHyphens("aa")])}`);+ // A line breaks at the first soft hyphen when the hyphen at the second doesn't fit.+ const item = document.getElementById("item-before-wide-run");+ item.style.width = `${width("aaaa") + 2}px`;+ println(`item-before-wide-run: ${item.scrollWidth > item.clientWidth + 0.5 ? "overflows" : "fits"}, ${Math.round(item.getBoundingClientRect().height / lineHeight)} line(s)`);+ // A soft hyphen with only out-of-flow content after it gets no line break, so it needs no room for a hyphen.+ const outOfFlow = document.getElementById("before-out-of-flow");+ outOfFlow.style.width = `${width("x ab") + width("a") / 2}px`;+ println(`before-out-of-flow: ${Math.round(outOfFlow.getBoundingClientRect().height / lineHeight)} line(s)`);+ // An out-of-flow box before a soft hyphen keeps its static position when the line ends in a hyphen there.+ const markerLine = document.getElementById("out-of-flow-before-soft-hyphen");+ markerLine.style.width = `${width("ab") + width("a") / 2}px`;+ const markerLeft = document.getElementById("marker").getBoundingClientRect().left - markerLine.getBoundingClientRect().left;+ println(`out-of-flow-before-soft-hyphen: box after ${describe(markerLeft, withHyphens("ab"))}`);+ // An atomic inline after a soft hyphen has to fit too, or the line breaks there and ends in a hyphen.+ const beforeBlock = document.getElementById("anywhere-before-inline-block");+ beforeBlock.style.width = `${width("ab") + width("a") / 2}px`;+ println(`anywhere-before-inline-block: ${beforeBlock.scrollWidth > beforeBlock.clientWidth + 0.5 ? "overflows" : "fits"}`);+ // The text after an out-of-flow box decides if a line can break at the soft hyphen before the box, so the line+ // ending there leaves room for its hyphen.+ const beforeOutOfFlowBox = document.getElementById("anywhere-before-out-of-flow");+ beforeOutOfFlowBox.style.width = `${width("ab") + width("a") / 2}px`;+ println(`anywhere-before-out-of-flow: ${beforeOutOfFlowBox.scrollWidth > beforeOutOfFlowBox.clientWidth + 0.5 ? "overflows" : "fits"}`);+ const nowrapBox = document.getElementById("space-before-nowrap-out-of-flow");+ nowrapBox.style.width = `${width("x ab") + width("a") / 2}px`;+ println(`space-before-nowrap-out-of-flow: ${nowrapBox.scrollWidth > nowrapBox.clientWidth + 0.5 ? "overflows" : "fits"}, ${Math.round(nowrapBox.getBoundingClientRect().height / lineHeight)} line(s)`);+ // A line that breaks at the space after a soft hyphen breaks there, not at the soft hyphen, so it draws no hyphen.+ const beforeSpace = document.getElementById("before-space");+ beforeSpace.style.width = `${width("ab-") + 1}px`;+ const beforeSpaceRange = document.createRange();+ beforeSpaceRange.setStart(beforeSpace.firstChild, 0);+ beforeSpaceRange.setEnd(beforeSpace.firstChild, 3);+ println(`before-space: text as wide as ${describe(beforeSpaceRange.getBoundingClientRect().width, withHyphens("ab"))}, ${Math.round(beforeSpace.getBoundingClientRect().height / lineHeight)} line(s)`);+ // A min-content box leaves room for a hyphen before an inline-block, so its text never overflows it.+ const tiny = document.getElementById("before-tiny-inline-block");+ const tinyRange = document.createRange();+ tinyRange.selectNodeContents(tiny.firstChild);+ println(`before-tiny-inline-block: text ${tinyRange.getBoundingClientRect().width > tiny.getBoundingClientRect().width + 0.5 ? "overflows" : "fits"}`);+ // A line that breaks after an inline-block draws no hyphen before it.+ const block = document.getElementById("before-inline-block");+ const blockRange = document.createRange();+ blockRange.selectNodeContents(block.firstChild);+ println(`before-inline-block: text as wide as ${describe(blockRange.getBoundingClientRect().width, withHyphens("ab"))}`);+ document.getElementById("references").remove();+ });+</script>