Index: third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp |
diff --git a/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp |
index d8847a98be7b6806406adf92acbf0d51bd5c0dda..bf18f11b32e18f5cee022e0f740b0fbf00b1b93e 100644 |
--- a/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp |
+++ b/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp |
@@ -27,7 +27,6 @@ |
#include "core/css/parser/CSSPropertyParser.h" |
#include "core/StylePropertyShorthand.h" |
-#include "core/css/CSSBasicShapeValues.h" |
#include "core/css/CSSBorderImage.h" |
#include "core/css/CSSContentDistributionValue.h" |
#include "core/css/CSSCrossfadeValue.h" |
@@ -447,23 +446,6 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::legacyParseValue(CSSProperty |
parsedValue = parseGridTemplateAreas(); |
break; |
- case CSSPropertyWebkitClipPath: |
- if (id == CSSValueNone) { |
- validPrimitive = true; |
- } else if (value->m_unit == CSSParserValue::Function) { |
- parsedValue = parseBasicShape(); |
- } else if (value->m_unit == CSSParserValue::URI) { |
- // TODO(timloh): This will allow trailing junk |
- return CSSURIValue::create(value->string); |
- } |
- break; |
- case CSSPropertyShapeOutside: |
- if (id == CSSValueNone) |
- validPrimitive = true; |
- else |
- parsedValue = parseShapeProperty(propId); |
- break; |
- |
case CSSPropertyAlignContent: |
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
parsedValue = parseContentDistributionOverflowPosition(); |
@@ -2185,80 +2167,6 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridAutoFlow(CSSParserV |
return parsedValues; |
} |
-void completeBorderRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4]) |
-{ |
- if (radii[3]) |
- return; |
- if (!radii[2]) { |
- if (!radii[1]) |
- radii[1] = radii[0]; |
- radii[2] = radii[0]; |
- } |
- radii[3] = radii[1]; |
-} |
- |
-PassRefPtrWillBeRawPtr<CSSBasicShapeInsetValue> CSSPropertyParser::parseBasicShapeInset(CSSParserValueList* args) |
-{ |
- ASSERT(args); |
- |
- RefPtrWillBeRawPtr<CSSBasicShapeInsetValue> shape = CSSBasicShapeInsetValue::create(); |
- |
- CSSParserValue* argument = args->current(); |
- WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>> widthArguments; |
- bool hasRoundedInset = false; |
- |
- while (argument) { |
- if (argument->m_unit == CSSParserValue::Identifier && argument->id == CSSValueRound) { |
- if (!args->next()) |
- return nullptr; |
- hasRoundedInset = true; |
- break; |
- } |
- |
- Units unitFlags = FLength | FPercent; |
- if (!validUnit(argument, unitFlags) || widthArguments.size() > 4) |
- return nullptr; |
- |
- widthArguments.append(createPrimitiveNumericValue(argument)); |
- argument = args->next(); |
- } |
- |
- switch (widthArguments.size()) { |
- case 1: { |
- shape->updateShapeSize1Value(widthArguments[0].get()); |
- break; |
- } |
- case 2: { |
- shape->updateShapeSize2Values(widthArguments[0].get(), widthArguments[1].get()); |
- break; |
- } |
- case 3: { |
- shape->updateShapeSize3Values(widthArguments[0].get(), widthArguments[1].get(), widthArguments[2].get()); |
- break; |
- } |
- case 4: { |
- shape->updateShapeSize4Values(widthArguments[0].get(), widthArguments[1].get(), widthArguments[2].get(), widthArguments[3].get()); |
- break; |
- } |
- default: |
- return nullptr; |
- } |
- |
- if (hasRoundedInset) { |
- // FIXME: Refactor completeBorderRadii and the array |
- RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4]; |
- RefPtrWillBeRawPtr<CSSPrimitiveValue> radii2[4]; |
- if (!parseRadii(radii, radii2, args)) |
- return nullptr; |
- shape->setTopLeftRadius(CSSValuePair::create(radii[0].release(), radii2[0].release(), CSSValuePair::DropIdenticalValues)); |
- shape->setTopRightRadius(CSSValuePair::create(radii[1].release(), radii2[1].release(), CSSValuePair::DropIdenticalValues)); |
- shape->setBottomRightRadius(CSSValuePair::create(radii[2].release(), radii2[2].release(), CSSValuePair::DropIdenticalValues)); |
- shape->setBottomLeftRadius(CSSValuePair::create(radii[3].release(), radii2[3].release(), CSSValuePair::DropIdenticalValues)); |
- } |
- |
- return shape.release(); |
-} |
- |
static bool isContentDistributionKeyword(CSSValueID id) |
{ |
return id == CSSValueSpaceBetween || id == CSSValueSpaceAround |
@@ -2407,243 +2315,6 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseItemPositionOverflowPos |
return position.release(); |
} |
-PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseShapeRadius(CSSParserValue* value) |
-{ |
- if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide) |
- return cssValuePool().createIdentifierValue(value->id); |
- |
- if (!validUnit(value, FLength | FPercent | FNonNeg)) |
- return nullptr; |
- |
- return createPrimitiveNumericValue(value); |
-} |
- |
-PassRefPtrWillBeRawPtr<CSSBasicShapeCircleValue> CSSPropertyParser::parseBasicShapeCircle(CSSParserValueList* args) |
-{ |
- ASSERT(args); |
- |
- // circle(radius) |
- // circle(radius at <position>) |
- // circle(at <position>) |
- // where position defines centerX and centerY using a CSS <position> data type. |
- RefPtrWillBeRawPtr<CSSBasicShapeCircleValue> shape = CSSBasicShapeCircleValue::create(); |
- |
- for (CSSParserValue* argument = args->current(); argument; argument = args->next()) { |
- // The call to parseFillPosition below should consume all of the |
- // arguments except the first two. Thus, and index greater than one |
- // indicates an invalid production. |
- if (args->currentIndex() > 1) |
- return nullptr; |
- |
- if (!args->currentIndex() && argument->id != CSSValueAt) { |
- if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(argument)) { |
- shape->setRadius(radius); |
- continue; |
- } |
- |
- return nullptr; |
- } |
- |
- if (argument->id == CSSValueAt && args->next()) { |
- RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; |
- RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; |
- parseFillPosition(args, centerX, centerY); |
- if (centerX && centerY && !args->current()) { |
- shape->setCenterX(centerX); |
- shape->setCenterY(centerY); |
- } else { |
- return nullptr; |
- } |
- } else { |
- return nullptr; |
- } |
- } |
- |
- return shape.release(); |
-} |
- |
-PassRefPtrWillBeRawPtr<CSSBasicShapeEllipseValue> CSSPropertyParser::parseBasicShapeEllipse(CSSParserValueList* args) |
-{ |
- ASSERT(args); |
- |
- // ellipse(radiusX) |
- // ellipse(radiusX at <position>) |
- // ellipse(radiusX radiusY) |
- // ellipse(radiusX radiusY at <position>) |
- // ellipse(at <position>) |
- // where position defines centerX and centerY using a CSS <position> data type. |
- RefPtrWillBeRawPtr<CSSBasicShapeEllipseValue> shape = CSSBasicShapeEllipseValue::create(); |
- |
- for (CSSParserValue* argument = args->current(); argument; argument = args->next()) { |
- // The call to parseFillPosition below should consume all of the |
- // arguments except the first three. Thus, an index greater than two |
- // indicates an invalid production. |
- if (args->currentIndex() > 2) |
- return nullptr; |
- |
- if (args->currentIndex() < 2 && argument->id != CSSValueAt) { |
- if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(argument)) { |
- if (!shape->radiusX()) |
- shape->setRadiusX(radius); |
- else |
- shape->setRadiusY(radius); |
- continue; |
- } |
- |
- return nullptr; |
- } |
- |
- if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(.. at <position>) |
- return nullptr; |
- RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; |
- RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; |
- parseFillPosition(args, centerX, centerY); |
- if (!centerX || !centerY || args->current()) |
- return nullptr; |
- |
- shape->setCenterX(centerX); |
- shape->setCenterY(centerY); |
- } |
- |
- return shape.release(); |
-} |
- |
-PassRefPtrWillBeRawPtr<CSSBasicShapePolygonValue> CSSPropertyParser::parseBasicShapePolygon(CSSParserValueList* args) |
-{ |
- ASSERT(args); |
- |
- unsigned size = args->size(); |
- if (!size) |
- return nullptr; |
- |
- RefPtrWillBeRawPtr<CSSBasicShapePolygonValue> shape = CSSBasicShapePolygonValue::create(); |
- |
- CSSParserValue* argument = args->current(); |
- if (argument->id == CSSValueEvenodd || argument->id == CSSValueNonzero) { |
- shape->setWindRule(argument->id == CSSValueEvenodd ? RULE_EVENODD : RULE_NONZERO); |
- args->next(); |
- |
- if (!consumeComma(args)) |
- return nullptr; |
- |
- size -= 2; |
- } |
- |
- // <length> <length>, ... <length> <length> -> each pair has 3 elements except the last one |
- if (!size || (size % 3) - 2) |
- return nullptr; |
- |
- while (true) { |
- CSSParserValue* argumentX = args->current(); |
- if (!argumentX || !validUnit(argumentX, FLength | FPercent)) |
- return nullptr; |
- RefPtrWillBeRawPtr<CSSPrimitiveValue> xLength = createPrimitiveNumericValue(argumentX); |
- |
- CSSParserValue* argumentY = args->next(); |
- if (!argumentY || !validUnit(argumentY, FLength | FPercent)) |
- return nullptr; |
- RefPtrWillBeRawPtr<CSSPrimitiveValue> yLength = createPrimitiveNumericValue(argumentY); |
- |
- shape->appendPoint(xLength.release(), yLength.release()); |
- |
- if (!args->next()) |
- break; |
- if (!consumeComma(args)) |
- return nullptr; |
- } |
- |
- return shape.release(); |
-} |
- |
-static bool isBoxValue(CSSValueID valueId) |
-{ |
- switch (valueId) { |
- case CSSValueContentBox: |
- case CSSValuePaddingBox: |
- case CSSValueBorderBox: |
- case CSSValueMarginBox: |
- return true; |
- default: |
- break; |
- } |
- |
- return false; |
-} |
- |
-PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseShapeProperty(CSSPropertyID propId) |
-{ |
- RefPtrWillBeRawPtr<CSSValue> imageValue = nullptr; |
- if (parseFillImage(m_valueList, imageValue)) { |
- m_valueList->next(); |
- return imageValue.release(); |
- } |
- |
- return parseBasicShapeAndOrBox(); |
-} |
- |
-PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBasicShapeAndOrBox() |
-{ |
- CSSParserValue* value = m_valueList->current(); |
- |
- bool shapeFound = false; |
- bool boxFound = false; |
- CSSValueID valueId; |
- |
- RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
- for (unsigned i = 0; i < 2; ++i) { |
- if (!value) |
- break; |
- valueId = value->id; |
- if (value->m_unit == CSSParserValue::Function && !shapeFound) { |
- // parseBasicShape already asks for the next value list item. |
- RefPtrWillBeRawPtr<CSSValue> shapeValue = parseBasicShape(); |
- if (!shapeValue) |
- return nullptr; |
- list->append(shapeValue.release()); |
- shapeFound = true; |
- } else if (isBoxValue(valueId) && !boxFound) { |
- list->append(parseValidPrimitive(valueId, value)); |
- boxFound = true; |
- m_valueList->next(); |
- } else { |
- return nullptr; |
- } |
- |
- value = m_valueList->current(); |
- } |
- |
- if (m_valueList->current()) |
- return nullptr; |
- return list.release(); |
-} |
- |
-PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBasicShape() |
-{ |
- CSSParserValue* value = m_valueList->current(); |
- ASSERT(value->m_unit == CSSParserValue::Function); |
- CSSParserValueList* args = value->function->args.get(); |
- |
- if (!args) |
- return nullptr; |
- |
- RefPtrWillBeRawPtr<CSSValue> shape = nullptr; |
- if (value->function->id == CSSValueCircle) |
- shape = parseBasicShapeCircle(args); |
- else if (value->function->id == CSSValueEllipse) |
- shape = parseBasicShapeEllipse(args); |
- else if (value->function->id == CSSValuePolygon) |
- shape = parseBasicShapePolygon(args); |
- else if (value->function->id == CSSValueInset) |
- shape = parseBasicShapeInset(args); |
- |
- if (!shape) |
- return nullptr; |
- |
- m_valueList->next(); |
- |
- return shape.release(); |
-} |
- |
inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) |
{ |
bool isPercent; |
@@ -3332,48 +3003,6 @@ bool CSSPropertyParser::parseBorderImageOutset(RefPtrWillBeRawPtr<CSSQuadValue>& |
return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); |
} |
-bool CSSPropertyParser::parseRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4], RefPtrWillBeRawPtr<CSSPrimitiveValue> radii2[4], CSSParserValueList* args, CSSPropertyID unresolvedProperty) |
-{ |
-#if ENABLE(OILPAN) |
- // Unconditionally zero initialize the arrays of raw pointers. |
- memset(radii, 0, 4 * sizeof(radii[0])); |
- memset(radii2, 0, 4 * sizeof(radii2[0])); |
-#endif |
- CSSParserValue* value = args->current(); |
- int i; |
- for (i = 0; i < 4 && value && value->m_unit != CSSParserValue::Operator;++i, value = args->next()) { |
- if (!validUnit(value, FLength | FPercent | FNonNeg)) |
- return false; |
- |
- radii[i] = createPrimitiveNumericValue(value); |
- } |
- |
- if (!i || (value && value->m_unit == CSSParserValue::Operator && value->iValue != '/')) |
- return false; |
- // Legacy syntax: -webkit-border-radius: l1 l2; is equivalent to border-radius: l1 / l2; |
- if (!value && i == 2 && unresolvedProperty == CSSPropertyAliasWebkitBorderRadius) { |
- radii2[0] = radii[1]; |
- radii[1] = nullptr; |
- completeBorderRadii(radii); |
- completeBorderRadii(radii2); |
- return true; |
- } |
- completeBorderRadii(radii); |
- if (value) { |
- value = args->next(); |
- for (i = 0; i < 4 && value && validUnit(value, FLength | FPercent | FNonNeg); ++i, value = args->next()) |
- radii2[i] = createPrimitiveNumericValue(value); |
- if (!i || value) |
- return false; |
- completeBorderRadii(radii2); |
- } else { |
- for (unsigned i = 0; i < 4; ++i) |
- radii2[i] = radii[i]; |
- } |
- |
- return true; |
-} |
- |
// This should go away once we drop support for -webkit-gradient |
static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CSSParserValue* a, bool horizontal) |
{ |