Skip to content

Lightpanda: the headless browser designed for AI and automation

webapi: Extends like of known CSS properties

Karl Seguin4c4409e5a5ce
diff --git a/src/browser/css/properties.zig b/src/browser/css/properties.zig
new file mode 100644
index 000000000..1be3f292d
--- /dev/null
+++ b/src/browser/css/properties.zig
@@ -0,0 +1,766 @@
+// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
+//
+// Francis Bouvier <[email protected]>
+// Pierre Tachoire <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+//! Every CSS property `CSS.supports()` and `el.style` recognize, with whether it
+//! inherits and the computed value of `initial` as Chrome serializes it.
+//!
+//! Generated: the names and initial values come from Chrome 151 (CSS.supports
+//! plus getComputedStyle under a display:none ancestor, so values are computed
+//! rather than resolved against layout); `inherited` comes from Blink's
+//! css_properties.json5. Aliases (word-wrap, -webkit-transform, ...) carry their
+//! target's flags. Shorthands have no initial value.
+
+const std = @import("std");
+
+pub const Property = struct {
+ inherited: bool = false,
+ initial: ?[]const u8 = null,
+};
+
+pub fn get(name: []const u8) ?Property {
+ return properties.get(name);
+}
+
+pub fn isKnown(name: []const u8) bool {
+ return properties.has(name);
+}
+
+const P = Property;
+
+const properties = std.StaticStringMap(Property).initComptime(.{
+ .{ "-epub-caption-side", P{ .inherited = true, .initial = "top" } },
+ .{ "-epub-text-combine", P{ .inherited = true, .initial = "none" } },
+ .{ "-epub-text-emphasis", P{} },
+ .{ "-epub-text-emphasis-color", P{ .inherited = true, .initial = "rgb(0, 0, 0)" } },
+ .{ "-epub-text-emphasis-style", P{ .inherited = true, .initial = "none" } },
+ .{ "-epub-text-orientation", P{ .inherited = true, .initial = "vertical-right" } },
+ .{ "-epub-text-transform", P{ .inherited = true, .initial = "none" } },
+ .{ "-epub-word-break", P{ .inherited = true, .initial = "normal" } },
+ .{ "-epub-writing-mode", P{ .inherited = true, .initial = "horizontal-tb" } },
+ .{ "-webkit-align-content", P{ .initial = "normal" } },
+ .{ "-webkit-align-items", P{ .initial = "normal" } },
+ .{ "-webkit-align-self", P{ .initial = "auto" } },
+ .{ "-webkit-animation", P{} },
+ .{ "-webkit-animation-delay", P{ .initial = "0s" } },
+ .{ "-webkit-animation-direction", P{ .initial = "normal" } },
+ .{ "-webkit-animation-duration", P{ .initial = "0s" } },
+ .{ "-webkit-animation-fill-mode", P{ .initial = "none" } },
+ .{ "-webkit-animation-iteration-count", P{ .initial = "1" } },
+ .{ "-webkit-animation-name", P{ .initial = "none" } },
+ .{ "-webkit-animation-play-state", P{ .initial = "running" } },
+ .{ "-webkit-animation-timing-function", P{ .initial = "ease" } },
+ .{ "-webkit-app-region", P{ .initial = "none" } },
+ .{ "-webkit-appearance", P{ .initial = "none" } },
+ .{ "-webkit-backface-visibility", P{ .initial = "visible" } },
+ .{ "-webkit-background-clip", P{ .initial = "border-box" } },
+ .{ "-webkit-background-origin", P{ .initial = "padding-box" } },
+ .{ "-webkit-background-size", P{ .initial = "auto" } },
+ .{ "-webkit-border-after", P{} },
+ .{ "-webkit-border-after-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "-webkit-border-after-style", P{ .initial = "none" } },
+ .{ "-webkit-border-after-width", P{ .initial = "0px" } },
+ .{ "-webkit-border-before", P{} },
+ .{ "-webkit-border-before-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "-webkit-border-before-style", P{ .initial = "none" } },
+ .{ "-webkit-border-before-width", P{ .initial = "0px" } },
+ .{ "-webkit-border-bottom-left-radius", P{ .initial = "0px" } },
+ .{ "-webkit-border-bottom-right-radius", P{ .initial = "0px" } },
+ .{ "-webkit-border-end", P{} },
+ .{ "-webkit-border-end-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "-webkit-border-end-style", P{ .initial = "none" } },
+ .{ "-webkit-border-end-width", P{ .initial = "0px" } },
+ .{ "-webkit-border-horizontal-spacing", P{ .inherited = true, .initial = "0px" } },
+ .{ "-webkit-border-image", P{ .initial = "none" } },
+ .{ "-webkit-border-radius", P{} },
+ .{ "-webkit-border-start", P{} },
+ .{ "-webkit-border-start-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "-webkit-border-start-style", P{ .initial = "none" } },
+ .{ "-webkit-border-start-width", P{ .initial = "0px" } },
+ .{ "-webkit-border-top-left-radius", P{ .initial = "0px" } },
+ .{ "-webkit-border-top-right-radius", P{ .initial = "0px" } },
+ .{ "-webkit-border-vertical-spacing", P{ .inherited = true, .initial = "0px" } },
+ .{ "-webkit-box-align", P{ .initial = "stretch" } },
+ .{ "-webkit-box-decoration-break", P{ .initial = "slice" } },
+ .{ "-webkit-box-direction", P{ .initial = "normal" } },
+ .{ "-webkit-box-flex", P{ .initial = "0" } },
+ .{ "-webkit-box-ordinal-group", P{ .initial = "1" } },
+ .{ "-webkit-box-orient", P{ .initial = "horizontal" } },
+ .{ "-webkit-box-pack", P{ .initial = "start" } },
+ .{ "-webkit-box-reflect", P{ .initial = "none" } },
+ .{ "-webkit-box-shadow", P{ .initial = "none" } },
+ .{ "-webkit-box-sizing", P{ .initial = "content-box" } },
+ .{ "-webkit-clip-path", P{ .initial = "none" } },
+ .{ "-webkit-column-break-after", P{} },
+ .{ "-webkit-column-break-before", P{} },
+ .{ "-webkit-column-break-inside", P{} },
+ .{ "-webkit-column-count", P{ .initial = "auto" } },
+ .{ "-webkit-column-gap", P{ .initial = "normal" } },
+ .{ "-webkit-column-rule", P{} },
+ .{ "-webkit-column-rule-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "-webkit-column-rule-style", P{ .initial = "none" } },
+ .{ "-webkit-column-rule-width", P{ .initial = "3px" } },
+ .{ "-webkit-column-span", P{ .initial = "none" } },
+ .{ "-webkit-column-width", P{ .initial = "auto" } },
+ .{ "-webkit-columns", P{} },
+ .{ "-webkit-filter", P{ .initial = "none" } },
+ .{ "-webkit-flex", P{} },
+ .{ "-webkit-flex-basis", P{ .initial = "auto" } },
+ .{ "-webkit-flex-direction", P{ .initial = "row" } },
+ .{ "-webkit-flex-flow", P{} },
+ .{ "-webkit-flex-grow", P{ .initial = "0" } },
+ .{ "-webkit-flex-shrink", P{ .initial = "1" } },
+ .{ "-webkit-flex-wrap", P{ .initial = "nowrap" } },
+ .{ "-webkit-font-feature-settings", P{ .inherited = true, .initial = "normal" } },
+ .{ "-webkit-font-smoothing", P{ .inherited = true, .initial = "auto" } },
+ .{ "-webkit-hyphenate-character", P{ .inherited = true, .initial = "auto" } },
+ .{ "-webkit-justify-content", P{ .initial = "normal" } },
+ .{ "-webkit-line-break", P{ .initial = "auto" } },
+ .{ "-webkit-line-clamp", P{ .initial = "none" } },
+ .{ "-webkit-locale", P{ .inherited = true, .initial = "auto" } },
+ .{ "-webkit-logical-height", P{ .initial = "auto" } },
+ .{ "-webkit-logical-width", P{ .initial = "auto" } },
+ .{ "-webkit-margin-after", P{ .initial = "0px" } },
+ .{ "-webkit-margin-before", P{ .initial = "0px" } },
+ .{ "-webkit-margin-end", P{ .initial = "0px" } },
+ .{ "-webkit-margin-start", P{ .initial = "0px" } },
+ .{ "-webkit-mask", P{} },
+ .{ "-webkit-mask-box-image", P{ .initial = "none" } },
+ .{ "-webkit-mask-box-image-outset", P{ .initial = "0" } },
+ .{ "-webkit-mask-box-image-repeat", P{ .initial = "stretch" } },
+ .{ "-webkit-mask-box-image-slice", P{ .initial = "0 fill" } },
+ .{ "-webkit-mask-box-image-source", P{ .initial = "none" } },
+ .{ "-webkit-mask-box-image-width", P{ .initial = "auto" } },
+ .{ "-webkit-mask-clip", P{ .initial = "border-box" } },
+ .{ "-webkit-mask-composite", P{ .initial = "add" } },
+ .{ "-webkit-mask-image", P{ .initial = "none" } },
+ .{ "-webkit-mask-origin", P{ .initial = "border-box" } },
+ .{ "-webkit-mask-position", P{ .initial = "0% 0%" } },
+ .{ "-webkit-mask-position-x", P{ .initial = "0%" } },
+ .{ "-webkit-mask-position-y", P{ .initial = "0%" } },
+ .{ "-webkit-mask-repeat", P{ .initial = "repeat" } },
+ .{ "-webkit-mask-size", P{ .initial = "auto" } },
+ .{ "-webkit-max-logical-height", P{ .initial = "none" } },
+ .{ "-webkit-max-logical-width", P{ .initial = "none" } },
+ .{ "-webkit-min-logical-height", P{ .initial = "0px" } },
+ .{ "-webkit-min-logical-width", P{ .initial = "0px" } },
+ .{ "-webkit-opacity", P{ .initial = "1" } },
+ .{ "-webkit-order", P{ .initial = "0" } },
+ .{ "-webkit-padding-after", P{ .initial = "0px" } },
+ .{ "-webkit-padding-before", P{ .initial = "0px" } },
+ .{ "-webkit-padding-end", P{ .initial = "0px" } },
+ .{ "-webkit-padding-start", P{ .initial = "0px" } },
+ .{ "-webkit-perspective", P{ .initial = "none" } },
+ .{ "-webkit-perspective-origin", P{ .initial = "50% 50%" } },
+ .{ "-webkit-perspective-origin-x", P{} },
+ .{ "-webkit-perspective-origin-y", P{} },
+ .{ "-webkit-print-color-adjust", P{ .inherited = true, .initial = "economy" } },
+ .{ "-webkit-rtl-ordering", P{ .inherited = true, .initial = "logical" } },
+ .{ "-webkit-ruby-position", P{ .inherited = true, .initial = "before" } },
+ .{ "-webkit-shape-image-threshold", P{ .initial = "0" } },
+ .{ "-webkit-shape-margin", P{ .initial = "0px" } },
+ .{ "-webkit-shape-outside", P{ .initial = "none" } },
+ .{ "-webkit-tap-highlight-color", P{ .inherited = true, .initial = "rgba(0, 0, 0, 0.18)" } },
+ .{ "-webkit-text-combine", P{ .inherited = true, .initial = "none" } },
+ .{ "-webkit-text-decorations-in-effect", P{ .inherited = true, .initial = "none" } },
+ .{ "-webkit-text-emphasis", P{} },
+ .{ "-webkit-text-emphasis-color", P{ .inherited = true, .initial = "rgb(0, 0, 0)" } },
+ .{ "-webkit-text-emphasis-position", P{ .inherited = true, .initial = "over" } },
+ .{ "-webkit-text-emphasis-style", P{ .inherited = true, .initial = "none" } },
+ .{ "-webkit-text-fill-color", P{ .inherited = true, .initial = "rgb(0, 0, 0)" } },
+ .{ "-webkit-text-orientation", P{ .inherited = true, .initial = "vertical-right" } },
+ .{ "-webkit-text-security", P{ .inherited = true, .initial = "none" } },
+ .{ "-webkit-text-size-adjust", P{ .inherited = true, .initial = "auto" } },
+ .{ "-webkit-text-stroke", P{} },
+ .{ "-webkit-text-stroke-color", P{ .inherited = true, .initial = "rgb(0, 0, 0)" } },
+ .{ "-webkit-text-stroke-width", P{ .inherited = true, .initial = "0px" } },
+ .{ "-webkit-transform", P{ .initial = "none" } },
+ .{ "-webkit-transform-origin", P{ .initial = "50% 50%" } },
+ .{ "-webkit-transform-origin-x", P{} },
+ .{ "-webkit-transform-origin-y", P{} },
+ .{ "-webkit-transform-origin-z", P{} },
+ .{ "-webkit-transform-style", P{ .initial = "flat" } },
+ .{ "-webkit-transition", P{} },
+ .{ "-webkit-transition-delay", P{ .initial = "0s" } },
+ .{ "-webkit-transition-duration", P{ .initial = "0s" } },
+ .{ "-webkit-transition-property", P{ .initial = "all" } },
+ .{ "-webkit-transition-timing-function", P{ .initial = "ease" } },
+ .{ "-webkit-user-drag", P{ .initial = "auto" } },
+ .{ "-webkit-user-modify", P{ .inherited = true, .initial = "read-only" } },
+ .{ "-webkit-user-select", P{ .inherited = true, .initial = "auto" } },
+ .{ "-webkit-writing-mode", P{ .inherited = true, .initial = "horizontal-tb" } },
+ .{ "accent-color", P{ .inherited = true, .initial = "auto" } },
+ .{ "align-content", P{ .initial = "normal" } },
+ .{ "align-items", P{ .initial = "normal" } },
+ .{ "align-self", P{ .initial = "auto" } },
+ .{ "alignment-baseline", P{ .initial = "auto" } },
+ .{ "all", P{} },
+ .{ "anchor-name", P{ .initial = "none" } },
+ .{ "anchor-scope", P{ .initial = "none" } },
+ .{ "animation", P{} },
+ .{ "animation-composition", P{ .initial = "replace" } },
+ .{ "animation-delay", P{ .initial = "0s" } },
+ .{ "animation-direction", P{ .initial = "normal" } },
+ .{ "animation-duration", P{ .initial = "0s" } },
+ .{ "animation-fill-mode", P{ .initial = "none" } },
+ .{ "animation-iteration-count", P{ .initial = "1" } },
+ .{ "animation-name", P{ .initial = "none" } },
+ .{ "animation-play-state", P{ .initial = "running" } },
+ .{ "animation-range", P{} },
+ .{ "animation-range-end", P{ .initial = "normal" } },
+ .{ "animation-range-start", P{ .initial = "normal" } },
+ .{ "animation-timeline", P{ .initial = "auto" } },
+ .{ "animation-timing-function", P{ .initial = "ease" } },
+ .{ "animation-trigger", P{ .initial = "none" } },
+ .{ "app-region", P{ .initial = "none" } },
+ .{ "appearance", P{ .initial = "none" } },
+ .{ "aspect-ratio", P{ .initial = "auto" } },
+ .{ "backdrop-filter", P{ .initial = "none" } },
+ .{ "backface-visibility", P{ .initial = "visible" } },
+ .{ "background", P{} },
+ .{ "background-attachment", P{ .initial = "scroll" } },
+ .{ "background-blend-mode", P{ .initial = "normal" } },
+ .{ "background-clip", P{ .initial = "border-box" } },
+ .{ "background-color", P{ .initial = "rgba(0, 0, 0, 0)" } },
+ .{ "background-image", P{ .initial = "none" } },
+ .{ "background-origin", P{ .initial = "padding-box" } },
+ .{ "background-position", P{ .initial = "0% 0%" } },
+ .{ "background-position-x", P{} },
+ .{ "background-position-y", P{} },
+ .{ "background-repeat", P{ .initial = "repeat" } },
+ .{ "background-size", P{ .initial = "auto" } },
+ .{ "baseline-shift", P{ .initial = "0px" } },
+ .{ "baseline-source", P{ .initial = "auto" } },
+ .{ "block-size", P{ .initial = "auto" } },
+ .{ "border", P{} },
+ .{ "border-block", P{} },
+ .{ "border-block-color", P{} },
+ .{ "border-block-end", P{} },
+ .{ "border-block-end-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "border-block-end-style", P{ .initial = "none" } },
+ .{ "border-block-end-width", P{ .initial = "0px" } },
+ .{ "border-block-start", P{} },
+ .{ "border-block-start-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "border-block-start-style", P{ .initial = "none" } },
+ .{ "border-block-start-width", P{ .initial = "0px" } },
+ .{ "border-block-style", P{} },
+ .{ "border-block-width", P{} },
+ .{ "border-bottom", P{} },
+ .{ "border-bottom-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "border-bottom-left-radius", P{ .initial = "0px" } },
+ .{ "border-bottom-right-radius", P{ .initial = "0px" } },
+ .{ "border-bottom-style", P{ .initial = "none" } },
+ .{ "border-bottom-width", P{ .initial = "0px" } },
+ .{ "border-collapse", P{ .inherited = true, .initial = "separate" } },
+ .{ "border-color", P{} },
+ .{ "border-end-end-radius", P{ .initial = "0px" } },
+ .{ "border-end-start-radius", P{ .initial = "0px" } },
+ .{ "border-image", P{} },
+ .{ "border-image-outset", P{ .initial = "0" } },
+ .{ "border-image-repeat", P{ .initial = "stretch" } },
+ .{ "border-image-slice", P{ .initial = "100%" } },
+ .{ "border-image-source", P{ .initial = "none" } },
+ .{ "border-image-width", P{ .initial = "1" } },
+ .{ "border-inline", P{} },
+ .{ "border-inline-color", P{} },
+ .{ "border-inline-end", P{} },
+ .{ "border-inline-end-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "border-inline-end-style", P{ .initial = "none" } },
+ .{ "border-inline-end-width", P{ .initial = "0px" } },
+ .{ "border-inline-start", P{} },
+ .{ "border-inline-start-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "border-inline-start-style", P{ .initial = "none" } },
+ .{ "border-inline-start-width", P{ .initial = "0px" } },
+ .{ "border-inline-style", P{} },
+ .{ "border-inline-width", P{} },
+ .{ "border-left", P{} },
+ .{ "border-left-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "border-left-style", P{ .initial = "none" } },
+ .{ "border-left-width", P{ .initial = "0px" } },
+ .{ "border-radius", P{} },
+ .{ "border-right", P{} },
+ .{ "border-right-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "border-right-style", P{ .initial = "none" } },
+ .{ "border-right-width", P{ .initial = "0px" } },
+ .{ "border-shape", P{ .initial = "none" } },
+ .{ "border-spacing", P{} },
+ .{ "border-start-end-radius", P{ .initial = "0px" } },
+ .{ "border-start-start-radius", P{ .initial = "0px" } },
+ .{ "border-style", P{} },
+ .{ "border-top", P{} },
+ .{ "border-top-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "border-top-left-radius", P{ .initial = "0px" } },
+ .{ "border-top-right-radius", P{ .initial = "0px" } },
+ .{ "border-top-style", P{ .initial = "none" } },
+ .{ "border-top-width", P{ .initial = "0px" } },
+ .{ "border-width", P{} },
+ .{ "bottom", P{ .initial = "auto" } },
+ .{ "box-decoration-break", P{ .initial = "slice" } },
+ .{ "box-shadow", P{ .initial = "none" } },
+ .{ "box-sizing", P{ .initial = "content-box" } },
+ .{ "break-after", P{ .initial = "auto" } },
+ .{ "break-before", P{ .initial = "auto" } },
+ .{ "break-inside", P{ .initial = "auto" } },
+ .{ "buffered-rendering", P{ .initial = "auto" } },
+ .{ "caption-side", P{ .inherited = true, .initial = "top" } },
+ .{ "caret-animation", P{ .inherited = true, .initial = "auto" } },
+ .{ "caret-color", P{ .inherited = true, .initial = "rgb(0, 0, 0)" } },
+ .{ "caret-shape", P{ .inherited = true, .initial = "auto" } },
+ .{ "clear", P{ .initial = "none" } },
+ .{ "clip", P{ .initial = "auto" } },
+ .{ "clip-path", P{ .initial = "none" } },
+ .{ "clip-rule", P{ .inherited = true, .initial = "nonzero" } },
+ .{ "color", P{ .inherited = true, .initial = "rgb(0, 0, 0)" } },
+ .{ "color-interpolation", P{ .inherited = true, .initial = "srgb" } },
+ .{ "color-interpolation-filters", P{ .inherited = true, .initial = "linearrgb" } },
+ .{ "color-rendering", P{ .inherited = true, .initial = "auto" } },
+ .{ "color-scheme", P{ .inherited = true, .initial = "normal" } },
+ .{ "column-count", P{ .initial = "auto" } },
+ .{ "column-fill", P{ .initial = "balance" } },
+ .{ "column-gap", P{ .initial = "normal" } },
+ .{ "column-height", P{ .initial = "auto" } },
+ .{ "column-rule", P{} },
+ .{ "column-rule-break", P{ .initial = "normal" } },
+ .{ "column-rule-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "column-rule-inset", P{} },
+ .{ "column-rule-inset-cap", P{} },
+ .{ "column-rule-inset-cap-end", P{ .initial = "0px" } },
+ .{ "column-rule-inset-cap-start", P{ .initial = "0px" } },
+ .{ "column-rule-inset-end", P{} },
+ .{ "column-rule-inset-junction", P{} },
+ .{ "column-rule-inset-junction-end", P{ .initial = "0px" } },
+ .{ "column-rule-inset-junction-start", P{ .initial = "0px" } },
+ .{ "column-rule-inset-start", P{} },
+ .{ "column-rule-style", P{ .initial = "none" } },
+ .{ "column-rule-visibility-items", P{ .initial = "normal" } },
+ .{ "column-rule-width", P{ .initial = "3px" } },
+ .{ "column-span", P{ .initial = "none" } },
+ .{ "column-width", P{ .initial = "auto" } },
+ .{ "column-wrap", P{ .initial = "auto" } },
+ .{ "columns", P{} },
+ .{ "contain", P{ .initial = "none" } },
+ .{ "contain-intrinsic-block-size", P{ .initial = "none" } },
+ .{ "contain-intrinsic-height", P{ .initial = "none" } },
+ .{ "contain-intrinsic-inline-size", P{ .initial = "none" } },
+ .{ "contain-intrinsic-size", P{ .initial = "none" } },
+ .{ "contain-intrinsic-width", P{ .initial = "none" } },
+ .{ "container", P{} },
+ .{ "container-name", P{ .initial = "none" } },
+ .{ "container-type", P{ .initial = "normal" } },
+ .{ "content", P{ .initial = "normal" } },
+ .{ "content-visibility", P{ .initial = "visible" } },
+ .{ "corner-block-end-shape", P{} },
+ .{ "corner-block-start-shape", P{} },
+ .{ "corner-bottom-left-shape", P{ .initial = "round" } },
+ .{ "corner-bottom-right-shape", P{ .initial = "round" } },
+ .{ "corner-bottom-shape", P{} },
+ .{ "corner-end-end-shape", P{ .initial = "round" } },
+ .{ "corner-end-start-shape", P{ .initial = "round" } },
+ .{ "corner-inline-end-shape", P{} },
+ .{ "corner-inline-start-shape", P{} },
+ .{ "corner-left-shape", P{} },
+ .{ "corner-right-shape", P{} },
+ .{ "corner-shape", P{} },
+ .{ "corner-start-end-shape", P{ .initial = "round" } },
+ .{ "corner-start-start-shape", P{ .initial = "round" } },
+ .{ "corner-top-left-shape", P{ .initial = "round" } },
+ .{ "corner-top-right-shape", P{ .initial = "round" } },
+ .{ "corner-top-shape", P{} },
+ .{ "counter-increment", P{ .initial = "none" } },
+ .{ "counter-reset", P{ .initial = "none" } },
+ .{ "counter-set", P{ .initial = "none" } },
+ .{ "cursor", P{ .inherited = true, .initial = "auto" } },
+ .{ "cx", P{ .initial = "0px" } },
+ .{ "cy", P{ .initial = "0px" } },
+ .{ "d", P{ .initial = "none" } },
+ .{ "direction", P{ .inherited = true, .initial = "ltr" } },
+ .{ "display", P{ .initial = "inline" } },
+ .{ "dominant-baseline", P{ .inherited = true, .initial = "auto" } },
+ .{ "dynamic-range-limit", P{ .inherited = true, .initial = "no-limit" } },
+ .{ "empty-cells", P{ .inherited = true, .initial = "show" } },
+ .{ "field-sizing", P{ .initial = "fixed" } },
+ .{ "fill", P{ .inherited = true, .initial = "rgb(0, 0, 0)" } },
+ .{ "fill-opacity", P{ .inherited = true, .initial = "1" } },
+ .{ "fill-rule", P{ .inherited = true, .initial = "nonzero" } },
+ .{ "filter", P{ .initial = "none" } },
+ .{ "flex", P{} },
+ .{ "flex-basis", P{ .initial = "auto" } },
+ .{ "flex-direction", P{ .initial = "row" } },
+ .{ "flex-flow", P{} },
+ .{ "flex-grow", P{ .initial = "0" } },
+ .{ "flex-line-count", P{ .initial = "1" } },
+ .{ "flex-shrink", P{ .initial = "1" } },
+ .{ "flex-wrap", P{ .initial = "nowrap" } },
+ .{ "float", P{ .initial = "none" } },
+ .{ "flood-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "flood-opacity", P{ .initial = "1" } },
+ .{ "font", P{} },
+ .{ "font-family", P{ .inherited = true, .initial = "\"Times New Roman\"" } },
+ .{ "font-feature-settings", P{ .inherited = true, .initial = "normal" } },
+ .{ "font-kerning", P{ .inherited = true, .initial = "auto" } },
+ .{ "font-language-override", P{ .inherited = true, .initial = "normal" } },
+ .{ "font-optical-sizing", P{ .inherited = true, .initial = "auto" } },
+ .{ "font-palette", P{ .inherited = true, .initial = "normal" } },
+ .{ "font-size", P{ .inherited = true, .initial = "16px" } },
+ .{ "font-size-adjust", P{ .inherited = true, .initial = "none" } },
+ .{ "font-stretch", P{ .inherited = true, .initial = "100%" } },
+ .{ "font-style", P{ .inherited = true, .initial = "normal" } },
+ .{ "font-synthesis", P{} },
+ .{ "font-synthesis-small-caps", P{ .inherited = true, .initial = "auto" } },
+ .{ "font-synthesis-style", P{ .inherited = true, .initial = "auto" } },
+ .{ "font-synthesis-weight", P{ .inherited = true, .initial = "auto" } },
+ .{ "font-variant", P{ .initial = "normal" } },
+ .{ "font-variant-alternates", P{ .inherited = true, .initial = "normal" } },
+ .{ "font-variant-caps", P{ .inherited = true, .initial = "normal" } },
+ .{ "font-variant-east-asian", P{ .inherited = true, .initial = "normal" } },
+ .{ "font-variant-emoji", P{ .inherited = true, .initial = "normal" } },
+ .{ "font-variant-ligatures", P{ .inherited = true, .initial = "normal" } },
+ .{ "font-variant-numeric", P{ .inherited = true, .initial = "normal" } },
+ .{ "font-variant-position", P{ .inherited = true, .initial = "normal" } },
+ .{ "font-variation-settings", P{ .inherited = true, .initial = "normal" } },
+ .{ "font-weight", P{ .inherited = true, .initial = "400" } },
+ .{ "forced-color-adjust", P{ .inherited = true, .initial = "auto" } },
+ .{ "gap", P{} },
+ .{ "grid", P{} },
+ .{ "grid-area", P{} },
+ .{ "grid-auto-columns", P{ .initial = "auto" } },
+ .{ "grid-auto-flow", P{ .initial = "row" } },
+ .{ "grid-auto-rows", P{ .initial = "auto" } },
+ .{ "grid-column", P{} },
+ .{ "grid-column-end", P{ .initial = "auto" } },
+ .{ "grid-column-gap", P{ .initial = "normal" } },
+ .{ "grid-column-start", P{ .initial = "auto" } },
+ .{ "grid-gap", P{} },
+ .{ "grid-row", P{} },
+ .{ "grid-row-end", P{ .initial = "auto" } },
+ .{ "grid-row-gap", P{ .initial = "normal" } },
+ .{ "grid-row-start", P{ .initial = "auto" } },
+ .{ "grid-template", P{} },
+ .{ "grid-template-areas", P{ .initial = "none" } },
+ .{ "grid-template-columns", P{ .initial = "none" } },
+ .{ "grid-template-rows", P{ .initial = "none" } },
+ .{ "height", P{ .initial = "auto" } },
+ .{ "hyphenate-character", P{ .inherited = true, .initial = "auto" } },
+ .{ "hyphenate-limit-chars", P{ .inherited = true, .initial = "auto" } },
+ .{ "hyphens", P{ .inherited = true, .initial = "manual" } },
+ .{ "image-orientation", P{ .inherited = true, .initial = "from-image" } },
+ .{ "image-rendering", P{ .inherited = true, .initial = "auto" } },
+ .{ "initial-letter", P{ .initial = "normal" } },
+ .{ "inline-size", P{ .initial = "auto" } },
+ .{ "inset", P{} },
+ .{ "inset-block", P{} },
+ .{ "inset-block-end", P{ .initial = "auto" } },
+ .{ "inset-block-start", P{ .initial = "auto" } },
+ .{ "inset-inline", P{} },
+ .{ "inset-inline-end", P{ .initial = "auto" } },
+ .{ "inset-inline-start", P{ .initial = "auto" } },
+ .{ "interactivity", P{ .inherited = true, .initial = "auto" } },
+ .{ "interest-delay", P{} },
+ .{ "interest-delay-end", P{ .initial = "normal" } },
+ .{ "interest-delay-start", P{ .initial = "normal" } },
+ .{ "interpolate-size", P{ .inherited = true, .initial = "numeric-only" } },
+ .{ "isolation", P{ .initial = "auto" } },
+ .{ "justify-content", P{ .initial = "normal" } },
+ .{ "justify-items", P{ .initial = "normal" } },
+ .{ "justify-self", P{ .initial = "auto" } },
+ .{ "left", P{ .initial = "auto" } },
+ .{ "letter-spacing", P{ .inherited = true, .initial = "normal" } },
+ .{ "lighting-color", P{ .initial = "rgb(255, 255, 255)" } },
+ .{ "line-break", P{ .inherited = true, .initial = "auto" } },
+ .{ "line-height", P{ .inherited = true, .initial = "normal" } },
+ .{ "list-style", P{} },
+ .{ "list-style-image", P{ .inherited = true, .initial = "none" } },
+ .{ "list-style-position", P{ .inherited = true, .initial = "outside" } },
+ .{ "list-style-type", P{ .inherited = true, .initial = "disc" } },
+ .{ "margin", P{} },
+ .{ "margin-block", P{} },
+ .{ "margin-block-end", P{ .initial = "0px" } },
+ .{ "margin-block-start", P{ .initial = "0px" } },
+ .{ "margin-bottom", P{ .initial = "0px" } },
+ .{ "margin-inline", P{} },
+ .{ "margin-inline-end", P{ .initial = "0px" } },
+ .{ "margin-inline-start", P{ .initial = "0px" } },
+ .{ "margin-left", P{ .initial = "0px" } },
+ .{ "margin-right", P{ .initial = "0px" } },
+ .{ "margin-top", P{ .initial = "0px" } },
+ .{ "marker", P{} },
+ .{ "marker-end", P{ .inherited = true, .initial = "none" } },
+ .{ "marker-mid", P{ .inherited = true, .initial = "none" } },
+ .{ "marker-start", P{ .inherited = true, .initial = "none" } },
+ .{ "mask", P{} },
+ .{ "mask-clip", P{ .initial = "border-box" } },
+ .{ "mask-composite", P{ .initial = "add" } },
+ .{ "mask-image", P{ .initial = "none" } },
+ .{ "mask-mode", P{ .initial = "match-source" } },
+ .{ "mask-origin", P{ .initial = "border-box" } },
+ .{ "mask-position", P{ .initial = "0% 0%" } },
+ .{ "mask-repeat", P{ .initial = "repeat" } },
+ .{ "mask-size", P{ .initial = "auto" } },
+ .{ "mask-type", P{ .initial = "luminance" } },
+ .{ "math-depth", P{ .inherited = true, .initial = "0" } },
+ .{ "math-shift", P{ .inherited = true, .initial = "normal" } },
+ .{ "math-style", P{ .inherited = true, .initial = "normal" } },
+ .{ "max-block-size", P{ .initial = "none" } },
+ .{ "max-height", P{ .initial = "none" } },
+ .{ "max-inline-size", P{ .initial = "none" } },
+ .{ "max-width", P{ .initial = "none" } },
+ .{ "min-block-size", P{ .initial = "0px" } },
+ .{ "min-height", P{ .initial = "0px" } },
+ .{ "min-inline-size", P{ .initial = "0px" } },
+ .{ "min-width", P{ .initial = "0px" } },
+ .{ "mix-blend-mode", P{ .initial = "normal" } },
+ .{ "object-fit", P{ .initial = "fill" } },
+ .{ "object-position", P{ .initial = "50% 50%" } },
+ .{ "object-view-box", P{ .initial = "none" } },
+ .{ "offset", P{} },
+ .{ "offset-anchor", P{ .initial = "auto" } },
+ .{ "offset-distance", P{ .initial = "0px" } },
+ .{ "offset-path", P{ .initial = "none" } },
+ .{ "offset-position", P{ .initial = "normal" } },
+ .{ "offset-rotate", P{ .initial = "auto 0deg" } },
+ .{ "opacity", P{ .initial = "1" } },
+ .{ "order", P{ .initial = "0" } },
+ .{ "orphans", P{ .inherited = true, .initial = "2" } },
+ .{ "outline", P{} },
+ .{ "outline-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "outline-offset", P{ .initial = "0px" } },
+ .{ "outline-style", P{ .initial = "none" } },
+ .{ "outline-width", P{ .initial = "3px" } },
+ .{ "overflow", P{} },
+ .{ "overflow-anchor", P{ .initial = "auto" } },
+ .{ "overflow-block", P{ .initial = "visible" } },
+ .{ "overflow-clip-margin", P{ .initial = "0px" } },
+ .{ "overflow-inline", P{ .initial = "visible" } },
+ .{ "overflow-wrap", P{ .inherited = true, .initial = "normal" } },
+ .{ "overflow-x", P{ .initial = "visible" } },
+ .{ "overflow-y", P{ .initial = "visible" } },
+ .{ "overlay", P{ .initial = "none" } },
+ .{ "overscroll-behavior", P{} },
+ .{ "overscroll-behavior-block", P{ .initial = "auto" } },
+ .{ "overscroll-behavior-inline", P{ .initial = "auto" } },
+ .{ "overscroll-behavior-x", P{ .initial = "auto" } },
+ .{ "overscroll-behavior-y", P{ .initial = "auto" } },
+ .{ "padding", P{} },
+ .{ "padding-block", P{} },
+ .{ "padding-block-end", P{ .initial = "0px" } },
+ .{ "padding-block-start", P{ .initial = "0px" } },
+ .{ "padding-bottom", P{ .initial = "0px" } },
+ .{ "padding-inline", P{} },
+ .{ "padding-inline-end", P{ .initial = "0px" } },
+ .{ "padding-inline-start", P{ .initial = "0px" } },
+ .{ "padding-left", P{ .initial = "0px" } },
+ .{ "padding-right", P{ .initial = "0px" } },
+ .{ "padding-top", P{ .initial = "0px" } },
+ .{ "page", P{} },
+ .{ "page-break-after", P{} },
+ .{ "page-break-before", P{} },
+ .{ "page-break-inside", P{} },
+ .{ "page-margin-safety", P{} },
+ .{ "page-orientation", P{} },
+ .{ "paint-order", P{ .inherited = true, .initial = "normal" } },
+ .{ "perspective", P{ .initial = "none" } },
+ .{ "perspective-origin", P{ .initial = "50% 50%" } },
+ .{ "place-content", P{} },
+ .{ "place-items", P{} },
+ .{ "place-self", P{} },
+ .{ "pointer-events", P{ .inherited = true, .initial = "auto" } },
+ .{ "position", P{ .initial = "static" } },
+ .{ "position-anchor", P{ .initial = "normal" } },
+ .{ "position-area", P{ .initial = "none" } },
+ .{ "position-try", P{} },
+ .{ "position-try-fallbacks", P{ .initial = "none" } },
+ .{ "position-try-order", P{ .initial = "normal" } },
+ .{ "position-visibility", P{ .initial = "anchors-visible" } },
+ .{ "print-color-adjust", P{ .inherited = true, .initial = "economy" } },
+ .{ "quotes", P{ .inherited = true, .initial = "auto" } },
+ .{ "r", P{ .initial = "0px" } },
+ .{ "reading-flow", P{ .initial = "normal" } },
+ .{ "reading-order", P{ .initial = "0" } },
+ .{ "resize", P{ .initial = "none" } },
+ .{ "right", P{ .initial = "auto" } },
+ .{ "rotate", P{ .initial = "none" } },
+ .{ "row-gap", P{ .initial = "normal" } },
+ .{ "row-rule", P{} },
+ .{ "row-rule-break", P{ .initial = "normal" } },
+ .{ "row-rule-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "row-rule-inset", P{} },
+ .{ "row-rule-inset-cap", P{} },
+ .{ "row-rule-inset-cap-end", P{ .initial = "0px" } },
+ .{ "row-rule-inset-cap-start", P{ .initial = "0px" } },
+ .{ "row-rule-inset-end", P{} },
+ .{ "row-rule-inset-junction", P{} },
+ .{ "row-rule-inset-junction-end", P{ .initial = "0px" } },
+ .{ "row-rule-inset-junction-start", P{ .initial = "0px" } },
+ .{ "row-rule-inset-start", P{} },
+ .{ "row-rule-style", P{ .initial = "none" } },
+ .{ "row-rule-visibility-items", P{ .initial = "normal" } },
+ .{ "row-rule-width", P{ .initial = "3px" } },
+ .{ "ruby-align", P{ .inherited = true, .initial = "space-around" } },
+ .{ "ruby-overhang", P{ .inherited = true, .initial = "auto" } },
+ .{ "ruby-position", P{ .inherited = true, .initial = "over" } },
+ .{ "rule", P{} },
+ .{ "rule-break", P{} },
+ .{ "rule-color", P{} },
+ .{ "rule-inset", P{} },
+ .{ "rule-inset-cap", P{} },
+ .{ "rule-inset-end", P{} },
+ .{ "rule-inset-junction", P{} },
+ .{ "rule-inset-start", P{} },
+ .{ "rule-overlap", P{ .initial = "row-over-column" } },
+ .{ "rule-style", P{} },
+ .{ "rule-visibility-items", P{} },
+ .{ "rule-width", P{} },
+ .{ "rx", P{ .initial = "auto" } },
+ .{ "ry", P{ .initial = "auto" } },
+ .{ "scale", P{ .initial = "none" } },
+ .{ "scroll-behavior", P{ .initial = "auto" } },
+ .{ "scroll-initial-target", P{ .initial = "none" } },
+ .{ "scroll-margin", P{} },
+ .{ "scroll-margin-block", P{} },
+ .{ "scroll-margin-block-end", P{ .initial = "0px" } },
+ .{ "scroll-margin-block-start", P{ .initial = "0px" } },
+ .{ "scroll-margin-bottom", P{ .initial = "0px" } },
+ .{ "scroll-margin-inline", P{} },
+ .{ "scroll-margin-inline-end", P{ .initial = "0px" } },
+ .{ "scroll-margin-inline-start", P{ .initial = "0px" } },
+ .{ "scroll-margin-left", P{ .initial = "0px" } },
+ .{ "scroll-margin-right", P{ .initial = "0px" } },
+ .{ "scroll-margin-top", P{ .initial = "0px" } },
+ .{ "scroll-marker-group", P{ .initial = "none" } },
+ .{ "scroll-padding", P{} },
+ .{ "scroll-padding-block", P{} },
+ .{ "scroll-padding-block-end", P{ .initial = "auto" } },
+ .{ "scroll-padding-block-start", P{ .initial = "auto" } },
+ .{ "scroll-padding-bottom", P{ .initial = "auto" } },
+ .{ "scroll-padding-inline", P{} },
+ .{ "scroll-padding-inline-end", P{ .initial = "auto" } },
+ .{ "scroll-padding-inline-start", P{ .initial = "auto" } },
+ .{ "scroll-padding-left", P{ .initial = "auto" } },
+ .{ "scroll-padding-right", P{ .initial = "auto" } },
+ .{ "scroll-padding-top", P{ .initial = "auto" } },
+ .{ "scroll-snap-align", P{ .initial = "none" } },
+ .{ "scroll-snap-stop", P{ .initial = "normal" } },
+ .{ "scroll-snap-type", P{ .initial = "none" } },
+ .{ "scroll-target-group", P{ .initial = "none" } },
+ .{ "scroll-timeline", P{} },
+ .{ "scroll-timeline-axis", P{ .initial = "block" } },
+ .{ "scroll-timeline-name", P{ .initial = "none" } },
+ .{ "scrollbar-color", P{ .inherited = true, .initial = "auto" } },
+ .{ "scrollbar-gutter", P{ .initial = "auto" } },
+ .{ "scrollbar-width", P{ .initial = "auto" } },
+ .{ "shape-image-threshold", P{ .initial = "0" } },
+ .{ "shape-margin", P{ .initial = "0px" } },
+ .{ "shape-outside", P{ .initial = "none" } },
+ .{ "shape-rendering", P{ .inherited = true, .initial = "auto" } },
+ .{ "size", P{} },
+ .{ "speak", P{ .inherited = true, .initial = "normal" } },
+ .{ "stop-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "stop-opacity", P{ .initial = "1" } },
+ .{ "stroke", P{ .inherited = true, .initial = "none" } },
+ .{ "stroke-dasharray", P{ .inherited = true, .initial = "none" } },
+ .{ "stroke-dashoffset", P{ .inherited = true, .initial = "0px" } },
+ .{ "stroke-linecap", P{ .inherited = true, .initial = "butt" } },
+ .{ "stroke-linejoin", P{ .inherited = true, .initial = "miter" } },
+ .{ "stroke-miterlimit", P{ .inherited = true, .initial = "4" } },
+ .{ "stroke-opacity", P{ .inherited = true, .initial = "1" } },
+ .{ "stroke-width", P{ .inherited = true, .initial = "1px" } },
+ .{ "tab-size", P{ .inherited = true, .initial = "8" } },
+ .{ "table-layout", P{ .initial = "auto" } },
+ .{ "text-align", P{ .inherited = true, .initial = "start" } },
+ .{ "text-align-last", P{ .inherited = true, .initial = "auto" } },
+ .{ "text-anchor", P{ .inherited = true, .initial = "start" } },
+ .{ "text-autospace", P{ .inherited = true, .initial = "no-autospace" } },
+ .{ "text-box", P{} },
+ .{ "text-box-edge", P{ .inherited = true, .initial = "auto" } },
+ .{ "text-box-trim", P{ .initial = "none" } },
+ .{ "text-combine-upright", P{ .inherited = true, .initial = "none" } },
+ .{ "text-decoration", P{ .initial = "none" } },
+ .{ "text-decoration-color", P{ .initial = "rgb(0, 0, 0)" } },
+ .{ "text-decoration-line", P{ .initial = "none" } },
+ .{ "text-decoration-skip-ink", P{ .inherited = true, .initial = "auto" } },
+ .{ "text-decoration-style", P{ .initial = "solid" } },
+ .{ "text-decoration-thickness", P{ .initial = "auto" } },
+ .{ "text-emphasis", P{} },
+ .{ "text-emphasis-color", P{ .inherited = true, .initial = "rgb(0, 0, 0)" } },
+ .{ "text-emphasis-position", P{ .inherited = true, .initial = "over" } },
+ .{ "text-emphasis-style", P{ .inherited = true, .initial = "none" } },
+ .{ "text-fit", P{ .inherited = true, .initial = "none" } },
+ .{ "text-indent", P{ .inherited = true, .initial = "0px" } },
+ .{ "text-justify", P{ .inherited = true, .initial = "auto" } },
+ .{ "text-orientation", P{ .inherited = true, .initial = "mixed" } },
+ .{ "text-overflow", P{ .initial = "clip" } },
+ .{ "text-rendering", P{ .inherited = true, .initial = "auto" } },
+ .{ "text-shadow", P{ .inherited = true, .initial = "none" } },
+ .{ "text-size-adjust", P{ .inherited = true, .initial = "auto" } },
+ .{ "text-spacing-trim", P{ .inherited = true, .initial = "normal" } },
+ .{ "text-transform", P{ .inherited = true, .initial = "none" } },
+ .{ "text-underline-offset", P{ .inherited = true, .initial = "auto" } },
+ .{ "text-underline-position", P{ .inherited = true, .initial = "auto" } },
+ .{ "text-wrap", P{} },
+ .{ "text-wrap-mode", P{ .inherited = true, .initial = "wrap" } },
+ .{ "text-wrap-style", P{ .inherited = true, .initial = "auto" } },
+ .{ "timeline-scope", P{ .initial = "none" } },
+ .{ "timeline-trigger", P{} },
+ .{ "timeline-trigger-activation-range", P{} },
+ .{ "timeline-trigger-activation-range-end", P{ .initial = "normal" } },
+ .{ "timeline-trigger-activation-range-start", P{ .initial = "normal" } },
+ .{ "timeline-trigger-active-range", P{} },
+ .{ "timeline-trigger-active-range-end", P{ .initial = "auto" } },
+ .{ "timeline-trigger-active-range-start", P{ .initial = "auto" } },
+ .{ "timeline-trigger-name", P{ .initial = "none" } },
+ .{ "timeline-trigger-source", P{ .initial = "auto" } },
+ .{ "top", P{ .initial = "auto" } },
+ .{ "touch-action", P{ .initial = "auto" } },
+ .{ "transform", P{ .initial = "none" } },
+ .{ "transform-box", P{ .initial = "view-box" } },
+ .{ "transform-origin", P{ .initial = "50% 50%" } },
+ .{ "transform-style", P{ .initial = "flat" } },
+ .{ "transition", P{} },
+ .{ "transition-behavior", P{ .initial = "normal" } },
+ .{ "transition-delay", P{ .initial = "0s" } },
+ .{ "transition-duration", P{ .initial = "0s" } },
+ .{ "transition-property", P{ .initial = "all" } },
+ .{ "transition-timing-function", P{ .initial = "ease" } },
+ .{ "translate", P{ .initial = "none" } },
+ .{ "trigger-scope", P{ .initial = "none" } },
+ .{ "unicode-bidi", P{ .initial = "normal" } },
+ .{ "user-select", P{ .inherited = true, .initial = "auto" } },
+ .{ "vector-effect", P{ .initial = "none" } },
+ .{ "vertical-align", P{ .initial = "baseline" } },
+ .{ "view-timeline", P{} },
+ .{ "view-timeline-axis", P{ .initial = "block" } },
+ .{ "view-timeline-inset", P{ .initial = "auto" } },
+ .{ "view-timeline-name", P{ .initial = "none" } },
+ .{ "view-transition-class", P{ .initial = "none" } },
+ .{ "view-transition-group", P{ .initial = "normal" } },
+ .{ "view-transition-name", P{ .initial = "none" } },
+ .{ "view-transition-scope", P{ .initial = "none" } },
+ .{ "visibility", P{ .inherited = true, .initial = "visible" } },
+ .{ "white-space", P{} },
+ .{ "white-space-collapse", P{ .inherited = true, .initial = "collapse" } },
+ .{ "widows", P{ .inherited = true, .initial = "2" } },
+ .{ "width", P{ .initial = "auto" } },
+ .{ "will-change", P{ .initial = "auto" } },
+ .{ "word-break", P{ .inherited = true, .initial = "normal" } },
+ .{ "word-spacing", P{ .inherited = true, .initial = "0px" } },
+ .{ "word-wrap", P{ .inherited = true, .initial = "normal" } },
+ .{ "writing-mode", P{ .inherited = true, .initial = "horizontal-tb" } },
+ .{ "x", P{ .initial = "0px" } },
+ .{ "y", P{ .initial = "0px" } },
+ .{ "z-index", P{ .initial = "auto" } },
+ .{ "zoom", P{ .initial = "1" } },
+});
diff --git a/src/browser/css/supports.zig b/src/browser/css/supports.zig
new file mode 100644
index 000000000..d7a02ebdc
--- /dev/null
+++ b/src/browser/css/supports.zig
@@ -0,0 +1,347 @@
+// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
+//
+// Francis Bouvier <[email protected]>
+// Pierre Tachoire <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+//! `<supports-condition>` evaluation, for CSS.supports(). A declaration is
+//! supported when we know its property; its value isn't validated, we don't
+//! have a grammar for most properties.
+
+const std = @import("std");
+
+const SelectorParser = @import("../webapi/selector/Parser.zig");
+
+const Tokenizer = @import("Tokenizer.zig");
+const CssParser = @import("Parser.zig");
+const properties = @import("properties.zig");
+
+const Allocator = std.mem.Allocator;
+
+/// CSS.supports(property, value)
+pub fn declaration(name: []const u8, value: []const u8) bool {
+ if (std.mem.trim(u8, value, &std.ascii.whitespace).len == 0) {
+ return false;
+ }
+ if (std.mem.startsWith(u8, name, "--")) {
+ return true;
+ }
+ var buf: [64]u8 = undefined;
+ if (name.len > buf.len) {
+ return false;
+ }
+ return properties.isKnown(std.ascii.lowerString(&buf, name));
+}
+
+/// CSS.supports(conditionText).
+pub fn condition(arena: Allocator, text: []const u8) bool {
+ if (evaluate(arena, text)) |result| {
+ return result;
+ }
+ // retry wrapped in parentheses so that a bare declaration, e.g.
+ // `display: grid`, works.
+ const wrapped = std.mem.concat(arena, u8, &.{ "(", text, ")" }) catch return false;
+ return evaluate(arena, wrapped) orelse false;
+}
+
+/// The condition's value, or null when `text` isn't a condition.
+fn evaluate(arena: Allocator, text: []const u8) ?bool {
+ var evaluator: Evaluator = .{ .arena = arena, .tokenizer = .{ .input = text } };
+ const result = evaluator.condition() orelse return null;
+ if (evaluator.nextToken() != null) {
+ return null;
+ }
+ return result;
+}
+
+const Evaluator = struct {
+ arena: Allocator,
+ tokenizer: Tokenizer,
+
+ // <supports-condition> = not <supports-in-parens>
+ // | <supports-in-parens> [ and <supports-in-parens> ]*
+ // | <supports-in-parens> [ or <supports-in-parens> ]*
+ fn condition(self: *Evaluator) ?bool {
+ const start = self.tokenizer.position;
+ if (self.nextToken()) |token| {
+ if (isIdent(token, "not")) {
+ return !(self.inParens() orelse return null);
+ }
+ }
+ self.tokenizer.position = start;
+
+ var result = self.inParens() orelse return null;
+ var operator: ?enum { @"and", @"or" } = null;
+ while (true) {
+ const before = self.tokenizer.position;
+ const token = self.nextToken() orelse return result;
+ const this: @TypeOf(operator) = if (isIdent(token, "and")) .@"and" else if (isIdent(token, "or")) .@"or" else {
+ self.tokenizer.position = before;
+ return result;
+ };
+ // Mixing `and` and `or` needs parentheses.
+ if (operator != null and operator != this) {
+ return null;
+ }
+ operator = this;
+ const next = self.inParens() orelse return null;
+ result = if (this == .@"and") result and next else result or next;
+ }
+ }
+
+ // <supports-in-parens> = ( <supports-condition> ) | <supports-feature> | <general-enclosed>
+ fn inParens(self: *Evaluator) ?bool {
+ const token = self.nextToken() orelse return null;
+ switch (token) {
+ .parenthesis_block => {
+ const inner = self.block() orelse return null;
+ if (evaluate(self.arena, inner)) |result| {
+ return result;
+ }
+ return supportsDeclaration(inner);
+ },
+ .function => |name| {
+ const args = std.mem.trim(u8, self.block() orelse return null, &std.ascii.whitespace);
+ if (std.ascii.eqlIgnoreCase(name, "selector")) {
+ return self.supportsSelector(args);
+ }
+ if (std.ascii.eqlIgnoreCase(name, "font-format")) {
+ return font_formats.has(singleIdent(args) orelse return false);
+ }
+ if (std.ascii.eqlIgnoreCase(name, "font-tech")) {
+ return font_techs.has(singleIdent(args) orelse return false);
+ }
+ if (std.ascii.eqlIgnoreCase(name, "at-rule")) {
+ return at_rules.has(singleAtKeyword(args) orelse return false);
+ }
+ // <general-enclosed>: valid, but never supported.
+ return false;
+ },
+ else => return null,
+ }
+ }
+
+ /// The text up to the `)` closing the block just opened, which is
+ /// consumed. Null when it is never closed.
+ fn block(self: *Evaluator) ?[]const u8 {
+ const start = self.tokenizer.position;
+ var depth: usize = 1;
+ while (self.tokenizer.next()) |token| {
+ switch (token) {
+ .parenthesis_block, .function => depth += 1,
+ .close_parenthesis => {
+ depth -= 1;
+ if (depth == 0) {
+ return self.tokenizer.input[start .. self.tokenizer.position - 1];
+ }
+ },
+ else => {},
+ }
+ }
+ return null;
+ }
+
+ fn supportsSelector(self: *Evaluator, text: []const u8) bool {
+ const selectors = SelectorParser.parseList(self.arena, text) catch return false;
+ // A single complex selector, not a list.
+ return selectors.len == 1;
+ }
+
+ /// The next token that isn't whitespace or a comment.
+ fn nextToken(self: *Evaluator) ?Tokenizer.Token {
+ while (self.tokenizer.next()) |token| {
+ switch (token) {
+ .white_space, .comment => {},
+ else => return token,
+ }
+ }
+ return null;
+ }
+};
+
+// <supports-decl> = ( <declaration> )
+fn supportsDeclaration(text: []const u8) bool {
+ var it = CssParser.parseDeclarationsList(text);
+ const decl = it.next() orelse return false;
+ if (it.next() != null) {
+ return false;
+ }
+ return declaration(decl.name, decl.value);
+}
+
+fn isIdent(token: Tokenizer.Token, comptime word: []const u8) bool {
+ return switch (token) {
+ .ident => |name| std.ascii.eqlIgnoreCase(name, word),
+ else => false,
+ };
+}
+
+/// `text` when it is a single identifier; font-format() and font-tech() take
+/// neither quoted strings nor lists.
+fn singleIdent(text: []const u8) ?[]const u8 {
+ var tokenizer: Tokenizer = .{ .input = text };
+ const name = switch (tokenizer.next() orelse return null) {
+ .ident => |name| name,
+ else => return null,
+ };
+ if (tokenizer.next() != null) {
+ return null;
+ }
+ return name;
+}
+
+/// The name in `text` when it is a single at-keyword (`@media`).
+fn singleAtKeyword(text: []const u8) ?[]const u8 {
+ var tokenizer: Tokenizer = .{ .input = text };
+ const name = switch (tokenizer.next() orelse return null) {
+ .at_keyword => |name| name,
+ else => return null,
+ };
+ if (tokenizer.next() != null) {
+ return null;
+ }
+ return name;
+}
+
+const KeywordSet = std.StaticStringMapWithEql(void, std.static_string_map.eqlAsciiIgnoreCase);
+
+// The keyword lists match what Chrome 151 reports as supported.
+const font_formats = KeywordSet.initComptime(.{
+ .{ "collection", {} },
+ .{ "opentype", {} },
+ .{ "truetype", {} },
+ .{ "woff", {} },
+ .{ "woff2", {} },
+});
+
+const font_techs = KeywordSet.initComptime(.{
+ .{ "features-opentype", {} },
+ .{ "features-aat", {} },
+ .{ "color-colrv0", {} },
+ .{ "color-colrv1", {} },
+ .{ "color-sbix", {} },
+ .{ "color-cbdt", {} },
+ .{ "variations", {} },
+ .{ "palettes", {} },
+});
+
+// @charset isn't an at-rule, only a marker at the start of a stylesheet.
+const at_rules = KeywordSet.initComptime(.{
+ .{ "import", {} },
+ .{ "namespace", {} },
+ .{ "media", {} },
+ .{ "supports", {} },
+ .{ "font-face", {} },
+ .{ "font-feature-values", {} },
+ .{ "font-palette-values", {} },
+ .{ "keyframes", {} },
+ .{ "-webkit-keyframes", {} },
+ .{ "page", {} },
+ .{ "counter-style", {} },
+ .{ "layer", {} },
+ .{ "property", {} },
+ .{ "container", {} },
+ .{ "scope", {} },
+ .{ "starting-style", {} },
+ .{ "view-transition", {} },
+ .{ "position-try", {} },
+ .{ "function", {} },
+ // @font-feature-values blocks
+ .{ "swash", {} },
+ .{ "annotation", {} },
+ .{ "ornaments", {} },
+ .{ "stylistic", {} },
+ .{ "styleset", {} },
+ .{ "character-variant", {} },
+ // @page margin boxes
+ .{ "top-left-corner", {} },
+ .{ "top-left", {} },
+ .{ "top-center", {} },
+ .{ "top-right", {} },
+ .{ "top-right-corner", {} },
+ .{ "bottom-left-corner", {} },
+ .{ "bottom-left", {} },
+ .{ "bottom-center", {} },
+ .{ "bottom-right", {} },
+ .{ "bottom-right-corner", {} },
+ .{ "left-top", {} },
+ .{ "left-middle", {} },
+ .{ "left-bottom", {} },
+ .{ "right-top", {} },
+ .{ "right-middle", {} },
+ .{ "right-bottom", {} },
+});
+
+const testing = @import("../../testing.zig");
+
+test "supports: condition" {
+ defer testing.reset();
+ const arena = testing.arena_allocator;
+ const cases = [_]struct { []const u8, bool }{
+ .{ "(color: red)", true },
+ .{ "color: red", true },
+ .{ "display: block", true },
+ .{ " display:block ", true },
+ .{ "(COLOR: red)", true },
+ .{ "(--foo: blah)", true },
+ .{ "--foo: blah", true },
+ .{ "(color: red) and (color: blue)", true },
+ .{ "(color: red) and (bogus: blue)", false },
+ .{ "(color: red) or (bogus: blue)", true },
+ .{ "(color: red) and (color: blue) or (color: red)", false },
+ .{ "((color: red) and (color: blue)) or (bogus: red)", true },
+ .{ "not (foobar)", true },
+ .{ "not (color: red)", false },
+ .{ "not(color: red)", false },
+ .{ "(foobar)", false },
+ .{ "unknownproperty: blah", false },
+ .{ "unicode-range: U+0-7F", false },
+ .{ "(color: red; display: block)", false },
+ .{ "(color:)", false },
+ .{ "func(x)", false },
+ .{ "(color: red", false },
+ .{ "", false },
+ .{ "color", false },
+ .{ "selector(div)", true },
+ .{ "selector(div + .c)", true },
+ .{ "selector(div, div)", false },
+ .{ "selector(div | .c)", false },
+ .{ "font-format(opentype)", true },
+ .{ "font-format(OpenType)", true },
+ .{ "font-format(xyzzy)", false },
+ .{ "font-format(opentype, truetype)", false },
+ .{ "font-format('opentype')", false },
+ .{ "font-tech(features-opentype)", true },
+ .{ "font-tech(color-COLRv0)", true },
+ .{ "font-tech(feature-opentype)", false },
+ .{ "(color: red) and selector(div)", true },
+ .{ "font-tech(incremental)", false },
+ .{ "font-format(svg)", false },
+ .{ "at-rule(@supports)", true },
+ .{ "at-rule( @MEDIA )", true },
+ .{ "at-rule(@doesnotexist)", false },
+ .{ "at-rule(@charset)", false },
+ .{ "at-rule(supports)", false },
+ .{ "at-rule(@counter-style; system: fixed)", false },
+ .{ "not at-rule(@doesnotexist)", true },
+ .{ "(doesnotexist: red) or at-rule(@doesnotexist)", false },
+ };
+ for (cases) |case| {
+ testing.expectEqual(case[1], condition(arena, case[0])) catch |err| {
+ std.debug.print("condition: {s}\n", .{case[0]});
+ return err;
+ };
+ }
+}
diff --git a/src/browser/tests/css.html b/src/browser/tests/css.html
index 6f2d830c7..457a23b47 100644
--- a/src/browser/tests/css.html
+++ b/src/browser/tests/css.html
@@ -67,6 +67,35 @@
}
</script>
+<script id="supports_unknown_properties">
+ {
+ testing.expectEqual(false, CSS.supports('not-a-property', 'red'));
+ testing.expectEqual(false, CSS.supports('-moz-user-select', 'none'));
+ testing.expectEqual(false, CSS.supports(' color', 'red'));
+ // @font-face descriptors aren't properties
+ testing.expectEqual(false, CSS.supports('src', 'inherit'));
+ testing.expectEqual(true, CSS.supports('COLOR', 'red'));
+ testing.expectEqual(true, CSS.supports('-webkit-transform', 'none'));
+ testing.expectEqual(true, CSS.supports('word-wrap', 'normal'));
+ testing.expectEqual(true, CSS.supports('--anything', 'x'));
+ }
+</script>
+
+<script id="supports_condition">
+ {
+ testing.expectEqual(true, CSS.supports('display: block'));
+ testing.expectEqual(true, CSS.supports('(display: grid) and (gap: 1px)'));
+ testing.expectEqual(true, CSS.supports('not (not-a-property: 1)'));
+ testing.expectEqual(false, CSS.supports('not-a-property: 1'));
+ testing.expectEqual(false, CSS.supports('(display: grid) and (color: red) or (gap: 1px)'));
+ testing.expectEqual(true, CSS.supports('selector(:has(a))'));
+ testing.expectEqual(true, CSS.supports('selector(div > p)'));
+ testing.expectEqual(false, CSS.supports('selector(a, b)'));
+ testing.expectEqual(false, CSS.supports('unknown-function(x)'));
+ testing.expectEqual(false, CSS.supports('color', ''));
+ }
+</script>
+
<script id="supports_common_properties">
{
testing.expectEqual(true, CSS.supports('margin', '10px'));
diff --git a/src/browser/tests/css/computed_inheritance.html b/src/browser/tests/css/computed_inheritance.html
new file mode 100644
index 000000000..9d39f8e50
--- /dev/null
+++ b/src/browser/tests/css/computed_inheritance.html
@@ -0,0 +1,114 @@
+<!DOCTYPE html>
+<head>
+ <meta name=lp-mode content=test>
+ <script src="../testing.js"></script>
+</head>
+
+<!--
+ getComputedStyle for properties only inline styles declare: initial values,
+ inheritance up the tree and the CSS-wide keywords. Values match Chrome.
+-->
+
+<div id=grand><div id=container><span id=target></span></div></div>
+<a id=link href="#"><span id=in-link></span></a>
+<a id=not-link><span id=in-not-link></span></a>
+
+<script id=initial_values>
+{
+ const target = $('#target');
+ const cs = getComputedStyle(target);
+ testing.expectEqual('auto', cs.isolation);
+ testing.expectEqual('normal', cs.backgroundBlendMode);
+ testing.expectEqual('none', cs.float);
+ testing.expectEqual('none', cs.cssFloat);
+ testing.expectEqual('normal', cs.wordWrap);
+ testing.expectEqual('none', cs.webkitTransform);
+ testing.expectEqual('rgb(0, 0, 0)', cs.color);
+ testing.expectEqual('0px', cs.minWidth);
+ testing.expectEqual('0px', cs.margin);
+ testing.expectEqual(undefined, cs.notARealProperty);
+}
+</script>
+
+<script id=inherited>
+{
+ const grand = $('#grand');
+ const container = $('#container');
+ const target = $('#target');
+
+ grand.style.fontStyle = 'italic';
+ testing.expectEqual('italic', getComputedStyle(target).fontStyle);
+
+ container.style.fontStyle = 'oblique';
+ testing.expectEqual('oblique', getComputedStyle(target).fontStyle);
+
+ // canonicalized like a declared color
+ container.style.color = 'red';
+ testing.expectEqual('rgb(255, 0, 0)', getComputedStyle(target).color);
+
+ container.style.cssText = '';
+ grand.style.cssText = '';
+ testing.expectEqual('normal', getComputedStyle(target).fontStyle);
+}
+</script>
+
+<script id=not_inherited>
+{
+ const container = $('#container');
+ const target = $('#target');
+
+ container.style.isolation = 'isolate';
+ testing.expectEqual('isolate', getComputedStyle(container).isolation);
+ testing.expectEqual('auto', getComputedStyle(target).isolation);
+
+ target.style.isolation = 'inherit';
+ testing.expectEqual('isolate', getComputedStyle(target).isolation);
+
+ target.style.isolation = 'unset';
+ testing.expectEqual('auto', getComputedStyle(target).isolation);
+
+ container.style.cssText = '';
+ target.style.cssText = '';
+}
+</script>
+
+<script id=keywords>
+{
+ const container = $('#container');
+ const target = $('#target');
+
+ container.style.fontStyle = 'italic';
+ target.style.fontStyle = 'initial';
+ testing.expectEqual('normal', getComputedStyle(target).fontStyle);
+ target.style.fontStyle = 'unset';
+ testing.expectEqual('italic', getComputedStyle(target).fontStyle);
+ target.style.fontStyle = 'INHERIT';
+ testing.expectEqual('italic', getComputedStyle(target).fontStyle);
+
+ // initial is the property's initial value, not the element's UA default
+ container.style.display = 'initial';
+ testing.expectEqual('inline', getComputedStyle(container).display);
+ container.style.display = '';
+ testing.expectEqual('block', getComputedStyle(container).display);
+
+ container.style.paddingBlockStart = 'initial';
+ testing.expectEqual('0px', getComputedStyle(container).paddingBlockStart);
+
+ container.style.cssText = '';
+ target.style.cssText = '';
+}
+</script>
+
+<script id=ua_default_color>
+{
+ testing.expectEqual('rgb(0, 0, 238)', getComputedStyle($('#link')).color);
+ testing.expectEqual('rgb(0, 0, 238)', getComputedStyle($('#in-link')).color);
+
+ $('#link').style.color = 'initial';
+ testing.expectEqual('rgb(0, 0, 0)', getComputedStyle($('#in-link')).color);
+ $('#link').style.color = '';
+
+ testing.expectEqual('rgb(0, 0, 0)', getComputedStyle($('#not-link')).color);
+ testing.expectEqual('rgb(0, 0, 0)', getComputedStyle($('#in-not-link')).color);
+}
+</script>
diff --git a/src/browser/tests/element/css_style_properties.html b/src/browser/tests/element/css_style_properties.html
index 3100d2cd2..857bb33a2 100644
--- a/src/browser/tests/element/css_style_properties.html
+++ b/src/browser/tests/element/css_style_properties.html
@@ -89,7 +89,14 @@
testing.expectEqual(undefined, div.style.oTransition);
testing.expectEqual('rotate(45deg)', div.style['-webkit-transform']);
- testing.expectEqual('none', div.style['-moz-user-select']);
+ // unknown properties are dropped, not stored
+ testing.expectEqual(undefined, div.style['-moz-user-select']);
+
+ div.style.cssText = 'not-a-property: 1; color: red; --custom: x';
+ testing.expectEqual('color: red; --custom: x;', div.style.cssText);
+ div.setAttribute('style', 'bogus: 1; margin-top: 2px');
+ testing.expectEqual('margin-top: 2px;', div.style.cssText);
+ div.removeAttribute('style');
}
</script>
@@ -131,6 +138,29 @@
}
</script>
+<script id="knownPropertyPresence">
+{
+ const div = $('#test-div');
+ div.style.cssText = '';
+
+ // Known properties are present while unset, whichever spelling is used.
+ testing.expectEqual('', div.style.webkitTransform);
+ testing.expectEqual('', div.style.WebkitTransform);
+ testing.expectEqual('', div.style['-webkit-transform']);
+ testing.expectEqual(true, 'webkitTransform' in div.style);
+ testing.expectEqual(true, 'WebkitTransform' in div.style);
+ testing.expectEqual(true, 'isolation' in div.style);
+ testing.expectEqual(true, 'positionArea' in div.style);
+ testing.expectEqual(false, 'mozUserSelect' in div.style);
+ testing.expectEqual(false, '-moz-user-select' in div.style);
+
+ const computed = getComputedStyle(div);
+ testing.expectEqual(true, 'isolation' in computed);
+ testing.expectEqual(true, 'background-blend-mode' in computed);
+ testing.expectEqual(false, 'notARealProperty' in computed);
+}
+</script>
+
<script id="propertyAssignment">
{
const div = $('#test-div');
diff --git a/src/browser/webapi/CSS.zig b/src/browser/webapi/CSS.zig
index 4a29629c6..4a56880b6 100644
--- a/src/browser/webapi/CSS.zig
+++ b/src/browser/webapi/CSS.zig
@@ -17,9 +17,11 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
const std = @import("std");
+
const js = @import("../js/js.zig");
const Frame = @import("../Frame.zig");
const Tokenizer = @import("../css/Tokenizer.zig");
+const css_supports = @import("../css/supports.zig");
const CSS = @This();
_pad: bool = false,
@@ -120,10 +122,14 @@ pub fn escape(value: []const u8, frame: *Frame) ![]const u8 {
return result;
}
-pub fn supports(property_or_condition: []const u8, value: ?[]const u8) bool {
- _ = property_or_condition;
- _ = value;
- return true;
+// With two arguments, this is asking: do we recognize the property. We don't
+// currently validate the value, we don't have a grammar for most properties.
+// With one, it's a condition: `(display: grid) and selector(:has(a))`.
+pub fn supports(property_or_condition: []const u8, value: ?[]const u8, frame: *Frame) bool {
+ if (value) |v| {
+ return css_supports.declaration(property_or_condition, v);
+ }
+ return css_supports.condition(frame.local_arena, property_or_condition);
}
fn escapeLen(comptime is_first: bool, c: u8) usize {
diff --git a/src/browser/webapi/css/CSSStyleDeclaration.zig b/src/browser/webapi/css/CSSStyleDeclaration.zig
index b23142e01..7c51e781f 100644
--- a/src/browser/webapi/css/CSSStyleDeclaration.zig
+++ b/src/browser/webapi/css/CSSStyleDeclaration.zig
@@ -23,6 +23,8 @@ const js = @import("../../js/js.zig");
const Frame = @import("../../Frame.zig");
const color = @import("../../color.zig");
const CssParser = @import("../../css/Parser.zig");
+const properties = @import("../../css/properties.zig");
+const StyleManager = @import("../../StyleManager.zig");
const Element = @import("../Element.zig");
const DOMMatrixReadOnly = @import("../DOMMatrixReadOnly.zig");
@@ -168,7 +170,9 @@ fn propertyValue(self: *const CSSStyleDeclaration, normalized: []const u8, wrapp
// parsed inline style, so computed values match `el.style`. One
// an !important rule beats falls through to the values below.
if (style_manager.inlineStyleValue(element, wrapped)) |value| {
- return value;
+ if (CssWideKeyword.parse(value) == null) {
+ return value;
+ }
}
// Computed width/height must agree with the synthetic layout
@@ -183,9 +187,61 @@ fn propertyValue(self: *const CSSStyleDeclaration, normalized: []const u8, wrapp
if (wrapped.eql(comptime .wrap("height"))) {
return resolvedDimension(element, .height, frame);
}
+ return inlineCascadedValue(style_manager, element, wrapped, owner);
+ }
+ }
+ const element = self._element orelse return initialValue(wrapped);
+ return uaDefaultValue(element, wrapped) orelse initialValue(wrapped);
+}
+
+const CssWideKeyword = enum {
+ initial,
+ inherit,
+ unset,
+ revert,
+
+ fn parse(value: []const u8) ?CssWideKeyword {
+ const map = std.StaticStringMap(CssWideKeyword).initComptime(.{
+ .{ "initial", .initial },
+ .{ "inherit", .inherit },
+ .{ "unset", .unset },
+ .{ "revert", .revert },
+ .{ "revert-layer", .revert },
+ });
+ var buf: [16]u8 = undefined;
+ if (value.len > buf.len) {
+ return null;
+ }
+ return map.get(std.ascii.lowerString(&buf, value));
+ }
+};
+
+/// The computed value inline styles
+fn inlineCascadedValue(style_manager: *StyleManager, element: *Element, name: String, frame: *Frame) []const u8 {
+ const inherited = if (properties.get(name.str())) |p| p.inherited else false;
+ var current = element;
+ while (true) {
+ // Nothing declared reads like `revert`: the UA default, or else what
+ // the property does by default.
+ const keyword: CssWideKeyword = blk: {
+ const value = style_manager.inlineStyleValue(current, name) orelse break :blk .revert;
+ break :blk CssWideKeyword.parse(value) orelse return value;
+ };
+ switch (keyword) {
+ .initial => return initialValue(name),
+ .inherit => {},
+ .unset => if (inherited == false) return initialValue(name),
+ .revert => {
+ if (uaDefaultValue(current, name)) |value| {
+ return value;
+ }
+ if (inherited == false) {
+ return initialValue(name);
+ }
+ },
}
+ current = current.asNode().flatTreeParentElement(frame) orelse return initialValue(name);
}
- return getDefaultPropertyValue(self, wrapped);
}
/// The value of a declared property, or null when it isn't declared. An axis
@@ -368,6 +424,10 @@ fn setPropertyImpl(self: *CSSStyleDeclaration, property_name: []const u8, value:
}
const normalized = normalizePropertyName(frame.local_arena, property_name);
+ // A declaration of a property we don't know is dropped, as in Chrome.
+ if (isCustomProperty(normalized) == false and properties.isKnown(normalized) == false) {
+ return false;
+ }
if (CssParser.axisShorthand(normalized)) |shorthand| {
const values = CssParser.splitAxisPair(value) orelse return false;
const x = try self.setPropertyImpl(shorthand.x, values.x, important, frame);
@@ -1098,99 +1158,36 @@ fn isLengthProperty(name: []const u8) bool {
return length_properties.has(name);
}
-// Computed values of properties nothing declares: their CSS initial values, as
-// Chrome reports them for a plain element. Measuring code parses many of these
-// (parseFloat, keyword checks), so '' would read as NaN or as no value at all.
-// Border widths compute to zero while border-style is its initial `none`.
-const initial_values = std.StaticStringMap([]const u8).initComptime(.{
- .{ "margin", "0px" },
- .{ "margin-top", "0px" },
- .{ "margin-right", "0px" },
- .{ "margin-bottom", "0px" },
- .{ "margin-left", "0px" },
- .{ "padding", "0px" },
- .{ "padding-top", "0px" },
- .{ "padding-right", "0px" },
- .{ "padding-bottom", "0px" },
- .{ "padding-left", "0px" },
- .{ "border-width", "0px" },
- .{ "border-top-width", "0px" },
- .{ "border-right-width", "0px" },
- .{ "border-bottom-width", "0px" },
- .{ "border-left-width", "0px" },
- .{ "border-style", "none" },
- .{ "border-top-style", "none" },
- .{ "border-right-style", "none" },
- .{ "border-bottom-style", "none" },
- .{ "border-left-style", "none" },
- .{ "border-radius", "0px" },
- .{ "border-top-left-radius", "0px" },
- .{ "border-top-right-radius", "0px" },
- .{ "border-bottom-right-radius", "0px" },
- .{ "border-bottom-left-radius", "0px" },
- .{ "font-weight", "400" },
- .{ "line-height", "normal" },
- .{ "letter-spacing", "normal" },
- .{ "word-spacing", "0px" },
- .{ "text-indent", "0px" },
- .{ "top", "auto" },
- .{ "right", "auto" },
- .{ "bottom", "auto" },
- .{ "left", "auto" },
- .{ "z-index", "auto" },
- .{ "box-sizing", "content-box" },
- .{ "min-width", "0px" },
- .{ "min-height", "0px" },
- .{ "max-width", "none" },
- .{ "max-height", "none" },
- .{ "flex-grow", "0" },
- .{ "flex-shrink", "1" },
- .{ "flex-basis", "auto" },
- .{ "transform", "none" },
- .{ "gap", "normal" },
- .{ "row-gap", "normal" },
- .{ "column-gap", "normal" },
-});
-
-fn getDefaultPropertyValue(self: *const CSSStyleDeclaration, name: String) []const u8 {
- if (initial_values.get(name.str())) |value| {
- return value;
+/// Computed value of `initial` or '' for a name we don't know
+fn initialValue(name: String) []const u8 {
+ if (properties.get(name.str())) |property| {
+ if (property.initial) |value| {
+ return value;
+ }
}
- switch (name.len) {
- 5 => {
- if (name.eql(comptime .wrap("color"))) {
- const element = self._element orelse return "";
- return getDefaultColor(element);
- }
- },
- 7 => {
- if (name.eql(comptime .wrap("opacity"))) {
- return "1";
- }
- if (name.eql(comptime .wrap("display"))) {
- const element = self._element orelse return "";
- return getDefaultDisplay(element);
- }
- },
- 10 => {
- if (name.eql(comptime .wrap("visibility"))) {
- return "visible";
- }
- },
- 14 => {
- if (name.eqlSlice("pointer-events")) {
- return "auto";
- }
- },
- 16 => {
- if (name.eqlSlice("background-color")) {
- // transparent
- return "rgba(0, 0, 0, 0)";
- }
- },
- else => {},
+
+ // shorthand initial value
+ const shorthand_initial_values = std.StaticStringMap([]const u8).initComptime(.{
+ .{ "margin", "0px" },
+ .{ "padding", "0px" },
+ .{ "border-width", "0px" },
+ .{ "border-style", "none" },
+ .{ "border-radius", "0px" },
+ .{ "gap", "normal" },
+ });
+
+ return shorthand_initial_values.get(name.str()) orelse "";
+}
+
+/// The UA stylesheet's value for `element`, when it isn't the initial value.
+fn uaDefaultValue(element: *const Element, name: String) ?[]const u8 {
+ if (name.eql(comptime .wrap("display"))) {
+ return getDefaultDisplay(element);
}
- return "";
+ if (name.eql(comptime .wrap("color"))) {
+ return getDefaultColor(element);
+ }
+ return null;
}
fn getDefaultDisplay(element: *const Element) []const u8 {
@@ -1226,15 +1223,16 @@ fn isInlineTag(tag_name: []const u8) bool {
return false;
}
-fn getDefaultColor(element: *const Element) []const u8 {
+fn getDefaultColor(element: *const Element) ?[]const u8 {
switch (element._type) {
.html => {
return switch (element.subtype(Element.Html)._type) {
- .anchor => "rgb(0, 0, 238)", // blue
- else => "rgb(0, 0, 0)",
+ // a:link, blue; an anchor without href isn't a link
+ .anchor => if (element.hasAttributeInterned("href")) "rgb(0, 0, 238)" else null,
+ else => null,
};
},
- .svg => return "rgb(0, 0, 0)",
+ .svg => return null,
}
}
@@ -1298,6 +1296,10 @@ test "WebApi: CSSStyleDeclaration computed transform" {
try testing.htmlRunner("css/computed_transform.html", .{});
}
+test "WebApi: CSSStyleDeclaration computed inheritance" {
+ try testing.htmlRunner("css/computed_inheritance.html", .{});
+}
+
test "writeCssNumber: six significant digits" {
const cases = [_]struct { f64, []const u8 }{
.{ 0, "0" },
diff --git a/src/browser/webapi/css/CSSStyleProperties.zig b/src/browser/webapi/css/CSSStyleProperties.zig
index 453170eaf..b6a1bc76a 100644
--- a/src/browser/webapi/css/CSSStyleProperties.zig
+++ b/src/browser/webapi/css/CSSStyleProperties.zig
@@ -22,6 +22,7 @@ const js = @import("../../js/js.zig");
const Element = @import("../Element.zig");
const Frame = @import("../../Frame.zig");
const CSSStyleDeclaration = @import("CSSStyleDeclaration.zig");
+const properties = @import("../../css/properties.zig");
const Allocator = std.mem.Allocator;
@@ -81,251 +82,14 @@ fn getNamed(self: *CSSStyleProperties, name: []const u8, frame: *Frame) ![]const
const value = self._proto.getPropertyValue(dash_case, frame);
- // Property accessors have special handling for empty values:
- // - Known CSS properties return '' when not set
- // - Vendor-prefixed properties return undefined when not set
- // - Unknown properties return undefined
- if (value.len == 0) {
- // Vendor-prefixed properties always return undefined when not set
- if (std.mem.startsWith(u8, dash_case, "-")) {
- return error.NotHandled;
- }
-
- // Known CSS properties return '', unknown properties return undefined
- if (!isKnownCSSProperty(dash_case)) {
- return error.NotHandled;
- }
-
- return "";
+ // Known properties read '' when not set, unknown ones are undefined (and
+ // so not `in` the declaration).
+ if (value.len == 0 and properties.isKnown(dash_case) == false) {
+ return error.NotHandled;
}
-
return value;
}
-fn isKnownCSSProperty(dash_case: []const u8) bool {
- const known_properties = std.StaticStringMap(void).initComptime(.{
- // Colors & backgrounds
- .{ "color", {} },
- .{ "background", {} },
- .{ "background-color", {} },
- .{ "background-image", {} },
- .{ "background-position", {} },
- .{ "background-repeat", {} },
- .{ "background-size", {} },
- .{ "background-attachment", {} },
- .{ "background-clip", {} },
- .{ "background-origin", {} },
- // Typography
- .{ "font", {} },
- .{ "font-family", {} },
- .{ "font-size", {} },
- .{ "font-style", {} },
- .{ "font-weight", {} },
- .{ "font-variant", {} },
- .{ "line-height", {} },
- .{ "letter-spacing", {} },
- .{ "word-spacing", {} },
- .{ "text-align", {} },
- .{ "text-decoration", {} },
- .{ "text-indent", {} },
- .{ "text-transform", {} },
- .{ "white-space", {} },
- .{ "word-break", {} },
- .{ "word-wrap", {} },
- .{ "overflow-wrap", {} },
- // Box model
- .{ "margin", {} },
- .{ "margin-top", {} },
- .{ "margin-right", {} },
- .{ "margin-bottom", {} },
- .{ "margin-left", {} },
- .{ "margin-block", {} },
- .{ "margin-block-start", {} },
- .{ "margin-block-end", {} },
- .{ "margin-inline", {} },
- .{ "margin-inline-start", {} },
- .{ "margin-inline-end", {} },
- .{ "padding", {} },
- .{ "padding-top", {} },
- .{ "padding-right", {} },
- .{ "padding-bottom", {} },
- .{ "padding-left", {} },
- .{ "padding-block", {} },
- .{ "padding-block-start", {} },
- .{ "padding-block-end", {} },
- .{ "padding-inline", {} },
- .{ "padding-inline-start", {} },
- .{ "padding-inline-end", {} },
- // Border
- .{ "border", {} },
- .{ "border-width", {} },
- .{ "border-style", {} },
- .{ "border-color", {} },
- .{ "border-top", {} },
- .{ "border-top-width", {} },
- .{ "border-top-style", {} },
- .{ "border-top-color", {} },
- .{ "border-right", {} },
- .{ "border-right-width", {} },
- .{ "border-right-style", {} },
- .{ "border-right-color", {} },
- .{ "border-bottom", {} },
- .{ "border-bottom-width", {} },
- .{ "border-bottom-style", {} },
- .{ "border-bottom-color", {} },
- .{ "border-left", {} },
- .{ "border-left-width", {} },
- .{ "border-left-style", {} },
- .{ "border-left-color", {} },
- .{ "border-radius", {} },
- .{ "border-top-left-radius", {} },
- .{ "border-top-right-radius", {} },
- .{ "border-bottom-left-radius", {} },
- .{ "border-bottom-right-radius", {} },
- .{ "border-collapse", {} },
- .{ "border-spacing", {} },
- // Sizing
- .{ "width", {} },
- .{ "height", {} },
- .{ "min-width", {} },
- .{ "min-height", {} },
- .{ "max-width", {} },
- .{ "max-height", {} },
- .{ "box-sizing", {} },
- // Positioning
- .{ "position", {} },
- .{ "top", {} },
- .{ "right", {} },
- .{ "bottom", {} },
- .{ "left", {} },
- .{ "inset", {} },
- .{ "inset-block", {} },
- .{ "inset-block-start", {} },
- .{ "inset-block-end", {} },
- .{ "inset-inline", {} },
- .{ "inset-inline-start", {} },
- .{ "inset-inline-end", {} },
- .{ "z-index", {} },
- .{ "float", {} },
- .{ "clear", {} },
- // Display & visibility
- .{ "display", {} },
- .{ "visibility", {} },
- .{ "opacity", {} },
- .{ "overflow", {} },
- .{ "overflow-x", {} },
- .{ "overflow-y", {} },
- .{ "clip", {} },
- .{ "clip-path", {} },
- // Flexbox
- .{ "flex", {} },
- .{ "flex-direction", {} },
- .{ "flex-wrap", {} },
- .{ "flex-flow", {} },
- .{ "flex-grow", {} },
- .{ "flex-shrink", {} },
- .{ "flex-basis", {} },
- .{ "order", {} },
- // Grid
- .{ "grid", {} },
- .{ "grid-template", {} },
- .{ "grid-template-columns", {} },
- .{ "grid-template-rows", {} },
- .{ "grid-template-areas", {} },
- .{ "grid-auto-columns", {} },
- .{ "grid-auto-rows", {} },
- .{ "grid-auto-flow", {} },
- .{ "grid-column", {} },
- .{ "grid-column-start", {} },
- .{ "grid-column-end", {} },
- .{ "grid-row", {} },
- .{ "grid-row-start", {} },
- .{ "grid-row-end", {} },
- .{ "grid-area", {} },
- .{ "gap", {} },
- .{ "row-gap", {} },
- .{ "column-gap", {} },
- // Alignment (flexbox & grid)
- .{ "align-content", {} },
- .{ "align-items", {} },
- .{ "align-self", {} },
- .{ "justify-content", {} },
- .{ "justify-items", {} },
- .{ "justify-self", {} },
- .{ "place-content", {} },
- .{ "place-items", {} },
- .{ "place-self", {} },
- // Transforms & animations
- .{ "transform", {} },
- .{ "transform-origin", {} },
- .{ "transform-style", {} },
- .{ "perspective", {} },
- .{ "perspective-origin", {} },
- .{ "transition", {} },
- .{ "transition-property", {} },
- .{ "transition-duration", {} },
- .{ "transition-timing-function", {} },
- .{ "transition-delay", {} },
- .{ "animation", {} },
- .{ "animation-name", {} },
- .{ "animation-duration", {} },
- .{ "animation-timing-function", {} },
- .{ "animation-delay", {} },
- .{ "animation-iteration-count", {} },
- .{ "animation-direction", {} },
- .{ "animation-fill-mode", {} },
- .{ "animation-play-state", {} },
- // Filters & effects
- .{ "filter", {} },
- .{ "backdrop-filter", {} },
- .{ "box-shadow", {} },
- .{ "text-shadow", {} },
- // Outline
- .{ "outline", {} },
- .{ "outline-width", {} },
- .{ "outline-style", {} },
- .{ "outline-color", {} },
- .{ "outline-offset", {} },
- // Lists
- .{ "list-style", {} },
- .{ "list-style-type", {} },
- .{ "list-style-position", {} },
- .{ "list-style-image", {} },
- // Tables
- .{ "table-layout", {} },
- .{ "caption-side", {} },
- .{ "empty-cells", {} },
- // Misc
- .{ "cursor", {} },
- .{ "pointer-events", {} },
- .{ "user-select", {} },
- .{ "resize", {} },
- .{ "object-fit", {} },
- .{ "object-position", {} },
- .{ "vertical-align", {} },
- .{ "content", {} },
- .{ "quotes", {} },
- .{ "counter-reset", {} },
- .{ "counter-increment", {} },
- // Scrolling
- .{ "scroll-behavior", {} },
- .{ "scroll-margin", {} },
- .{ "scroll-padding", {} },
- .{ "overscroll-behavior", {} },
- .{ "overscroll-behavior-x", {} },
- .{ "overscroll-behavior-y", {} },
- // Containment
- .{ "contain", {} },
- .{ "container", {} },
- .{ "container-type", {} },
- .{ "container-name", {} },
- // Aspect ratio
- .{ "aspect-ratio", {} },
- });
-
- return known_properties.has(dash_case);
-}
-
fn camelCaseToDashCase(allocator: Allocator, name: []const u8) ![]const u8 {
if (name.len == 0) {
return name;
@@ -341,6 +105,13 @@ fn camelCaseToDashCase(allocator: Allocator, name: []const u8) ![]const u8 {
return std.ascii.allocLowerString(allocator, name);
}
+ // The CSSOM's webkit-cased attribute: WebkitTransform -> -webkit-transform
+ if (name.len > 6 and std.mem.startsWith(u8, name, "Webkit") and std.ascii.isUpper(name[6])) {
+ const lowered = try allocator.dupe(u8, name);
+ lowered[0] = 'w';
+ return camelCaseToDashCase(allocator, lowered);
+ }
+
// Check if this looks like proper camelCase (starts with lowercase)
// If not (e.g. "COLOR", "BackgroundColor"), just lowercase it
if (name.len == 0 or !std.ascii.isLower(name[0])) {