mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb/CSS: Make UnresolvedStyleValue figure out if it contains ASFs
UnresolvedStyleValue::create() has one user where we know if there are any arbitrary substitution functions in the list of CVs, and two users where we don't know and just hope there aren't any. I'm about to add another user that also doesn't know, and so it seems worth just making UnresolvedStyleValue::create() do that work instead. We keep the parameter, now Optional<>, so that we save some redundant work in that one place where we do already know.
This commit is contained in:
committed by
Tim Ledbetter
parent
5aba457009
commit
d18b0c07ca
Notes:
github-actions[bot]
2025-07-16 13:49:59 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/d18b0c07caf Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5400 Reviewed-by: https://github.com/tcl3 ✅
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
||||
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
||||
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
@@ -13,6 +13,31 @@
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
ValueComparingNonnullRefPtr<UnresolvedStyleValue const> UnresolvedStyleValue::create(Vector<Parser::ComponentValue>&& values, Optional<bool> contains_arbitrary_substitution_function, Optional<String> original_source_text)
|
||||
{
|
||||
if (!contains_arbitrary_substitution_function.has_value()) {
|
||||
bool found_asf = false;
|
||||
for (auto const& value : values) {
|
||||
if ((value.is_function() && value.function().contains_arbitrary_substitution_function())
|
||||
|| (value.is_block() && value.block().contains_arbitrary_substitution_function())) {
|
||||
found_asf = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
contains_arbitrary_substitution_function = found_asf;
|
||||
}
|
||||
|
||||
return adopt_ref(*new (nothrow) UnresolvedStyleValue(move(values), contains_arbitrary_substitution_function.value(), move(original_source_text)));
|
||||
}
|
||||
|
||||
UnresolvedStyleValue::UnresolvedStyleValue(Vector<Parser::ComponentValue>&& values, bool contains_arbitrary_substitution_function, Optional<String> original_source_text)
|
||||
: CSSStyleValue(Type::Unresolved)
|
||||
, m_values(move(values))
|
||||
, m_contains_arbitrary_substitution_function(contains_arbitrary_substitution_function)
|
||||
, m_original_source_text(move(original_source_text))
|
||||
{
|
||||
}
|
||||
|
||||
String UnresolvedStyleValue::to_string(SerializationMode) const
|
||||
{
|
||||
if (m_original_source_text.has_value())
|
||||
|
||||
Reference in New Issue
Block a user