2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004-2010, 2015 Apple Inc. All rights reserved.
4 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 - 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
25 #include "CSSParserMode.h"
27 #include "WritingMode.h"
28 #include <wtf/text/WTFString.h>
32 class CSSParserObserver;
33 class CSSSelectorList;
36 class ImmutableStyleProperties;
37 class MutableStyleProperties;
39 class StyleRuleKeyframe;
40 class StyleSheetContents;
44 enum class ParseResult {
50 WEBCORE_EXPORT explicit CSSParser(const CSSParserContext&);
51 WEBCORE_EXPORT ~CSSParser();
53 enum class RuleParsing { Normal, Deferred };
54 void parseSheet(StyleSheetContents*, const String&, RuleParsing = RuleParsing::Normal);
56 static RefPtr<StyleRuleBase> parseRule(const CSSParserContext&, StyleSheetContents*, const String&);
58 RefPtr<StyleRuleKeyframe> parseKeyframeRule(const String&);
59 static std::unique_ptr<Vector<double>> parseKeyframeKeyList(const String&);
61 bool parseSupportsCondition(const String&);
63 static void parseSheetForInspector(const CSSParserContext&, StyleSheetContents*, const String&, CSSParserObserver&);
64 static void parseDeclarationForInspector(const CSSParserContext&, const String&, CSSParserObserver&);
66 static ParseResult parseValue(MutableStyleProperties&, CSSPropertyID, const String&, bool important, const CSSParserContext&);
67 static ParseResult parseCustomPropertyValue(MutableStyleProperties&, const AtomicString& propertyName, const String&, bool important, const CSSParserContext&);
69 static RefPtr<CSSValue> parseFontFaceDescriptor(CSSPropertyID, const String&, const CSSParserContext&);
71 static RefPtr<CSSValue> parseSingleValue(CSSPropertyID, const String&, const CSSParserContext& = strictCSSParserContext());
73 WEBCORE_EXPORT bool parseDeclaration(MutableStyleProperties&, const String&);
74 static Ref<ImmutableStyleProperties> parseInlineStyleDeclaration(const String&, const Element*);
76 void parseSelector(const String&, CSSSelectorList&);
78 RefPtr<CSSValue> parseValueWithVariableReferences(CSSPropertyID, const CSSValue&, const CustomPropertyValueMap& customProperties, TextDirection, WritingMode);
80 static Color parseColor(const String&, bool strict = false);
81 static Color parseSystemColor(const String&, const CSSParserContext*);
84 ParseResult parseValue(MutableStyleProperties&, CSSPropertyID, const String&, bool important);
86 CSSParserContext m_context;
89 } // namespace WebCore