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.h68
1 files changed, 55 insertions, 13 deletions
diff --git a/WebCore/css/CSSParser.h b/WebCore/css/CSSParser.h
index 3922a2a..1e233c8 100644
--- a/WebCore/css/CSSParser.h
+++ b/WebCore/css/CSSParser.h
@@ -2,6 +2,7 @@
* Copyright (C) 2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Eric Seidel <eric@webkit.org>
+ * Copyright (C) 2009 - 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -22,13 +23,14 @@
#ifndef CSSParser_h
#define CSSParser_h
-#include "AtomicString.h"
#include "Color.h"
#include "CSSParserValues.h"
#include "CSSSelectorList.h"
#include "MediaQuery.h"
+#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/Vector.h>
+#include <wtf/text/AtomicString.h>
namespace WebCore {
@@ -38,6 +40,7 @@ namespace WebCore {
class CSSRule;
class CSSRuleList;
class CSSSelector;
+ class CSSStyleRule;
class CSSStyleSheet;
class CSSValue;
class CSSValueList;
@@ -52,10 +55,12 @@ namespace WebCore {
class CSSParser {
public:
+ typedef HashMap<CSSStyleRule*, std::pair<unsigned, unsigned> > StyleRuleRanges;
+
CSSParser(bool strictParsing = true);
~CSSParser();
- void parseSheet(CSSStyleSheet*, const String&);
+ void parseSheet(CSSStyleSheet*, const String&, int startLineNumber = 0, StyleRuleRanges* ruleRangeMap = 0);
PassRefPtr<CSSRule> parseRule(CSSStyleSheet*, const String&);
PassRefPtr<CSSRule> parseKeyframeRule(CSSStyleSheet*, const String&);
bool parseValue(CSSMutableStyleDeclaration*, int propId, const String&, bool important);
@@ -84,7 +89,7 @@ namespace WebCore {
void parseFillPosition(RefPtr<CSSValue>&, RefPtr<CSSValue>&);
void parseFillRepeat(RefPtr<CSSValue>&, RefPtr<CSSValue>&);
PassRefPtr<CSSValue> parseFillSize(int propId, bool &allowComma);
-
+
bool parseFillProperty(int propId, int& propId1, int& propId2, RefPtr<CSSValue>&, RefPtr<CSSValue>&);
bool parseFillShorthand(int propId, const int* properties, int numProperties, bool important);
@@ -95,6 +100,7 @@ namespace WebCore {
PassRefPtr<CSSValue> parseAnimationDelay();
PassRefPtr<CSSValue> parseAnimationDirection();
PassRefPtr<CSSValue> parseAnimationDuration();
+ PassRefPtr<CSSValue> parseAnimationFillMode();
PassRefPtr<CSSValue> parseAnimationIterationCount();
PassRefPtr<CSSValue> parseAnimationName();
PassRefPtr<CSSValue> parseAnimationPlayState();
@@ -106,7 +112,7 @@ namespace WebCore {
bool parseAnimationProperty(int propId, RefPtr<CSSValue>&);
bool parseTransitionShorthand(bool important);
bool parseAnimationShorthand(bool important);
-
+
bool parseDashboardRegions(int propId, bool important);
bool parseShape(int propId, bool important);
@@ -120,7 +126,7 @@ namespace WebCore {
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);
+ bool parseColorFromValue(CSSParserValue*, RGBA32&);
void parseSelector(const String&, Document* doc, CSSSelectorList&);
static bool parseColor(const String&, RGBA32& rgb, bool strict);
@@ -138,11 +144,15 @@ namespace WebCore {
PassRefPtr<CSSValue> parseSVGStrokeDasharray();
#endif
+#if ENABLE(WCSS)
+ PassRefPtr<CSSValue> parseWCSSInputProperty();
+#endif
+
// CSS3 Parsing Routines (for properties specific to CSS3)
bool parseShadow(int propId, bool important);
bool parseBorderImage(int propId, bool important, RefPtr<CSSValue>&);
bool parseBorderRadius(int propId, bool important);
-
+
bool parseReflect(int propId, bool important);
// Image generators
@@ -178,6 +188,10 @@ namespace WebCore {
CSSRule* createStyleRule(Vector<CSSSelector*>* selectors);
CSSRule* createFontFaceRule();
CSSRule* createVariablesRule(MediaList*, bool variablesKeyword);
+ CSSRule* createPageRule(CSSSelector* pageSelector);
+ CSSRule* createMarginAtRule(CSSSelector::MarginBoxType marginBox);
+ void startDeclarationsForMarginBox();
+ void endDeclarationsForMarginBox();
MediaQueryExp* createFloatingMediaQueryExp(const AtomicString&, CSSParserValueList*);
MediaQueryExp* sinkFloatingMediaQueryExp(MediaQueryExp*);
@@ -194,9 +208,13 @@ namespace WebCore {
bool checkForVariables(CSSParserValueList*);
void addUnresolvedProperty(int propId, bool important);
void invalidBlockHit();
-
+
Vector<CSSSelector*>* reusableSelectorVector() { return &m_reusableSelectorVector; }
+ void updateLastSelectorLineAndPosition();
+
+ void clearProperties();
+
bool m_strict;
bool m_important;
int m_id;
@@ -209,6 +227,7 @@ namespace WebCore {
CSSSelectorList* m_selectorListForParseSelector;
unsigned m_numParsedProperties;
unsigned m_maxParsedProperties;
+ unsigned m_numParsedPropertiesBeforeMarginBox;
int m_inParseShorthand;
int m_currentShorthand;
@@ -223,26 +242,43 @@ namespace WebCore {
AtomicString m_defaultNamespace;
// tokenizer methods and data
+ unsigned m_ruleBodyStartOffset;
+ unsigned m_ruleBodyEndOffset;
+ StyleRuleRanges* m_ruleRanges;
+ void markRuleBodyStart();
+ void markRuleBodyEnd();
+ void resetRuleBodyMarks() { m_ruleBodyStartOffset = m_ruleBodyEndOffset = 0; }
int lex(void* yylval);
int token() { return yyTok; }
UChar* text(int* length);
+ void countLines();
int lex();
-
+
private:
void recheckAtKeyword(const UChar* str, int len);
-
- void clearProperties();
void setupParser(const char* prefix, const String&, const char* suffix);
bool inShorthand() const { return m_inParseShorthand; }
void checkForOrphanedUnits();
-
+
void clearVariables();
void deleteFontFaceOnlyValues();
+ enum SizeParameterType {
+ None,
+ Auto,
+ Length,
+ PageSize,
+ Orientation,
+ };
+
+ bool parsePage(int propId, bool important);
+ bool parseSize(int propId, bool important);
+ SizeParameterType parseSizeParameter(CSSValueList* parsedValues, CSSParserValue* value, SizeParameterType prevParamType);
+
UChar* m_data;
UChar* yytext;
UChar* yy_c_buf_p;
@@ -252,6 +288,8 @@ namespace WebCore {
int yyleng;
int yyTok;
int yy_start;
+ int m_lineNumber;
+ int m_lastSelectorLineNumber;
bool m_allowImportRules;
bool m_allowVariablesRules;
@@ -266,7 +304,7 @@ namespace WebCore {
MediaQuery* m_floatingMediaQuery;
MediaQueryExp* m_floatingMediaQueryExp;
Vector<MediaQueryExp*>* m_floatingMediaQueryExpList;
-
+
Vector<CSSSelector*> m_reusableSelectorVector;
// defines units allowed for a certain property, used in parseUnit
@@ -289,7 +327,7 @@ namespace WebCore {
}
static bool validUnit(CSSParserValue*, Units, bool strict);
-
+
friend class TransformOperationInfo;
};
@@ -314,6 +352,10 @@ namespace WebCore {
CSSParser* m_parser;
};
+ String quoteCSSString(const String&);
+ String quoteCSSStringIfNeeded(const String&);
+ String quoteCSSURLIfNeeded(const String&);
+
} // namespace WebCore
#endif // CSSParser_h