• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "config.h"
6 #include "core/css/parser/CSSParser.h"
7 
8 #include "core/css/CSSKeyframeRule.h"
9 #include "core/css/StyleColor.h"
10 #include "core/css/StyleRule.h"
11 
12 namespace blink {
13 
CSSParser(const CSSParserContext & context)14 CSSParser::CSSParser(const CSSParserContext& context)
15     : m_bisonParser(context)
16 {
17 }
18 
parseDeclaration(MutableStylePropertySet * propertySet,const String & declaration,CSSParserObserver * observer,StyleSheetContents * styleSheet)19 bool CSSParser::parseDeclaration(MutableStylePropertySet* propertySet, const String& declaration, CSSParserObserver* observer, StyleSheetContents* styleSheet)
20 {
21     return m_bisonParser.parseDeclaration(propertySet, declaration, observer, styleSheet);
22 }
23 
parseSelector(const String & selector,CSSSelectorList & selectorList)24 void CSSParser::parseSelector(const String& selector, CSSSelectorList& selectorList)
25 {
26     m_bisonParser.parseSelector(selector, selectorList);
27 }
28 
parseRule(const CSSParserContext & context,StyleSheetContents * styleSheet,const String & rule)29 PassRefPtrWillBeRawPtr<StyleRuleBase> CSSParser::parseRule(const CSSParserContext& context, StyleSheetContents* styleSheet, const String& rule)
30 {
31     return BisonCSSParser(context).parseRule(styleSheet, rule);
32 }
33 
parseSheet(const CSSParserContext & context,StyleSheetContents * styleSheet,const String & text,const TextPosition & startPosition,CSSParserObserver * observer,bool logErrors)34 void CSSParser::parseSheet(const CSSParserContext& context, StyleSheetContents* styleSheet, const String& text, const TextPosition& startPosition, CSSParserObserver* observer, bool logErrors)
35 {
36     BisonCSSParser(context).parseSheet(styleSheet, text, startPosition, observer, logErrors);
37 }
38 
parseValue(MutableStylePropertySet * declaration,CSSPropertyID propertyID,const String & string,bool important,CSSParserMode parserMode,StyleSheetContents * styleSheet)39 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode parserMode, StyleSheetContents* styleSheet)
40 {
41     return BisonCSSParser::parseValue(declaration, propertyID, string, important, parserMode, styleSheet);
42 }
43 
parseValue(MutableStylePropertySet * declaration,CSSPropertyID propertyID,const String & string,bool important,const CSSParserContext & context)44 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, const CSSParserContext& context)
45 {
46     return BisonCSSParser::parseValue(declaration, propertyID, string, important, context);
47 }
48 
parseSingleValue(CSSPropertyID propertyID,const String & string,const CSSParserContext & context)49 PassRefPtrWillBeRawPtr<CSSValue> CSSParser::parseSingleValue(CSSPropertyID propertyID, const String& string, const CSSParserContext& context)
50 {
51     if (string.isEmpty())
52         return nullptr;
53     RefPtrWillBeRawPtr<MutableStylePropertySet> stylePropertySet = MutableStylePropertySet::create();
54     bool success = parseValue(stylePropertySet.get(), propertyID, string, false, context);
55     ASSERT_UNUSED(success, success == stylePropertySet->hasProperty(propertyID));
56     return stylePropertySet->getPropertyCSSValue(propertyID);
57 }
58 
parseInlineStyleDeclaration(const String & styleString,Element * element)59 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> CSSParser::parseInlineStyleDeclaration(const String& styleString, Element* element)
60 {
61     return BisonCSSParser::parseInlineStyleDeclaration(styleString, element);
62 }
63 
parseKeyframeKeyList(const String & keyList)64 PassOwnPtr<Vector<double> > CSSParser::parseKeyframeKeyList(const String& keyList)
65 {
66     return BisonCSSParser(strictCSSParserContext()).parseKeyframeKeyList(keyList);
67 }
68 
parseKeyframeRule(const CSSParserContext & context,StyleSheetContents * styleSheet,const String & rule)69 PassRefPtrWillBeRawPtr<StyleKeyframe> CSSParser::parseKeyframeRule(const CSSParserContext& context, StyleSheetContents* styleSheet, const String& rule)
70 {
71     return BisonCSSParser(context).parseKeyframeRule(styleSheet, rule);
72 }
73 
parseSupportsCondition(const String & condition)74 bool CSSParser::parseSupportsCondition(const String& condition)
75 {
76     return BisonCSSParser(CSSParserContext(HTMLStandardMode, 0)).parseSupportsCondition(condition);
77 }
78 
parseColor(RGBA32 & color,const String & string,bool strict)79 bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict)
80 {
81     return BisonCSSParser::parseColor(color, string, strict);
82 }
83 
colorFromRGBColorString(const String & string)84 StyleColor CSSParser::colorFromRGBColorString(const String& string)
85 {
86     return BisonCSSParser::colorFromRGBColorString(string);
87 }
88 
parseSystemColor(RGBA32 & color,const String & colorString)89 bool CSSParser::parseSystemColor(RGBA32& color, const String& colorString)
90 {
91     return BisonCSSParser::parseSystemColor(color, colorString);
92 }
93 
94 } // namespace blink
95