#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/css/resolver/style_cascade.h"
#include <bit>
#include <optional>
#include "base/not_fatal_until.h"
#include "base/notreached.h"
#include "third_party/blink/renderer/core/animation/css/css_animations.h"
#include "third_party/blink/renderer/core/animation/css_interpolation_environment.h"
#include "third_party/blink/renderer/core/animation/css_interpolation_types_map.h"
#include "third_party/blink/renderer/core/animation/invalidatable_interpolation.h"
#include "third_party/blink/renderer/core/animation/property_handle.h"
#include "third_party/blink/renderer/core/animation/transition_interpolation.h"
#include "third_party/blink/renderer/core/css/css_appearance_auto_base_select_value_pair.h"
#include "third_party/blink/renderer/core/css/css_attr_type.h"
#include "third_party/blink/renderer/core/css/css_cyclic_variable_value.h"
#include "third_party/blink/renderer/core/css/css_flip_revert_value.h"
#include "third_party/blink/renderer/core/css/css_font_selector.h"
#include "third_party/blink/renderer/core/css/css_invalid_variable_value.h"
#include "third_party/blink/renderer/core/css/css_math_function_value.h"
#include "third_party/blink/renderer/core/css/css_numeric_literal_value.h"
#include "third_party/blink/renderer/core/css/css_pending_substitution_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
#include "third_party/blink/renderer/core/css/css_syntax_string_parser.h"
#include "third_party/blink/renderer/core/css/css_unparsed_declaration_value.h"
#include "third_party/blink/renderer/core/css/css_unset_value.h"
#include "third_party/blink/renderer/core/css/css_value.h"
#include "third_party/blink/renderer/core/css/css_variable_data.h"
#include "third_party/blink/renderer/core/css/document_style_environment_variables.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_local_context.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_token.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_token_stream.h"
#include "third_party/blink/renderer/core/css/parser/css_property_parser.h"
#include "third_party/blink/renderer/core/css/parser/css_tokenizer.h"
#include "third_party/blink/renderer/core/css/parser/css_variable_parser.h"
#include "third_party/blink/renderer/core/css/properties/css_parsing_utils.h"
#include "third_party/blink/renderer/core/css/properties/css_property.h"
#include "third_party/blink/renderer/core/css/properties/css_property_ref.h"
#include "third_party/blink/renderer/core/css/properties/longhands.h"
#include "third_party/blink/renderer/core/css/property_bitsets.h"
#include "third_party/blink/renderer/core/css/property_registry.h"
#include "third_party/blink/renderer/core/css/resolver/cascade_expansion-inl.h"
#include "third_party/blink/renderer/core/css/resolver/cascade_expansion.h"
#include "third_party/blink/renderer/core/css/resolver/cascade_interpolations.h"
#include "third_party/blink/renderer/core/css/resolver/cascade_resolver.h"
#include "third_party/blink/renderer/core/css/resolver/scoped_style_resolver.h"
#include "third_party/blink/renderer/core/css/resolver/style_builder.h"
#include "third_party/blink/renderer/core/css/resolver/style_builder_converter.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/css/try_value_flips.h"
#include "third_party/blink/renderer/core/css_value_keywords.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/html/forms/html_select_element.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/style_property_shorthand.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_view.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
namespace {
AtomicString ConsumeVariableName(CSSParserTokenStream& stream) { … }
bool ConsumeComma(CSSParserTokenStream& stream) { … }
CSSAttrType ConsumeAttributeType(CSSParserTokenStream& stream) { … }
const CSSValue* Parse(const CSSProperty& property,
CSSParserTokenStream& stream,
const CSSParserContext* context) { … }
const CSSValue* ValueAt(const MatchResult& result, uint32_t position) { … }
const TreeScope& TreeScopeAt(const MatchResult& result, uint32_t position) { … }
const CSSValue* EnsureScopedValue(const Document& document,
const MatchResult& match_result,
CascadePriority priority,
const CSSValue* value) { … }
PropertyHandle ToPropertyHandle(const CSSProperty& property,
CascadePriority priority) { … }
CascadeOrigin TargetOriginForRevert(CascadeOrigin origin) { … }
CSSPropertyID UnvisitedID(CSSPropertyID id) { … }
bool IsInterpolation(CascadePriority priority) { … }
std::optional<CSSParserToken> GetAttrSubstitutionValue(
const String& attribute_value,
const CSSAttrType& attribute_type,
const CSSParserContext& context) { … }
}
MatchResult& StyleCascade::MutableMatchResult() { … }
void StyleCascade::AddInterpolations(const ActiveInterpolationsMap* map,
CascadeOrigin origin) { … }
void StyleCascade::Apply(CascadeFilter filter) { … }
std::unique_ptr<CSSBitset> StyleCascade::GetImportantSet() { … }
void StyleCascade::Reset() { … }
const CSSValue* StyleCascade::Resolve(const CSSPropertyName& name,
const CSSValue& value,
CascadeOrigin origin,
CascadeResolver& resolver) { … }
HeapHashMap<CSSPropertyName, Member<const CSSValue>>
StyleCascade::GetCascadedValues() const { … }
const CSSValue* StyleCascade::Resolve(StyleResolverState& state,
const CSSPropertyName& name,
const CSSValue& value) { … }
void StyleCascade::AnalyzeIfNeeded() { … }
void StyleCascade::AnalyzeMatchResult() { … }
void StyleCascade::AnalyzeInterpolations() { … }
void StyleCascade::AddExplicitDefaults() { … }
void StyleCascade::Reanalyze() { … }
void StyleCascade::ApplyCascadeAffecting(CascadeResolver& resolver) { … }
void StyleCascade::ApplyHighPriority(CascadeResolver& resolver) { … }
void StyleCascade::ApplyWideOverlapping(CascadeResolver& resolver) { … }
void StyleCascade::ApplyMatchResult(CascadeResolver& resolver) { … }
void StyleCascade::ApplyInterpolations(CascadeResolver& resolver) { … }
void StyleCascade::ApplyInterpolationMap(const ActiveInterpolationsMap& map,
CascadeOrigin origin,
size_t index,
CascadeResolver& resolver) { … }
void StyleCascade::ApplyInterpolation(
const CSSProperty& property,
CascadePriority priority,
const ActiveInterpolations& interpolations,
CascadeResolver& resolver) { … }
void StyleCascade::LookupAndApply(const CSSPropertyName& name,
CascadeResolver& resolver) { … }
void StyleCascade::LookupAndApply(const CSSProperty& property,
CascadeResolver& resolver) { … }
void StyleCascade::LookupAndApplyValue(const CSSProperty& property,
CascadePriority* priority,
CascadeResolver& resolver) { … }
void StyleCascade::LookupAndApplyDeclaration(const CSSProperty& property,
CascadePriority* priority,
CascadeResolver& resolver) { … }
void StyleCascade::LookupAndApplyInterpolation(const CSSProperty& property,
CascadePriority* priority,
CascadeResolver& resolver) { … }
bool StyleCascade::IsRootElement() const { … }
StyleCascade::TokenSequence::TokenSequence(const CSSVariableData* data)
: … { … }
bool StyleCascade::TokenSequence::AppendFallback(const TokenSequence& sequence,
wtf_size_t byte_limit) { … }
static bool IsNonWhitespaceToken(const CSSParserToken& token) { … }
bool StyleCascade::TokenSequence::Append(CSSVariableData* data,
wtf_size_t byte_limit) { … }
void StyleCascade::TokenSequence::Append(const CSSParserToken& token,
StringView original_text) { … }
CSSVariableData* StyleCascade::TokenSequence::BuildVariableData() { … }
const CSSValue* StyleCascade::Resolve(const CSSProperty& property,
const CSSValue& value,
CascadePriority priority,
CascadeOrigin& origin,
CascadeResolver& resolver) { … }
const CSSValue* StyleCascade::ResolveSubstitutions(const CSSProperty& property,
const CSSValue& value,
CascadeResolver& resolver) { … }
const CSSValue* StyleCascade::ResolveCustomProperty(
const CSSProperty& property,
const CSSUnparsedDeclarationValue& decl,
CascadeResolver& resolver) { … }
const CSSValue* StyleCascade::ResolveVariableReference(
const CSSProperty& property,
const CSSUnparsedDeclarationValue& value,
CascadeResolver& resolver) { … }
const CSSValue* StyleCascade::ResolvePendingSubstitution(
const CSSProperty& property,
const cssvalue::CSSPendingSubstitutionValue& value,
CascadeResolver& resolver) { … }
const CSSValue* StyleCascade::ResolveRevert(const CSSProperty& property,
const CSSValue& value,
CascadeOrigin& origin,
CascadeResolver& resolver) { … }
const CSSValue* StyleCascade::ResolveRevertLayer(const CSSProperty& property,
CascadePriority priority,
CascadeOrigin& origin,
CascadeResolver& resolver) { … }
const CSSValue* StyleCascade::ResolveFlipRevert(const CSSProperty& property,
const CSSFlipRevertValue& value,
CascadePriority priority,
CascadeOrigin& origin,
CascadeResolver& resolver) { … }
const CSSValue* StyleCascade::ResolveAppearanceAutoBaseSelect(
const CSSProperty& property,
const CSSAppearanceAutoBaseSelectValuePair& value,
CascadePriority priority,
CascadeOrigin& origin,
CascadeResolver& resolver) { … }
const CSSValue* StyleCascade::ResolveMathFunction(
const CSSProperty& property,
const CSSMathFunctionValue& math_value,
CascadePriority priority) { … }
CSSVariableData* StyleCascade::ResolveVariableData(
CSSVariableData* data,
const CSSParserContext& context,
CascadeResolver& resolver) { … }
bool StyleCascade::ResolveTokensInto(CSSParserTokenStream& stream,
CascadeResolver& resolver,
const CSSParserContext& context,
const FunctionContext& function_context,
TokenSequence& out) { … }
bool StyleCascade::ResolveVarInto(CSSParserTokenStream& stream,
CascadeResolver& resolver,
const CSSParserContext& context,
TokenSequence& out) { … }
bool StyleCascade::ResolveFunctionInto(StringView function_name,
CSSParserTokenStream& stream,
CascadeResolver& resolver,
const CSSParserContext& context,
const FunctionContext& function_context,
TokenSequence& out) { … }
const CSSValue* StyleCascade::ResolveFunctionExpression(
StringView expr,
const StyleRuleFunction::Type& type,
CascadeResolver& resolver,
const CSSParserContext& context,
const FunctionContext& function_context) { … }
bool StyleCascade::ResolveEnvInto(CSSParserTokenStream& stream,
CascadeResolver& resolver,
const CSSParserContext& context,
TokenSequence& out) { … }
bool StyleCascade::ResolveArgInto(CSSParserTokenStream& stream,
CascadeResolver& resolver,
const CSSParserContext& context,
const FunctionContext& function_context,
TokenSequence& out) { … }
bool StyleCascade::ResolveAttrInto(CSSParserTokenStream& stream,
CascadeResolver& resolver,
const CSSParserContext& context,
TokenSequence& out) { … }
CSSVariableData* StyleCascade::GetVariableData(
const CustomProperty& property) const { … }
CSSVariableData* StyleCascade::GetEnvironmentVariable(
const AtomicString& name,
WTF::Vector<unsigned> indices) const { … }
const CSSParserContext* StyleCascade::GetParserContext(
const CSSUnparsedDeclarationValue& value) { … }
bool StyleCascade::HasFontSizeDependency(const CustomProperty& property,
CSSVariableData* data) const { … }
bool StyleCascade::HasLineHeightDependency(const CustomProperty& property,
CSSVariableData* data) const { … }
bool StyleCascade::ValidateFallback(const CustomProperty& property,
StringView value) const { … }
void StyleCascade::MarkIsReferenced(const CSSProperty& referencer,
const CustomProperty& referenced) { … }
void StyleCascade::MarkHasVariableReference(const CSSProperty& property) { … }
bool StyleCascade::TreatAsRevertLayer(CascadePriority priority) const { … }
const Document& StyleCascade::GetDocument() const { … }
const CSSProperty& StyleCascade::ResolveSurrogate(const CSSProperty& property) { … }
void StyleCascade::CountUse(WebFeature feature) { … }
void StyleCascade::MaybeUseCountRevert(const CSSValue& value) { … }
}