From 38d2ad95928c4b5c1feac2e615724445d2ec9474 Mon Sep 17 00:00:00 2001 From: Oriol Brufau Date: Fri, 23 Feb 2024 16:36:36 +0100 Subject: [PATCH] Support
and
on inline layout (#31388) As per HTML [1],
and
should behave as if they had the text-align property set to the corresponding value. Servo implements that as internal text-align values because there should the extra effect of aligning block descendants, but that part has not been implemented yet. This patch only adds support for inline layout. [1]: https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3 --- components/layout_2020/flow/inline.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/components/layout_2020/flow/inline.rs b/components/layout_2020/flow/inline.rs index d071200eeaa..c5d6156afb6 100644 --- a/components/layout_2020/flow/inline.rs +++ b/components/layout_2020/flow/inline.rs @@ -828,7 +828,6 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> { End, } let style = self.containing_block.style; - let line_left_is_inline_start = style.writing_mode.line_left_is_inline_start(); let mut text_align_keyword = style.clone_text_align(); if last_line_or_forced_line_break { @@ -848,19 +847,23 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> { let text_align = match text_align_keyword { TextAlignKeyword::Start => TextAlign::Start, - TextAlignKeyword::Center => TextAlign::Center, + TextAlignKeyword::Center | TextAlignKeyword::ServoCenter => TextAlign::Center, TextAlignKeyword::End => TextAlign::End, - TextAlignKeyword::Left if line_left_is_inline_start => TextAlign::Start, - TextAlignKeyword::Left => TextAlign::End, - TextAlignKeyword::Right if line_left_is_inline_start => TextAlign::End, - TextAlignKeyword::Right => TextAlign::Start, - TextAlignKeyword::Justify => TextAlign::Start, - TextAlignKeyword::ServoCenter | - TextAlignKeyword::ServoLeft | - TextAlignKeyword::ServoRight => { - // TODO: Implement these modes which seem to be used by quirks mode. - TextAlign::Start + TextAlignKeyword::Left | TextAlignKeyword::ServoLeft => { + if style.writing_mode.line_left_is_inline_start() { + TextAlign::Start + } else { + TextAlign::End + } }, + TextAlignKeyword::Right | TextAlignKeyword::ServoRight => { + if style.writing_mode.line_left_is_inline_start() { + TextAlign::End + } else { + TextAlign::Start + } + }, + TextAlignKeyword::Justify => TextAlign::Start, }; let (line_start, available_space) = match self.current_line.placement_among_floats.get() {