1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:47:44 +00:00

LibWeb: Add -libweb-left and -libweb-right text-align values

These ensure that block level elements are also left and right aligned
respectively on top of the regular text alignment, matching
-libweb-center.
This commit is contained in:
kamp 2023-06-15 17:31:27 +02:00 committed by Andreas Kling
parent 7302f8838c
commit 4ac7c41483
4 changed files with 10 additions and 1 deletions

View file

@ -242,7 +242,9 @@
"justify", "justify",
"left", "left",
"right", "right",
"-libweb-center" "-libweb-center",
"-libweb-left",
"-libweb-right"
], ],
"text-decoration-line": [ "text-decoration-line": [
"blink", "blink",

View file

@ -1,5 +1,7 @@
[ [
"-libweb-center", "-libweb-center",
"-libweb-left",
"-libweb-right",
"-libweb-link", "-libweb-link",
"-libweb-palette-active-link", "-libweb-palette-active-link",
"-libweb-palette-active-window-border1", "-libweb-palette-active-window-border1",

View file

@ -815,6 +815,9 @@ void BlockFormattingContext::place_block_level_element_in_normal_flow_horizontal
if (child_box.containing_block()->computed_values().text_align() == CSS::TextAlign::LibwebCenter) { if (child_box.containing_block()->computed_values().text_align() == CSS::TextAlign::LibwebCenter) {
x += (available_width_within_containing_block / 2) - box_state.content_width() / 2; x += (available_width_within_containing_block / 2) - box_state.content_width() / 2;
} else if (child_box.containing_block()->computed_values().text_align() == CSS::TextAlign::LibwebRight) {
// Subtracting the left margin here because left and right margins need to be swapped when aligning to the right
x += available_width_within_containing_block - box_state.content_width() - box_state.margin_box_left();
} else { } else {
x += box_state.margin_box_left(); x += box_state.margin_box_left();
} }

View file

@ -180,9 +180,11 @@ void LineBuilder::update_last_line()
x_offset += excess_horizontal_space / 2; x_offset += excess_horizontal_space / 2;
break; break;
case CSS::TextAlign::Right: case CSS::TextAlign::Right:
case CSS::TextAlign::LibwebRight:
x_offset += excess_horizontal_space; x_offset += excess_horizontal_space;
break; break;
case CSS::TextAlign::Left: case CSS::TextAlign::Left:
case CSS::TextAlign::LibwebLeft:
case CSS::TextAlign::Justify: case CSS::TextAlign::Justify:
default: default:
break; break;