Skip to content

Truly independent web browser

LibWeb: Create an empty numeric type from an empty unit map

Andreas Kling6113acd90dcd
diff --git a/Libraries/LibWeb/CSS/NumericType.cpp b/Libraries/LibWeb/CSS/NumericType.cpp
index 17c6bac3524..f8ad01e295a 100644
--- a/Libraries/LibWeb/CSS/NumericType.cpp
+++ b/Libraries/LibWeb/CSS/NumericType.cpp
@@ -143,8 +143,9 @@ Optional<NumericType> NumericType::create_from_unit_map(UnitMap const& unit_map)
}
// 3. Return the result of multiplying all the items of types.
+ // NB: Multiplying no types at all, as for the empty unit map of a plain number, results in an empty type.
if (types.is_empty())
- return {};
+ return NumericType {};
auto result = types.first();
bool first = true;
for (auto const& type : types) {
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/animation-iteration-count.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/animation-iteration-count.txt
index 75c8550dee8..0e56b6a0105 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/animation-iteration-count.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/animation-iteration-count.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 32 tests
-31 Pass
-1 Fail
+32 Pass
Pass Can set 'animation-iteration-count' to CSS-wide keywords: initial
Pass Can set 'animation-iteration-count' to CSS-wide keywords: inherit
Pass Can set 'animation-iteration-count' to CSS-wide keywords: unset
@@ -13,7 +12,7 @@ Pass Can set 'animation-iteration-count' to the 'infinite' keyword: infinite
Pass Can set 'animation-iteration-count' to a number: 0
Pass Can set 'animation-iteration-count' to a number: -3.14
Pass Can set 'animation-iteration-count' to a number: 3.14
-Fail Can set 'animation-iteration-count' to a number: calc(2 + 3)
+Pass Can set 'animation-iteration-count' to a number: calc(2 + 3)
Pass Setting 'animation-iteration-count' to a length: 0px throws TypeError
Pass Setting 'animation-iteration-count' to a length: -3.14em throws TypeError
Pass Setting 'animation-iteration-count' to a length: 3.14cm throws TypeError
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/fill-opacity.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/fill-opacity.txt
index 1642b9c57aa..18873967914 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/fill-opacity.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/fill-opacity.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 31 tests
-30 Pass
-1 Fail
+31 Pass
Pass Can set 'fill-opacity' to CSS-wide keywords: initial
Pass Can set 'fill-opacity' to CSS-wide keywords: inherit
Pass Can set 'fill-opacity' to CSS-wide keywords: unset
@@ -12,7 +11,7 @@ Pass Can set 'fill-opacity' to var() references: var(--A)
Pass Can set 'fill-opacity' to a number: 0
Pass Can set 'fill-opacity' to a number: -3.14
Pass Can set 'fill-opacity' to a number: 3.14
-Fail Can set 'fill-opacity' to a number: calc(2 + 3)
+Pass Can set 'fill-opacity' to a number: calc(2 + 3)
Pass Can set 'fill-opacity' to a percent: 0%
Pass Can set 'fill-opacity' to a percent: -3.14%
Pass Can set 'fill-opacity' to a percent: 3.14%
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/flex-grow.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/flex-grow.txt
index 54c86357c31..d9abf5f4206 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/flex-grow.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/flex-grow.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 31 tests
-30 Pass
-1 Fail
+31 Pass
Pass Can set 'flex-grow' to CSS-wide keywords: initial
Pass Can set 'flex-grow' to CSS-wide keywords: inherit
Pass Can set 'flex-grow' to CSS-wide keywords: unset
@@ -12,7 +11,7 @@ Pass Can set 'flex-grow' to var() references: var(--A)
Pass Can set 'flex-grow' to a number: 0
Pass Can set 'flex-grow' to a number: -3.14
Pass Can set 'flex-grow' to a number: 3.14
-Fail Can set 'flex-grow' to a number: calc(2 + 3)
+Pass Can set 'flex-grow' to a number: calc(2 + 3)
Pass Setting 'flex-grow' to a length: 0px throws TypeError
Pass Setting 'flex-grow' to a length: -3.14em throws TypeError
Pass Setting 'flex-grow' to a length: 3.14cm throws TypeError
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/flex-shrink.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/flex-shrink.txt
index f27d3d14355..22ff28ae119 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/flex-shrink.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/flex-shrink.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 31 tests
-30 Pass
-1 Fail
+31 Pass
Pass Can set 'flex-shrink' to CSS-wide keywords: initial
Pass Can set 'flex-shrink' to CSS-wide keywords: inherit
Pass Can set 'flex-shrink' to CSS-wide keywords: unset
@@ -12,7 +11,7 @@ Pass Can set 'flex-shrink' to var() references: var(--A)
Pass Can set 'flex-shrink' to a number: 0
Pass Can set 'flex-shrink' to a number: -3.14
Pass Can set 'flex-shrink' to a number: 3.14
-Fail Can set 'flex-shrink' to a number: calc(2 + 3)
+Pass Can set 'flex-shrink' to a number: calc(2 + 3)
Pass Setting 'flex-shrink' to a length: 0px throws TypeError
Pass Setting 'flex-shrink' to a length: -3.14em throws TypeError
Pass Setting 'flex-shrink' to a length: 3.14cm throws TypeError
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/flood-opacity.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/flood-opacity.txt
index 0fd23dc6a0d..d6f7f5b548e 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/flood-opacity.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/flood-opacity.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 31 tests
-30 Pass
-1 Fail
+31 Pass
Pass Can set 'flood-opacity' to CSS-wide keywords: initial
Pass Can set 'flood-opacity' to CSS-wide keywords: inherit
Pass Can set 'flood-opacity' to CSS-wide keywords: unset
@@ -12,7 +11,7 @@ Pass Can set 'flood-opacity' to var() references: var(--A)
Pass Can set 'flood-opacity' to a number: 0
Pass Can set 'flood-opacity' to a number: -3.14
Pass Can set 'flood-opacity' to a number: 3.14
-Fail Can set 'flood-opacity' to a number: calc(2 + 3)
+Pass Can set 'flood-opacity' to a number: calc(2 + 3)
Pass Can set 'flood-opacity' to a percent: 0%
Pass Can set 'flood-opacity' to a percent: -3.14%
Pass Can set 'flood-opacity' to a percent: 3.14%
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font-size-adjust.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font-size-adjust.txt
index cb3e9b9b1b6..4d7eb9fdbd3 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font-size-adjust.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font-size-adjust.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 32 tests
-31 Pass
-1 Fail
+32 Pass
Pass Can set 'font-size-adjust' to CSS-wide keywords: initial
Pass Can set 'font-size-adjust' to CSS-wide keywords: inherit
Pass Can set 'font-size-adjust' to CSS-wide keywords: unset
@@ -13,7 +12,7 @@ Pass Can set 'font-size-adjust' to the 'none' keyword: none
Pass Can set 'font-size-adjust' to a number: 0
Pass Can set 'font-size-adjust' to a number: -3.14
Pass Can set 'font-size-adjust' to a number: 3.14
-Fail Can set 'font-size-adjust' to a number: calc(2 + 3)
+Pass Can set 'font-size-adjust' to a number: calc(2 + 3)
Pass Setting 'font-size-adjust' to a length: 0px throws TypeError
Pass Setting 'font-size-adjust' to a length: -3.14em throws TypeError
Pass Setting 'font-size-adjust' to a length: 3.14cm throws TypeError
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font-weight.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font-weight.txt
index 3cab31292e3..4f5aa695ecd 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font-weight.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font-weight.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 35 tests
-34 Pass
-1 Fail
+35 Pass
Pass Can set 'font-weight' to CSS-wide keywords: initial
Pass Can set 'font-weight' to CSS-wide keywords: inherit
Pass Can set 'font-weight' to CSS-wide keywords: unset
@@ -16,7 +15,7 @@ Pass Can set 'font-weight' to the 'lighter' keyword: lighter
Pass Can set 'font-weight' to a number: 0
Pass Can set 'font-weight' to a number: -3.14
Pass Can set 'font-weight' to a number: 3.14
-Fail Can set 'font-weight' to a number: calc(2 + 3)
+Pass Can set 'font-weight' to a number: calc(2 + 3)
Pass Setting 'font-weight' to a length: 0px throws TypeError
Pass Setting 'font-weight' to a length: -3.14em throws TypeError
Pass Setting 'font-weight' to a length: 3.14cm throws TypeError
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/opacity.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/opacity.txt
index 6daeff3d778..dfee2d38907 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/opacity.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/opacity.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 31 tests
-30 Pass
-1 Fail
+31 Pass
Pass Can set 'opacity' to CSS-wide keywords: initial
Pass Can set 'opacity' to CSS-wide keywords: inherit
Pass Can set 'opacity' to CSS-wide keywords: unset
@@ -12,7 +11,7 @@ Pass Can set 'opacity' to var() references: var(--A)
Pass Can set 'opacity' to a number: 0
Pass Can set 'opacity' to a number: -3.14
Pass Can set 'opacity' to a number: 3.14
-Fail Can set 'opacity' to a number: calc(2 + 3)
+Pass Can set 'opacity' to a number: calc(2 + 3)
Pass Can set 'opacity' to a percent: 0%
Pass Can set 'opacity' to a percent: -3.14%
Pass Can set 'opacity' to a percent: 3.14%
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/shape-image-threshold.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/shape-image-threshold.txt
index 8f520e74e4e..f1f9ae88a68 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/shape-image-threshold.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/shape-image-threshold.txt
@@ -2,8 +2,8 @@ Harness status: OK
Found 31 tests
-26 Pass
-5 Fail
+27 Pass
+4 Fail
Pass Can set 'shape-image-threshold' to CSS-wide keywords: initial
Pass Can set 'shape-image-threshold' to CSS-wide keywords: inherit
Pass Can set 'shape-image-threshold' to CSS-wide keywords: unset
@@ -12,7 +12,7 @@ Pass Can set 'shape-image-threshold' to var() references: var(--A)
Pass Can set 'shape-image-threshold' to a number: 0
Pass Can set 'shape-image-threshold' to a number: -3.14
Pass Can set 'shape-image-threshold' to a number: 3.14
-Fail Can set 'shape-image-threshold' to a number: calc(2 + 3)
+Pass Can set 'shape-image-threshold' to a number: calc(2 + 3)
Pass Setting 'shape-image-threshold' to a length: 0px throws TypeError
Pass Setting 'shape-image-threshold' to a length: -3.14em throws TypeError
Pass Setting 'shape-image-threshold' to a length: 3.14cm throws TypeError
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/stop-opacity.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/stop-opacity.txt
index 658a05c13ab..bcdf9064a60 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/stop-opacity.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/stop-opacity.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 31 tests
-30 Pass
-1 Fail
+31 Pass
Pass Can set 'stop-opacity' to CSS-wide keywords: initial
Pass Can set 'stop-opacity' to CSS-wide keywords: inherit
Pass Can set 'stop-opacity' to CSS-wide keywords: unset
@@ -12,7 +11,7 @@ Pass Can set 'stop-opacity' to var() references: var(--A)
Pass Can set 'stop-opacity' to a number: 0
Pass Can set 'stop-opacity' to a number: -3.14
Pass Can set 'stop-opacity' to a number: 3.14
-Fail Can set 'stop-opacity' to a number: calc(2 + 3)
+Pass Can set 'stop-opacity' to a number: calc(2 + 3)
Pass Can set 'stop-opacity' to a percent: 0%
Pass Can set 'stop-opacity' to a percent: -3.14%
Pass Can set 'stop-opacity' to a percent: 3.14%
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/stroke-miterlimit.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/stroke-miterlimit.txt
index f1552f3ebc9..dbaac6d7f24 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/stroke-miterlimit.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/stroke-miterlimit.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 31 tests
-30 Pass
-1 Fail
+31 Pass
Pass Can set 'stroke-miterlimit' to CSS-wide keywords: initial
Pass Can set 'stroke-miterlimit' to CSS-wide keywords: inherit
Pass Can set 'stroke-miterlimit' to CSS-wide keywords: unset
@@ -12,7 +11,7 @@ Pass Can set 'stroke-miterlimit' to var() references: var(--A)
Pass Can set 'stroke-miterlimit' to a number: 0
Pass Can set 'stroke-miterlimit' to a number: -3.14
Pass Can set 'stroke-miterlimit' to a number: 3.14
-Fail Can set 'stroke-miterlimit' to a number: calc(2 + 3)
+Pass Can set 'stroke-miterlimit' to a number: calc(2 + 3)
Pass Setting 'stroke-miterlimit' to a length: 0px throws TypeError
Pass Setting 'stroke-miterlimit' to a length: -3.14em throws TypeError
Pass Setting 'stroke-miterlimit' to a length: 3.14cm throws TypeError
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/stroke-opacity.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/stroke-opacity.txt
index d9218da598a..5c17f33e0ed 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/stroke-opacity.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/stroke-opacity.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 31 tests
-30 Pass
-1 Fail
+31 Pass
Pass Can set 'stroke-opacity' to CSS-wide keywords: initial
Pass Can set 'stroke-opacity' to CSS-wide keywords: inherit
Pass Can set 'stroke-opacity' to CSS-wide keywords: unset
@@ -12,7 +11,7 @@ Pass Can set 'stroke-opacity' to var() references: var(--A)
Pass Can set 'stroke-opacity' to a number: 0
Pass Can set 'stroke-opacity' to a number: -3.14
Pass Can set 'stroke-opacity' to a number: 3.14
-Fail Can set 'stroke-opacity' to a number: calc(2 + 3)
+Pass Can set 'stroke-opacity' to a number: calc(2 + 3)
Pass Can set 'stroke-opacity' to a percent: 0%
Pass Can set 'stroke-opacity' to a percent: -3.14%
Pass Can set 'stroke-opacity' to a percent: 3.14%
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/tab-size.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/tab-size.txt
index 66aec03c842..d4bb56bc398 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/tab-size.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/tab-size.txt
@@ -2,8 +2,8 @@ Harness status: OK
Found 31 tests
-28 Pass
-3 Fail
+29 Pass
+2 Fail
Pass Can set 'tab-size' to CSS-wide keywords: initial
Pass Can set 'tab-size' to CSS-wide keywords: inherit
Pass Can set 'tab-size' to CSS-wide keywords: unset
@@ -12,7 +12,7 @@ Pass Can set 'tab-size' to var() references: var(--A)
Fail Can set 'tab-size' to a number: 0
Fail Can set 'tab-size' to a number: -3.14
Pass Can set 'tab-size' to a number: 3.14
-Fail Can set 'tab-size' to a number: calc(2 + 3)
+Pass Can set 'tab-size' to a number: calc(2 + 3)
Pass Can set 'tab-size' to a length: 0px
Pass Can set 'tab-size' to a length: -3.14em
Pass Can set 'tab-size' to a length: 3.14cm