Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (209317 => 209318)
--- trunk/Source/WebCore/css/parser/CSSParser.cpp 2016-12-05 17:06:28 UTC (rev 209317)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp 2016-12-05 17:13:42 UTC (rev 209318)
@@ -312,6 +312,8 @@
void CSSParser::setupParser(const char* prefix, unsigned prefixLength, StringView string, const char* suffix, unsigned suffixLength)
{
+ ASSERT(!m_context.useNewParser);
+
m_parsedTextPrefixLength = prefixLength;
unsigned stringLength = string.length();
unsigned length = stringLength + m_parsedTextPrefixLength + suffixLength + 1;
@@ -368,7 +370,7 @@
// FIXME-NEWPARSER: It's easier for testing to let the entire UA sheet parse with the old
// parser. That way we can still have the default styles look correct while we add in support for
// properties.
- if (m_context.useNewParser && m_context.mode != UASheetMode)
+ if (m_context.useNewParser)
return CSSParserImpl::parseStyleSheet(string, m_context, sheet);
setStyleSheet(sheet);
@@ -400,7 +402,7 @@
RefPtr<StyleRuleBase> CSSParser::parseRule(StyleSheetContents* sheet, const String& string)
{
- if (m_context.useNewParser && m_context.mode != UASheetMode)
+ if (m_context.useNewParser)
return CSSParserImpl::parseRule(string, m_context, sheet, CSSParserImpl::AllowImportRules);
setStyleSheet(sheet);
m_allowNamespaceDeclarations = false;
@@ -411,7 +413,7 @@
RefPtr<StyleKeyframe> CSSParser::parseKeyframeRule(StyleSheetContents* sheet, const String& string)
{
- if (m_context.useNewParser && m_context.mode != UASheetMode) {
+ if (m_context.useNewParser) {
RefPtr<StyleRuleBase> keyframe = CSSParserImpl::parseRule(string, m_context, nullptr, CSSParserImpl::KeyframeRules);
return downcast<StyleKeyframe>(keyframe.get());
}
@@ -424,10 +426,10 @@
bool CSSParser::parseSupportsCondition(const String& condition)
{
- if (m_context.useNewParser && m_context.mode != UASheetMode) {
+ if (m_context.useNewParser) {
CSSTokenizer::Scope scope(condition);
CSSParserTokenRange range = scope.tokenRange();
- CSSParserImpl parser(strictCSSParserContext());
+ CSSParserImpl parser(m_context);
return CSSSupportsParser::supportsCondition(range, parser) == CSSSupportsParser::Supported;
}
@@ -1334,21 +1336,28 @@
CSSParser::ParseResult CSSParser::parseValue(MutableStyleProperties& declaration, CSSPropertyID propertyID, const String& string, bool important, const CSSParserContext& context, StyleSheetContents* contextStyleSheet)
{
ASSERT(!string.isEmpty());
- CSSParser::ParseResult result = parseSimpleLengthValue(declaration, propertyID, string, important, context.mode);
- if (result != ParseResult::Error)
- return result;
+ if (context.useNewParser) {
+ RefPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue(propertyID, string, context.mode, contextStyleSheet);
+ if (value)
+ return declaration.addParsedProperty(CSSProperty(propertyID, WTFMove(value), important)) ? CSSParser::ParseResult::Changed : CSSParser::ParseResult::Unchanged;
+ } else {
+ // FIXME-NEWPARSER: Remove all this code when the old parser goes away.
+ CSSParser::ParseResult result = parseSimpleLengthValue(declaration, propertyID, string, important, context.mode);
+ if (result != ParseResult::Error)
+ return result;
- result = parseColorValue(declaration, propertyID, string, important, context.mode);
- if (result != ParseResult::Error)
- return result;
+ result = parseColorValue(declaration, propertyID, string, important, context.mode);
+ if (result != ParseResult::Error)
+ return result;
- result = parseKeywordValue(declaration, propertyID, string, important, context, contextStyleSheet);
- if (result != ParseResult::Error)
- return result;
+ result = parseKeywordValue(declaration, propertyID, string, important, context, contextStyleSheet);
+ if (result != ParseResult::Error)
+ return result;
- result = parseTranslateTransformValue(declaration, propertyID, string, important);
- if (result != ParseResult::Error)
- return result;
+ result = parseTranslateTransformValue(declaration, propertyID, string, important);
+ if (result != ParseResult::Error)
+ return result;
+ }
CSSParser parser(context);
return parser.parseValue(declaration, propertyID, string, important, contextStyleSheet);
@@ -1363,6 +1372,9 @@
CSSParser::ParseResult CSSParser::parseValue(MutableStyleProperties& declaration, CSSPropertyID propertyID, const String& string, bool important, StyleSheetContents* contextStyleSheet)
{
+ if (m_context.useNewParser)
+ return CSSParserImpl::parseValue(&declaration, propertyID, string, important, m_context);
+
setStyleSheet(contextStyleSheet);
setupParser("@-webkit-value{", string, "} ");
@@ -1436,7 +1448,7 @@
void CSSParser::parseSelector(const String& string, CSSSelectorList& selectorList)
{
- if (m_context.useNewParser && m_context.mode != UASheetMode) {
+ if (m_context.useNewParser) {
CSSTokenizer::Scope scope(string);
selectorList = CSSSelectorParser::parseSelector(scope.tokenRange(), m_context, nullptr);
return;
@@ -1480,7 +1492,7 @@
bool CSSParser::parseDeclaration(MutableStyleProperties& declaration, const String& string, RefPtr<CSSRuleSourceData>&& ruleSourceData, StyleSheetContents* contextStyleSheet)
{
- if (m_context.useNewParser && m_context.mode != UASheetMode)
+ if (m_context.useNewParser)
return CSSParserImpl::parseDeclarationList(&declaration, string, m_context);
// Length of the "@-webkit-decls{" prefix.
Modified: trunk/Source/WebCore/css/parser/CSSParserImpl.cpp (209317 => 209318)
--- trunk/Source/WebCore/css/parser/CSSParserImpl.cpp 2016-12-05 17:06:28 UTC (rev 209317)
+++ trunk/Source/WebCore/css/parser/CSSParserImpl.cpp 2016-12-05 17:13:42 UTC (rev 209318)
@@ -62,7 +62,7 @@
{
}
-bool CSSParserImpl::parseValue(MutableStyleProperties* declaration, CSSPropertyID propertyID, const String& string, bool important, const CSSParserContext& context)
+CSSParser::ParseResult CSSParserImpl::parseValue(MutableStyleProperties* declaration, CSSPropertyID propertyID, const String& string, bool important, const CSSParserContext& context)
{
CSSParserImpl parser(context);
StyleRule::Type ruleType = StyleRule::Style;
@@ -73,8 +73,8 @@
CSSTokenizer::Scope scope(string);
parser.consumeDeclarationValue(scope.tokenRange(), propertyID, important, ruleType);
if (parser.m_parsedProperties.isEmpty())
- return false;
- return declaration->addParsedProperties(parser.m_parsedProperties);
+ return CSSParser::ParseResult::Error;
+ return declaration->addParsedProperties(parser.m_parsedProperties) ? CSSParser::ParseResult::Changed : CSSParser::ParseResult::Unchanged;
}
static inline void filterProperties(bool important, const ParsedPropertyVector& input, ParsedPropertyVector& output, size_t& unusedEntries, std::bitset<numCSSProperties>& seenProperties, HashSet<AtomicString>& seenCustomProperties)
Modified: trunk/Source/WebCore/css/parser/CSSParserImpl.h (209317 => 209318)
--- trunk/Source/WebCore/css/parser/CSSParserImpl.h 2016-12-05 17:06:28 UTC (rev 209317)
+++ trunk/Source/WebCore/css/parser/CSSParserImpl.h 2016-12-05 17:13:42 UTC (rev 209318)
@@ -29,6 +29,7 @@
#pragma once
+#include "CSSParser.h"
#include "CSSParserMode.h"
#include "CSSParserTokenRange.h"
#include "CSSProperty.h"
@@ -61,7 +62,7 @@
class ImmutableStyleProperties;
class Element;
class MutableStyleProperties;
-
+
class CSSParserImpl {
WTF_MAKE_NONCOPYABLE(CSSParserImpl);
public:
@@ -82,7 +83,7 @@
NoRules, // For parsing at-rules inside declaration lists
};
- static bool parseValue(MutableStyleProperties*, CSSPropertyID, const String&, bool important, const CSSParserContext&);
+ static CSSParser::ParseResult parseValue(MutableStyleProperties*, CSSPropertyID, const String&, bool important, const CSSParserContext&);
static Ref<ImmutableStyleProperties> parseInlineStyleDeclaration(const String&, Element*);
static bool parseDeclarationList(MutableStyleProperties*, const String&, const CSSParserContext&);
static RefPtr<StyleRuleBase> parseRule(const String&, const CSSParserContext&, StyleSheetContents*, AllowedRulesType);