LibWeb: Support non-fixed <random-value-sharing>

This works by generating random values using XorShift128PlusRNG at
compute time and then caching them on the document using the relevant
random-caching-key
This commit is contained in:
Callum Law
2025-11-05 13:27:48 +13:00
committed by Sam Atkins
parent 86e6aa0291
commit 12e8f503aa
Notes: github-actions[bot] 2025-12-01 11:01:47 +00:00
15 changed files with 226 additions and 54 deletions

View File

@@ -98,7 +98,6 @@ ErrorOr<void> generate_implementation_file(JsonObject& functions_data, Core::Fil
#include <LibWeb/CSS/Parser/ErrorReporter.h>
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
#include <LibWeb/CSS/StyleValues/RandomValueSharingStyleValue.h>
namespace Web::CSS {
@@ -312,8 +311,7 @@ RefPtr<CalculationNode const> Parser::parse_math_function(Function const& functi
parameter_generator.set("parse_function", MUST(String::formatted("parse_random_value_sharing(tokens_{})", parameter_index)));
parameter_generator.set("check_function", " != nullptr"_string);
parameter_generator.set("release_function", ".release_nonnull()"_string);
// FIXME: This should be 'auto' rather than 'fixed 0' by default
parameter_generator.set("parameter_default", MUST(String::formatted(" = RandomValueSharingStyleValue::create_fixed(NumberStyleValue::create(0))")));
parameter_generator.set("parameter_default", MUST(String::formatted(" = RandomValueSharingStyleValue::create_auto(random_value_sharing_auto_name(), false)")));
} else {
// NOTE: This assumes everything not handled above is a calculation node of some kind.
parameter_is_calculation = true;