#include "third_party/blink/renderer/core/css/properties/css_color_function_parser.h"
#include <cmath>
#include "base/containers/fixed_flat_map.h"
#include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom-shared.h"
#include "third_party/blink/renderer/core/css/css_color.h"
#include "third_party/blink/renderer/core/css/css_color_mix_value.h"
#include "third_party/blink/renderer/core/css/css_identifier_value.h"
#include "third_party/blink/renderer/core/css/css_math_function_value.h"
#include "third_party/blink/renderer/core/css/css_relative_color_value.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_save_point.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_token_range.h"
#include "third_party/blink/renderer/core/css/properties/css_parsing_utils.h"
#include "third_party/blink/renderer/core/css_value_keywords.h"
namespace blink {
struct ColorFunctionParser::FunctionMetadata { … };
namespace {
bool IsValidColorFunction(CSSValueID id) { … }
Color::ColorSpace ColorSpaceFromFunctionName(CSSValueID id) { … }
Color::ColorSpace ColorSpaceFromColorSpaceArgument(CSSValueID id) { … }
enum class FunctionMetadataEntry : uint8_t { … };
constexpr double kPercentNotApplicable = …;
constexpr auto kFunctionMetadataMap = …;
constexpr auto kColorSpaceFunctionMap = …;
bool ColorChannelIsHue(Color::ColorSpace color_space, int channel) { … }
std::optional<Color> TryResolveAtParseTime(const CSSValue& value) { … }
CSSValue* ConsumeRelativeColorChannel(
CSSParserTokenStream& stream,
const CSSParserContext& context,
const CSSColorChannelMap& color_channel_map,
CalculationResultCategorySet expected_categories,
const double percentage_base = 0) { … }
bool IsInGamutRec2020(Color color) { … }
}
bool ColorFunctionParser::ConsumeColorSpaceAndOriginColor(
CSSParserTokenStream& stream,
CSSValueID function_id,
const CSSParserContext& context) { … }
bool ColorFunctionParser::ConsumeChannel(CSSParserTokenStream& stream,
const CSSParserContext& context,
int i) { … }
bool ColorFunctionParser::ConsumeAlpha(CSSParserTokenStream& stream,
const CSSParserContext& context) { … }
void ColorFunctionParser::MakePerColorSpaceAdjustments() { … }
double ColorFunctionParser::ResolveColorChannel(
const CSSValue* value,
ChannelType channel_type,
double percentage_base,
const CSSColorChannelMap& color_channel_map) { … }
double ColorFunctionParser::ResolveAlpha(
const CSSValue* value,
ChannelType channel_type,
const CSSColorChannelMap& color_channel_map) { … }
double ColorFunctionParser::ResolveRelativeChannelValue(
const CSSValue* value,
ChannelType channel_type,
double percentage_base,
const CSSColorChannelMap& color_channel_map) { … }
bool ColorFunctionParser::IsRelativeColor() const { … }
CSSValue* ColorFunctionParser::ConsumeFunctionalSyntaxColor(
CSSParserTokenStream& stream,
const CSSParserContext& context) { … }
}