#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/css/parser/css_parser_fast_paths.h"
#ifdef __SSE2__
#include <immintrin.h>
#elif defined(__ARM_NEON__)
#include <arm_neon.h>
#endif
#include "build/build_config.h"
#include "third_party/blink/public/public_buildflags.h"
#include "third_party/blink/renderer/core/css/css_color.h"
#include "third_party/blink/renderer/core/css/css_function_value.h"
#include "third_party/blink/renderer/core/css/css_identifier_value.h"
#include "third_party/blink/renderer/core/css/css_inherited_value.h"
#include "third_party/blink/renderer/core/css/css_initial_value.h"
#include "third_party/blink/renderer/core/css/css_numeric_literal_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
#include "third_party/blink/renderer/core/css/css_revert_layer_value.h"
#include "third_party/blink/renderer/core/css/css_revert_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_value_clamping_utils.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_idioms.h"
#include "third_party/blink/renderer/core/css/parser/css_property_parser.h"
#include "third_party/blink/renderer/core/css/properties/css_bitset.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/style_color.h"
#include "third_party/blink/renderer/core/css_value_keywords.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
#include "third_party/blink/renderer/core/style_property_shorthand.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/text/character_visitor.h"
#include "third_party/blink/renderer/platform/wtf/text/string_to_number.h"
namespace blink {
static unsigned ParsePositiveDouble(const LChar* string,
const LChar* end,
double& value);
static bool ParseDoubleWithPrefix(const LChar* string,
const LChar* end,
double& value);
static inline bool IsSimpleLengthPropertyID(CSSPropertyID property_id,
bool& accepts_negative_numbers) { … }
ALWAYS_INLINE static bool ParseSimpleLength(const LChar* characters,
unsigned length,
CSSPrimitiveValue::UnitType& unit,
double& number) { … }
static CSSValue* ParseSimpleLengthValue(CSSPropertyID property_id,
StringView string,
CSSParserMode css_parser_mode) { … }
ALWAYS_INLINE static unsigned ParseSimpleAngle(
const LChar* characters,
unsigned length,
CSSPrimitiveValue::UnitType& unit,
double& number) { … }
static inline bool IsColorPropertyID(CSSPropertyID property_id) { … }
static inline bool ColorPropertyAllowsQuirkyColor(CSSPropertyID property_id) { … }
static unsigned FindLengthOfValidDouble(const LChar* string, const LChar* end) { … }
static bool ContainsCharAtPos(const LChar* string,
const LChar* end,
int pos,
char ch,
bool also_accept_whitespace) { … }
static bool ParseDoubleWithPrefix(const LChar* string,
const LChar* end,
double& value) { … }
ALWAYS_INLINE static unsigned ParsePositiveDouble(const LChar* string,
const LChar* end,
double& value) { … }
ALWAYS_INLINE static bool ParseFloatWithMaxValue(const LChar*& string,
const LChar* end,
int max_value,
double& value,
bool& negative) { … }
namespace {
enum TerminatorStatus { … };
}
static bool SkipToTerminator(const LChar*& string,
const LChar* end,
const char terminator,
TerminatorStatus& terminator_status) { … }
static bool ParseColorNumberOrPercentage(const LChar*& string,
const LChar* end,
const char terminator,
TerminatorStatus& terminator_status,
CSSPrimitiveValue::UnitType& expect,
int& value) { … }
ALWAYS_INLINE static bool ParsePercentage(const LChar*& string,
const LChar* end,
const char terminator,
TerminatorStatus& terminator_status,
double& value) { … }
static inline bool IsTenthAlpha(const LChar* string, const wtf_size_t length) { … }
ALWAYS_INLINE static bool ParseAlphaValue(const LChar*& string,
const LChar* end,
const char terminator,
int& value) { … }
template <int N>
static inline bool MatchesLiteral(const LChar* a, const char (&b)[N]) { … }
template <int N>
static inline bool MatchesLiteral(const UChar* a, const char (&b)[N]) { … }
static inline bool MatchesCaseInsensitiveLiteral4(const LChar* a,
const char (&b)[5]) { … }
static inline bool MatchesCaseInsensitiveLiteral2(const LChar* a,
const char (&b)[3]) { … }
static inline bool MightBeRGBOrRGBA(const LChar* characters, unsigned length) { … }
static inline bool MightBeHSLOrHSLA(const LChar* characters, unsigned length) { … }
static bool FastParseColorInternal(Color& color,
const LChar* characters,
unsigned length,
bool quirks_mode) { … }
static ParseColorResult ParseColor(CSSPropertyID property_id,
StringView string,
CSSParserMode parser_mode,
Color& out_color,
CSSValueID& out_color_keyword) { … }
ParseColorResult CSSParserFastPaths::ParseColor(const String& string,
CSSParserMode parser_mode,
Color& color) { … }
bool CSSParserFastPaths::IsValidKeywordPropertyAndValue(
CSSPropertyID property_id,
CSSValueID value_id,
CSSParserMode parser_mode) { … }
CSSBitset CSSParserFastPaths::handled_by_keyword_fast_paths_properties_{ … };
bool CSSParserFastPaths::IsValidSystemFont(CSSValueID value_id) { … }
static inline CSSValue* ParseCSSWideKeywordValue(const LChar* ptr,
unsigned length) { … }
static CSSValue* ParseKeywordValue(CSSPropertyID property_id,
StringView string,
const CSSParserContext* context) { … }
static bool ParseTransformTranslateArguments(
const LChar*& pos,
const LChar* end,
unsigned expected_count,
CSSFunctionValue* transform_value) { … }
static bool ParseTransformRotateArgument(const LChar*& pos,
const LChar* end,
CSSFunctionValue* transform_value) { … }
static bool ParseTransformNumberArguments(const LChar*& pos,
const LChar* end,
unsigned expected_count,
CSSFunctionValue* transform_value) { … }
static const int kShortestValidTransformStringLength = …;
static CSSFunctionValue* ParseSimpleTransformValue(const LChar*& pos,
const LChar* end) { … }
static bool TransformCanLikelyUseFastPath(const LChar* chars, unsigned length) { … }
static CSSValue* ParseSimpleTransform(CSSPropertyID property_id,
StringView string) { … }
CSSValue* CSSParserFastPaths::MaybeParseValue(CSSPropertyID property_id,
StringView string,
const CSSParserContext* context) { … }
}