Truly independent web browser
LibWeb: Support the prefixed text alignment keywords
sideshowbarker40a4e7d04f52
diff --git a/Libraries/LibWeb/CSS/Default.css b/Libraries/LibWeb/CSS/Default.cssindex dc0381f4699..29c373c5848 100644--- a/Libraries/LibWeb/CSS/Default.css+++ b/Libraries/LibWeb/CSS/Default.css@@ -17,7 +17,7 @@ body {}center {- text-align: -libweb-center;+ text-align: -webkit-center;}blink {diff --git a/Libraries/LibWeb/CSS/Enums.json b/Libraries/LibWeb/CSS/Enums.jsonindex 639c9ee0049..c0fdf3a95dd 100644--- a/Libraries/LibWeb/CSS/Enums.json+++ b/Libraries/LibWeb/CSS/Enums.json@@ -1150,10 +1150,10 @@"left","right","match-parent",- "-libweb-center",+ "-webkit-center","-libweb-inherit-or-center",- "-libweb-left",- "-libweb-right"+ "-webkit-left",+ "-webkit-right"],"text-align-last": ["auto",diff --git a/Libraries/LibWeb/CSS/Keywords.json b/Libraries/LibWeb/CSS/Keywords.jsonindex 52c2793ccb1..28a01900da5 100644--- a/Libraries/LibWeb/CSS/Keywords.json+++ b/Libraries/LibWeb/CSS/Keywords.json@@ -9,11 +9,14 @@"-libweb-quirk-inherit","-libweb-right","-webkit-box",+ "-webkit-center","-webkit-fill-available","-webkit-flex","-webkit-inline-box","-webkit-inline-flex",+ "-webkit-left","-webkit-legacy",+ "-webkit-right","a","a3","a4",diff --git a/Libraries/LibWeb/CSS/Properties.json b/Libraries/LibWeb/CSS/Properties.jsonindex 43394e7d672..6a50542059e 100644--- a/Libraries/LibWeb/CSS/Properties.json+++ b/Libraries/LibWeb/CSS/Properties.json@@ -5399,6 +5399,11 @@"requires-computation": "never","valid-types": ["text-align"+ ],+ "valid-identifiers": [+ "-libweb-center>-webkit-center",+ "-libweb-left>-webkit-left",+ "-libweb-right>-webkit-right"]},"text-align-last": {diff --git a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp b/Libraries/LibWeb/Editing/Internal/Algorithms.cppindex bff39135880..f574d1cf1b3 100644--- a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp+++ b/Libraries/LibWeb/Editing/Internal/Algorithms.cpp@@ -114,15 +114,15 @@ JustifyAlignment alignment_value_of_node(GC::Ptr<DOM::Node> node)// Browsers give these the alignment value of the matching regular "text-align" value.switch (text_align_value.value()) {case CSS::Keyword::Center:- case CSS::Keyword::LibwebCenter:+ case CSS::Keyword::WebkitCenter:return JustifyAlignment::Center;case CSS::Keyword::Justify:return JustifyAlignment::Justify;case CSS::Keyword::Left:- case CSS::Keyword::LibwebLeft:+ case CSS::Keyword::WebkitLeft:return JustifyAlignment::Left;case CSS::Keyword::Right:- case CSS::Keyword::LibwebRight:+ case CSS::Keyword::WebkitRight:return JustifyAlignment::Right;default:// 6. Return "left".diff --git a/Libraries/LibWeb/HTML/HTMLDivElement.cpp b/Libraries/LibWeb/HTML/HTMLDivElement.cppindex e861fa8b121..5cca1a9645b 100644--- a/Libraries/LibWeb/HTML/HTMLDivElement.cpp+++ b/Libraries/LibWeb/HTML/HTMLDivElement.cpp@@ -34,11 +34,11 @@ void HTMLDivElement::apply_presentational_hints(Vector<CSS::StyleProperty>& propfor_each_attribute([&](Utf16FlyString const& name, Utf16View value) {if (name == HTML::AttributeNames::align) {if (value.equals_ignoring_ascii_case(u"left"sv))- properties.append({ .property_id = CSS::PropertyID::TextAlign, .value = CSS::KeywordStyleValue::create(CSS::Keyword::LibwebLeft) });+ properties.append({ .property_id = CSS::PropertyID::TextAlign, .value = CSS::KeywordStyleValue::create(CSS::Keyword::WebkitLeft) });else if (value.equals_ignoring_ascii_case(u"right"sv))- properties.append({ .property_id = CSS::PropertyID::TextAlign, .value = CSS::KeywordStyleValue::create(CSS::Keyword::LibwebRight) });+ properties.append({ .property_id = CSS::PropertyID::TextAlign, .value = CSS::KeywordStyleValue::create(CSS::Keyword::WebkitRight) });else if (value.equals_ignoring_ascii_case(u"center"sv))- properties.append({ .property_id = CSS::PropertyID::TextAlign, .value = CSS::KeywordStyleValue::create(CSS::Keyword::LibwebCenter) });+ properties.append({ .property_id = CSS::PropertyID::TextAlign, .value = CSS::KeywordStyleValue::create(CSS::Keyword::WebkitCenter) });else if (value.equals_ignoring_ascii_case(u"justify"sv))properties.append({ .property_id = CSS::PropertyID::TextAlign, .value = CSS::KeywordStyleValue::create(CSS::Keyword::Justify) });}diff --git a/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Libraries/LibWeb/HTML/Parser/HTMLParser.cppindex 05d3424c9e6..33b07d30add 100644--- a/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp+++ b/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp@@ -2701,19 +2701,19 @@ RefPtr<CSS::StyleValue const> parse_table_child_element_align_value(Utf16View st// themselves, as if they had their 'text-align' property set to 'center' in a presentational hint, and to align// descendants to the center.if (string_view.equals_ignoring_ascii_case(u"center"sv) || string_view.equals_ignoring_ascii_case(u"middle"sv))- return CSS::KeywordStyleValue::create(CSS::Keyword::LibwebCenter);+ return CSS::KeywordStyleValue::create(CSS::Keyword::WebkitCenter);// The thead, tbody, tfoot, tr, td, and th elements, when they have an align attribute whose value is an ASCII// case-insensitive match for the string "left", are expected to left-align text within themselves, as if they had// their 'text-align' property set to 'left' in a presentational hint, and to align descendants to the left.if (string_view.equals_ignoring_ascii_case(u"left"sv))- return CSS::KeywordStyleValue::create(CSS::Keyword::LibwebLeft);+ return CSS::KeywordStyleValue::create(CSS::Keyword::WebkitLeft);// The thead, tbody, tfoot, tr, td, and th elements, when they have an align attribute whose value is an ASCII// case-insensitive match for the string "right", are expected to right-align text within themselves, as if they// had their 'text-align' property set to 'right' in a presentational hint, and to align descendants to the right.if (string_view.equals_ignoring_ascii_case(u"right"sv))- return CSS::KeywordStyleValue::create(CSS::Keyword::LibwebRight);+ return CSS::KeywordStyleValue::create(CSS::Keyword::WebkitRight);// The thead, tbody, tfoot, tr, td, and th elements, when they have an align attribute whose value is an ASCII// case-insensitive match for the string "justify", are expected to full-justify text within themselves, as if theydiff --git a/Libraries/LibWeb/Rust/src/css/style_compute/adjustments.rs b/Libraries/LibWeb/Rust/src/css/style_compute/adjustments.rsindex 3a2322553eb..ffa1d8303fd 100644--- a/Libraries/LibWeb/Rust/src/css/style_compute/adjustments.rs+++ b/Libraries/LibWeb/Rust/src/css/style_compute/adjustments.rs@@ -223,7 +223,7 @@ pub(super) fn adjust_element_style(let new_text_align = if input.is_table_element&& matches!(text_align,- keyword::_LIBWEB_LEFT | keyword::_LIBWEB_CENTER | keyword::_LIBWEB_RIGHT+ keyword::_WEBKIT_LEFT | keyword::_WEBKIT_CENTER | keyword::_WEBKIT_RIGHT) {keyword::START} else {diff --git a/Libraries/LibWeb/Rust/src/css/style_compute/tests.rs b/Libraries/LibWeb/Rust/src/css/style_compute/tests.rsindex 0cbbaa148be..1e45137abef 100644--- a/Libraries/LibWeb/Rust/src/css/style_compute/tests.rs+++ b/Libraries/LibWeb/Rust/src/css/style_compute/tests.rs@@ -197,7 +197,7 @@ fn element_styles_adjust_from_marshaled_facts() {input = element_adjustment_input();input.is_table_element = true;- let adjustment = adjust_element_style(&input, FfiDisplay::block(), keyword::_LIBWEB_CENTER);+ let adjustment = adjust_element_style(&input, FfiDisplay::block(), keyword::_WEBKIT_CENTER);assert!(adjustment.changed_text_align);assert_eq!(adjustment.text_align, keyword::START);diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rsindex 2cfeee5ed55..7713e297784 100644--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs@@ -2769,16 +2769,43 @@ impl<'pass> BlockFormattingContext<'pass> {self.rebuild_float_bands();}- /// The left edge of the border box of a box that avoids floats, in its containing block's content box.- fn border_box_left_of_box_avoiding_floats(+ /// The left edge of the border box, relative to the containing block, for float avoidance and final placement.+ fn normal_flow_border_box_left(&self,node: Node,metrics: &impl BoxMetricCells,- space_used_by_floats: inline_formatting_context::SpaceUsedByFloats,+ alignment: Option<box_alignment::SelfAlignment>,+ float_insets: Option<inline_formatting_context::SpaceUsedByFloats>,border_box_inline_size: CssPixels,available_inline_size: CssPixels,) -> CssPixels {+ use box_alignment::{OverflowSafety, SelfPosition};+let style = self.style(node);+ if let Some(alignment) = alignment {+ let space = float_insets.unwrap_or_default();+ let margin_left = style.margin_left().to_px(available_inline_size);+ let margin_right = style.margin_right().to_px(available_inline_size);+ // Align the margin box in the space between floats. The start margin can overlap a float on its side.+ let free =+ available_inline_size - space.left - space.right - border_box_inline_size - margin_left - margin_right;+ // https://drafts.csswg.org/css-align-3/#baseline-values+ // AD-HOC: CSS Align specifies safe self-start for first baseline, but prefixed text alignment uses+ // the container's start edge for compatibility when a block requests baseline alignment.+ let edge = match alignment.position_for(free, OverflowSafety::Unsafe) {+ SelfPosition::Edge(edge) => edge,+ _ => alignment.container_start,+ };+ if alignment.container_start == box_alignment::AxisEdge::End {+ let right = Self::border_box_inset_beside_floats(false, margin_right, space.right, space.left);+ return available_inline_size - right - border_box_inline_size - edge.reversed().offset(free);+ }+ let left = Self::border_box_inset_beside_floats(false, margin_left, space.left, space.right);+ return left + edge.offset(free);+ }+ let Some(space_used_by_floats) = float_insets else {+ return metrics.margin_left();+ };// NB: A box placed from its right edge has its right margin and the floats on the right decide where it goes, as// the left ones do for a box placed from its left edge.if self.box_avoiding_floats_is_placed_from_right(node) {@@ -2805,10 +2832,10 @@ impl<'pass> BlockFormattingContext<'pass> {containing_block_style.direction() == direction::RTL&& !matches!(containing_block_style.text_align(),- text_align::_LIBWEB_CENTER+ text_align::_WEBKIT_CENTER| text_align::_LIBWEB_INHERIT_OR_CENTER- | text_align::_LIBWEB_LEFT- | text_align::_LIBWEB_RIGHT+ | text_align::_WEBKIT_LEFT+ | text_align::_WEBKIT_RIGHT)}@@ -2948,6 +2975,7 @@ impl<'pass> BlockFormattingContext<'pass> {{return content_block_offset;}+ let alignment = self.prefixed_block_alignment(node);// https://drafts.csswg.org/css2/#floats// If necessary, implementations should clear the said element by placing it below any preceding floats, but may// place it adjacent to such floats if there is sufficient space.@@ -2978,10 +3006,11 @@ impl<'pass> BlockFormattingContext<'pass> {);let constrained = space.left > CssPixels::default() || space.right > CssPixels::default();let available_inline_size = available_space.inline_size.to_px_or_zero();- let border_box_left = self.border_box_left_of_box_avoiding_floats(+ let border_box_left = self.normal_flow_border_box_left(node,&metrics,- space,+ alignment,+ Some(space),candidate_border_box_inline_size,available_inline_size,);@@ -3571,6 +3600,38 @@ impl<'pass> BlockFormattingContext<'pass> {position_past_floats.filter(|_| introduces_clearance)}+ fn prefixed_block_alignment(&self, node: Node) -> Option<box_alignment::SelfAlignment> {+ use box_alignment::{AxisDirections, OverflowSafety, SelfKeyword};++ let container = self.style(self.containing_block(node));+ let style = self.style(node);+ let legacy_keyword = match container.text_align() {+ text_align::_WEBKIT_LEFT => Some(SelfKeyword::Left),+ text_align::_WEBKIT_CENTER => Some(SelfKeyword::Center),+ text_align::_WEBKIT_RIGHT => Some(SelfKeyword::Right),+ _ => None,+ };+ legacy_keyword+ .filter(|_| !style.margin_left().is_auto() && !style.margin_right().is_auto())+ .map(|legacy| {+ let directions = AxisDirections {+ self_start_is_low: geometry::start_is_low_side_in_frame(+ self.run.pass.frame,+ style.writing_mode(),+ style.direction(),+ true,+ ),+ ..AxisDirections::of(container.direction() != direction::RTL, Some(true))+ };+ let (keyword, safety) = SelfKeyword::justify_self_of(*style, Some(*container));+ if keyword == SelfKeyword::Normal {+ legacy.resolve(OverflowSafety::Safe, directions)+ } else {+ keyword.resolve(safety, directions)+ }+ })+ }+fn compute_normal_flow_inline_offset(&self,sized_child: ChildSizedHere<'_>,@@ -3580,24 +3641,22 @@ impl<'pass> BlockFormattingContext<'pass> {) -> CssPixels {let node = sized_child.node;let metrics = self.metrics_of(sized_child);- let mut inline_offset = CssPixels::default();- let mut available_inline_size_within_containing_block = available_space.inline_size.to_px_or_zero();- if self.box_should_avoid_floats_because_it_establishes_fc(node) {- // NB: The floats the box avoids are the ones beside its border box, as the check that moves it below them- // measures them. And a box placed from the right, or centered or right-aligned by a legacy alignment- // value of its containing block, has the floats measured across the whole line, not just over its own- // inline size from the left.- let legacy_alignment_uses_whole_line = matches!(- self.style(self.containing_block(node)).text_align(),- text_align::_LIBWEB_CENTER | text_align::_LIBWEB_RIGHT- );+ let alignment = self.prefixed_block_alignment(node);+ let available_inline_size = available_space.inline_size.to_px_or_zero();+ let space = if self.box_should_avoid_floats_because_it_establishes_fc(node) {+ let uses_whole_line = alignment.is_some()+ || self.box_avoiding_floats_is_placed_from_right(node)+ || matches!(+ self.style(self.containing_block(node)).text_align(),+ text_align::_WEBKIT_CENTER | text_align::_WEBKIT_RIGHT+ );let (border_box_block_size, block_size_is_unresolved) =self.block_extent_of_box_avoiding_floats(sized_child);let border_box_rect = CssPixelRect {x: content_position_in_root.x,y: content_position_in_root.y - metrics.border_box_top(false),- width: if self.box_avoiding_floats_is_placed_from_right(node) || legacy_alignment_uses_whole_line {- available_inline_size_within_containing_block+ width: if uses_whole_line {+ available_inline_size} else {content_inline_size},@@ -3612,34 +3671,20 @@ impl<'pass> BlockFormattingContext<'pass> {),border_box_rect,);- let border_box_inline_size =- content_inline_size + metrics.border_box_left(false) + metrics.border_box_right(false);- let border_box_left = self.border_box_left_of_box_avoiding_floats(- node,- &metrics,- space,- border_box_inline_size,- available_inline_size_within_containing_block,- );- available_inline_size_within_containing_block -= space.left + space.right;- // Subtracting the left margin here because it is applied again when the margin box offset is added below.- inline_offset = border_box_left - metrics.margin_left();- }-- let containing_block = self.containing_block(node);- let containing_text_align = self.style(containing_block).text_align();- if containing_text_align == text_align::_LIBWEB_CENTER {- inline_offset += available_inline_size_within_containing_block / 2 - content_inline_size / 2;- } else if containing_text_align == text_align::_LIBWEB_RIGHT {- // Subtracting the left margin here because left and right margins need to be swapped when aligning to the right- inline_offset += available_inline_size_within_containing_block- - content_inline_size- - metrics.margin_left()- - metrics.border_box_left(false);+ Some(space)} else {- inline_offset += metrics.margin_left() + metrics.border_box_left(false);- }- inline_offset+ None+ };+ let border_box_inline_size =+ content_inline_size + metrics.border_box_left(false) + metrics.border_box_right(false);+ self.normal_flow_border_box_left(+ node,+ &metrics,+ alignment,+ space,+ border_box_inline_size,+ available_inline_size,+ ) + metrics.border_box_left(false)}fn marker_centered_block_offset(marker_line_height: CssPixels, marker_block_size: CssPixels) -> CssPixels {@@ -5141,7 +5186,7 @@ impl<'pass> BlockFormattingContext<'pass> {&self.run,input,block_container_inline_size,- self.style(block_container).direction() == direction::RTL,+ self.style(block_container),stretch_fit_block_margins,self.outside_marker_line.get(),)diff --git a/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs b/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rsindex 8d1e917e3cc..53e3bee12e8 100644--- a/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs+++ b/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs@@ -25,6 +25,8 @@ pub(super) struct InFlowBlockKey {pub(super) input: LayoutInput,pub(super) containing_block_inline_size: CssPixels,pub(super) containing_block_is_right_to_left: bool,+ containing_text_align: u8,+ containing_justify_items: (u8, u8),/// The block margins of the child that stretch-fit sizing subtracts, which it treats as zero on a side where the/// containing block has no border or padding.pub(super) stretch_fit_block_margins: (CssPixels, CssPixels),@@ -41,14 +43,19 @@ impl InFlowBlockKey {run: &FormattingContextRun<'_>,input: LayoutInput,containing_block_inline_size: CssPixels,- containing_block_is_right_to_left: bool,+ container_style: StyleValues<'_>,stretch_fit_block_margins: (CssPixels, CssPixels),incoming_outside_marker_line: Option<block_formatting_context::OutsideMarkerLine>,) -> Self {Self {input,containing_block_inline_size,- containing_block_is_right_to_left,+ containing_block_is_right_to_left: container_style.direction() == direction::RTL,+ containing_text_align: container_style.text_align(),+ containing_justify_items: (+ container_style.justify_items(),+ container_style.justify_items_overflow(),+ ),stretch_fit_block_margins,incoming_outside_marker_line,run_root: run.box_,diff --git a/Libraries/LibWeb/Rust/src/layout/line_builder.rs b/Libraries/LibWeb/Rust/src/layout/line_builder.rsindex d0baab845a4..629a675b2e5 100644--- a/Libraries/LibWeb/Rust/src/layout/line_builder.rs+++ b/Libraries/LibWeb/Rust/src/layout/line_builder.rs@@ -1641,12 +1641,12 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {}start_inline_offset+ match text_align {- text_align::CENTER | text_align::_LIBWEB_CENTER | text_align::_LIBWEB_INHERIT_OR_CENTER => {+ text_align::CENTER | text_align::_WEBKIT_CENTER | text_align::_LIBWEB_INHERIT_OR_CENTER => {excess / 2}text_align::START if line_direction == direction::RTL => excess,text_align::END if line_direction == direction::LTR => excess,- text_align::RIGHT | text_align::_LIBWEB_RIGHT => excess,+ text_align::RIGHT | text_align::_WEBKIT_RIGHT => excess,text_align::MATCH_PARENT => unreachable!("match-parent must be resolved"),_ => CssPixels::default(),}diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-align/blocks/justify-self-text-align.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-align/blocks/justify-self-text-align.htmlnew file mode 100644index 00000000000..a5985088e57--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-align/blocks/justify-self-text-align.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<link rel="help" href="https://drafts.csswg.org/css-align-3/#justify-abspos">+<link rel="match" href="../../../../../expected/wpt-import/css/css-align/blocks/../../reference/ref-filled-green-100px-square.xht">+<meta name="assert" content="justify-self wins over text-align:-webkit-*" />+<style>+ #reference-overlapped-red {+ position: absolute;+ background-color: red;+ width: 100px;+ height: 100px;+ z-index: -1;+ }+</style>++<p>Test passes if there is a filled green square and <strong>no red</strong>.+</p>++<div id=reference-overlapped-red></div>++<div style="width: 200px; text-align: -webkit-right;">+ <div+ style="width: 100px; height:100px; justify-self: left; background: green;">+ </div>+</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-align/blocks/safe-justify-self-text-align-1.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-align/blocks/safe-justify-self-text-align-1.htmlnew file mode 100644index 00000000000..ef042b54580--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-align/blocks/safe-justify-self-text-align-1.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<link rel="help" href="https://drafts.csswg.org/css-align/#justify-self-property">+<link rel="match" href="../../../../../expected/wpt-import/css/css-align/blocks/../../reference/ref-filled-green-100px-square.xht">+<meta name="assert" content="text-align:-webkit values are safe aligned" />+<style>+ #reference-overlapped-red {+ position: absolute;+ background-color: red;+ width: 100px;+ height: 100px;+ z-index: -1;+ }+</style>++<p>Test passes if there is a filled green square and <strong>no red</strong>.+</p>++<div id=reference-overlapped-red></div>++<div style="width: 50px; text-align: -webkit-right;">+ <div+ style="width: 100px; height:100px; background: green;">+ </div>+</div>diff --git a/Tests/LibWeb/Text/expected/css/style-engine/presentational-hint-change.txt b/Tests/LibWeb/Text/expected/css/style-engine/presentational-hint-change.txtindex 594730ec730..d388b18aa0a 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/presentational-hint-change.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/presentational-hint-change.txt@@ -1,2 +1,2 @@-text-align: -libweb-right+text-align: -webkit-rightcolor: rgb(0, 128, 0)diff --git a/Tests/LibWeb/Text/expected/prefixed-alignment-beside-floats.txt b/Tests/LibWeb/Text/expected/prefixed-alignment-beside-floats.txtnew file mode 100644index 00000000000..fade890252e--- /dev/null+++ b/Tests/LibWeb/Text/expected/prefixed-alignment-beside-floats.txt@@ -0,0 +1,28 @@+ltr left left 60 0+ltr left center 100 0+ltr left right 140 0+ltr left self-start 60 0+ltr left self-end 140 0+ltr right left 0 0+ltr right center 40 0+ltr right right 80 0+ltr right self-start 0 0+ltr right self-end 80 0+rtl left left 60 0+rtl left center 100 0+rtl left right 140 0+rtl left self-start 140 0+rtl left self-end 60 0+rtl right left 0 0+rtl right center 40 0+rtl right right 80 0+rtl right self-start 80 0+rtl right self-end 0 0+rtl left 80px: 60 0+rtl left 90px: 25 30+rtl left 150px: -10 30+ltr right 80px: 80 0+ltr right 90px: 115 30+ltr right 150px: 150 30+ltr left start margin: 80 0+rtl right start margin: 60 0diff --git a/Tests/LibWeb/Text/expected/prefixed-alignment-justify-items-change.txt b/Tests/LibWeb/Text/expected/prefixed-alignment-justify-items-change.txtnew file mode 100644index 00000000000..90a75552e09--- /dev/null+++ b/Tests/LibWeb/Text/expected/prefixed-alignment-justify-items-change.txt@@ -0,0 +1,15 @@+100 center 50+100 right 100+100 safe center 50+100 unsafe center 50+100 left 0+100 center 50+240 center -20+240 right -40+240 safe center 0+240 unsafe center -20+240 left 0+240 center -20+-webkit-left 0+-webkit-center 50+-webkit-right 100diff --git a/Tests/LibWeb/Text/expected/prefixed-text-align.txt b/Tests/LibWeb/Text/expected/prefixed-text-align.txtnew file mode 100644index 00000000000..ccd5e4913d2--- /dev/null+++ b/Tests/LibWeb/Text/expected/prefixed-text-align.txt@@ -0,0 +1,47 @@+ltr -webkit-left 0+ltr -webkit-center 100+ltr -webkit-right 200+ltr center 0+ltr -webkit-left 350px 0 0+ltr -webkit-left 100px 0 auto 100+ltr -webkit-left 100px 0 5px 0 15px 15+ltr -webkit-center 350px 0 0+ltr -webkit-center 100px 0 auto 100+ltr -webkit-center 100px 0 5px 0 15px 105+ltr -webkit-right 350px 0 0+ltr -webkit-right 100px 0 auto 100+ltr -webkit-right 100px 0 5px 0 15px 195+rtl -webkit-left 0+rtl -webkit-center 100+rtl -webkit-right 200+rtl center 200+rtl -webkit-left 350px 0 -50+rtl -webkit-left 100px 0 auto 100+rtl -webkit-left 100px 0 5px 0 15px 15+rtl -webkit-center 350px 0 -50+rtl -webkit-center 100px 0 auto 100+rtl -webkit-center 100px 0 5px 0 15px 105+rtl -webkit-right 350px 0 -50+rtl -webkit-right 100px 0 auto 100+rtl -webkit-right 100px 0 5px 0 15px 195+horizontal-tb rtl self-start: 200+horizontal-tb rtl self-end: 0+horizontal-tb rtl baseline: 0+vertical-rl ltr self-start: 200+vertical-rl ltr self-end: 0+vertical-rl ltr baseline: 0+vertical-lr rtl self-start: 0+vertical-lr rtl self-end: 200+vertical-lr rtl baseline: 0+vertical-rl ltr -webkit-left 0+vertical-rl ltr -webkit-center 100+vertical-rl ltr -webkit-right 200+vertical-rl rtl -webkit-left 0+vertical-rl rtl -webkit-center 100+vertical-rl rtl -webkit-right 200+vertical-lr ltr -webkit-left 0+vertical-lr ltr -webkit-center 100+vertical-lr ltr -webkit-right 200+vertical-lr rtl -webkit-left 0+vertical-lr rtl -webkit-center 100+vertical-lr rtl -webkit-right 200diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-align/blocks/justify-self-text-align-2.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-align/blocks/justify-self-text-align-2.txtnew file mode 100644index 00000000000..d055897ba87--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-align/blocks/justify-self-text-align-2.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Pass+Pass .item 1+Pass .item 2+Pass .item 3\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/prefixed-alignment-beside-floats.html b/Tests/LibWeb/Text/input/prefixed-alignment-beside-floats.htmlnew file mode 100644index 00000000000..9987d756329--- /dev/null+++ b/Tests/LibWeb/Text/input/prefixed-alignment-beside-floats.html@@ -0,0 +1,40 @@+<!doctype html>+<script src="include.js"></script>+<style>+ #container { width: 200px; display: flow-root; text-align: -webkit-left; }+ #obstacle { width: 60px; height: 30px; }+ #child { width: 60px; height: 20px; display: flow-root; }+</style>+<div id="container"><div id="obstacle"></div><div id="child"></div></div>+<script>+ test(() => {+ for (const direction of ["ltr", "rtl"]) {+ container.dir = direction;+ for (const side of ["left", "right"]) {+ obstacle.style.float = side;+ for (const alignment of ["left", "center", "right", "self-start", "self-end"]) {+ child.style.justifySelf = alignment;+ println([direction, side, alignment, child.offsetLeft - container.offsetLeft, child.offsetTop - container.offsetTop].join(" "));+ }+ }+ }+ container.style.textAlign = "-webkit-center";+ child.style.justifySelf = "auto";+ for (const [direction, side, margin] of [["rtl", "left", "marginRight"], ["ltr", "right", "marginLeft"]]) {+ container.dir = direction;+ obstacle.style.float = side;+ child.style.margin = "0";+ for (const size of [80, 90, 150]) {+ child.style[margin] = size + "px";+ println(`${direction} ${side} ${size}px: ${child.offsetLeft - container.offsetLeft} ${child.offsetTop - container.offsetTop}`);+ }+ }+ for (const [direction, side, margin] of [["ltr", "left", "marginLeft"], ["rtl", "right", "marginRight"]]) {+ container.dir = direction;+ obstacle.style.float = side;+ child.style.margin = "0";+ child.style[margin] = "80px";+ println(`${direction} ${side} start margin: ${child.offsetLeft - container.offsetLeft} ${child.offsetTop - container.offsetTop}`);+ }+ });+</script>diff --git a/Tests/LibWeb/Text/input/prefixed-alignment-justify-items-change.html b/Tests/LibWeb/Text/input/prefixed-alignment-justify-items-change.htmlnew file mode 100644index 00000000000..8bbaebd8815--- /dev/null+++ b/Tests/LibWeb/Text/input/prefixed-alignment-justify-items-change.html@@ -0,0 +1,25 @@+<!doctype html>+<script src="include.js"></script>+<style>+ #container { width: 200px; text-align: -webkit-left; }+ #child { width: 100px; height: 10px; }+</style>+<div id="container"><div id="child"><div></div></div></div>+<script>+ test(() => {+ for (const width of [100, 240]) {+ child.style.width = width + "px";+ for (const alignment of ["center", "right", "safe center", "unsafe center", "left", "center"]) {+ container.style.justifyItems = alignment;+ println([width, alignment, child.offsetLeft - container.offsetLeft].join(" "));+ }+ }+ child.style.width = "100px";+ child.style.textAlign = "left";+ container.style.justifyItems = "normal";+ for (const value of ["-webkit-left", "-webkit-center", "-webkit-right"]) {+ container.style.textAlign = value;+ println([value, child.offsetLeft - container.offsetLeft].join(" "));+ }+ });+</script>diff --git a/Tests/LibWeb/Text/input/prefixed-text-align.html b/Tests/LibWeb/Text/input/prefixed-text-align.htmlnew file mode 100644index 00000000000..a3806f09fc9--- /dev/null+++ b/Tests/LibWeb/Text/input/prefixed-text-align.html@@ -0,0 +1,49 @@+<!DOCTYPE html>+<script src="include.js"></script>+<div id="parentBox" style="width: 300px"><div id="childBox" style="width: 100px"></div></div>+<script>+ test(() => {+ for (const direction of ["ltr", "rtl"]) {+ parentBox.dir = direction;+ for (const align of ["-webkit-left", "-webkit-center", "-webkit-right", "center"]) {+ parentBox.style.textAlign = align;+ const offset = childBox.getBoundingClientRect().left - parentBox.getBoundingClientRect().left;+ println(`${direction} ${getComputedStyle(parentBox).textAlign} ${offset}`);+ }+ for (const align of ["-webkit-left", "-webkit-center", "-webkit-right"]) {+ parentBox.style.textAlign = align;+ for (const [width, margin] of [["350px", "0"], ["100px", "0 auto"], ["100px", "0 5px 0 15px"]]) {+ childBox.style.width = width;+ childBox.style.margin = margin;+ println(`${direction} ${align} ${width} ${margin} ${childBox.offsetLeft - parentBox.offsetLeft}`);+ }+ }+ childBox.style.cssText = "width: 100px";+ }+ parentBox.dir = "ltr";+ parentBox.style.textAlign = "-webkit-right";+ for (const [mode, direction] of [["horizontal-tb", "rtl"], ["vertical-rl", "ltr"], ["vertical-lr", "rtl"]]) {+ childBox.dir = direction;+ childBox.style.writingMode = mode;+ for (const alignment of ["self-start", "self-end", "baseline"]) {+ childBox.style.justifySelf = alignment;+ println(`${mode} ${direction} ${alignment}: ${childBox.offsetLeft - parentBox.offsetLeft}`);+ }+ }+ childBox.removeAttribute("dir");+ childBox.style.cssText = "width: 100px";+ parentBox.dir = "rtl";+ parentBox.style.height = "300px";+ childBox.style.height = "100px";+ for (const mode of ["vertical-rl", "vertical-lr"]) {+ parentBox.style.writingMode = mode;+ for (const direction of ["ltr", "rtl"]) {+ parentBox.dir = direction;+ for (const align of ["-webkit-left", "-webkit-center", "-webkit-right"]) {+ parentBox.style.textAlign = align;+ println(`${mode} ${direction} ${align} ${childBox.offsetTop - parentBox.offsetTop}`);+ }+ }+ }+ });+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-align/blocks/justify-self-text-align-2.html b/Tests/LibWeb/Text/input/wpt-import/css/css-align/blocks/justify-self-text-align-2.htmlnew file mode 100644index 00000000000..e872b18d8eb--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-align/blocks/justify-self-text-align-2.html@@ -0,0 +1,40 @@+<!DOCTYPE html>+<link rel="help" href="https://drafts.csswg.org/css-align/#justify-self-property">+<meta name="assert" content="text-align:-webkit-*, justify-items, justify-self work correctly in tandem when all are specified" />+<style>++.container {+ width: 200px;+ position: relative;+ outline: solid;+ justify-items: center;+ text-align: -webkit-right;+}++.item {+ background: lightblue;+ width: 100px;+ height: 100px;+ outline: solid;+}++</style>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script src="../../../resources/check-layout-th.js"></script>++<div class="container">+ <div class="item" style="justify-self: normal;" data-offset-x="100">+ normal+ </div>+ <div class="item" style="justify-self: auto;" data-offset-x="50">+ auto+ </div>+ <div class="item" style="justify-self: left;" data-offset-x="0">+ left+ </div>+</div>++<script>+ checkLayout('.item');+</script>