Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Unified Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 1319343004: Add property parser code path based on CSSParserTokenRange (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add handling of overflow shorthand Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/parser/CSSPropertyParserNew.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp
index d08862af53cf57c0a7509af8f5495f06444435a7..cf7f0a8ce2e160d92f3dbf7fb5cad14f6db3b072 100644
--- a/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/Source/core/css/parser/CSSPropertyParser.cpp
@@ -56,6 +56,7 @@
#include "core/css/HashTools.h"
#include "core/css/parser/CSSParserFastPaths.h"
#include "core/css/parser/CSSParserValues.h"
+#include "core/css/parser/CSSPropertyParserNew.cpp"
alancutter (OOO until 2018) 2015/09/09 04:45:26 Don't include CPP files, parseSingleValue() is def
#include "core/frame/UseCounter.h"
#include "core/layout/LayoutTheme.h"
#include "core/style/GridCoordinate.h"
@@ -74,10 +75,11 @@ static bool equalIgnoringCase(const CSSParserString& a, const char (&b)[N])
return a.is8Bit() ? WTF::equalIgnoringCase(b, a.characters8(), length) : WTF::equalIgnoringCase(b, a.characters16(), length);
}
-CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList,
+CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList, const CSSParserTokenRange& range,
const CSSParserContext& context, WillBeHeapVector<CSSProperty, 256>& parsedProperties,
StyleRule::Type ruleType)
: m_valueList(valueList)
+ , m_range(range)
, m_context(context)
, m_parsedProperties(parsedProperties)
, m_ruleType(ruleType)
@@ -88,12 +90,15 @@ CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList,
}
bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool important,
- CSSParserValueList* valueList, const CSSParserContext& context,
+ const CSSParserTokenRange& range, const CSSParserContext& context,
WillBeHeapVector<CSSProperty, 256>& parsedProperties, StyleRule::Type ruleType)
{
int parsedPropertiesSize = parsedProperties.size();
- CSSPropertyParser parser(valueList, context, parsedProperties, ruleType);
+ CSSParserValueList valueList(range);
+ if (!valueList.size())
+ return false; // Parser error
+ CSSPropertyParser parser(&valueList, range, context, parsedProperties, ruleType);
CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty);
bool parseSuccess;
@@ -469,9 +474,18 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
return true;
}
+ RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr;
+ if ((parsedValue = parseSingleValue(propId))) {
+ if (!m_range.atEnd())
+ return false;
+ addProperty(propId, parsedValue.release(), important);
+ return true;
+ }
+ if (parseShorthand(propId, important))
+ return true;
+
bool validPrimitive = false;
Units unitless = FUnknown;
- RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr;
switch (propId) {
case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ]
@@ -498,24 +512,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
/* Start of supported CSS properties with validation. This is needed for parseShorthand to work
* correctly and allows optimization in blink::applyRule(..)
*/
- case CSSPropertyOverflow: {
- ShorthandScope scope(this, propId);
- if (!parseValue(CSSPropertyOverflowY, important) || m_valueList->current())
- return false;
-
- RefPtrWillBeRawPtr<CSSValue> overflowXValue = nullptr;
-
- // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. If this value has been
- // set using the shorthand, then for now overflow-x will default to auto, but once we implement
- // pagination controls, it should default to hidden. If the overflow-y value is anything but
- // paged-x or paged-y, then overflow-x and overflow-y should have the same value.
- if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY)
- overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto);
- else
- overflowXValue = m_parsedProperties.last().value();
- addProperty(CSSPropertyOverflowX, overflowXValue.release(), important);
- return true;
- }
case CSSPropertyTextAlign:
// left | right | center | justify | -webkit-left | -webkit-right | -webkit-center | -webkit-match-parent
@@ -1281,19 +1277,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
return parseGridShorthand(important);
- case CSSPropertyWebkitMarginCollapse: {
- ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse);
- if (!parseValue(webkitMarginCollapseShorthand().properties()[0], important))
- return false;
- if (!m_valueList->current()) {
- CSSValue* value = m_parsedProperties.last().value();
- addProperty(webkitMarginCollapseShorthand().properties()[1], value, important);
- return true;
- }
- if (!parseValue(webkitMarginCollapseShorthand().properties()[1], important))
- return false;
- return !m_valueList->current();
- }
case CSSPropertyWebkitColumnCount:
parsedValue = parseColumnCount();
break;
@@ -1309,9 +1292,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
case CSSPropertyWebkitColumnWidth: // auto | <length>
parsedValue = parseColumnWidth();
break;
- case CSSPropertyWillChange:
- parsedValue = parseWillChange();
- break;
// End of CSS3 properties
// Apple specific properties. These will never be standardized and are purely to
@@ -1443,9 +1423,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
return parseTransitionShorthand(important);
case CSSPropertyInvalid:
return false;
- case CSSPropertyPage:
- parsedValue = parsePage();
- break;
// CSS Text Layout Module Level 3: Vertical writing support
case CSSPropertyWebkitTextEmphasis:
return parseShorthand(propId, webkitTextEmphasisShorthand(), important);
@@ -1523,6 +1500,14 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
validPrimitive = false;
break;
+ // These were not accepted by the new path above so we should return false.
+ case CSSPropertyWebkitMarginCollapse:
+ case CSSPropertyWillChange:
+ case CSSPropertyPage:
+ case CSSPropertyOverflow:
+ validPrimitive = false;
+ break;
+
case CSSPropertyScrollSnapPointsX:
case CSSPropertyScrollSnapPointsY:
parsedValue = parseScrollSnapPoints();
@@ -2064,19 +2049,6 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate()
return parsePositionList(m_valueList);
}
-PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parsePage()
-{
- CSSParserValue* value = m_valueList->current();
- m_valueList->next();
- ASSERT(value);
-
- if (value->id == CSSValueAuto)
- return cssValuePool().createIdentifierValue(value->id);
- if (value->m_unit == CSSParserValue::Identifier)
- return createPrimitiveCustomIdentValue(value);
- return nullptr;
-}
-
// <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ]
PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseSize()
{
@@ -6716,56 +6688,6 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValue
return imageSet.release();
}
-PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseWillChange()
-{
- RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
- if (m_valueList->current()->id == CSSValueAuto) {
- // FIXME: This will be read back as an empty string instead of auto
- return values.release();
- }
-
- // Every comma-separated list of identifiers is a valid will-change value,
- // unless the list includes an explicitly disallowed identifier.
- while (true) {
- CSSParserValue* currentValue = m_valueList->current();
- if (!currentValue || currentValue->m_unit != CSSParserValue::Identifier)
- return nullptr;
-
- CSSPropertyID unresolvedProperty = unresolvedCSSPropertyID(currentValue->string);
- if (unresolvedProperty) {
- ASSERT(CSSPropertyMetadata::isEnabledProperty(unresolvedProperty));
- // Now "all" is used by both CSSValue and CSSPropertyValue.
- // Need to return nullptr when currentValue is CSSPropertyAll.
- if (unresolvedProperty == CSSPropertyWillChange || unresolvedProperty == CSSPropertyAll)
- return nullptr;
- values->append(cssValuePool().createIdentifierValue(unresolvedProperty));
- } else {
- switch (currentValue->id) {
- case CSSValueNone:
- case CSSValueAll:
- case CSSValueAuto:
- case CSSValueDefault:
- case CSSValueInitial:
- case CSSValueInherit:
- return nullptr;
- case CSSValueContents:
- case CSSValueScrollPosition:
- values->append(cssValuePool().createIdentifierValue(currentValue->id));
- break;
- default:
- break;
- }
- }
-
- if (!m_valueList->next())
- break;
- if (!consumeComma(m_valueList))
- return nullptr;
- }
-
- return values.release();
-}
-
PassRefPtrWillBeRawPtr<CSSFunctionValue> CSSPropertyParser::parseBuiltinFilterArguments(CSSParserValueList* args, CSSValueID filterType)
{
RefPtrWillBeRawPtr<CSSFunctionValue> filterValue = CSSFunctionValue::create(filterType);
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/parser/CSSPropertyParserNew.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698