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 14 CSSParser::CSSParser(const CSSParserContext& context) 15 : m_bisonParser(context) 16 { 17 } 18 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 24 void CSSParser::parseSelector(const String& selector, CSSSelectorList& selectorList) 25 { 26 m_bisonParser.parseSelector(selector, selectorList); 27 } 28 29 PassRefPtrWillBeRawPtr<StyleRuleBase> CSSParser::parseRule(const CSSParserContext& context, StyleSheetContents* styleSheet, const String& rule) 30 { 31 return BisonCSSParser(context).parseRule(styleSheet, rule); 32 } 33 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 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 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 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 59 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> CSSParser::parseInlineStyleDeclaration(const String& styleString, Element* element) 60 { 61 return BisonCSSParser::parseInlineStyleDeclaration(styleString, element); 62 } 63 64 PassOwnPtr<Vector<double> > CSSParser::parseKeyframeKeyList(const String& keyList) 65 { 66 return BisonCSSParser(strictCSSParserContext()).parseKeyframeKeyList(keyList); 67 } 68 69 PassRefPtrWillBeRawPtr<StyleKeyframe> CSSParser::parseKeyframeRule(const CSSParserContext& context, StyleSheetContents* styleSheet, const String& rule) 70 { 71 return BisonCSSParser(context).parseKeyframeRule(styleSheet, rule); 72 } 73 74 bool CSSParser::parseSupportsCondition(const String& condition) 75 { 76 return BisonCSSParser(CSSParserContext(HTMLStandardMode, 0)).parseSupportsCondition(condition); 77 } 78 79 bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict) 80 { 81 return BisonCSSParser::parseColor(color, string, strict); 82 } 83 84 StyleColor CSSParser::colorFromRGBColorString(const String& string) 85 { 86 return BisonCSSParser::colorFromRGBColorString(string); 87 } 88 89 bool CSSParser::parseSystemColor(RGBA32& color, const String& colorString) 90 { 91 return BisonCSSParser::parseSystemColor(color, colorString); 92 } 93 94 } // namespace blink 95