WebKit export of https://bugs.webkit.org/show_bug.cgi?id=249206 (#37652)

[margin-trim] Implement margin trim for block containers
https://commits.webkit.org/258457@main
diff --git a/css/css-box/margin-trim/block-container-block-001.html b/css/css-box/margin-trim/block-container-block-001.html
new file mode 100644
index 0000000..516a90c
--- /dev/null
+++ b/css/css-box/margin-trim/block-container-block-001.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>CSS margin-trim: block trim 001</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block should trim block start and end margins for block-level first child">
+<style>
+.container {
+    background-color: green;
+    width: 100px;
+    margin-trim: block;
+}
+.outer {
+    background-color: green;
+    width: 100px;
+    height: 50px;
+}
+.child {
+    margin-top: 50px;
+    margin-bottom: 50px;
+    height: 50px;
+}
+</style>
+</head>
+<body>
+    <p>Test passes if there is a filled green square.</p>
+    <div class="container">
+        <div class="child"></div>
+    </div>
+    <div class="outer"></div>
+</body>
+</html>
diff --git a/css/css-box/margin-trim/block-container-block-002.html b/css/css-box/margin-trim/block-container-block-002.html
new file mode 100644
index 0000000..1f86d55
--- /dev/null
+++ b/css/css-box/margin-trim/block-container-block-002.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>CSS margin-trim: block trim 002</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block should trim block start and end margins for ONLY block-level first/last children">
+<style>
+.container {
+    background-color: green;
+    width: 100px;
+    margin-trim: block;
+}
+.first {
+    margin-top: 50px;
+    height: 25px;
+}
+.second {
+    width: 100px;
+    height: 10px;
+    margin-bottom: 15px;
+}
+.third {
+    width: 100px;
+    height: 25px;
+    margin-bottom: 50px;
+}
+.outer {
+    width: 100px;
+    height: 25px;
+    background-color: green;
+}
+</style>
+</head>
+<body>
+    <p>Test passes if there is a filled green square.</p>
+    <div class="container">
+        <div class="first"></div>
+        <div class="second"></div>
+        <div class="third"></div>
+    </div>
+    <div class="outer"></div>
+</body>
+</html>
diff --git a/css/css-box/margin-trim/block-container-block-end-001.html b/css/css-box/margin-trim/block-container-block-end-001.html
new file mode 100644
index 0000000..e36a207
--- /dev/null
+++ b/css/css-box/margin-trim/block-container-block-end-001.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>CSS margin-trim: block end trim 001</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block-end should trim block end margin for block-level first child">
+<style>
+.container {
+    background-color: green;
+    width: 100px;
+    margin-trim: block-end;
+}
+.outer {
+    background-color: green;
+    width: 100px;
+    height: 50px;
+}
+.child {
+    margin-bottom: 50px;
+    height: 50px;
+}
+</style>
+</head>
+<body>
+    <p>Test passes if there is a filled green square.</p>
+    <div class="container">
+        <div class="child"></div>
+    </div>
+    <div class="outer"></div>
+</body>
+</html>
diff --git a/css/css-box/margin-trim/block-container-block-end-002.html b/css/css-box/margin-trim/block-container-block-end-002.html
new file mode 100644
index 0000000..2859e10
--- /dev/null
+++ b/css/css-box/margin-trim/block-container-block-end-002.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>CSS margin-trim: block end trim 002</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block-end should trim block end margin for ONLY block-level first child">
+<style>
+.container {
+    width: 100px;
+    margin-trim: block-end;
+    background-color: green;
+}
+.outer {
+    width: 100px;
+    height: 40px;
+    background-color: green;
+}
+.first {
+    width: 100%;
+    margin-bottom: 25px;
+    height: 25px;
+}
+.second {
+    margin-bottom: 100px;
+    width: 100%;
+    height: 10px;
+}
+</style>
+</head>
+<body>
+    <p>Test passes if there is a filled green square.</p>
+    <div class="container">
+        <div class="first"></div>
+        <div class="second"></div>
+    </div>
+    <div class="outer"></div>
+</body>
+</html>
diff --git a/css/css-box/margin-trim/block-container-block-start-001.html b/css/css-box/margin-trim/block-container-block-start-001.html
new file mode 100644
index 0000000..2fecf07
--- /dev/null
+++ b/css/css-box/margin-trim/block-container-block-start-001.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>CSS margin-trim: block start trim 001</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block-start should trim block start margin for block-level first child">
+<style>
+.container {
+    background-color: green;
+    width: 100px;
+    margin-trim: block-start;
+}
+.outer {
+    background-color: green;
+    width: 100px;
+    height: 50px;
+}
+.child {
+    margin-top: 50px;
+    height: 50px;
+}
+</style>
+</head>
+<body>
+    <p>Test passes if there is a filled green square.</p>
+    <div class="outer"></div>
+    <div class="container">
+        <div class="child"></div>
+    </div>
+</body>
+</html>
diff --git a/css/css-box/margin-trim/block-container-block-start-002.html b/css/css-box/margin-trim/block-container-block-start-002.html
new file mode 100644
index 0000000..6edbb54
--- /dev/null
+++ b/css/css-box/margin-trim/block-container-block-start-002.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>CSS margin-trim: block start trim 002</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block-start should trim block start margin for ONLY block-level first child">
+<style>
+.container {
+    background-color: green;
+    width: 100px;
+    margin-trim: block-start;
+}
+.outer {
+    background-color: green;
+    width: 100px;
+    height: 10px;
+}
+.first {
+    margin-top: 50px;
+    width: 100%;
+    height: 40px;
+}
+.second {
+    margin-top: 10px;
+    width: 100%;
+    height: 40px;
+}
+</style>
+</head>
+<body>
+    <p>Test passes if there is a filled green square.</p>
+    <div class="outer"></div>
+    <div class="container">
+        <div class="first"></div>
+        <div class="second"></div>
+    </div>
+</body>
+</html>
diff --git a/css/css-box/margin-trim/block-container-replaced-block-end.html b/css/css-box/margin-trim/block-container-replaced-block-end.html
new file mode 100644
index 0000000..6011d10
--- /dev/null
+++ b/css/css-box/margin-trim/block-container-replaced-block-end.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>CSS margin-trim: block container replaced block-end trim</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block level replaced element should have block-end trimmed">
+<style>
+.container {
+   width: 100px;
+   margin-trim: block-end;
+}
+.outer {
+    background-color: green;
+    width: 100px;
+    height: 40px;
+}
+.child {
+    display: block;
+    margin-bottom: 50px;
+    background-color: green;
+    padding-right: 40px;
+}
+</style>
+</head>
+<body>
+    <p>Test passes if there is a filled green square.</p>
+    <div class="container">
+        <img class="child" src="/css/support/60x60-green.png"/>
+    </div>
+    <div class="outer"></div>
+</body>
+</html>
diff --git a/css/css-box/margin-trim/block-container-replaced-block-start.html b/css/css-box/margin-trim/block-container-replaced-block-start.html
new file mode 100644
index 0000000..c943fb1
--- /dev/null
+++ b/css/css-box/margin-trim/block-container-replaced-block-start.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>CSS margin-trim: block container replaced block-start trim</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block level replaced element should have block-start trimmed">
+<style>
+.container {
+   width: 100px;
+   margin-trim: block-start;
+}
+.outer {
+    background-color: green;
+    width: 100px;
+    height: 40px;
+}
+.child {
+    display: block;
+    margin-top: 50px;
+    background-color: green;
+    padding-right: 40px;
+}
+</style>
+</head>
+<body>
+    <p>Test passes if there is a filled green square.</p>
+    <div class="outer"></div>
+    <div class="container">
+        <img class="child" src="/css/support/60x60-green.png"/>
+    </div>
+</body>
+</html>
diff --git a/css/css-box/margin-trim/block-container-replaced-block.html b/css/css-box/margin-trim/block-container-replaced-block.html
new file mode 100644
index 0000000..54d7011
--- /dev/null
+++ b/css/css-box/margin-trim/block-container-replaced-block.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>CSS margin-trim: block container replaced block trim</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block level replaced element should have both block-start and block-end trimmed when block is specified">
+<style>
+.container {
+    width: 100px;
+    margin-trim: block;
+}
+.outer {
+    background-color: green;
+    width: 100px;
+    height: 40px;
+}
+.child {
+    display: block;
+    margin-top: 50px;
+    margin-bottom: 50px;
+    background-color: green;
+    padding-right: 40px;
+}
+</style>
+</head>
+<body>
+    <p>Test passes if there is a filled green square.</p>
+    <div class="container">
+        <img class="child" src="/css/support/60x60-green.png"/>
+    </div>
+    <div class="outer"></div>
+</body>
+</html>