Repository: servo/servo (language: python)

Issue:
Incorrect image alignment on https://servo.org
**Describe the bug:**
The header of https://servo.org has incorrectly aligned images when rendered with Servo (it works fine in Chrome, so this is rendering engine bug). See screenshot below:

<img width="1150" alt="Screenshot 2024-10-31 at 11 59 18" src="https://github.com/user-attachments/assets/e1fc7d0f-e473-4add-aebb-978cce204783">

In both cases it seems like the images are getting "start" alignment rather than "center/middle" alignment. But that might just be a coincidence.

**To Reproduce:**
Load https://servo.org in Servo.

**Platform:**
Presumably all platforms. Tested on macOS.



Discussion / hints:
Reduced to
```html
<!DOCTYPE html>
<html>
<head>
  <style>
    .button {
      display: inline-flex;
      justify-content: center;
      outline: 1px solid black;
    }

    .icon {
      height: 2em;
      width: 2em;
      margin: 0 1em;
      outline: 1px solid green;
    }
  </style>
</head>

<body>
  <a class="button">
    <span class="icon"></span>
  </a>
</body>
</html>
```
| Servo cc6f7c5bc42c049302480d42a5ebd70f984a1e8e | Firefox |
| --- | --- |
| ![image](https://github.com/user-attachments/assets/88e5f6e6-4740-4b79-be2f-fe488aa13a46)| ![image](https://github.com/user-attachments/assets/74db5932-ba47-4e38-9e6c-358da236a7c3) |

(This is a reduction for the social media icons, it's possible that the misalignment of the servo brand image on the left is caused by something else)

Fix patch:
diff --git a/components/layout_2020/flexbox/layout.rs b/components/layout_2020/flexbox/layout.rs
index bb580c23f8d6b..c9f369ed45609 100644
--- a/components/layout_2020/flexbox/layout.rs
+++ b/components/layout_2020/flexbox/layout.rs
@@ -1393,12 +1393,12 @@ impl InitialFlexLineLayout<'_> {
         }
 
         let check_for_flexible_items = || frozen_count.get() < items.len();
-        let free_space = || {
+        let free_space = |all_items_frozen: bool| {
             container_main_size -
                 items_and_main_sizes()
                     .map(|((item, target_main_size), frozen)| {
                         item.pbm_auto_is_zero.main +
-                            if frozen.get() {
+                            if all_items_frozen || frozen.get() {
                                 target_main_size.get()
                             } else {
                                 item.flex_base_size
@@ -1407,7 +1407,7 @@ impl InitialFlexLineLayout<'_> {
                     .sum()
         };
         // https://drafts.csswg.org/css-flexbox/#initial-free-space
-        let initial_free_space = free_space();
+        let initial_free_space = free_space(false);
         let unfrozen_items = || {
             items_and_main_sizes().filter_map(|(item_and_target_main_size, frozen)| {
                 if !frozen.get() {
@@ -1419,7 +1419,7 @@ impl InitialFlexLineLayout<'_> {
         };
         loop {
             // https://drafts.csswg.org/css-flexbox/#remaining-free-space
-            let mut remaining_free_space = free_space();
+            let mut remaining_free_space = free_space(false);
             if !check_for_flexible_items() {
                 return (target_main_sizes_vec, remaining_free_space);
             }
@@ -1481,8 +1481,7 @@ impl InitialFlexLineLayout<'_> {
                 Ordering::Equal => {
                     // “Freeze all items.”
                     // Return instead, as that’s what the next loop iteration would do.
-                    let remaining_free_space =
-                        container_main_size - target_main_sizes_vec.iter().cloned().sum();
+                    let remaining_free_space = free_space(true);
                     return (target_main_sizes_vec, remaining_free_space);
                 },
                 Ordering::Greater => {


Test patch:
diff --git a/tests/wpt/meta/css/css-flexbox/flex-flow-013.html.ini b/tests/wpt/meta/css/css-flexbox/flex-flow-013.html.ini
index f42a2a0010df2..60c9c874e5594 100644
--- a/tests/wpt/meta/css/css-flexbox/flex-flow-013.html.ini
+++ b/tests/wpt/meta/css/css-flexbox/flex-flow-013.html.ini
@@ -5,18 +5,6 @@
   [.flexbox 11]
     expected: FAIL
 
-  [.flexbox 4]
-    expected: FAIL
-
-  [.flexbox 2]
-    expected: FAIL
-
-  [.flexbox 1]
-    expected: FAIL
-
-  [.flexbox 3]
-    expected: FAIL
-
   [.flexbox 9]
     expected: FAIL
 
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-canvas-horiz-001.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-canvas-horiz-001.xhtml.ini
deleted file mode 100644
index 33508636edf72..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-canvas-horiz-001.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-canvas-horiz-001.xhtml]
-  expected: FAIL
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-canvas-horiz-001v.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-canvas-horiz-001v.xhtml.ini
deleted file mode 100644
index c33eb69f9e904..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-canvas-horiz-001v.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-canvas-horiz-001v.xhtml]
-  expected: FAIL
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-canvas-vert-001.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-canvas-vert-001.xhtml.ini
deleted file mode 100644
index 50da74a7d55ae..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-canvas-vert-001.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-canvas-vert-001.xhtml]
-  expected: FAIL
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-canvas-vert-001v.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-canvas-vert-001v.xhtml.ini
deleted file mode 100644
index 33cdfcd51eed3..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-canvas-vert-001v.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-canvas-vert-001v.xhtml]
-  expected: FAIL
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-fieldset-horiz-001.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-fieldset-horiz-001.xhtml.ini
deleted file mode 100644
index ab01e596fb67c..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-fieldset-horiz-001.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-fieldset-horiz-001.xhtml]
-  expected: FAIL
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-fieldset-vert-001.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-fieldset-vert-001.xhtml.ini
deleted file mode 100644
index bdb738da04e88..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-fieldset-vert-001.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-fieldset-vert-001.xhtml]
-  expected: FAIL
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-iframe-horiz-001.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-iframe-horiz-001.xhtml.ini
deleted file mode 100644
index 36cc12e570cdc..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-iframe-horiz-001.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-iframe-horiz-001.xhtml]
-  expected: FAIL
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-iframe-vert-001.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-iframe-vert-001.xhtml.ini
deleted file mode 100644
index 98e1aadf6ea9f..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-iframe-vert-001.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-iframe-vert-001.xhtml]
-  expected: FAIL
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-img-horiz-001.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-img-horiz-001.xhtml.ini
deleted file mode 100644
index b81dc136ed22b..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-img-horiz-001.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-img-horiz-001.xhtml]
-  expected: FAIL
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-img-vert-001.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-img-vert-001.xhtml.ini
deleted file mode 100644
index 8d2aa03e0d7ad..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-img-vert-001.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-img-vert-001.xhtml]
-  expected: FAIL
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-textarea-horiz-001.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-textarea-horiz-001.xhtml.ini
deleted file mode 100644
index fcbae31856fb6..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-textarea-horiz-001.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-textarea-horiz-001.xhtml]
-  expected: FAIL
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-textarea-vert-001.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-textarea-vert-001.xhtml.ini
deleted file mode 100644
index 6209fc1effce3..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-textarea-vert-001.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-textarea-vert-001.xhtml]
-  expected: FAIL
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-video-horiz-001.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-video-horiz-001.xhtml.ini
deleted file mode 100644
index 228a9d52f61a9..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-video-horiz-001.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-video-horiz-001.xhtml]
-  expected: FAIL
diff --git a/tests/wpt/meta/css/css-flexbox/flexbox-basic-video-vert-001.xhtml.ini b/tests/wpt/meta/css/css-flexbox/flexbox-basic-video-vert-001.xhtml.ini
deleted file mode 100644
index 78a712924f514..0000000000000
--- a/tests/wpt/meta/css/css-flexbox/flexbox-basic-video-vert-001.xhtml.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flexbox-basic-video-vert-001.xhtml]
-  expected: FAIL