summaryrefslogtreecommitdiffstats
path: root/WebCore/css/CSSParser.h
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/css/CSSParser.h')
-rw-r--r--WebCore/css/CSSParser.h235
1 files changed, 118 insertions, 117 deletions
diff --git a/WebCore/css/CSSParser.h b/WebCore/css/CSSParser.h
index 0a7267f..6b66bfc 100644
--- a/WebCore/css/CSSParser.h
+++ b/WebCore/css/CSSParser.h
@@ -1,8 +1,7 @@
/*
- * This file is part of the DOM implementation for KDE.
- *
* Copyright (C) 2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -25,6 +24,7 @@
#include "AtomicString.h"
#include "Color.h"
+#include "CSSParserValues.h"
#include "MediaQuery.h"
#include <wtf/HashSet.h>
#include <wtf/Vector.h>
@@ -37,77 +37,18 @@ namespace WebCore {
class CSSRule;
class CSSRuleList;
class CSSSelector;
+ class CSSNthSelector;
class CSSStyleSheet;
class CSSValue;
class CSSValueList;
+ class CSSVariablesDeclaration;
class Document;
class MediaList;
- class MediaList;
class MediaQueryExp;
class StyleBase;
class StyleList;
- struct Function;
-
- struct ParseString {
- UChar* characters;
- int length;
-
- void lower();
- };
-
- struct Value {
- int id;
- bool isInt;
- union {
- double fValue;
- int iValue;
- ParseString string;
- Function* function;
- };
- enum {
- Operator = 0x100000,
- Function = 0x100001,
- Q_EMS = 0x100002
- };
- int unit;
- };
-
- DeprecatedString deprecatedString(const ParseString&);
-
- static inline String domString(const ParseString& ps)
- {
- return String(ps.characters, ps.length);
- }
-
- static inline AtomicString atomicString(const ParseString& ps)
- {
- return AtomicString(ps.characters, ps.length);
- }
-
- class ValueList {
- public:
- ValueList() : m_current(0) { }
- ~ValueList();
-
- void addValue(const Value& v) { m_values.append(v); }
- unsigned size() const { return m_values.size(); }
- Value* current() { return m_current < m_values.size() ? &m_values[m_current] : 0; }
- Value* next() { ++m_current; return current(); }
-
- Value* valueAt(unsigned i) { return i < m_values.size() ? &m_values[i] : 0; }
- void deleteValueAt(unsigned i) { m_values.remove(i); }
-
- private:
- Vector<Value, 16> m_values;
- unsigned m_current;
- };
-
- struct Function {
- ParseString name;
- ValueList* args;
-
- ~Function() { delete args; }
- };
+ class WebKitCSSKeyframeRule;
+ class WebKitCSSKeyframesRule;
class CSSParser {
public:
@@ -116,19 +57,18 @@ namespace WebCore {
void parseSheet(CSSStyleSheet*, const String&);
PassRefPtr<CSSRule> parseRule(CSSStyleSheet*, const String&);
+ PassRefPtr<CSSRule> parseKeyframeRule(CSSStyleSheet*, const String&);
bool parseValue(CSSMutableStyleDeclaration*, int propId, const String&, bool important);
static bool parseColor(RGBA32& color, const String&, bool strict = false);
bool parseColor(CSSMutableStyleDeclaration*, const String&);
bool parseDeclaration(CSSMutableStyleDeclaration*, const String&);
bool parseMediaQuery(MediaList*, const String&);
- static CSSParser* current() { return currentParser; }
-
Document* document() const;
void addProperty(int propId, PassRefPtr<CSSValue>, bool important);
void rollbackLastProperties(int num);
- bool hasProperties() const { return numParsedProperties > 0; }
+ bool hasProperties() const { return m_numParsedProperties > 0; }
bool parseValue(int propId, bool important);
bool parseShorthand(int propId, const int* properties, int numProperties, bool important);
@@ -136,24 +76,32 @@ namespace WebCore {
bool parseContent(int propId, bool important);
PassRefPtr<CSSValue> parseBackgroundColor();
- bool parseBackgroundImage(RefPtr<CSSValue>&);
- PassRefPtr<CSSValue> parseBackgroundPositionXY(bool& xFound, bool& yFound);
- void parseBackgroundPosition(RefPtr<CSSValue>&, RefPtr<CSSValue>&);
- PassRefPtr<CSSValue> parseBackgroundSize();
+
+ bool parseFillImage(RefPtr<CSSValue>&);
+ PassRefPtr<CSSValue> parseFillPositionXY(bool& xFound, bool& yFound);
+ void parseFillPosition(RefPtr<CSSValue>&, RefPtr<CSSValue>&);
+ PassRefPtr<CSSValue> parseFillSize();
- bool parseBackgroundProperty(int propId, int& propId1, int& propId2, RefPtr<CSSValue>&, RefPtr<CSSValue>&);
- bool parseBackgroundShorthand(bool important);
-
- void addBackgroundValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval);
-
- void addTransitionValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval);
- PassRefPtr<CSSValue> parseTransitionDuration();
- PassRefPtr<CSSValue> parseTransitionRepeatCount();
- PassRefPtr<CSSValue> parseTransitionTimingFunction();
- bool parseTimingFunctionValue(ValueList*& args, double& result);
- PassRefPtr<CSSValue> parseTransitionProperty();
- bool parseTransitionProperty(int propId, RefPtr<CSSValue>&);
+ bool parseFillProperty(int propId, int& propId1, int& propId2, RefPtr<CSSValue>&, RefPtr<CSSValue>&);
+ bool parseFillShorthand(int propId, const int* properties, int numProperties, bool important);
+
+ void addFillValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval);
+
+ void addAnimationValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval);
+
+ PassRefPtr<CSSValue> parseAnimationDelay();
+ PassRefPtr<CSSValue> parseAnimationDirection();
+ PassRefPtr<CSSValue> parseAnimationDuration();
+ PassRefPtr<CSSValue> parseAnimationIterationCount();
+ PassRefPtr<CSSValue> parseAnimationName();
+ PassRefPtr<CSSValue> parseAnimationPlayState();
+ PassRefPtr<CSSValue> parseAnimationProperty();
+ PassRefPtr<CSSValue> parseAnimationTimingFunction();
+
+ bool parseTimingFunctionValue(CSSParserValueList*& args, double& result);
+ bool parseAnimationProperty(int propId, RefPtr<CSSValue>&);
bool parseTransitionShorthand(bool important);
+ bool parseAnimationShorthand(bool important);
bool parseDashboardRegions(int propId, bool important);
@@ -163,15 +111,19 @@ namespace WebCore {
PassRefPtr<CSSValueList> parseFontFamily();
bool parseCounter(int propId, int defaultValue, bool important);
- PassRefPtr<CSSValue> parseCounterContent(ValueList* args, bool counters);
+ PassRefPtr<CSSValue> parseCounterContent(CSSParserValueList* args, bool counters);
- bool parseColorParameters(Value*, int* colorValues, bool parseAlpha);
- bool parseHSLParameters(Value*, double* colorValues, bool parseAlpha);
- PassRefPtr<CSSPrimitiveValue> parseColor(Value* = 0);
- bool parseColorFromValue(Value*, RGBA32&, bool = false);
+ bool parseColorParameters(CSSParserValue*, int* colorValues, bool parseAlpha);
+ bool parseHSLParameters(CSSParserValue*, double* colorValues, bool parseAlpha);
+ PassRefPtr<CSSPrimitiveValue> parseColor(CSSParserValue* = 0);
+ bool parseColorFromValue(CSSParserValue*, RGBA32&, bool = false);
+ std::auto_ptr<CSSSelector> parseSelector(const String&, Document* doc = 0);
static bool parseColor(const String&, RGBA32& rgb, bool strict);
+ bool parseFontStyle(bool important);
+ bool parseFontVariant(bool important);
+ bool parseFontWeight(bool important);
bool parseFontFaceSrc();
bool parseFontFaceUnicodeRange();
@@ -184,58 +136,82 @@ namespace WebCore {
// CSS3 Parsing Routines (for properties specific to CSS3)
bool parseShadow(int propId, bool important);
- bool parseBorderImage(int propId, bool important);
+ bool parseBorderImage(int propId, bool important, RefPtr<CSSValue>&);
- PassRefPtr<CSSValue> parseTransform();
+ bool parseReflect(int propId, bool important);
+
+ // Image generators
+ bool parseCanvas(RefPtr<CSSValue>&);
+ bool parseGradient(RefPtr<CSSValue>&);
+
+ PassRefPtr<CSSValueList> parseTransform();
bool parseTransformOrigin(int propId, int& propId1, int& propId2, RefPtr<CSSValue>&, RefPtr<CSSValue>&);
-
+
+ bool parseVariable(CSSVariablesDeclaration*, const String& variableName, const String& variableValue);
+ void parsePropertyWithResolvedVariables(int propId, bool important, CSSMutableStyleDeclaration*, CSSParserValueList*);
+
int yyparse();
CSSSelector* createFloatingSelector();
+ CSSNthSelector* createFloatingNthSelector();
CSSSelector* sinkFloatingSelector(CSSSelector*);
- ValueList* createFloatingValueList();
- ValueList* sinkFloatingValueList(ValueList*);
+ CSSParserValueList* createFloatingValueList();
+ CSSParserValueList* sinkFloatingValueList(CSSParserValueList*);
- Function* createFloatingFunction();
- Function* sinkFloatingFunction(Function*);
+ CSSParserFunction* createFloatingFunction();
+ CSSParserFunction* sinkFloatingFunction(CSSParserFunction*);
- Value& sinkFloatingValue(Value&);
+ CSSParserValue& sinkFloatingValue(CSSParserValue&);
MediaList* createMediaList();
- CSSRule* createCharsetRule(const ParseString&);
- CSSRule* createImportRule(const ParseString&, MediaList*);
+ CSSRule* createCharsetRule(const CSSParserString&);
+ CSSRule* createImportRule(const CSSParserString&, MediaList*);
+ WebKitCSSKeyframeRule* createKeyframeRule(CSSParserValueList*);
+ WebKitCSSKeyframesRule* createKeyframesRule();
CSSRule* createMediaRule(MediaList*, CSSRuleList*);
CSSRuleList* createRuleList();
CSSRule* createStyleRule(CSSSelector*);
CSSRule* createFontFaceRule();
+ CSSRule* createVariablesRule(MediaList*, bool variablesKeyword);
- MediaQueryExp* createFloatingMediaQueryExp(const AtomicString&, ValueList*);
+ MediaQueryExp* createFloatingMediaQueryExp(const AtomicString&, CSSParserValueList*);
MediaQueryExp* sinkFloatingMediaQueryExp(MediaQueryExp*);
Vector<MediaQueryExp*>* createFloatingMediaQueryExpList();
Vector<MediaQueryExp*>* sinkFloatingMediaQueryExpList(Vector<MediaQueryExp*>*);
MediaQuery* createFloatingMediaQuery(MediaQuery::Restrictor, const String&, Vector<MediaQueryExp*>*);
+ MediaQuery* createFloatingMediaQuery(Vector<MediaQueryExp*>*);
MediaQuery* sinkFloatingMediaQuery(MediaQuery*);
+ bool addVariable(const CSSParserString&, CSSParserValueList*);
+ bool addVariableDeclarationBlock(const CSSParserString&);
+ bool checkForVariables(CSSParserValueList*);
+ void addUnresolvedProperty(int propId, bool important);
+
public:
- bool strict;
- bool important;
- int id;
- StyleList* styleElement;
- RefPtr<CSSRule> rule;
- MediaQuery* mediaQuery;
- ValueList* valueList;
- CSSProperty** parsedProperties;
- int numParsedProperties;
- int maxParsedProperties;
+ bool m_strict;
+ bool m_important;
+ int m_id;
+ CSSStyleSheet* m_styleSheet;
+ RefPtr<CSSRule> m_rule;
+ RefPtr<CSSRule> m_keyframe;
+ MediaQuery* m_mediaQuery;
+ CSSParserValueList* m_valueList;
+ CSSProperty** m_parsedProperties;
+ CSSSelector* m_floatingSelector;
+ int m_numParsedProperties;
+ int m_maxParsedProperties;
int m_inParseShorthand;
int m_currentShorthand;
bool m_implicitShorthand;
- AtomicString defaultNamespace;
+ bool m_hasFontFaceOnlyValues;
+
+ Vector<String> m_variableNames;
+ Vector<RefPtr<StyleBase> > m_variableValues;
- static CSSParser* currentParser;
+ AtomicString m_defaultNamespace;
// tokenizer methods and data
public:
@@ -253,7 +229,11 @@ namespace WebCore {
void checkForOrphanedUnits();
- UChar* data;
+ void clearVariables();
+
+ void deleteFontFaceOnlyValues();
+
+ UChar* m_data;
UChar* yytext;
UChar* yy_c_buf_p;
UChar yy_hold_char;
@@ -266,8 +246,8 @@ namespace WebCore {
Vector<RefPtr<StyleBase> > m_parsedStyleObjects;
Vector<RefPtr<CSSRuleList> > m_parsedRuleLists;
HashSet<CSSSelector*> m_floatingSelectors;
- HashSet<ValueList*> m_floatingValueLists;
- HashSet<Function*> m_floatingFunctions;
+ HashSet<CSSParserValueList*> m_floatingValueLists;
+ HashSet<CSSParserFunction*> m_floatingFunctions;
MediaQuery* m_floatingMediaQuery;
MediaQueryExp* m_floatingMediaQueryExp;
@@ -292,11 +272,32 @@ namespace WebCore {
return static_cast<Units>(static_cast<unsigned>(a) | static_cast<unsigned>(b));
}
- static bool validUnit(Value*, Units, bool strict);
+ static bool validUnit(CSSParserValue*, Units, bool strict);
friend class TransformOperationInfo;
};
+ int cssPropertyID(const CSSParserString&);
+ int cssPropertyID(const String&);
+ int cssValueKeywordID(const CSSParserString&);
+
+ class ShorthandScope {
+ public:
+ ShorthandScope(CSSParser* parser, int propId) : m_parser(parser)
+ {
+ if (!(m_parser->m_inParseShorthand++))
+ m_parser->m_currentShorthand = propId;
+ }
+ ~ShorthandScope()
+ {
+ if (!(--m_parser->m_inParseShorthand))
+ m_parser->m_currentShorthand = 0;
+ }
+
+ private:
+ CSSParser* m_parser;
+ };
+
} // namespace WebCore
#endif // CSSParser_h