Truly independent web browser
LibWeb: Look up custom functions in the scope being evaluated
Callum Law899d232ba898
diff --git a/Libraries/LibWeb/Rust/src/css/custom_properties.rs b/Libraries/LibWeb/Rust/src/css/custom_properties.rsindex ed08718f8b8..e8473c8dd95 100644--- a/Libraries/LibWeb/Rust/src/css/custom_properties.rs+++ b/Libraries/LibWeb/Rust/src/css/custom_properties.rs@@ -876,17 +876,6 @@ impl GuardedSubstitutionContexts {}true}-- fn innermost_function(&self) -> Option<CustomFunctionIdentity> {- self.contexts- .borrow()- .iter()- .rev()- .find_map(|context| match &context.dependency {- SubstitutionContextDependency::Function(identity) => Some(*identity),- _ => None,- })- }}#[derive(Default)]@@ -2726,13 +2715,13 @@ fn replace_a_dashed_function(// FIXME: Top-level calls use the element's style scope, but should use the relevant CSS rule's style scope. See the// failing tests in function-shadow.html.let caller_scope_identity = context- .guarded_contexts- .innermost_function()- .and_then(|identity| {+ .function_local_scopes+ .last()+ .and_then(|scope| {functions.definitions.iter()- .find(|definition| definition.identity == identity)+ .find(|definition| definition.identity == scope.function_identity).map(|definition| definition.scope_identity)}).unwrap_or(functions.caller_scope_identity);diff --git a/Tests/LibWeb/Text/expected/css/custom-function-inherited-local-scope.txt b/Tests/LibWeb/Text/expected/css/custom-function-inherited-local-scope.txtnew file mode 100644index 00000000000..7ef22e9a431--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/custom-function-inherited-local-scope.txt@@ -0,0 +1 @@+PASSdiff --git a/Tests/LibWeb/Text/input/css/custom-function-inherited-local-scope.html b/Tests/LibWeb/Text/input/css/custom-function-inherited-local-scope.htmlnew file mode 100644index 00000000000..9e2fbb4fe8b--- /dev/null+++ b/Tests/LibWeb/Text/input/css/custom-function-inherited-local-scope.html@@ -0,0 +1,36 @@+<!doctype html>+<style>+ @function --value() {+ result: FAIL;+ }++ @function --read() {+ result: var(--source);+ }+</style>+<div id="host">+ <template shadowrootmode="open">+ <style>+ @function --value() {+ result: PASS;+ }++ @function --owner() {+ --call: --read();+ --source: --value();+ result: var(--call);+ }++ #target {+ --foo: --owner();+ }+ </style>+ <div id="target"></div>+ </template>+</div>+<script src="../include.js"></script>+<script>+ test(() => {+ println(getComputedStyle(host.shadowRoot.getElementById("target")).getPropertyValue("--foo"));+ });+</script>