Explorar o código

LibWeb: Support "normal" and "stretch" justify-content in CSS parser

Aliaksandr Kalenik hai 1 ano
pai
achega
56ff9bffae

+ 1 - 1
Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt

@@ -87,7 +87,7 @@ inset-block-end: auto
 inset-block-start: auto
 inset-inline-end: auto
 inset-inline-start: auto
-justify-content: flex-start
+justify-content: normal
 justify-items: legacy
 justify-self: auto
 left: auto

+ 3 - 1
Userland/Libraries/LibWeb/CSS/Enums.json

@@ -206,6 +206,7 @@
     "optimizequality=smooth"
   ],
   "justify-content": [
+    "normal",
     "start",
     "end",
     "flex-start",
@@ -213,7 +214,8 @@
     "center",
     "space-between",
     "space-around",
-    "space-evenly"
+    "space-evenly",
+    "stretch"
   ],
   "justify-items": [
     "baseline",

+ 1 - 1
Userland/Libraries/LibWeb/CSS/Properties.json

@@ -1264,7 +1264,7 @@
   },
   "justify-content": {
     "inherited": false,
-    "initial": "flex-start",
+    "initial": "normal",
     "valid-types": [
       "justify-content"
     ]

+ 6 - 0
Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp

@@ -1319,6 +1319,8 @@ void FlexFormattingContext::distribute_any_remaining_free_space()
         if (auto_margins == 0 && number_of_items > 0) {
             switch (flex_container().computed_values().justify_content()) {
             case CSS::JustifyContent::Start:
+            case CSS::JustifyContent::Stretch:
+            case CSS::JustifyContent::Normal:
                 initial_offset = 0;
                 break;
             case CSS::JustifyContent::FlexStart:
@@ -1385,11 +1387,13 @@ void FlexFormattingContext::distribute_any_remaining_free_space()
 
         if (auto_margins == 0) {
             switch (flex_container().computed_values().justify_content()) {
+            case CSS::JustifyContent::Normal:
             case CSS::JustifyContent::FlexStart:
             case CSS::JustifyContent::Center:
             case CSS::JustifyContent::SpaceAround:
             case CSS::JustifyContent::SpaceBetween:
             case CSS::JustifyContent::SpaceEvenly:
+            case CSS::JustifyContent::Stretch:
                 if (is_direction_reverse()) {
                     flex_region_render_cursor = FlexRegionRenderCursor::Right;
                 }
@@ -2221,6 +2225,8 @@ CSSPixelPoint FlexFormattingContext::calculate_static_position(Box const& box) c
     CSSPixels main_offset = 0;
     switch (flex_container().computed_values().justify_content()) {
     case CSS::JustifyContent::Start:
+    case CSS::JustifyContent::Stretch:
+    case CSS::JustifyContent::Normal:
         pack_from_end = false;
         break;
     case CSS::JustifyContent::FlexStart: