Skip to content

Truly independent web browser

LibWeb: Recognize legacy prefixed logical properties

sideshowbarker1293c639bb64
diff --git a/Libraries/LibWeb/CSS/Properties.json b/Libraries/LibWeb/CSS/Properties.json
index b1d6a3af4e1..8936cd44ce6 100644
--- a/Libraries/LibWeb/CSS/Properties.json
+++ b/Libraries/LibWeb/CSS/Properties.json
@@ -53,15 +53,51 @@
"-webkit-background-size": {
"legacy-alias-for": "background-size"
},
+ "-webkit-border-after-color": {
+ "legacy-alias-for": "border-block-end-color"
+ },
+ "-webkit-border-after-style": {
+ "legacy-alias-for": "border-block-end-style"
+ },
+ "-webkit-border-after-width": {
+ "legacy-alias-for": "border-block-end-width"
+ },
+ "-webkit-border-before-color": {
+ "legacy-alias-for": "border-block-start-color"
+ },
+ "-webkit-border-before-style": {
+ "legacy-alias-for": "border-block-start-style"
+ },
+ "-webkit-border-before-width": {
+ "legacy-alias-for": "border-block-start-width"
+ },
"-webkit-border-bottom-left-radius": {
"legacy-alias-for": "border-bottom-left-radius"
},
"-webkit-border-bottom-right-radius": {
"legacy-alias-for": "border-bottom-right-radius"
},
+ "-webkit-border-end-color": {
+ "legacy-alias-for": "border-inline-end-color"
+ },
+ "-webkit-border-end-style": {
+ "legacy-alias-for": "border-inline-end-style"
+ },
+ "-webkit-border-end-width": {
+ "legacy-alias-for": "border-inline-end-width"
+ },
"-webkit-border-radius": {
"legacy-alias-for": "border-radius"
},
+ "-webkit-border-start-color": {
+ "legacy-alias-for": "border-inline-start-color"
+ },
+ "-webkit-border-start-style": {
+ "legacy-alias-for": "border-inline-start-style"
+ },
+ "-webkit-border-start-width": {
+ "legacy-alias-for": "border-inline-start-width"
+ },
"-webkit-border-top-left-radius": {
"legacy-alias-for": "border-top-left-radius"
},
@@ -150,6 +186,24 @@
"continue"
]
},
+ "-webkit-logical-height": {
+ "legacy-alias-for": "block-size"
+ },
+ "-webkit-logical-width": {
+ "legacy-alias-for": "inline-size"
+ },
+ "-webkit-margin-after": {
+ "legacy-alias-for": "margin-block-end"
+ },
+ "-webkit-margin-before": {
+ "legacy-alias-for": "margin-block-start"
+ },
+ "-webkit-margin-end": {
+ "legacy-alias-for": "margin-inline-end"
+ },
+ "-webkit-margin-start": {
+ "legacy-alias-for": "margin-inline-start"
+ },
"-webkit-mask": {
"legacy-alias-for": "mask"
},
@@ -174,9 +228,33 @@
"-webkit-mask-size": {
"legacy-alias-for": "mask-size"
},
+ "-webkit-max-logical-height": {
+ "legacy-alias-for": "max-block-size"
+ },
+ "-webkit-max-logical-width": {
+ "legacy-alias-for": "max-inline-size"
+ },
+ "-webkit-min-logical-height": {
+ "legacy-alias-for": "min-block-size"
+ },
+ "-webkit-min-logical-width": {
+ "legacy-alias-for": "min-inline-size"
+ },
"-webkit-order": {
"legacy-alias-for": "order"
},
+ "-webkit-padding-after": {
+ "legacy-alias-for": "padding-block-end"
+ },
+ "-webkit-padding-before": {
+ "legacy-alias-for": "padding-block-start"
+ },
+ "-webkit-padding-end": {
+ "legacy-alias-for": "padding-inline-end"
+ },
+ "-webkit-padding-start": {
+ "legacy-alias-for": "padding-inline-start"
+ },
"-webkit-perspective": {
"legacy-alias-for": "perspective"
},
diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt
index cd2d0081fd3..7331118921c 100644
--- a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt
+++ b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt
@@ -53,15 +53,51 @@ All supported properties and their default values exposed from CSSStylePropertie
'WebkitBackgroundSize': 'auto'
'webkitBackgroundSize': 'auto'
'-webkit-background-size': 'auto'
+'WebkitBorderAfterColor': 'rgb(0, 0, 0)'
+'webkitBorderAfterColor': 'rgb(0, 0, 0)'
+'-webkit-border-after-color': 'rgb(0, 0, 0)'
+'WebkitBorderAfterStyle': 'none'
+'webkitBorderAfterStyle': 'none'
+'-webkit-border-after-style': 'none'
+'WebkitBorderAfterWidth': '0px'
+'webkitBorderAfterWidth': '0px'
+'-webkit-border-after-width': '0px'
+'WebkitBorderBeforeColor': 'rgb(0, 0, 0)'
+'webkitBorderBeforeColor': 'rgb(0, 0, 0)'
+'-webkit-border-before-color': 'rgb(0, 0, 0)'
+'WebkitBorderBeforeStyle': 'none'
+'webkitBorderBeforeStyle': 'none'
+'-webkit-border-before-style': 'none'
+'WebkitBorderBeforeWidth': '0px'
+'webkitBorderBeforeWidth': '0px'
+'-webkit-border-before-width': '0px'
'WebkitBorderBottomLeftRadius': '0px'
'webkitBorderBottomLeftRadius': '0px'
'-webkit-border-bottom-left-radius': '0px'
'WebkitBorderBottomRightRadius': '0px'
'webkitBorderBottomRightRadius': '0px'
'-webkit-border-bottom-right-radius': '0px'
+'WebkitBorderEndColor': 'rgb(0, 0, 0)'
+'webkitBorderEndColor': 'rgb(0, 0, 0)'
+'-webkit-border-end-color': 'rgb(0, 0, 0)'
+'WebkitBorderEndStyle': 'none'
+'webkitBorderEndStyle': 'none'
+'-webkit-border-end-style': 'none'
+'WebkitBorderEndWidth': '0px'
+'webkitBorderEndWidth': '0px'
+'-webkit-border-end-width': '0px'
'WebkitBorderRadius': '0px'
'webkitBorderRadius': '0px'
'-webkit-border-radius': '0px'
+'WebkitBorderStartColor': 'rgb(0, 0, 0)'
+'webkitBorderStartColor': 'rgb(0, 0, 0)'
+'-webkit-border-start-color': 'rgb(0, 0, 0)'
+'WebkitBorderStartStyle': 'none'
+'webkitBorderStartStyle': 'none'
+'-webkit-border-start-style': 'none'
+'WebkitBorderStartWidth': '0px'
+'webkitBorderStartWidth': '0px'
+'-webkit-border-start-width': '0px'
'WebkitBorderTopLeftRadius': '0px'
'webkitBorderTopLeftRadius': '0px'
'-webkit-border-top-left-radius': '0px'
@@ -128,6 +164,24 @@ All supported properties and their default values exposed from CSSStylePropertie
'WebkitLineClamp': 'none'
'webkitLineClamp': 'none'
'-webkit-line-clamp': 'none'
+'WebkitLogicalHeight': '134px'
+'webkitLogicalHeight': '134px'
+'-webkit-logical-height': '134px'
+'WebkitLogicalWidth': '284px'
+'webkitLogicalWidth': '284px'
+'-webkit-logical-width': '284px'
+'WebkitMarginAfter': '8px'
+'webkitMarginAfter': '8px'
+'-webkit-margin-after': '8px'
+'WebkitMarginBefore': '8px'
+'webkitMarginBefore': '8px'
+'-webkit-margin-before': '8px'
+'WebkitMarginEnd': '8px'
+'webkitMarginEnd': '8px'
+'-webkit-margin-end': '8px'
+'WebkitMarginStart': '8px'
+'webkitMarginStart': '8px'
+'-webkit-margin-start': '8px'
'WebkitMask': 'none'
'webkitMask': 'none'
'-webkit-mask': 'none'
@@ -152,9 +206,33 @@ All supported properties and their default values exposed from CSSStylePropertie
'WebkitMaskSize': 'auto'
'webkitMaskSize': 'auto'
'-webkit-mask-size': 'auto'
+'WebkitMaxLogicalHeight': 'none'
+'webkitMaxLogicalHeight': 'none'
+'-webkit-max-logical-height': 'none'
+'WebkitMaxLogicalWidth': 'none'
+'webkitMaxLogicalWidth': 'none'
+'-webkit-max-logical-width': 'none'
+'WebkitMinLogicalHeight': 'auto'
+'webkitMinLogicalHeight': 'auto'
+'-webkit-min-logical-height': 'auto'
+'WebkitMinLogicalWidth': 'auto'
+'webkitMinLogicalWidth': 'auto'
+'-webkit-min-logical-width': 'auto'
'WebkitOrder': '0'
'webkitOrder': '0'
'-webkit-order': '0'
+'WebkitPaddingAfter': '0px'
+'webkitPaddingAfter': '0px'
+'-webkit-padding-after': '0px'
+'WebkitPaddingBefore': '0px'
+'webkitPaddingBefore': '0px'
+'-webkit-padding-before': '0px'
+'WebkitPaddingEnd': '0px'
+'webkitPaddingEnd': '0px'
+'-webkit-padding-end': '0px'
+'WebkitPaddingStart': '0px'
+'webkitPaddingStart': '0px'
+'-webkit-padding-start': '0px'
'WebkitPerspective': 'none'
'webkitPerspective': 'none'
'-webkit-perspective': 'none'
diff --git a/Tests/LibWeb/Text/expected/css/webkit-legacy-logical-properties.txt b/Tests/LibWeb/Text/expected/css/webkit-legacy-logical-properties.txt
new file mode 100644
index 00000000000..f0f22278106
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/webkit-legacy-logical-properties.txt
@@ -0,0 +1,32 @@
+-webkit-margin-before: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-padding-before: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-border-before-color: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-border-before-style: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-border-before-width: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-margin-after: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-padding-after: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-border-after-color: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-border-after-style: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-border-after-width: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-margin-start: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-padding-start: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-border-start-color: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-border-start-style: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-border-start-width: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-margin-end: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-padding-end: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-border-end-color: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-border-end-style: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-border-end-width: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-logical-width: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-logical-height: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-min-logical-width: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-min-logical-height: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-max-logical-width: parsed=true, serialized=true, IDL=true, writing modes=true
+-webkit-max-logical-height: parsed=true, serialized=true, IDL=true, writing modes=true
+padding-inline-start: 12px; -webkit-padding-start: 0: 0px
+-webkit-padding-start: 0; padding-inline-start: 12px: 12px
+padding-inline-start: 12px; -webkit-padding-start: 0 !important; padding-inline-start: 20px: 0px
+-webkit-padding-start: var(--indent); --indent: 9px: 9px
+remove canonical: 7px, remaining=0
+remove alias: 7px, remaining=0
diff --git a/Tests/LibWeb/Text/input/css/webkit-legacy-logical-properties.html b/Tests/LibWeb/Text/input/css/webkit-legacy-logical-properties.html
new file mode 100644
index 00000000000..2a55a778968
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/webkit-legacy-logical-properties.html
@@ -0,0 +1,61 @@
+<!doctype html>
+<script src="../include.js"></script>
+<script>
+ test(() => {
+ const aliases = [];
+ for (const [legacy, logical] of [["before", "block-start"], ["after", "block-end"], ["start", "inline-start"], ["end", "inline-end"]]) {
+ for (const property of ["margin", "padding"])
+ aliases.push([`-webkit-${property}-${legacy}`, `${property}-${logical}`, "7px"]);
+ for (const [component, value] of [["color", "rgb(255, 0, 0)"], ["style", "dashed"], ["width", "7px"]])
+ aliases.push([`-webkit-border-${legacy}-${component}`, `border-${logical}-${component}`, value]);
+ }
+ for (const prefix of ["", "min-", "max-"]) {
+ aliases.push([`-webkit-${prefix}logical-width`, `${prefix}inline-size`, "77px"]);
+ aliases.push([`-webkit-${prefix}logical-height`, `${prefix}block-size`, "77px"]);
+ }
+
+ const target = document.createElement("div");
+ const reference = document.createElement("div");
+ document.body.append(target, reference);
+ for (const [alias, canonical, value] of aliases) {
+ target.style.cssText = `${alias}: ${value}`;
+ const parsed = CSS.supports(alias, value) && target.style.getPropertyValue(canonical) === value;
+ const serialized = target.style.cssText === `${canonical}: ${value};`;
+ const idl = alias.substring(1).replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
+ target.style.cssText = "";
+ target.style[idl] = value;
+ const reflected = target.style.getPropertyValue(canonical) === value;
+ let matched = true;
+ for (const writingMode of ["horizontal-tb", "vertical-rl", "vertical-lr"]) {
+ for (const direction of ["ltr", "rtl"]) {
+ const base = `position: absolute; width: 100px; height: 100px; border: 1px solid; writing-mode: ${writingMode}; direction: ${direction};`;
+ target.style.cssText = `${base} ${alias}: ${value}`;
+ reference.style.cssText = `${base} ${canonical}: ${value}`;
+ const actual = getComputedStyle(target);
+ const expected = getComputedStyle(reference);
+ matched &&= actual.getPropertyValue(alias) === expected.getPropertyValue(canonical);
+ for (const side of ["top", "right", "bottom", "left"]) {
+ for (const property of [`margin-${side}`, `padding-${side}`, `border-${side}-color`, `border-${side}-style`, `border-${side}-width`])
+ matched &&= actual.getPropertyValue(property) === expected.getPropertyValue(property);
+ }
+ matched &&= actual.width === expected.width && actual.height === expected.height;
+ }
+ }
+ println(`${alias}: parsed=${parsed}, serialized=${serialized}, IDL=${reflected}, writing modes=${matched}`);
+ }
+
+ for (const declarations of [
+ "padding-inline-start: 12px; -webkit-padding-start: 0",
+ "-webkit-padding-start: 0; padding-inline-start: 12px",
+ "padding-inline-start: 12px; -webkit-padding-start: 0 !important; padding-inline-start: 20px",
+ "-webkit-padding-start: var(--indent); --indent: 9px",
+ ]) {
+ target.style.cssText = declarations;
+ println(`${declarations}: ${getComputedStyle(target).paddingInlineStart}`);
+ }
+ target.style.cssText = "-webkit-margin-before: 7px";
+ println(`remove canonical: ${target.style.removeProperty("margin-block-start")}, remaining=${target.style.length}`);
+ target.style.cssText = "margin-block-start: 7px";
+ println(`remove alias: ${target.style.removeProperty("-webkit-margin-before")}, remaining=${target.style.length}`);
+ });
+</script>