Truly independent web browser
LibWeb: Prepare style query inputs for attribute values
Callum Lawe43f4fbebf79
diff --git a/Libraries/LibWeb/Rust/src/css/style/custom_property_cascade.rs b/Libraries/LibWeb/Rust/src/css/style/custom_property_cascade.rsindex 679fb124d82..52635bbf9c3 100644--- a/Libraries/LibWeb/Rust/src/css/style/custom_property_cascade.rs+++ b/Libraries/LibWeb/Rust/src/css/style/custom_property_cascade.rs@@ -529,12 +529,17 @@ pub(super) fn value_reads_inherited_values(value: &StyleValueData) -> bool {)}-/// Whether a written value substitutes `if()`, whose conditions read the document's media-/// features and the element's lengths beside its custom-property environment.+/// Whether a written value may substitute `if()`, directly or through an attribute's value.+/// Its conditions read the document's media features and the element's lengths beside its+/// custom-property environment.pub(super) fn value_reads_conditions(value: &StyleValueData) -> bool {matches!(substituted_tokens(value),StyleValueData::Unresolved { presence_if: true, .. }+ | StyleValueData::Unresolved {+ presence_attr: true,+ ..+ })}diff --git a/Tests/LibWeb/Text/expected/css/attr-style-query-inputs.txt b/Tests/LibWeb/Text/expected/css/attr-style-query-inputs.txtnew file mode 100644index 00000000000..13681c748ae--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/attr-style-query-inputs.txt@@ -0,0 +1,3 @@+initial: 10px, 10px+attribute changed: 30px, 30px+property changed: 40px, 40pxdiff --git a/Tests/LibWeb/Text/input/css/attr-style-query-inputs.html b/Tests/LibWeb/Text/input/css/attr-style-query-inputs.htmlnew file mode 100644index 00000000000..2a89492650a--- /dev/null+++ b/Tests/LibWeb/Text/input/css/attr-style-query-inputs.html@@ -0,0 +1,32 @@+<!doctype html>+<style>+ @property --length {+ syntax: "<length>";+ inherits: false;+ initial-value: 0px;+ }+ body {+ font-size: 10px;+ }+ #target {+ --length: 20px;+ --value: attr(data-expression type(<length>));+ width: var(--value);+ height: attr(data-expression type(<length>));+ }+</style>+<div id="target" data-expression="if(style(--length: 2em): 10px; else: 20px)"></div>+<script src="../include.js"></script>+<script>+ test(() => {+ function dump(label) {+ const style = getComputedStyle(target);+ println(`${label}: ${style.width}, ${style.height}`);+ }+ dump("initial");+ target.dataset.expression = "if(style(--length: 2em): 30px; else: 40px)";+ dump("attribute changed");+ target.style.setProperty("--length", "30px");+ dump("property changed");+ });+</script>