OLD | NEW |
(Empty) | |
| 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/CSSParserImpl.h" |
| 7 |
| 8 #include "core/css/StylePropertySet.h" |
| 9 #include "core/css/parser/CSSParserValues.h" |
| 10 #include "core/css/parser/CSSPropertyParser.h" |
| 11 #include "core/css/parser/CSSTokenizer.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 CSSParserImpl::CSSParserImpl(const CSSParserContext& context, const String& s) |
| 16 : m_context(context) |
| 17 { |
| 18 CSSTokenizer::tokenize(s, m_tokens); |
| 19 } |
| 20 |
| 21 bool CSSParserImpl::parseValue(MutableStylePropertySet* declaration, CSSProperty
ID propertyID, const String& string, bool important, const CSSParserContext& con
text) |
| 22 { |
| 23 CSSParserImpl parser(context, string); |
| 24 CSSRuleSourceData::Type ruleType = CSSRuleSourceData::STYLE_RULE; |
| 25 if (declaration->cssParserMode() == CSSViewportRuleMode) |
| 26 ruleType = CSSRuleSourceData::VIEWPORT_RULE; |
| 27 parser.consumeDeclarationValue(parser.m_tokens.begin(), parser.m_tokens.end(
) - 1, propertyID, important, ruleType); |
| 28 if (parser.m_parsedProperties.isEmpty()) |
| 29 return false; |
| 30 declaration->addParsedProperties(parser.m_parsedProperties); |
| 31 return true; |
| 32 } |
| 33 |
| 34 void CSSParserImpl::consumeDeclarationValue(CSSParserTokenIterator start, CSSPar
serTokenIterator end, CSSPropertyID propertyID, bool important, CSSRuleSourceDat
a::Type ruleType) |
| 35 { |
| 36 CSSParserValueList valueList(start, end); |
| 37 if (!valueList.size()) |
| 38 return; // Parser error |
| 39 bool inViewport = ruleType == CSSRuleSourceData::VIEWPORT_RULE; |
| 40 CSSPropertyParser::parseValue(propertyID, important, &valueList, m_context,
inViewport, m_parsedProperties, ruleType); |
| 41 } |
| 42 |
| 43 } // namespace blink |
OLD | NEW |