diff --git a/Userland/Libraries/LibWeb/CSS/Enums.json b/Userland/Libraries/LibWeb/CSS/Enums.json index 7a3ee894405..ca091a0efbc 100644 --- a/Userland/Libraries/LibWeb/CSS/Enums.json +++ b/Userland/Libraries/LibWeb/CSS/Enums.json @@ -242,7 +242,9 @@ "justify", "left", "right", - "-libweb-center" + "-libweb-center", + "-libweb-left", + "-libweb-right" ], "text-decoration-line": [ "blink", diff --git a/Userland/Libraries/LibWeb/CSS/Identifiers.json b/Userland/Libraries/LibWeb/CSS/Identifiers.json index 06c50f2eda4..65151958695 100644 --- a/Userland/Libraries/LibWeb/CSS/Identifiers.json +++ b/Userland/Libraries/LibWeb/CSS/Identifiers.json @@ -1,5 +1,7 @@ [ "-libweb-center", + "-libweb-left", + "-libweb-right", "-libweb-link", "-libweb-palette-active-link", "-libweb-palette-active-window-border1", diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index db482ff25ba..da1d6ff82da 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -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) { 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 { x += box_state.margin_box_left(); } diff --git a/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp b/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp index 44ed5c689d1..858d47c67d7 100644 --- a/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp @@ -180,9 +180,11 @@ void LineBuilder::update_last_line() x_offset += excess_horizontal_space / 2; break; case CSS::TextAlign::Right: + case CSS::TextAlign::LibwebRight: x_offset += excess_horizontal_space; break; case CSS::TextAlign::Left: + case CSS::TextAlign::LibwebLeft: case CSS::TextAlign::Justify: default: break;