CSSPropertyParser.h [plain text]
#pragma once
#include "CSSParserTokenRange.h"
#include "StyleRule.h"
#include <wtf/text/StringView.h>
namespace WebCore {
class CSSProperty;
class CSSValue;
class StylePropertyShorthand;
class StyleSheetContents;
namespace Style {
class BuilderState;
}
class CSSPropertyParser {
WTF_MAKE_NONCOPYABLE(CSSPropertyParser);
public:
static bool parseValue(CSSPropertyID, bool important,
const CSSParserTokenRange&, const CSSParserContext&,
Vector<CSSProperty, 256>&, StyleRuleType);
static RefPtr<CSSValue> parseSingleValue(CSSPropertyID, const CSSParserTokenRange&, const CSSParserContext&);
static bool canParseTypedCustomPropertyValue(const String& syntax, const CSSParserTokenRange&, const CSSParserContext&);
static RefPtr<CSSCustomPropertyValue> parseTypedCustomPropertyValue(const String& name, const String& syntax, const CSSParserTokenRange&, const Style::BuilderState&, const CSSParserContext&);
static void collectParsedCustomPropertyValueDependencies(const String& syntax, bool isRoot, HashSet<CSSPropertyID>& dependencies, const CSSParserTokenRange&, const CSSParserContext&);
private:
CSSPropertyParser(const CSSParserTokenRange&, const CSSParserContext&, Vector<CSSProperty, 256>*, bool consumeWhitespace = true);
bool parseValueStart(CSSPropertyID, bool important);
bool consumeCSSWideKeyword(CSSPropertyID, bool important);
RefPtr<CSSValue> parseSingleValue(CSSPropertyID, CSSPropertyID = CSSPropertyInvalid);
bool canParseTypedCustomPropertyValue(const String& syntax);
RefPtr<CSSCustomPropertyValue> parseTypedCustomPropertyValue(const String& name, const String& syntax, const Style::BuilderState&);
void collectParsedCustomPropertyValueDependencies(const String& syntax, bool isRoot, HashSet<CSSPropertyID>& dependencies);
bool inQuirksMode() const { return m_context.mode == HTMLQuirksMode; }
bool parseViewportDescriptor(CSSPropertyID propId, bool important);
bool parseFontFaceDescriptor(CSSPropertyID);
void addProperty(CSSPropertyID, CSSPropertyID, Ref<CSSValue>&&, bool important, bool implicit = false);
void addExpandedPropertyForValue(CSSPropertyID propId, Ref<CSSValue>&&, bool);
bool consumeBorder(RefPtr<CSSValue>& width, RefPtr<CSSValue>& style, RefPtr<CSSValue>& color);
bool parseShorthand(CSSPropertyID, bool important);
bool consumeShorthandGreedily(const StylePropertyShorthand&, bool important);
bool consume2ValueShorthand(const StylePropertyShorthand&, bool important);
bool consume4ValueShorthand(const StylePropertyShorthand&, bool important);
bool consumeAnimationShorthand(const StylePropertyShorthand&, bool important);
bool consumeBackgroundShorthand(const StylePropertyShorthand&, bool important);
bool consumeOverflowShorthand(bool important);
bool consumeColumns(bool important);
bool consumeGridItemPositionShorthand(CSSPropertyID, bool important);
bool consumeGridTemplateRowsAndAreasAndColumns(CSSPropertyID, bool important);
bool consumeGridTemplateShorthand(CSSPropertyID, bool important);
bool consumeGridShorthand(bool important);
bool consumeGridAreaShorthand(bool important);
bool consumePlaceContentShorthand(bool important);
bool consumePlaceItemsShorthand(bool important);
bool consumePlaceSelfShorthand(bool important);
bool consumeFont(bool important);
bool consumeFontVariantShorthand(bool important);
bool consumeSystemFont(bool important);
bool consumeBorderSpacing(bool important);
bool consumeBorderImage(CSSPropertyID, bool important);
bool consumeFlex(bool important);
bool consumeLegacyBreakProperty(CSSPropertyID, bool important);
bool consumeTransformOrigin(bool important);
bool consumePerspectiveOrigin(bool important);
private:
CSSParserTokenRange m_range;
const CSSParserContext& m_context;
Vector<CSSProperty, 256>* m_parsedProperties;
};
CSSPropertyID cssPropertyID(StringView);
CSSValueID cssValueKeywordID(StringView);
bool isCustomPropertyName(const String&);
#if PLATFORM(IOS_FAMILY)
void cssPropertyNameIOSAliasing(const char* propertyName, const char*& propertyNameAlias, unsigned& newLength);
#endif
}