aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorOriol Brufau <obrufau@igalia.com>2024-02-23 16:36:36 +0100
committerGitHub <noreply@github.com>2024-02-23 15:36:36 +0000
commit38d2ad95928c4b5c1feac2e615724445d2ec9474 (patch)
treee1057a056ed076a8744a672d3ced2361e47e448c /components
parent0a8b69879a849a5ad9af2066076343232b0c18b7 (diff)
downloadservo-38d2ad95928c4b5c1feac2e615724445d2ec9474.tar.gz
servo-38d2ad95928c4b5c1feac2e615724445d2ec9474.zip
Support <div align="..."> and <center> on inline layout (#31388)
As per HTML [1], <div align="..."> and <center> 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
Diffstat (limited to 'components')
-rw-r--r--components/layout_2020/flow/inline.rs27
1 files 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() {