Diff
Modified: trunk/Source/WebCore/ChangeLog (206042 => 206043)
--- trunk/Source/WebCore/ChangeLog 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/ChangeLog 2016-09-16 20:24:23 UTC (rev 206043)
@@ -1,3 +1,132 @@
+2016-09-16 Dave Hyatt <hy...@apple.com>
+
+ [CSS Parser] Get CSSPropertyParserHelpers.cpp compiling
+ https://bugs.webkit.org/show_bug.cgi?id=162078
+
+ Reviewed by Dean Jackson.
+
+ * css/CSSCalculationValue.cpp:
+ (WebCore::hasDoubleValue):
+ (WebCore::checkDepthAndIndex):
+ (WebCore::CSSCalcExpressionNodeParser::parseCalc):
+ (WebCore::CSSCalcExpressionNodeParser::operatorValue):
+ (WebCore::CSSCalcExpressionNodeParser::parseValue):
+ (WebCore::CSSCalcExpressionNodeParser::parseValueTerm):
+ (WebCore::CSSCalcExpressionNodeParser::parseValueMultiplicativeExpression):
+ (WebCore::CSSCalcExpressionNodeParser::parseAdditiveValueExpression):
+ (WebCore::CSSCalcExpressionNodeParser::parseValueExpression):
+ (WebCore::checkDepthAndIndexDeprecated):
+ (WebCore::CSSCalcExpressionNodeParserDeprecated::parseValueTerm):
+ (WebCore::CSSCalcExpressionNodeParserDeprecated::parseValueMultiplicativeExpression):
+ (WebCore::CSSCalcExpressionNodeParserDeprecated::parseAdditiveValueExpression):
+ (WebCore::CSSCalcValue::create):
+ * css/CSSCalculationValue.h:
+ (WebCore::CSSCalcValue::createCalculationValue):
+ (WebCore::CSSCalcValue::setPermittedValueRange):
+ Switch off the permitted calc value range enum, since we can just use the identical ValueRange enum.
+ Deprecate the CSSParserValueList-based parser by renaming it, and add a new parser that operates
+ on tokens.
+
+ * css/CSSPrimitiveValue.cpp:
+ (WebCore::isValidCSSUnitTypeForDoubleConversion):
+ (WebCore::isStringType):
+ (WebCore::CSSPrimitiveValue::cleanup):
+ (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble):
+ (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText):
+ (WebCore::CSSPrimitiveValue::cloneForCSSOM):
+ (WebCore::CSSPrimitiveValue::equals):
+ (WebCore::CSSPrimitiveValue::buildParserValue):
+ * css/CSSPrimitiveValue.h:
+ Add support for CSS_QUIRKY_EMS as a unit type. This will let us eliminate the extra m_isQuirkValue boolean
+ eventually.
+
+ * css/parser/CSSParser.cpp:
+ (WebCore::CSSParser::validateCalculationUnit):
+ (WebCore::CSSParser::parseCalculation):
+ * css/parser/CSSParser.h:
+ Switch to ValueRange.
+
+ * css/parser/CSSParserIdioms.cpp:
+ (WebCore::completeURL):
+ * css/parser/CSSParserIdioms.h:
+ Make the URL completion function from CSSParser.cpp available to all.
+
+ * css/parser/CSSParserMode.h:
+ (WebCore::isUnitLessValueParsingEnabledForMode):
+ (WebCore::isUnitLessLengthParsingEnabledForMode): Deleted.
+ Rename this to value, since for now we're not supporting Blink's UserUnits. This means we need to support
+ unitless parsing for times and angles in addition to lengths, making the name of the function inappropriate.
+
+ * css/parser/CSSParserToken.cpp:
+ (WebCore::cssPrimitiveValueUnitFromTrie):
+ Turn quirky ems support back on.
+
+ * css/parser/CSSParserValues.cpp:
+ (WebCore::CSSParserValue::createCSSValue):
+ Support quirky ems.
+
+ * css/parser/CSSPropertyParserHelpers.cpp:
+ (WebCore::CSSPropertyParserHelpers::CalcParser::consumeValue):
+ (WebCore::CSSPropertyParserHelpers::CalcParser::consumeNumber):
+ (WebCore::CSSPropertyParserHelpers::consumeInteger):
+ (WebCore::CSSPropertyParserHelpers::consumePositiveInteger):
+ (WebCore::CSSPropertyParserHelpers::consumeNumber):
+ (WebCore::CSSPropertyParserHelpers::shouldAcceptUnitlessValue):
+ (WebCore::CSSPropertyParserHelpers::consumeLength):
+ (WebCore::CSSPropertyParserHelpers::consumePercent):
+ (WebCore::CSSPropertyParserHelpers::canConsumeCalcValue):
+ (WebCore::CSSPropertyParserHelpers::consumeLengthOrPercent):
+ (WebCore::CSSPropertyParserHelpers::consumeAngle):
+ (WebCore::CSSPropertyParserHelpers::consumeTime):
+ (WebCore::CSSPropertyParserHelpers::consumeIdent):
+ (WebCore::CSSPropertyParserHelpers::consumeIdentRange):
+ (WebCore::CSSPropertyParserHelpers::consumeCustomIdent):
+ (WebCore::CSSPropertyParserHelpers::consumeString):
+ (WebCore::CSSPropertyParserHelpers::consumeUrl):
+ (WebCore::CSSPropertyParserHelpers::parseRGBParameters):
+ (WebCore::CSSPropertyParserHelpers::parseHSLParameters):
+ (WebCore::CSSPropertyParserHelpers::consumeColor):
+ (WebCore::CSSPropertyParserHelpers::consumePositionComponent):
+ (WebCore::CSSPropertyParserHelpers::positionFromOneValue):
+ (WebCore::CSSPropertyParserHelpers::positionFromTwoValues):
+ (WebCore::CSSPropertyParserHelpers::createPrimitiveValuePair):
+ (WebCore::CSSPropertyParserHelpers::positionFromThreeOrFourValues):
+ (WebCore::CSSPropertyParserHelpers::consumePosition):
+ (WebCore::CSSPropertyParserHelpers::consumeOneOrTwoValuedPosition):
+ (WebCore::CSSPropertyParserHelpers::consumeDeprecatedGradientPoint):
+ (WebCore::CSSPropertyParserHelpers::consumeDeprecatedGradientStopColor):
+ (WebCore::CSSPropertyParserHelpers::consumeDeprecatedGradientColorStop):
+ (WebCore::CSSPropertyParserHelpers::consumeDeprecatedGradient):
+ (WebCore::CSSPropertyParserHelpers::consumeDeprecatedRadialGradient):
+ (WebCore::CSSPropertyParserHelpers::consumeRadialGradient):
+ (WebCore::CSSPropertyParserHelpers::consumeLinearGradient):
+ (WebCore::CSSPropertyParserHelpers::consumeImageOrNone):
+ (WebCore::CSSPropertyParserHelpers::consumeCrossFade):
+ (WebCore::CSSPropertyParserHelpers::consumeGeneratedImage):
+ (WebCore::CSSPropertyParserHelpers::consumeImageSet):
+ (WebCore::CSSPropertyParserHelpers::consumeImage):
+ * css/parser/CSSPropertyParserHelpers.h:
+ (WebCore::CSSPropertyParserHelpers::isCSSWideKeyword):
+ Lots of changes here. The most important is switching over to RefPtrs and Refs where appropriate, with the
+ requisite WTFMoves. Unit types also have to be converted back to our values, and unitless parsing has
+ to work with consumeTime and consumeAngle.
+
+ * platform/CalculationValue.cpp:
+ (WebCore::CalculationValue::create):
+ * platform/CalculationValue.h:
+ (WebCore::CalculationValue::CalculationValue):
+ Use ValueRange.
+
+ * platform/graphics/Color.cpp:
+ (WebCore::Color::parseHexColor):
+ (WebCore::Color::Color):
+ * platform/graphics/Color.h:
+ Add a StringView-based parseHexColor function.
+
+ * rendering/style/BasicShapes.cpp:
+ (WebCore::BasicShapeCenterCoordinate::updateComputedLength):
+ Use ValueRange
+
2016-09-16 Jer Noble <jer.no...@apple.com>
[media-source] Fix imported/w3c/web-platform-tests/media-source/mediasource-config-change-mp4-av-audio-bitrate.html
Modified: trunk/Source/WebCore/css/CSSCalculationValue.cpp (206042 => 206043)
--- trunk/Source/WebCore/css/CSSCalculationValue.cpp 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/CSSCalculationValue.cpp 2016-09-16 20:24:23 UTC (rev 206043)
@@ -33,6 +33,7 @@
#include "CSSCalculationValue.h"
#include "CSSParser.h"
+#include "CSSParserTokenRange.h"
#include "CSSPrimitiveValueMappings.h"
#include "StyleResolver.h"
#include <wtf/MathExtras.h>
@@ -142,6 +143,7 @@
case CSSPrimitiveValue::CSS_COUNTER_NAME:
case CSSPrimitiveValue::CSS_SHAPE:
case CSSPrimitiveValue::CSS_QUAD:
+ case CSSPrimitiveValue::CSS_QUIRKY_EMS:
#if ENABLE(CSS_SCROLL_SNAP)
case CSSPrimitiveValue::CSS_LENGTH_REPEAT:
#endif
@@ -559,17 +561,145 @@
const CalcOperator m_operator;
};
-static ParseState checkDepthAndIndex(int* depth, unsigned index, CSSParserValueList* tokens)
+static ParseState checkDepthAndIndex(int* depth, CSSParserTokenRange tokens)
{
(*depth)++;
+ if (tokens.atEnd())
+ return NoMoreTokens;
if (*depth > maxExpressionDepth)
return TooDeep;
+ return OK;
+}
+
+class CSSCalcExpressionNodeParser {
+public:
+ RefPtr<CSSCalcExpressionNode> parseCalc(CSSParserTokenRange tokens)
+ {
+ Value result;
+ tokens.consumeWhitespace();
+ bool ok = parseValueExpression(tokens, 0, &result);
+ if (!ok || !tokens.atEnd())
+ return nullptr;
+ return result.value;
+ }
+
+private:
+ struct Value {
+ RefPtr<CSSCalcExpressionNode> value;
+ };
+
+ char operatorValue(const CSSParserToken& token)
+ {
+ if (token.type() == DelimiterToken)
+ return token.delimiter();
+ return 0;
+ }
+
+ bool parseValue(CSSParserTokenRange& tokens, Value* result)
+ {
+ CSSParserToken token = tokens.consumeIncludingWhitespace();
+ if (!(token.type() == NumberToken || token.type() == PercentageToken || token.type() == DimensionToken))
+ return false;
+
+ CSSPrimitiveValue::UnitTypes type = token.unitType();
+ if (unitCategory(type) == CalcOther)
+ return false;
+
+ result->value = CSSCalcPrimitiveValue::create(CSSPrimitiveValue::create(token.numericValue(), type), token.numericValueType() == IntegerValueType);
+
+ return true;
+ }
+
+ bool parseValueTerm(CSSParserTokenRange& tokens, int depth, Value* result)
+ {
+ if (checkDepthAndIndex(&depth, tokens) != OK)
+ return false;
+
+ if (tokens.peek().type() == LeftParenthesisToken || tokens.peek().functionId() == CSSValueCalc) {
+ CSSParserTokenRange innerRange = tokens.consumeBlock();
+ tokens.consumeWhitespace();
+ innerRange.consumeWhitespace();
+ return parseValueExpression(innerRange, depth, result);
+ }
+
+ return parseValue(tokens, result);
+ }
+
+ bool parseValueMultiplicativeExpression(CSSParserTokenRange& tokens, int depth, Value* result)
+ {
+ if (checkDepthAndIndex(&depth, tokens) != OK)
+ return false;
+
+ if (!parseValueTerm(tokens, depth, result))
+ return false;
+
+ while (!tokens.atEnd()) {
+ char operatorCharacter = operatorValue(tokens.peek());
+ if (operatorCharacter != CalcMultiply && operatorCharacter != CalcDivide)
+ break;
+ tokens.consumeIncludingWhitespace();
+
+ Value rhs;
+ if (!parseValueTerm(tokens, depth, &rhs))
+ return false;
+
+ result->value = CSSCalcBinaryOperation::createSimplified(static_cast<CalcOperator>(operatorCharacter), result->value, rhs.value);
+
+ if (!result->value)
+ return false;
+ }
+
+ return true;
+ }
+
+ bool parseAdditiveValueExpression(CSSParserTokenRange& tokens, int depth, Value* result)
+ {
+ if (checkDepthAndIndex(&depth, tokens) != OK)
+ return false;
+
+ if (!parseValueMultiplicativeExpression(tokens, depth, result))
+ return false;
+
+ while (!tokens.atEnd()) {
+ char operatorCharacter = operatorValue(tokens.peek());
+ if (operatorCharacter != CalcAdd && operatorCharacter != CalcSubtract)
+ break;
+ if ((&tokens.peek() - 1)->type() != WhitespaceToken)
+ return false; // calc(1px+ 2px) is invalid
+ tokens.consume();
+ if (tokens.peek().type() != WhitespaceToken)
+ return false; // calc(1px +2px) is invalid
+ tokens.consumeIncludingWhitespace();
+
+ Value rhs;
+ if (!parseValueMultiplicativeExpression(tokens, depth, &rhs))
+ return false;
+
+ result->value = CSSCalcBinaryOperation::createSimplified(static_cast<CalcOperator>(operatorCharacter), result->value, rhs.value);
+ if (!result->value)
+ return false;
+ }
+
+ return true;
+ }
+
+ bool parseValueExpression(CSSParserTokenRange& tokens, int depth, Value* result)
+ {
+ return parseAdditiveValueExpression(tokens, depth, result);
+ }
+};
+
+static ParseState checkDepthAndIndexDeprecated(int* depth, unsigned index, CSSParserValueList* tokens)
+{
+ (*depth)++;
+ if (*depth > maxExpressionDepth)
+ return TooDeep;
if (index >= tokens->size())
return NoMoreTokens;
return OK;
}
-class CSSCalcExpressionNodeParser {
+class CSSCalcExpressionNodeParserDeprecated {
public:
RefPtr<CSSCalcExpressionNode> parseCalc(CSSParserValueList* tokens)
{
@@ -616,7 +746,7 @@
bool parseValueTerm(CSSParserValueList* tokens, int depth, unsigned* index, Value* result)
{
- if (checkDepthAndIndex(&depth, *index, tokens) != OK)
+ if (checkDepthAndIndexDeprecated(&depth, *index, tokens) != OK)
return false;
if (operatorValue(tokens, *index) == '(') {
@@ -635,7 +765,7 @@
bool parseValueMultiplicativeExpression(CSSParserValueList* tokens, int depth, unsigned* index, Value* result)
{
- if (checkDepthAndIndex(&depth, *index, tokens) != OK)
+ if (checkDepthAndIndexDeprecated(&depth, *index, tokens) != OK)
return false;
if (!parseValueTerm(tokens, depth, index, result))
@@ -662,7 +792,7 @@
bool parseAdditiveValueExpression(CSSParserValueList* tokens, int depth, unsigned* index, Value* result)
{
- if (checkDepthAndIndex(&depth, *index, tokens) != OK)
+ if (checkDepthAndIndexDeprecated(&depth, *index, tokens) != OK)
return false;
if (!parseValueMultiplicativeExpression(tokens, depth, index, result))
@@ -750,17 +880,25 @@
return nullptr;
}
-RefPtr<CSSCalcValue> CSSCalcValue::create(CSSParserString name, CSSParserValueList& parserValueList, CalculationPermittedValueRange range)
+RefPtr<CSSCalcValue> CSSCalcValue::create(CSSParserString name, CSSParserValueList& parserValueList, ValueRange range)
{
- CSSCalcExpressionNodeParser parser;
+ CSSCalcExpressionNodeParserDeprecated parser;
RefPtr<CSSCalcExpressionNode> _expression_;
if (equalLettersIgnoringASCIICase(name, "calc(") || equalLettersIgnoringASCIICase(name, "-webkit-calc("))
_expression_ = parser.parseCalc(&parserValueList);
- return _expression_ ? adoptRef(new CSSCalcValue(_expression_.releaseNonNull(), range != CalculationRangeAll)) : nullptr;
+ return _expression_ ? adoptRef(new CSSCalcValue(_expression_.releaseNonNull(), range != ValueRangeAll)) : nullptr;
}
+RefPtr<CSSCalcValue> CSSCalcValue::create(const CSSParserTokenRange& tokens, ValueRange range)
+{
+ CSSCalcExpressionNodeParser parser;
+ RefPtr<CSSCalcExpressionNode> _expression_ = parser.parseCalc(tokens);
+ return _expression_ ? adoptRef(new CSSCalcValue(_expression_.releaseNonNull(), range != ValueRangeAll)) : nullptr;
+
+}
+
RefPtr<CSSCalcValue> CSSCalcValue::create(const CalculationValue& value, const RenderStyle& style)
{
RefPtr<CSSCalcExpressionNode> _expression_ = createCSS(value._expression_(), style);
Modified: trunk/Source/WebCore/css/CSSCalculationValue.h (206042 => 206043)
--- trunk/Source/WebCore/css/CSSCalculationValue.h 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/CSSCalculationValue.h 2016-09-16 20:24:23 UTC (rev 206043)
@@ -35,6 +35,7 @@
namespace WebCore {
+class CSSParserTokenRange;
class CSSParserValueList;
class CSSToLengthConversionData;
class RenderStyle;
@@ -87,7 +88,10 @@
class CSSCalcValue final : public CSSValue {
public:
- static RefPtr<CSSCalcValue> create(CSSParserString name, CSSParserValueList& arguments, CalculationPermittedValueRange);
+ // FIXME-NEWPARSER: Remove the CSSParserString create when old parser goes away.
+ static RefPtr<CSSCalcValue> create(CSSParserString name, CSSParserValueList& arguments, ValueRange);
+ static RefPtr<CSSCalcValue> create(const CSSParserTokenRange&, ValueRange);
+
static RefPtr<CSSCalcValue> create(const CalculationValue&, const RenderStyle&);
CalculationCategory category() const { return m_expression->category(); }
@@ -94,11 +98,12 @@
bool isInt() const { return m_expression->isInteger(); }
double doubleValue() const;
bool isPositive() const { return m_expression->doubleValue() > 0; }
+ bool isNegative() const { return m_expression->doubleValue() < 0; }
double computeLengthPx(const CSSToLengthConversionData&) const;
unsigned short primitiveType() const { return m_expression->primitiveType(); }
Ref<CalculationValue> createCalculationValue(const CSSToLengthConversionData&) const;
- void setPermittedValueRange(CalculationPermittedValueRange);
+ void setPermittedValueRange(ValueRange);
String customCSSText() const;
bool equals(const CSSCalcValue&) const;
@@ -122,12 +127,12 @@
inline Ref<CalculationValue> CSSCalcValue::createCalculationValue(const CSSToLengthConversionData& conversionData) const
{
return CalculationValue::create(m_expression->createCalcExpression(conversionData),
- m_shouldClampToNonNegative ? CalculationRangeNonNegative : CalculationRangeAll);
+ m_shouldClampToNonNegative ? ValueRangeNonNegative : ValueRangeAll);
}
-inline void CSSCalcValue::setPermittedValueRange(CalculationPermittedValueRange range)
+inline void CSSCalcValue::setPermittedValueRange(ValueRange range)
{
- m_shouldClampToNonNegative = range != CalculationRangeAll;
+ m_shouldClampToNonNegative = range != ValueRangeAll;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (206042 => 206043)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2016-09-16 20:24:23 UTC (rev 206043)
@@ -71,6 +71,7 @@
case CSSPrimitiveValue::CSS_DEG:
case CSSPrimitiveValue::CSS_DIMENSION:
case CSSPrimitiveValue::CSS_EMS:
+ case CSSPrimitiveValue::CSS_QUIRKY_EMS:
case CSSPrimitiveValue::CSS_EXS:
case CSSPrimitiveValue::CSS_FR:
case CSSPrimitiveValue::CSS_GRAD:
@@ -160,6 +161,7 @@
case CSSPrimitiveValue::CSS_DPI:
case CSSPrimitiveValue::CSS_DPPX:
case CSSPrimitiveValue::CSS_EMS:
+ case CSSPrimitiveValue::CSS_QUIRKY_EMS:
case CSSPrimitiveValue::CSS_EXS:
case CSSPrimitiveValue::CSS_FONT_FAMILY:
case CSSPrimitiveValue::CSS_FR:
@@ -576,6 +578,7 @@
case CSS_PARSER_INTEGER:
case CSS_PERCENTAGE:
case CSS_EMS:
+ case CSS_QUIRKY_EMS:
case CSS_EXS:
case CSS_REMS:
case CSS_CHS:
@@ -685,6 +688,7 @@
switch (primitiveType) {
case CSS_EMS:
+ case CSS_QUIRKY_EMS:
ASSERT(conversionData.style());
factor = conversionData.computingFontSize() ? conversionData.style()->fontDescription().specifiedSize() : conversionData.style()->fontDescription().computedSize();
break;
@@ -1071,6 +1075,7 @@
case CSS_PERCENTAGE:
return formatNumberValue("%");
case CSS_EMS:
+ case CSS_QUIRKY_EMS:
return formatNumberValue("em");
case CSS_EXS:
return formatNumberValue("ex");
@@ -1174,7 +1179,7 @@
case CSS_PARSER_HEXCOLOR: {
RGBA32 rgbColor = m_value.rgbcolor;
if (m_primitiveUnitType == CSS_PARSER_HEXCOLOR)
- Color::parseHexColor(m_value.string, rgbColor);
+ Color::parseHexColor((String)m_value.string, rgbColor);
return Color(rgbColor).cssText();
}
case CSS_PAIR:
@@ -1315,6 +1320,7 @@
case CSS_PARSER_INTEGER:
case CSS_PERCENTAGE:
case CSS_EMS:
+ case CSS_QUIRKY_EMS:
case CSS_EXS:
case CSS_REMS:
case CSS_CHS:
@@ -1379,6 +1385,7 @@
case CSS_PARSER_INTEGER:
case CSS_PERCENTAGE:
case CSS_EMS:
+ case CSS_QUIRKY_EMS:
case CSS_EXS:
case CSS_REMS:
case CSS_PX:
@@ -1464,6 +1471,7 @@
case CSS_NUMBER:
case CSS_PERCENTAGE:
case CSS_EMS:
+ case CSS_QUIRKY_EMS:
case CSS_EXS:
case CSS_REMS:
case CSS_PX:
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (206042 => 206043)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.h 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h 2016-09-16 20:24:23 UTC (rev 206043)
@@ -156,7 +156,13 @@
CSS_VALUE_ID = 118,
// More internal parse stuff for CSS variables
- CSS_PARSER_WHITESPACE = 119
+ CSS_PARSER_WHITESPACE = 119,
+
+ // This value is used to handle quirky margins in reflow roots (body, td, and th) like WinIE.
+ // The basic idea is that a stylesheet can use the value __qem (for quirky em) instead of em.
+ // When the quirky value is used, if you're in quirks mode, the margin will collapse away
+ // inside a table cell. This quirk is specified in the HTML spec but our impl is different.
+ CSS_QUIRKY_EMS = 120
};
// This enum follows the CSSParser::Units enum augmented with UNIT_FREQUENCY for frequencies.
@@ -189,9 +195,12 @@
return primitiveUnitType == CSS_EMS
|| primitiveUnitType == CSS_EXS
|| primitiveUnitType == CSS_REMS
- || primitiveUnitType == CSS_CHS;
+ || primitiveUnitType == CSS_CHS
+ || primitiveUnitType == CSS_QUIRKY_EMS;
}
bool isFontRelativeLength() const { return isFontRelativeLength(m_primitiveUnitType); }
+
+ bool isQuirkyEms() const { return primitiveType() == UnitTypes::CSS_QUIRKY_EMS; }
static bool isViewportPercentageLength(unsigned short type) { return type >= CSS_VW && type <= CSS_VMAX; }
bool isViewportPercentageLength() const { return isViewportPercentageLength(m_primitiveUnitType); }
@@ -198,7 +207,7 @@
static bool isLength(unsigned short type)
{
- return (type >= CSS_EMS && type <= CSS_PC) || type == CSS_REMS || type == CSS_CHS || isViewportPercentageLength(type);
+ return (type >= CSS_EMS && type <= CSS_PC) || type == CSS_REMS || type == CSS_CHS || isViewportPercentageLength(type) || type == CSS_QUIRKY_EMS;
}
bool isLength() const { return isLength(primitiveType()); }
@@ -369,7 +378,8 @@
String customCSSText() const;
- bool isQuirkValue() const { return m_isQuirkValue; }
+ // FIXME-NEWPARSER: Can ditch the boolean and just use the unit type once old parser is gone.
+ bool isQuirkValue() const { return m_isQuirkValue || primitiveType() == CSS_QUIRKY_EMS; }
void addSubresourceStyleURLs(ListHashSet<URL>&, const StyleSheetContents*) const;
Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (206042 => 206043)
--- trunk/Source/WebCore/css/StyleBuilderConverter.h 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h 2016-09-16 20:24:23 UTC (rev 206043)
@@ -318,7 +318,7 @@
auto lhs = std::make_unique<CalcExpressionLength>(Length(100, Percent));
auto rhs = std::make_unique<CalcExpressionLength>(length);
auto op = std::make_unique<CalcExpressionBinaryOperation>(WTFMove(lhs), WTFMove(rhs), CalcSubtract);
- return Length(CalculationValue::create(WTFMove(op), CalculationRangeAll));
+ return Length(CalculationValue::create(WTFMove(op), ValueRangeAll));
}
inline Length StyleBuilderConverter::convertPositionComponent(StyleResolver& styleResolver, const CSSPrimitiveValue& value)
Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (206042 => 206043)
--- trunk/Source/WebCore/css/parser/CSSParser.cpp 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp 2016-09-16 20:24:23 UTC (rev 206043)
@@ -1620,9 +1620,9 @@
if (valueWithCalculation.calculation()) {
// The calculation value was already parsed so we reuse it. However, we may need to update its range.
calculation = valueWithCalculation.calculation();
- calculation->setPermittedValueRange(mustBeNonNegative ? CalculationRangeNonNegative : CalculationRangeAll);
+ calculation->setPermittedValueRange(mustBeNonNegative ? ValueRangeNonNegative : ValueRangeAll);
} else {
- valueWithCalculation.setCalculation(parseCalculation(valueWithCalculation, mustBeNonNegative ? CalculationRangeNonNegative : CalculationRangeAll));
+ valueWithCalculation.setCalculation(parseCalculation(valueWithCalculation, mustBeNonNegative ? ValueRangeNonNegative : ValueRangeAll));
calculation = valueWithCalculation.calculation();
if (!calculation)
return false;
@@ -11042,7 +11042,7 @@
return true;
}
-RefPtr<CSSCalcValue> CSSParser::parseCalculation(CSSParserValue& value, CalculationPermittedValueRange range)
+RefPtr<CSSCalcValue> CSSParser::parseCalculation(CSSParserValue& value, ValueRange range)
{
ASSERT(isCalculation(value));
Modified: trunk/Source/WebCore/css/parser/CSSParser.h (206042 => 206043)
--- trunk/Source/WebCore/css/parser/CSSParser.h 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/parser/CSSParser.h 2016-09-16 20:24:23 UTC (rev 206043)
@@ -359,7 +359,7 @@
bool parseHangingPunctuation(bool important);
bool parseLineBoxContain(bool important);
- RefPtr<CSSCalcValue> parseCalculation(CSSParserValue&, CalculationPermittedValueRange);
+ RefPtr<CSSCalcValue> parseCalculation(CSSParserValue&, ValueRange);
bool parseFontFeatureTag(CSSValueList&);
bool parseFontFeatureSettings(bool important);
Modified: trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp (206042 => 206043)
--- trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp 2016-09-16 20:24:23 UTC (rev 206043)
@@ -30,6 +30,7 @@
#include "config.h"
#include "CSSParserIdioms.h"
#include "CSSValueKeywords.h"
+#include "TextEncoding.h"
namespace WebCore {
@@ -61,4 +62,13 @@
}
}
+URL completeURL(const CSSParserContext& context, const String& url)
+{
+ if (url.isNull())
+ return URL();
+ if (context.charset.isEmpty())
+ return URL(context.baseURL, url);
+ return URL(context.baseURL, url, context.charset);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/css/parser/CSSParserIdioms.h (206042 => 206043)
--- trunk/Source/WebCore/css/parser/CSSParserIdioms.h 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/parser/CSSParserIdioms.h 2016-09-16 20:24:23 UTC (rev 206043)
@@ -38,6 +38,8 @@
namespace WebCore {
+class URL;
+
// Space characters as defined by the CSS specification.
// http://www.w3.org/TR/css3-syntax/#whitespace
inline bool isCSSSpace(UChar c)
@@ -62,7 +64,9 @@
void convertToASCIILowercaseInPlace(StringView&);
bool isValueAllowedInMode(unsigned short, CSSParserMode);
-
+
+URL completeURL(const CSSParserContext&, const String& url);
+
}
#endif
Modified: trunk/Source/WebCore/css/parser/CSSParserMode.h (206042 => 206043)
--- trunk/Source/WebCore/css/parser/CSSParserMode.h 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/parser/CSSParserMode.h 2016-09-16 20:24:23 UTC (rev 206043)
@@ -62,7 +62,7 @@
return mode == UASheetMode;
}
-inline bool isUnitLessLengthParsingEnabledForMode(CSSParserMode mode)
+inline bool isUnitLessValueParsingEnabledForMode(CSSParserMode mode)
{
return mode == HTMLAttributeMode || mode == SVGAttributeMode;
}
Modified: trunk/Source/WebCore/css/parser/CSSParserToken.cpp (206042 => 206043)
--- trunk/Source/WebCore/css/parser/CSSParserToken.cpp 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/parser/CSSParserToken.cpp 2016-09-16 20:24:23 UTC (rev 206043)
@@ -189,7 +189,7 @@
switch (toASCIILower(data[0])) {
case '_':
if (toASCIILower(data[1]) == '_' && toASCIILower(data[2]) == 'q' && toASCIILower(data[3]) == 'e' && toASCIILower(data[4]) == 'm')
- return CSSPrimitiveValue::UnitTypes::CSS_EMS; // FIXME-NEWPARSER: Need quirky ems.
+ return CSSPrimitiveValue::UnitTypes::CSS_QUIRKY_EMS;
break;
}
break;
Modified: trunk/Source/WebCore/css/parser/CSSParserValues.cpp (206042 => 206043)
--- trunk/Source/WebCore/css/parser/CSSParserValues.cpp 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/parser/CSSParserValues.cpp 2016-09-16 20:24:23 UTC (rev 206043)
@@ -126,6 +126,7 @@
return CSSPrimitiveValue::create(string, primitiveUnit);
case CSSPrimitiveValue::CSS_PERCENTAGE:
case CSSPrimitiveValue::CSS_EMS:
+ case CSSPrimitiveValue::CSS_QUIRKY_EMS:
case CSSPrimitiveValue::CSS_EXS:
case CSSPrimitiveValue::CSS_PX:
case CSSPrimitiveValue::CSS_CM:
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (206042 => 206043)
--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2016-09-16 20:24:23 UTC (rev 206043)
@@ -31,20 +31,17 @@
#include "CSSPropertyParserHelpers.h"
#include "CSSCalculationValue.h"
-// FIXME-NEWPARSER: #include "CSSColorValue.h"
#include "CSSCrossfadeValue.h"
#include "CSSGradientValue.h"
#include "CSSImageSetValue.h"
#include "CSSImageValue.h"
-// FIXME-NEWPARSER: #include "CSSPaintValue.h"
-// FIXME_NEWPARSER: #include "CSSStringValue.h"
-// FIXME-NEWPARSER: #include "CSSURIValue.h"
-// FIXME_NEWPARSER: #include "CSSValuePair.h"
+#include "CSSParserIdioms.h"
+#include "CSSValuePool.h"
+#include "Pair.h"
+#include "StyleColor.h"
namespace WebCore {
-/* FIXME-NEWPARSER: Disable for now.
-
namespace CSSPropertyParserHelpers {
bool consumeCommaIncludingWhitespace(CSSParserTokenRange& range)
@@ -88,7 +85,7 @@
}
const CSSCalcValue* value() const { return m_calcValue.get(); }
- CSSPrimitiveValue* consumeValue()
+ RefPtr<CSSPrimitiveValue> consumeValue()
{
if (!m_calcValue)
return nullptr;
@@ -95,12 +92,12 @@
m_sourceRange = m_range;
return CSSPrimitiveValue::create(m_calcValue.release());
}
- CSSPrimitiveValue* consumeNumber()
+ RefPtr<CSSPrimitiveValue> consumeNumber()
{
if (!m_calcValue)
return nullptr;
m_sourceRange = m_range;
- CSSPrimitiveValue::UnitType unitType = m_calcValue->isInt() ? CSSPrimitiveValue::UnitType::Integer : CSSPrimitiveValue::UnitType::Number;
+ CSSPrimitiveValue::UnitTypes unitType = m_calcValue->isInt() ? CSSPrimitiveValue::UnitTypes::CSS_PARSER_INTEGER : CSSPrimitiveValue::UnitTypes::CSS_NUMBER;
return CSSPrimitiveValue::create(m_calcValue->doubleValue(), unitType);
}
@@ -116,16 +113,16 @@
private:
CSSParserTokenRange& m_sourceRange;
CSSParserTokenRange m_range;
- Member<CSSCalcValue> m_calcValue;
+ RefPtr<CSSCalcValue> m_calcValue;
};
-CSSPrimitiveValue* consumeInteger(CSSParserTokenRange& range, double minimumValue)
+RefPtr<CSSPrimitiveValue> consumeInteger(CSSParserTokenRange& range, double minimumValue)
{
const CSSParserToken& token = range.peek();
if (token.type() == NumberToken) {
if (token.numericValueType() == NumberValueType || token.numericValue() < minimumValue)
return nullptr;
- return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitType::Integer);
+ return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitTypes::CSS_PARSER_INTEGER);
}
CalcParser calcParser(range);
if (const CSSCalcValue* calculation = calcParser.value()) {
@@ -139,7 +136,7 @@
return nullptr;
}
-CSSPrimitiveValue* consumePositiveInteger(CSSParserTokenRange& range)
+RefPtr<CSSPrimitiveValue> consumePositiveInteger(CSSParserTokenRange& range)
{
return consumeInteger(range, 1);
}
@@ -155,7 +152,7 @@
}
// FIXME: Work out if this can just call consumeNumberRaw
-CSSPrimitiveValue* consumeNumber(CSSParserTokenRange& range, ValueRange valueRange)
+RefPtr<CSSPrimitiveValue> consumeNumber(CSSParserTokenRange& range, ValueRange valueRange)
{
const CSSParserToken& token = range.peek();
if (token.type() == NumberToken) {
@@ -174,38 +171,37 @@
return nullptr;
}
-inline bool shouldAcceptUnitlessLength(double value, CSSParserMode cssParserMode, UnitlessQuirk unitless)
+inline bool shouldAcceptUnitlessValue(double value, CSSParserMode cssParserMode, UnitlessQuirk unitless)
{
// FIXME: Presentational HTML attributes shouldn't use the CSS parser for lengths
return value == 0
- || isUnitLessLengthParsingEnabledForMode(cssParserMode)
+ || isUnitLessValueParsingEnabledForMode(cssParserMode)
|| (cssParserMode == HTMLQuirksMode && unitless == UnitlessQuirk::Allow);
}
-CSSPrimitiveValue* consumeLength(CSSParserTokenRange& range, CSSParserMode cssParserMode, ValueRange valueRange, UnitlessQuirk unitless)
+RefPtr<CSSPrimitiveValue> consumeLength(CSSParserTokenRange& range, CSSParserMode cssParserMode, ValueRange valueRange, UnitlessQuirk unitless)
{
const CSSParserToken& token = range.peek();
if (token.type() == DimensionToken) {
switch (token.unitType()) {
- case CSSPrimitiveValue::UnitType::QuirkyEms:
+ case CSSPrimitiveValue::UnitTypes::CSS_QUIRKY_EMS:
if (cssParserMode != UASheetMode)
return nullptr;
FALLTHROUGH;
- case CSSPrimitiveValue::UnitType::Ems:
- case CSSPrimitiveValue::UnitType::Rems:
- case CSSPrimitiveValue::UnitType::Chs:
- case CSSPrimitiveValue::UnitType::Exs:
- case CSSPrimitiveValue::UnitType::Pixels:
- case CSSPrimitiveValue::UnitType::Centimeters:
- case CSSPrimitiveValue::UnitType::Millimeters:
- case CSSPrimitiveValue::UnitType::Inches:
- case CSSPrimitiveValue::UnitType::Points:
- case CSSPrimitiveValue::UnitType::Picas:
- case CSSPrimitiveValue::UnitType::UserUnits:
- case CSSPrimitiveValue::UnitType::ViewportWidth:
- case CSSPrimitiveValue::UnitType::ViewportHeight:
- case CSSPrimitiveValue::UnitType::ViewportMin:
- case CSSPrimitiveValue::UnitType::ViewportMax:
+ case CSSPrimitiveValue::UnitTypes::CSS_EMS:
+ case CSSPrimitiveValue::UnitTypes::CSS_REMS:
+ case CSSPrimitiveValue::UnitTypes::CSS_CHS:
+ case CSSPrimitiveValue::UnitTypes::CSS_EXS:
+ case CSSPrimitiveValue::UnitTypes::CSS_PX:
+ case CSSPrimitiveValue::UnitTypes::CSS_CM:
+ case CSSPrimitiveValue::UnitTypes::CSS_MM:
+ case CSSPrimitiveValue::UnitTypes::CSS_IN:
+ case CSSPrimitiveValue::UnitTypes::CSS_PT:
+ case CSSPrimitiveValue::UnitTypes::CSS_PC:
+ case CSSPrimitiveValue::UnitTypes::CSS_VW:
+ case CSSPrimitiveValue::UnitTypes::CSS_VH:
+ case CSSPrimitiveValue::UnitTypes::CSS_VMIN:
+ case CSSPrimitiveValue::UnitTypes::CSS_VMAX:
break;
default:
return nullptr;
@@ -215,12 +211,10 @@
return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), token.unitType());
}
if (token.type() == NumberToken) {
- if (!shouldAcceptUnitlessLength(token.numericValue(), cssParserMode, unitless)
+ if (!shouldAcceptUnitlessValue(token.numericValue(), cssParserMode, unitless)
|| (valueRange == ValueRangeNonNegative && token.numericValue() < 0))
return nullptr;
- CSSPrimitiveValue::UnitType unitType = CSSPrimitiveValue::UnitType::Pixels;
- if (cssParserMode == SVGAttributeMode)
- unitType = CSSPrimitiveValue::UnitType::UserUnits;
+ CSSPrimitiveValue::UnitTypes unitType = CSSPrimitiveValue::UnitTypes::CSS_PX;
return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), unitType);
}
if (cssParserMode == SVGAttributeMode)
@@ -231,13 +225,13 @@
return nullptr;
}
-CSSPrimitiveValue* consumePercent(CSSParserTokenRange& range, ValueRange valueRange)
+RefPtr<CSSPrimitiveValue> consumePercent(CSSParserTokenRange& range, ValueRange valueRange)
{
const CSSParserToken& token = range.peek();
if (token.type() == PercentageToken) {
if (valueRange == ValueRangeNonNegative && token.numericValue() < 0)
return nullptr;
- return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitType::Percentage);
+ return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE);
}
CalcParser calcParser(range, valueRange);
if (const CSSCalcValue* calculation = calcParser.value()) {
@@ -247,7 +241,7 @@
return nullptr;
}
-bool canConsumeCalcValue(CalculationCategory category, CSSParserMode cssParserMode)
+static bool canConsumeCalcValue(CalculationCategory category, CSSParserMode cssParserMode)
{
if (category == CalcLength || category == CalcPercent || category == CalcPercentLength)
return true;
@@ -255,13 +249,13 @@
if (cssParserMode != SVGAttributeMode)
return false;
- if (category == CalcNumber || category == CalcPercentNumber || category == CalcLengthNumber || category == CalcPercentLengthNumber)
+ if (category == CalcNumber || category == CalcPercentNumber)
return true;
return false;
}
-CSSPrimitiveValue* consumeLengthOrPercent(CSSParserTokenRange& range, CSSParserMode cssParserMode, ValueRange valueRange, UnitlessQuirk unitless)
+RefPtr<CSSPrimitiveValue> consumeLengthOrPercent(CSSParserTokenRange& range, CSSParserMode cssParserMode, ValueRange valueRange, UnitlessQuirk unitless)
{
const CSSParserToken& token = range.peek();
if (token.type() == DimensionToken || token.type() == NumberToken)
@@ -276,24 +270,25 @@
return nullptr;
}
-CSSPrimitiveValue* consumeAngle(CSSParserTokenRange& range)
+RefPtr<CSSPrimitiveValue> consumeAngle(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
{
const CSSParserToken& token = range.peek();
if (token.type() == DimensionToken) {
switch (token.unitType()) {
- case CSSPrimitiveValue::UnitType::Degrees:
- case CSSPrimitiveValue::UnitType::Radians:
- case CSSPrimitiveValue::UnitType::Gradians:
- case CSSPrimitiveValue::UnitType::Turns:
+ case CSSPrimitiveValue::UnitTypes::CSS_DEG:
+ case CSSPrimitiveValue::UnitTypes::CSS_RAD:
+ case CSSPrimitiveValue::UnitTypes::CSS_GRAD:
+ case CSSPrimitiveValue::UnitTypes::CSS_TURN:
return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), token.unitType());
default:
return nullptr;
}
}
- if (token.type() == NumberToken && token.numericValue() == 0) {
+ if (token.type() == NumberToken && shouldAcceptUnitlessValue(token.numericValue(), cssParserMode, unitless)) {
range.consumeIncludingWhitespace();
- return CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Degrees);
+ return CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitTypes::CSS_DEG);
}
+
CalcParser calcParser(range, ValueRangeAll);
if (const CSSCalcValue* calculation = calcParser.value()) {
if (calculation->category() == CalcAngle)
@@ -302,14 +297,17 @@
return nullptr;
}
-CSSPrimitiveValue* consumeTime(CSSParserTokenRange& range, ValueRange valueRange)
+RefPtr<CSSPrimitiveValue> consumeTime(CSSParserTokenRange& range, CSSParserMode cssParserMode, ValueRange valueRange, UnitlessQuirk unitless)
{
const CSSParserToken& token = range.peek();
- if (token.type() == DimensionToken) {
+ CSSPrimitiveValue::UnitTypes unit = token.unitType();
+ bool acceptUnitless = token.type() == NumberToken && shouldAcceptUnitlessValue(token.numericValue(), cssParserMode, unitless);
+ if (acceptUnitless)
+ unit = CSSPrimitiveValue::UnitTypes::CSS_MS;
+ if (token.type() == DimensionToken || acceptUnitless) {
if (valueRange == ValueRangeNonNegative && token.numericValue() < 0)
return nullptr;
- CSSPrimitiveValue::UnitType unit = token.unitType();
- if (unit == CSSPrimitiveValue::UnitType::Milliseconds || unit == CSSPrimitiveValue::UnitType::Seconds)
+ if (unit == CSSPrimitiveValue::UnitTypes::CSS_MS || unit == CSSPrimitiveValue::UnitTypes::CSS_S)
return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), token.unitType());
return nullptr;
}
@@ -321,7 +319,7 @@
return nullptr;
}
-CSSPrimitiveValue* consumeIdent(CSSParserTokenRange& range)
+RefPtr<CSSPrimitiveValue> consumeIdent(CSSParserTokenRange& range)
{
if (range.peek().type() != IdentToken)
return nullptr;
@@ -328,7 +326,7 @@
return CSSPrimitiveValue::createIdentifier(range.consumeIncludingWhitespace().id());
}
-CSSPrimitiveValue* consumeIdentRange(CSSParserTokenRange& range, CSSValueID lower, CSSValueID upper)
+RefPtr<CSSPrimitiveValue> consumeIdentRange(CSSParserTokenRange& range, CSSValueID lower, CSSValueID upper)
{
if (range.peek().id() < lower || range.peek().id() > upper)
return nullptr;
@@ -335,7 +333,7 @@
return consumeIdent(range);
}
-CSSCustomIdentValue* consumeCustomIdent(CSSParserTokenRange& range)
+RefPtr<CSSCustomIdentValue> consumeCustomIdent(CSSParserTokenRange& range)
{
if (range.peek().type() != IdentToken || isCSSWideKeyword(range.peek().id()))
return nullptr;
@@ -342,11 +340,11 @@
return CSSCustomIdentValue::create(range.consumeIncludingWhitespace().value().toString());
}
-CSSStringValue* consumeString(CSSParserTokenRange& range)
+RefPtr<CSSPrimitiveValue> consumeString(CSSParserTokenRange& range)
{
if (range.peek().type() != StringToken)
return nullptr;
- return CSSStringValue::create(range.consumeIncludingWhitespace().value().toString());
+ return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitTypes::CSS_STRING);
}
StringView consumeUrlAsStringView(CSSParserTokenRange& range)
@@ -371,12 +369,12 @@
return StringView();
}
-CSSURIValue* consumeUrl(CSSParserTokenRange& range)
+RefPtr<CSSPrimitiveValue> consumeUrl(CSSParserTokenRange& range)
{
StringView url = ""
if (url.isNull())
return nullptr;
- return CSSURIValue::create(url.toString());
+ return CSSPrimitiveValue::create(url.toString(), CSSPrimitiveValue::UnitTypes::CSS_URI);
}
static int clampRGBComponent(const CSSPrimitiveValue& value)
@@ -392,7 +390,7 @@
{
ASSERT(range.peek().functionId() == CSSValueRgb || range.peek().functionId() == CSSValueRgba);
CSSParserTokenRange args = consumeFunction(range);
- CSSPrimitiveValue* colorParameter = consumeInteger(args);
+ RefPtr<CSSPrimitiveValue> colorParameter = consumeInteger(args);
if (!colorParameter)
colorParameter = consumePercent(args, ValueRangeAll);
if (!colorParameter)
@@ -428,7 +426,7 @@
{
ASSERT(range.peek().functionId() == CSSValueHsl || range.peek().functionId() == CSSValueHsla);
CSSParserTokenRange args = consumeFunction(range);
- CSSPrimitiveValue* hslValue = consumeNumber(args, ValueRangeAll);
+ RefPtr<CSSPrimitiveValue> hslValue = consumeNumber(args, ValueRangeAll);
if (!hslValue)
return false;
double colorArray[3];
@@ -500,7 +498,7 @@
return true;
}
-CSSValue* consumeColor(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool acceptQuirkyColors)
+RefPtr<CSSPrimitiveValue> consumeColor(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool acceptQuirkyColors)
{
CSSValueID id = range.peek().id();
if (StyleColor::isColorKeyword(id)) {
@@ -511,10 +509,10 @@
RGBA32 color = Color::transparent;
if (!parseHexColor(range, color, acceptQuirkyColors) && !parseColorFunction(range, color))
return nullptr;
- return CSSColorValue::create(color);
+ return CSSPrimitiveValue::createColor(color);
}
-static CSSPrimitiveValue* consumePositionComponent(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
+static RefPtr<CSSPrimitiveValue> consumePositionComponent(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
{
if (range.peek().type() == IdentToken)
return consumeIdent<CSSValueLeft, CSSValueTop, CSSValueBottom, CSSValueRight, CSSValueCenter>(range);
@@ -531,32 +529,39 @@
return value.isValueID() && (value.getValueID() == CSSValueTop || value.getValueID() == CSSValueBottom);
}
-static void positionFromOneValue(CSSPrimitiveValue* value, CSSValue*& resultX, CSSValue*& resultY)
+static void positionFromOneValue(CSSPrimitiveValue& value, RefPtr<CSSPrimitiveValue>& resultX, RefPtr<CSSPrimitiveValue>& resultY)
{
- bool valueAppliesToYAxisOnly = isVerticalPositionKeywordOnly(*value);
- resultX = value;
+ bool valueAppliesToYAxisOnly = isVerticalPositionKeywordOnly(value);
+ resultX = &value;
resultY = CSSPrimitiveValue::createIdentifier(CSSValueCenter);
if (valueAppliesToYAxisOnly)
std::swap(resultX, resultY);
}
-static bool positionFromTwoValues(CSSPrimitiveValue* value1, CSSPrimitiveValue* value2,
- CSSValue*& resultX, CSSValue*& resultY)
+static bool positionFromTwoValues(CSSPrimitiveValue& value1, CSSPrimitiveValue& value2,
+ RefPtr<CSSPrimitiveValue>& resultX, RefPtr<CSSPrimitiveValue>& resultY)
{
- bool mustOrderAsXY = isHorizontalPositionKeywordOnly(*value1) || isVerticalPositionKeywordOnly(*value2)
- || !value1->isValueID() || !value2->isValueID();
- bool mustOrderAsYX = isVerticalPositionKeywordOnly(*value1) || isHorizontalPositionKeywordOnly(*value2);
+ bool mustOrderAsXY = isHorizontalPositionKeywordOnly(value1) || isVerticalPositionKeywordOnly(value2)
+ || !value1.isValueID() || !value2.isValueID();
+ bool mustOrderAsYX = isVerticalPositionKeywordOnly(value1) || isHorizontalPositionKeywordOnly(value2);
if (mustOrderAsXY && mustOrderAsYX)
return false;
- resultX = value1;
- resultY = value2;
+ resultX = &value1;
+ resultY = &value2;
if (mustOrderAsYX)
std::swap(resultX, resultY);
return true;
}
-static bool positionFromThreeOrFourValues(CSSPrimitiveValue** values, CSSValue*& resultX, CSSValue*& resultY)
+
+template<typename... Args>
+static Ref<CSSPrimitiveValue> createPrimitiveValuePair(Args&&... args)
{
+ return CSSValuePool::singleton().createValue(Pair::create(std::forward<Args>(args)...));
+}
+
+static bool positionFromThreeOrFourValues(CSSPrimitiveValue** values, RefPtr<CSSPrimitiveValue>& resultX, RefPtr<CSSPrimitiveValue>& resultY)
+{
CSSPrimitiveValue* center = nullptr;
for (int i = 0; values[i]; i++) {
CSSPrimitiveValue* currentValue = values[i];
@@ -571,12 +576,11 @@
continue;
}
- CSSValue* result = nullptr;
- if (values[i + 1] && !values[i + 1]->isValueID()) {
- result = CSSValuePair::create(currentValue, values[++i], CSSValuePair::KeepIdenticalValues);
- } else {
+ RefPtr<CSSPrimitiveValue> result;
+ if (values[i + 1] && !values[i + 1]->isValueID())
+ result = createPrimitiveValuePair(currentValue, values[++i]);
+ else
result = currentValue;
- }
if (id == CSSValueLeft || id == CSSValueRight) {
if (resultX)
@@ -606,67 +610,67 @@
// FIXME: This may consume from the range upon failure. The background
// shorthand works around it, but we should just fix it here.
-bool consumePosition(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless, CSSValue*& resultX, CSSValue*& resultY)
+bool consumePosition(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless, RefPtr<CSSPrimitiveValue>& resultX, RefPtr<CSSPrimitiveValue>& resultY)
{
- CSSPrimitiveValue* value1 = consumePositionComponent(range, cssParserMode, unitless);
+ RefPtr<CSSPrimitiveValue> value1 = consumePositionComponent(range, cssParserMode, unitless);
if (!value1)
return false;
- CSSPrimitiveValue* value2 = consumePositionComponent(range, cssParserMode, unitless);
+ RefPtr<CSSPrimitiveValue> value2 = consumePositionComponent(range, cssParserMode, unitless);
if (!value2) {
- positionFromOneValue(value1, resultX, resultY);
+ positionFromOneValue(*value1, resultX, resultY);
return true;
}
- CSSPrimitiveValue* value3 = consumePositionComponent(range, cssParserMode, unitless);
+ RefPtr<CSSPrimitiveValue> value3 = consumePositionComponent(range, cssParserMode, unitless);
if (!value3)
- return positionFromTwoValues(value1, value2, resultX, resultY);
+ return positionFromTwoValues(*value1, *value2, resultX, resultY);
- CSSPrimitiveValue* value4 = consumePositionComponent(range, cssParserMode, unitless);
+ RefPtr<CSSPrimitiveValue> value4 = consumePositionComponent(range, cssParserMode, unitless);
CSSPrimitiveValue* values[5];
- values[0] = value1;
- values[1] = value2;
- values[2] = value3;
- values[3] = value4;
+ values[0] = value1.get();
+ values[1] = value2.get();
+ values[2] = value3.get();
+ values[3] = value4.get();
values[4] = nullptr;
return positionFromThreeOrFourValues(values, resultX, resultY);
}
-CSSValuePair* consumePosition(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
+RefPtr<CSSPrimitiveValue> consumePosition(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
{
- CSSValue* resultX = nullptr;
- CSSValue* resultY = nullptr;
+ RefPtr<CSSPrimitiveValue> resultX;
+ RefPtr<CSSPrimitiveValue> resultY;
if (consumePosition(range, cssParserMode, unitless, resultX, resultY))
- return CSSValuePair::create(resultX, resultY, CSSValuePair::KeepIdenticalValues);
+ return createPrimitiveValuePair(resultX.releaseNonNull(), resultY.releaseNonNull());
return nullptr;
}
-bool consumeOneOrTwoValuedPosition(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless, CSSValue*& resultX, CSSValue*& resultY)
+bool consumeOneOrTwoValuedPosition(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless, RefPtr<CSSPrimitiveValue>& resultX, RefPtr<CSSPrimitiveValue>& resultY)
{
- CSSPrimitiveValue* value1 = consumePositionComponent(range, cssParserMode, unitless);
+ RefPtr<CSSPrimitiveValue> value1 = consumePositionComponent(range, cssParserMode, unitless);
if (!value1)
return false;
- CSSPrimitiveValue* value2 = consumePositionComponent(range, cssParserMode, unitless);
+ RefPtr<CSSPrimitiveValue> value2 = consumePositionComponent(range, cssParserMode, unitless);
if (!value2) {
- positionFromOneValue(value1, resultX, resultY);
+ positionFromOneValue(*value1, resultX, resultY);
return true;
}
- return positionFromTwoValues(value1, value2, resultX, resultY);
+ return positionFromTwoValues(*value1, *value2, resultX, resultY);
}
// This should go away once we drop support for -webkit-gradient
-static CSSPrimitiveValue* consumeDeprecatedGradientPoint(CSSParserTokenRange& args, bool horizontal)
+static RefPtr<CSSPrimitiveValue> consumeDeprecatedGradientPoint(CSSParserTokenRange& args, bool horizontal)
{
if (args.peek().type() == IdentToken) {
if ((horizontal && consumeIdent<CSSValueLeft>(args)) || (!horizontal && consumeIdent<CSSValueTop>(args)))
- return CSSPrimitiveValue::create(0., CSSPrimitiveValue::UnitType::Percentage);
+ return CSSPrimitiveValue::create(0., CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE);
if ((horizontal && consumeIdent<CSSValueRight>(args)) || (!horizontal && consumeIdent<CSSValueBottom>(args)))
- return CSSPrimitiveValue::create(100., CSSPrimitiveValue::UnitType::Percentage);
+ return CSSPrimitiveValue::create(100., CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE);
if (consumeIdent<CSSValueCenter>(args))
- return CSSPrimitiveValue::create(50., CSSPrimitiveValue::UnitType::Percentage);
+ return CSSPrimitiveValue::create(50., CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE);
return nullptr;
}
- CSSPrimitiveValue* result = consumePercent(args, ValueRangeAll);
+ RefPtr<CSSPrimitiveValue> result = consumePercent(args, ValueRangeAll);
if (!result)
result = consumeNumber(args, ValueRangeAll);
return result;
@@ -673,7 +677,7 @@
}
// Used to parse colors for -webkit-gradient(...).
-static CSSValue* consumeDeprecatedGradientStopColor(CSSParserTokenRange& args, CSSParserMode cssParserMode)
+static RefPtr<CSSPrimitiveValue> consumeDeprecatedGradientStopColor(CSSParserTokenRange& args, CSSParserMode cssParserMode)
{
if (args.peek().id() == CSSValueCurrentcolor)
return nullptr;
@@ -691,7 +695,7 @@
if (id == CSSValueFrom || id == CSSValueTo) {
position = (id == CSSValueFrom) ? 0 : 1;
} else {
- DCHECK(id == CSSValueColorStop);
+ ASSERT(id == CSSValueColorStop);
const CSSParserToken& arg = args.consumeIncludingWhitespace();
if (arg.type() == PercentageToken)
position = arg.numericValue() / 100.0;
@@ -704,14 +708,14 @@
return false;
}
- stop.m_position = CSSPrimitiveValue::create(position, CSSPrimitiveValue::UnitType::Number);
+ stop.m_position = CSSPrimitiveValue::create(position, CSSPrimitiveValue::UnitTypes::CSS_NUMBER);
stop.m_color = consumeDeprecatedGradientStopColor(args, cssParserMode);
return stop.m_color && args.atEnd();
}
-static CSSValue* consumeDeprecatedGradient(CSSParserTokenRange& args, CSSParserMode cssParserMode)
+static RefPtr<CSSValue> consumeDeprecatedGradient(CSSParserTokenRange& args, CSSParserMode cssParserMode)
{
- CSSGradientValue* result = nullptr;
+ RefPtr<CSSGradientValue> result;
CSSValueID id = args.consumeIncludingWhitespace().id();
bool isDeprecatedRadialGradient = (id == CSSValueRadial);
if (isDeprecatedRadialGradient)
@@ -721,14 +725,14 @@
if (!result || !consumeCommaIncludingWhitespace(args))
return nullptr;
- CSSPrimitiveValue* point = consumeDeprecatedGradientPoint(args, true);
+ RefPtr<CSSPrimitiveValue> point = consumeDeprecatedGradientPoint(args, true);
if (!point)
return nullptr;
- result->setFirstX(point);
+ result->setFirstX(WTFMove(point));
point = consumeDeprecatedGradientPoint(args, false);
if (!point)
return nullptr;
- result->setFirstY(point);
+ result->setFirstY(WTFMove(point));
if (!consumeCommaIncludingWhitespace(args))
return nullptr;
@@ -735,29 +739,29 @@
// For radial gradients only, we now expect a numeric radius.
if (isDeprecatedRadialGradient) {
- CSSPrimitiveValue* radius = consumeNumber(args, ValueRangeAll);
+ RefPtr<CSSPrimitiveValue> radius = consumeNumber(args, ValueRangeAll);
if (!radius || !consumeCommaIncludingWhitespace(args))
return nullptr;
- toCSSRadialGradientValue(result)->setFirstRadius(radius);
+ downcast<CSSRadialGradientValue>(result.get())->setFirstRadius(WTFMove(radius));
}
point = consumeDeprecatedGradientPoint(args, true);
if (!point)
return nullptr;
- result->setSecondX(point);
+ result->setSecondX(WTFMove(point));
point = consumeDeprecatedGradientPoint(args, false);
if (!point)
return nullptr;
- result->setSecondY(point);
+ result->setSecondY(WTFMove(point));
// For radial gradients only, we now expect the second radius.
if (isDeprecatedRadialGradient) {
if (!consumeCommaIncludingWhitespace(args))
return nullptr;
- CSSPrimitiveValue* radius = consumeNumber(args, ValueRangeAll);
+ RefPtr<CSSPrimitiveValue> radius = consumeNumber(args, ValueRangeAll);
if (!radius)
return nullptr;
- toCSSRadialGradientValue(result)->setSecondRadius(radius);
+ downcast<CSSRadialGradientValue>(result.get())->setSecondRadius(WTFMove(radius));
}
CSSGradientColorStop stop;
@@ -797,56 +801,56 @@
return gradient->stopCount() >= 2;
}
-static CSSValue* consumeDeprecatedRadialGradient(CSSParserTokenRange& args, CSSParserMode cssParserMode, CSSGradientRepeat repeating)
+static RefPtr<CSSValue> consumeDeprecatedRadialGradient(CSSParserTokenRange& args, CSSParserMode cssParserMode, CSSGradientRepeat repeating)
{
- CSSRadialGradientValue* result = CSSRadialGradientValue::create(repeating, CSSPrefixedRadialGradient);
- CSSValue* centerX = nullptr;
- CSSValue* centerY = nullptr;
+ RefPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::create(repeating, CSSPrefixedRadialGradient);
+ RefPtr<CSSPrimitiveValue> centerX;
+ RefPtr<CSSPrimitiveValue> centerY;
consumeOneOrTwoValuedPosition(args, cssParserMode, UnitlessQuirk::Forbid, centerX, centerY);
if ((centerX || centerY) && !consumeCommaIncludingWhitespace(args))
return nullptr;
- result->setFirstX(toCSSPrimitiveValue(centerX));
- result->setSecondX(toCSSPrimitiveValue(centerX));
- result->setFirstY(toCSSPrimitiveValue(centerY));
- result->setSecondY(toCSSPrimitiveValue(centerY));
+ result->setFirstX(WTFMove(centerX));
+ result->setFirstY(WTFMove(centerY));
+ result->setSecondX(WTFMove(centerX));
+ result->setSecondY(WTFMove(centerY));
- CSSPrimitiveValue* shape = consumeIdent<CSSValueCircle, CSSValueEllipse>(args);
- CSSPrimitiveValue* sizeKeyword = consumeIdent<CSSValueClosestSide, CSSValueClosestCorner, CSSValueFarthestSide, CSSValueFarthestCorner, CSSValueContain, CSSValueCover>(args);
+ RefPtr<CSSPrimitiveValue> shape = consumeIdent<CSSValueCircle, CSSValueEllipse>(args);
+ RefPtr<CSSPrimitiveValue> sizeKeyword = consumeIdent<CSSValueClosestSide, CSSValueClosestCorner, CSSValueFarthestSide, CSSValueFarthestCorner, CSSValueContain, CSSValueCover>(args);
if (!shape)
shape = consumeIdent<CSSValueCircle, CSSValueEllipse>(args);
- result->setShape(shape);
- result->setSizingBehavior(sizeKeyword);
+ result->setShape(WTFMove(shape));
+ result->setSizingBehavior(WTFMove(sizeKeyword));
// Or, two lengths or percentages
if (!shape && !sizeKeyword) {
- CSSPrimitiveValue* horizontalSize = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll);
- CSSPrimitiveValue* verticalSize = nullptr;
+ RefPtr<CSSPrimitiveValue> horizontalSize = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll);
+ RefPtr<CSSPrimitiveValue> verticalSize;
if (horizontalSize) {
verticalSize = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll);
if (!verticalSize)
return nullptr;
consumeCommaIncludingWhitespace(args);
- result->setEndHorizontalSize(horizontalSize);
- result->setEndVerticalSize(verticalSize);
+ result->setEndHorizontalSize(WTFMove(horizontalSize));
+ result->setEndVerticalSize(WTFMove(verticalSize));
}
} else {
consumeCommaIncludingWhitespace(args);
}
- if (!consumeGradientColorStops(args, cssParserMode, result))
+ if (!consumeGradientColorStops(args, cssParserMode, result.get()))
return nullptr;
return result;
}
-static CSSValue* consumeRadialGradient(CSSParserTokenRange& args, CSSParserMode cssParserMode, CSSGradientRepeat repeating)
+static RefPtr<CSSValue> consumeRadialGradient(CSSParserTokenRange& args, CSSParserMode cssParserMode, CSSGradientRepeat repeating)
{
- CSSRadialGradientValue* result = CSSRadialGradientValue::create(repeating, CSSRadialGradient);
+ RefPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::create(repeating, CSSRadialGradient);
- CSSPrimitiveValue* shape = nullptr;
- CSSPrimitiveValue* sizeKeyword = nullptr;
- CSSPrimitiveValue* horizontalSize = nullptr;
- CSSPrimitiveValue* verticalSize = nullptr;
+ RefPtr<CSSPrimitiveValue> shape;
+ RefPtr<CSSPrimitiveValue> sizeKeyword;
+ RefPtr<CSSPrimitiveValue> horizontalSize;
+ RefPtr<CSSPrimitiveValue> verticalSize;
// First part of grammar, the size/shape clause:
// [ circle || <length> ] |
@@ -867,7 +871,7 @@
break;
}
} else {
- CSSPrimitiveValue* center = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll);
+ RefPtr<CSSPrimitiveValue> center = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll);
if (!center)
break;
if (horizontalSize)
@@ -897,43 +901,45 @@
|| (verticalSize && verticalSize->isCalculatedPercentageWithLength()))
return nullptr;
- result->setShape(shape);
- result->setSizingBehavior(sizeKeyword);
- result->setEndHorizontalSize(horizontalSize);
- result->setEndVerticalSize(verticalSize);
+ result->setShape(WTFMove(shape));
+ result->setSizingBehavior(WTFMove(sizeKeyword));
+ result->setEndHorizontalSize(WTFMove(horizontalSize));
+ result->setEndVerticalSize(WTFMove(verticalSize));
- CSSValue* centerX = nullptr;
- CSSValue* centerY = nullptr;
+ RefPtr<CSSPrimitiveValue> centerX;
+ RefPtr<CSSPrimitiveValue> centerY;
if (args.peek().id() == CSSValueAt) {
args.consumeIncludingWhitespace();
consumePosition(args, cssParserMode, UnitlessQuirk::Forbid, centerX, centerY);
if (!(centerX && centerY))
return nullptr;
- result->setFirstX(centerX);
- result->setFirstY(centerY);
+
+ result->setFirstX(WTFMove(centerX));
+ result->setFirstY(WTFMove(centerY));
+
// Right now, CSS radial gradients have the same start and end centers.
- result->setSecondX(centerX);
- result->setSecondY(centerY);
+ result->setSecondX(WTFMove(centerX));
+ result->setSecondY(WTFMove(centerY));
}
if ((shape || sizeKeyword || horizontalSize || centerX || centerY) && !consumeCommaIncludingWhitespace(args))
return nullptr;
- if (!consumeGradientColorStops(args, cssParserMode, result))
+ if (!consumeGradientColorStops(args, cssParserMode, result.get()))
return nullptr;
return result;
}
-static CSSValue* consumeLinearGradient(CSSParserTokenRange& args, CSSParserMode cssParserMode, CSSGradientRepeat repeating, CSSGradientType gradientType)
+static RefPtr<CSSValue> consumeLinearGradient(CSSParserTokenRange& args, CSSParserMode cssParserMode, CSSGradientRepeat repeating, CSSGradientType gradientType)
{
- CSSLinearGradientValue* result = CSSLinearGradientValue::create(repeating, gradientType);
+ RefPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::create(repeating, gradientType);
bool expectComma = true;
- CSSPrimitiveValue* angle = consumeAngle(args);
- if (angle) {
- result->setAngle(angle);
- } else if (gradientType == CSSPrefixedLinearGradient || consumeIdent<CSSValueTo>(args)) {
- CSSPrimitiveValue* endX = consumeIdent<CSSValueLeft, CSSValueRight>(args);
- CSSPrimitiveValue* endY = consumeIdent<CSSValueBottom, CSSValueTop>(args);
+ RefPtr<CSSPrimitiveValue> angle = consumeAngle(args, cssParserMode, UnitlessQuirk::Forbid);
+ if (angle)
+ result->setAngle(angle.releaseNonNull());
+ else if (gradientType == CSSPrefixedLinearGradient || consumeIdent<CSSValueTo>(args)) {
+ RefPtr<CSSPrimitiveValue> endX = consumeIdent<CSSValueLeft, CSSValueRight>(args);
+ RefPtr<CSSPrimitiveValue> endY = consumeIdent<CSSValueBottom, CSSValueTop>(args);
if (!endX && !endY) {
if (gradientType == CSSLinearGradient)
return nullptr;
@@ -943,8 +949,8 @@
endX = consumeIdent<CSSValueLeft, CSSValueRight>(args);
}
- result->setFirstX(endX);
- result->setFirstY(endY);
+ result->setFirstX(WTFMove(endX));
+ result->setFirstY(WTFMove(endY));
} else {
expectComma = false;
}
@@ -951,12 +957,12 @@
if (expectComma && !consumeCommaIncludingWhitespace(args))
return nullptr;
- if (!consumeGradientColorStops(args, cssParserMode, result))
+ if (!consumeGradientColorStops(args, cssParserMode, result.get()))
return nullptr;
return result;
}
-CSSValue* consumeImageOrNone(CSSParserTokenRange& range, CSSParserContext context)
+RefPtr<CSSValue> consumeImageOrNone(CSSParserTokenRange& range, CSSParserContext context)
{
if (range.peek().id() == CSSValueNone)
return consumeIdent(range);
@@ -963,81 +969,54 @@
return consumeImage(range, context);
}
-static CSSValue* consumeCrossFade(CSSParserTokenRange& args, CSSParserContext context)
+static RefPtr<CSSValue> consumeCrossFade(CSSParserTokenRange& args, CSSParserContext context)
{
- CSSValue* fromImageValue = consumeImageOrNone(args, context);
+ RefPtr<CSSValue> fromImageValue = consumeImageOrNone(args, context);
if (!fromImageValue || !consumeCommaIncludingWhitespace(args))
return nullptr;
- CSSValue* toImageValue = consumeImageOrNone(args, context);
+ RefPtr<CSSValue> toImageValue = consumeImageOrNone(args, context);
if (!toImageValue || !consumeCommaIncludingWhitespace(args))
return nullptr;
- CSSPrimitiveValue* percentage = nullptr;
+ RefPtr<CSSPrimitiveValue> percentage;
const CSSParserToken& percentageArg = args.consumeIncludingWhitespace();
if (percentageArg.type() == PercentageToken)
- percentage = CSSPrimitiveValue::create(clampTo<double>(percentageArg.numericValue() / 100, 0, 1), CSSPrimitiveValue::UnitType::Number);
+ percentage = CSSPrimitiveValue::create(clampTo<double>(percentageArg.numericValue() / 100, 0, 1), CSSPrimitiveValue::UnitTypes::CSS_NUMBER);
else if (percentageArg.type() == NumberToken)
- percentage = CSSPrimitiveValue::create(clampTo<double>(percentageArg.numericValue(), 0, 1), CSSPrimitiveValue::UnitType::Number);
+ percentage = CSSPrimitiveValue::create(clampTo<double>(percentageArg.numericValue(), 0, 1), CSSPrimitiveValue::UnitTypes::CSS_NUMBER);
if (!percentage)
return nullptr;
- return CSSCrossfadeValue::create(fromImageValue, toImageValue, percentage);
+ return CSSCrossfadeValue::create(fromImageValue.releaseNonNull(), toImageValue.releaseNonNull(), percentage.releaseNonNull());
}
-static CSSValue* consumePaint(CSSParserTokenRange& args, CSSParserContext context)
+static RefPtr<CSSValue> consumeGeneratedImage(CSSParserTokenRange& range, CSSParserContext context)
{
- DCHECK(RuntimeEnabledFeatures::cssPaintAPIEnabled());
-
- CSSCustomIdentValue* name = consumeCustomIdent(args);
- if (!name)
- return nullptr;
-
- return CSSPaintValue::create(name);
-}
-
-static CSSValue* consumeGeneratedImage(CSSParserTokenRange& range, CSSParserContext context)
-{
CSSValueID id = range.peek().functionId();
CSSParserTokenRange rangeCopy = range;
CSSParserTokenRange args = consumeFunction(rangeCopy);
- CSSValue* result = nullptr;
- if (id == CSSValueRadialGradient) {
- result = consumeRadialGradient(args, context.mode(), NonRepeating);
- } else if (id == CSSValueRepeatingRadialGradient) {
- result = consumeRadialGradient(args, context.mode(), Repeating);
- } else if (id == CSSValueWebkitLinearGradient) {
- // FIXME: This should send a deprecation message.
- if (context.useCounter())
- context.useCounter()->count(UseCounter::DeprecatedWebKitLinearGradient);
- result = consumeLinearGradient(args, context.mode(), NonRepeating, CSSPrefixedLinearGradient);
- } else if (id == CSSValueWebkitRepeatingLinearGradient) {
- // FIXME: This should send a deprecation message.
- if (context.useCounter())
- context.useCounter()->count(UseCounter::DeprecatedWebKitRepeatingLinearGradient);
- result = consumeLinearGradient(args, context.mode(), Repeating, CSSPrefixedLinearGradient);
- } else if (id == CSSValueRepeatingLinearGradient) {
- result = consumeLinearGradient(args, context.mode(), Repeating, CSSLinearGradient);
- } else if (id == CSSValueLinearGradient) {
- result = consumeLinearGradient(args, context.mode(), NonRepeating, CSSLinearGradient);
- } else if (id == CSSValueWebkitGradient) {
- // FIXME: This should send a deprecation message.
- if (context.useCounter())
- context.useCounter()->count(UseCounter::DeprecatedWebKitGradient);
- result = consumeDeprecatedGradient(args, context.mode());
- } else if (id == CSSValueWebkitRadialGradient) {
- // FIXME: This should send a deprecation message.
- if (context.useCounter())
- context.useCounter()->count(UseCounter::DeprecatedWebKitRadialGradient);
- result = consumeDeprecatedRadialGradient(args, context.mode(), NonRepeating);
- } else if (id == CSSValueWebkitRepeatingRadialGradient) {
- if (context.useCounter())
- context.useCounter()->count(UseCounter::DeprecatedWebKitRepeatingRadialGradient);
- result = consumeDeprecatedRadialGradient(args, context.mode(), Repeating);
- } else if (id == CSSValueWebkitCrossFade) {
+ RefPtr<CSSValue> result;
+ if (id == CSSValueRadialGradient)
+ result = consumeRadialGradient(args, context.mode, NonRepeating);
+ else if (id == CSSValueRepeatingRadialGradient)
+ result = consumeRadialGradient(args, context.mode, Repeating);
+ else if (id == CSSValueWebkitLinearGradient)
+ result = consumeLinearGradient(args, context.mode, NonRepeating, CSSPrefixedLinearGradient);
+ else if (id == CSSValueWebkitRepeatingLinearGradient)
+ result = consumeLinearGradient(args, context.mode, Repeating, CSSPrefixedLinearGradient);
+ else if (id == CSSValueRepeatingLinearGradient)
+ result = consumeLinearGradient(args, context.mode, Repeating, CSSLinearGradient);
+ else if (id == CSSValueLinearGradient)
+ result = consumeLinearGradient(args, context.mode, NonRepeating, CSSLinearGradient);
+ else if (id == CSSValueWebkitGradient)
+ result = consumeDeprecatedGradient(args, context.mode);
+ else if (id == CSSValueWebkitRadialGradient)
+ result = consumeDeprecatedRadialGradient(args, context.mode, NonRepeating);
+ else if (id == CSSValueWebkitRepeatingRadialGradient)
+ result = consumeDeprecatedRadialGradient(args, context.mode, Repeating);
+ else if (id == CSSValueWebkitCrossFade)
result = consumeCrossFade(args, context);
- } else if (id == CSSValuePaint) {
- result = RuntimeEnabledFeatures::cssPaintAPIEnabled() ? consumePaint(args, context) : nullptr;
- }
+
if (!result || !args.atEnd())
return nullptr;
range = rangeCopy;
@@ -1044,24 +1023,17 @@
return result;
}
-static CSSValue* createCSSImageValueWithReferrer(const AtomicString& rawValue, const CSSParserContext& context)
+static RefPtr<CSSValue> consumeImageSet(CSSParserTokenRange& range, const CSSParserContext& context)
{
- CSSValue* imageValue = CSSImageValue::create(rawValue, context.completeURL(rawValue));
- toCSSImageValue(imageValue)->setReferrer(context.referrer());
- return imageValue;
-}
-
-static CSSValue* consumeImageSet(CSSParserTokenRange& range, const CSSParserContext& context)
-{
CSSParserTokenRange rangeCopy = range;
CSSParserTokenRange args = consumeFunction(rangeCopy);
- CSSImageSetValue* imageSet = CSSImageSetValue::create();
+ RefPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create();
do {
AtomicString urlValue = consumeUrlAsStringView(args).toAtomicString();
if (urlValue.isNull())
return nullptr;
- CSSValue* image = createCSSImageValueWithReferrer(urlValue, context);
+ RefPtr<CSSValue> image = CSSImageValue::create(completeURL(context, urlValue));
imageSet->append(*image);
const CSSParserToken& token = args.consumeIncludingWhitespace();
@@ -1069,11 +1041,11 @@
return nullptr;
if (token.value() != "x")
return nullptr;
- DCHECK(token.unitType() == CSSPrimitiveValue::UnitType::Unknown);
+ ASSERT(token.unitType() == CSSPrimitiveValue::UnitTypes::CSS_UNKNOWN);
double imageScaleFactor = token.numericValue();
if (imageScaleFactor <= 0)
return nullptr;
- imageSet->append(*CSSPrimitiveValue::create(imageScaleFactor, CSSPrimitiveValue::UnitType::Number));
+ imageSet->append(CSSPrimitiveValue::create(imageScaleFactor, CSSPrimitiveValue::UnitTypes::CSS_NUMBER));
} while (consumeCommaIncludingWhitespace(args));
if (!args.atEnd())
return nullptr;
@@ -1090,11 +1062,11 @@
|| id == CSSValueWebkitGradient || id == CSSValueWebkitCrossFade || id == CSSValuePaint;
}
-CSSValue* consumeImage(CSSParserTokenRange& range, CSSParserContext context, ConsumeGeneratedImage generatedImage)
+RefPtr<CSSValue> consumeImage(CSSParserTokenRange& range, CSSParserContext context, ConsumeGeneratedImage generatedImage)
{
AtomicString uri = consumeUrlAsStringView(range).toAtomicString();
if (!uri.isNull())
- return createCSSImageValueWithReferrer(uri, context);
+ return CSSImageValue::create(completeURL(context, uri));
if (range.peek().type() == FunctionToken) {
CSSValueID id = range.peek().functionId();
if (id == CSSValueWebkitImageSet)
@@ -1106,6 +1078,5 @@
}
} // namespace CSSPropertyParserHelpers
-*/
} // namespace WebCore
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h (206042 => 206043)
--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h 2016-09-16 20:24:23 UTC (rev 206043)
@@ -31,7 +31,7 @@
#ifndef CSSPropertyParserHelpers_h
#define CSSPropertyParserHelpers_h
-// FIXME-NEWPARSER #include "CSSCustomIdentValue.h"
+#include "CSSCustomIdentValue.h"
#include "CSSParserMode.h"
#include "CSSParserTokenRange.h"
#include "CSSPrimitiveValue.h"
@@ -39,10 +39,6 @@
namespace WebCore {
-class CSSStringValue;
-class CSSURIValue;
-class CSSValuePair;
-
// When these functions are successful, they will consume all the relevant
// tokens from the range and also consume any whitespace which follows. When
// the start of the range doesn't match the type we're looking for, the range
@@ -60,31 +56,31 @@
Forbid
};
-CSSPrimitiveValue* consumeInteger(CSSParserTokenRange&, double minimumValue = -std::numeric_limits<double>::max());
-CSSPrimitiveValue* consumePositiveInteger(CSSParserTokenRange&);
+RefPtr<CSSPrimitiveValue> consumeInteger(CSSParserTokenRange&, double minimumValue = -std::numeric_limits<double>::max());
+RefPtr<CSSPrimitiveValue> consumePositiveInteger(CSSParserTokenRange&);
bool consumeNumberRaw(CSSParserTokenRange&, double& result);
-CSSPrimitiveValue* consumeNumber(CSSParserTokenRange&, ValueRange);
-CSSPrimitiveValue* consumeLength(CSSParserTokenRange&, CSSParserMode, ValueRange, UnitlessQuirk = UnitlessQuirk::Forbid);
-CSSPrimitiveValue* consumePercent(CSSParserTokenRange&, ValueRange);
-CSSPrimitiveValue* consumeLengthOrPercent(CSSParserTokenRange&, CSSParserMode, ValueRange, UnitlessQuirk = UnitlessQuirk::Forbid);
-CSSPrimitiveValue* consumeAngle(CSSParserTokenRange&);
-CSSPrimitiveValue* consumeTime(CSSParserTokenRange&, ValueRange);
+RefPtr<CSSPrimitiveValue> consumeNumber(CSSParserTokenRange&, ValueRange);
+RefPtr<CSSPrimitiveValue> consumeLength(CSSParserTokenRange&, CSSParserMode, ValueRange, UnitlessQuirk = UnitlessQuirk::Forbid);
+RefPtr<CSSPrimitiveValue> consumePercent(CSSParserTokenRange&, ValueRange);
+RefPtr<CSSPrimitiveValue> consumeLengthOrPercent(CSSParserTokenRange&, CSSParserMode, ValueRange, UnitlessQuirk = UnitlessQuirk::Forbid);
+RefPtr<CSSPrimitiveValue> consumeAngle(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk = UnitlessQuirk::Forbid);
+RefPtr<CSSPrimitiveValue> consumeTime(CSSParserTokenRange&, CSSParserMode, ValueRange, UnitlessQuirk = UnitlessQuirk::Forbid);
-CSSPrimitiveValue* consumeIdent(CSSParserTokenRange&);
-CSSPrimitiveValue* consumeIdentRange(CSSParserTokenRange&, CSSValueID lower, CSSValueID upper);
+RefPtr<CSSPrimitiveValue> consumeIdent(CSSParserTokenRange&);
+RefPtr<CSSPrimitiveValue> consumeIdentRange(CSSParserTokenRange&, CSSValueID lower, CSSValueID upper);
template<CSSValueID, CSSValueID...> inline bool identMatches(CSSValueID id);
-template<CSSValueID... allowedIdents> CSSPrimitiveValue* consumeIdent(CSSParserTokenRange&);
+template<CSSValueID... allowedIdents> RefPtr<CSSPrimitiveValue> consumeIdent(CSSParserTokenRange&);
-// FIXME-NEWPARSER CSSCustomIdentValue* consumeCustomIdent(CSSParserTokenRange&);
-CSSStringValue* consumeString(CSSParserTokenRange&);
+RefPtr<CSSCustomIdentValue> consumeCustomIdent(CSSParserTokenRange&);
+RefPtr<CSSPrimitiveValue> consumeString(CSSParserTokenRange&);
StringView consumeUrlAsStringView(CSSParserTokenRange&);
-CSSURIValue* consumeUrl(CSSParserTokenRange&);
+RefPtr<CSSPrimitiveValue> consumeUrl(CSSParserTokenRange&);
-CSSValue* consumeColor(CSSParserTokenRange&, CSSParserMode, bool acceptQuirkyColors = false);
+RefPtr<CSSPrimitiveValue> consumeColor(CSSParserTokenRange&, CSSParserMode, bool acceptQuirkyColors = false);
-CSSValuePair* consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk);
-bool consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk, CSSValue*& resultX, CSSValue*& resultY);
-bool consumeOneOrTwoValuedPosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk, CSSValue*& resultX, CSSValue*& resultY);
+RefPtr<CSSPrimitiveValue> consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk);
+bool consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk, RefPtr<CSSPrimitiveValue>& resultX, RefPtr<CSSPrimitiveValue>& resultY);
+bool consumeOneOrTwoValuedPosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk, RefPtr<CSSPrimitiveValue>& resultX, RefPtr<CSSPrimitiveValue>& resultY);
enum class ConsumeGeneratedImage {
Allow,
@@ -91,8 +87,8 @@
Forbid
};
-CSSValue* consumeImage(CSSParserTokenRange&, CSSParserContext, ConsumeGeneratedImage = ConsumeGeneratedImage::Allow);
-CSSValue* consumeImageOrNone(CSSParserTokenRange&, CSSParserContext);
+RefPtr<CSSValue> consumeImage(CSSParserTokenRange&, CSSParserContext, ConsumeGeneratedImage = ConsumeGeneratedImage::Allow);
+RefPtr<CSSValue> consumeImageOrNone(CSSParserTokenRange&, CSSParserContext);
// Template implementations are at the bottom of the file for readability.
@@ -112,7 +108,7 @@
static inline bool isCSSWideKeyword(const CSSValueID& id)
{
- return id == CSSValueInitial || id == CSSValueInherit || id == CSSValueUnset || id == CSSValueDefault;
+ return id == CSSValueInitial || id == CSSValueInherit || id == CSSValueUnset || id == CSSValueRevert || id == CSSValueDefault;
}
} // namespace CSSPropertyParserHelpers
Modified: trunk/Source/WebCore/platform/CalculationValue.cpp (206042 => 206043)
--- trunk/Source/WebCore/platform/CalculationValue.cpp 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/platform/CalculationValue.cpp 2016-09-16 20:24:23 UTC (rev 206043)
@@ -36,7 +36,7 @@
namespace WebCore {
-Ref<CalculationValue> CalculationValue::create(std::unique_ptr<CalcExpressionNode> value, CalculationPermittedValueRange range)
+Ref<CalculationValue> CalculationValue::create(std::unique_ptr<CalcExpressionNode> value, ValueRange range)
{
return adoptRef(*new CalculationValue(WTFMove(value), range));
}
Modified: trunk/Source/WebCore/platform/CalculationValue.h (206042 => 206043)
--- trunk/Source/WebCore/platform/CalculationValue.h 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/platform/CalculationValue.h 2016-09-16 20:24:23 UTC (rev 206043)
@@ -46,11 +46,6 @@
CalcDivide = '/'
};
-enum CalculationPermittedValueRange {
- CalculationRangeAll,
- CalculationRangeNonNegative
-};
-
enum CalcExpressionNodeType {
CalcExpressionNodeUndefined,
CalcExpressionNodeNumber,
@@ -136,7 +131,7 @@
class CalculationValue : public RefCounted<CalculationValue> {
public:
- WEBCORE_EXPORT static Ref<CalculationValue> create(std::unique_ptr<CalcExpressionNode>, CalculationPermittedValueRange);
+ WEBCORE_EXPORT static Ref<CalculationValue> create(std::unique_ptr<CalcExpressionNode>, ValueRange);
float evaluate(float maxValue) const;
bool shouldClampToNonNegative() const { return m_shouldClampToNonNegative; }
@@ -143,7 +138,7 @@
const CalcExpressionNode& _expression_() const { return *m_expression; }
private:
- CalculationValue(std::unique_ptr<CalcExpressionNode>, CalculationPermittedValueRange);
+ CalculationValue(std::unique_ptr<CalcExpressionNode>, ValueRange);
std::unique_ptr<CalcExpressionNode> m_expression;
bool m_shouldClampToNonNegative;
@@ -154,9 +149,9 @@
{
}
-inline CalculationValue::CalculationValue(std::unique_ptr<CalcExpressionNode> _expression_, CalculationPermittedValueRange range)
+inline CalculationValue::CalculationValue(std::unique_ptr<CalcExpressionNode> _expression_, ValueRange range)
: m_expression(WTFMove(_expression_))
- , m_shouldClampToNonNegative(range == CalculationRangeNonNegative)
+ , m_shouldClampToNonNegative(range == ValueRangeNonNegative)
{
}
Modified: trunk/Source/WebCore/platform/Length.cpp (206042 => 206043)
--- trunk/Source/WebCore/platform/Length.cpp 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/platform/Length.cpp 2016-09-16 20:24:23 UTC (rev 206043)
@@ -293,7 +293,7 @@
return to;
auto blend = std::make_unique<CalcExpressionBlendLength>(from, to, progress);
- return Length(CalculationValue::create(WTFMove(blend), CalculationRangeAll));
+ return Length(CalculationValue::create(WTFMove(blend), ValueRangeAll));
}
Length blend(const Length& from, const Length& to, double progress)
Modified: trunk/Source/WebCore/platform/graphics/Color.cpp (206042 => 206043)
--- trunk/Source/WebCore/platform/graphics/Color.cpp 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/platform/graphics/Color.cpp 2016-09-16 20:24:23 UTC (rev 206043)
@@ -204,6 +204,16 @@
return parseHexColor(name.characters16(), name.length(), rgb);
}
+bool Color::parseHexColor(const StringView& name, RGBA32& rgb)
+{
+ unsigned length = name.length();
+ if (!length)
+ return false;
+ if (name.is8Bit())
+ return parseHexColor(name.characters8(), name.length(), rgb);
+ return parseHexColor(name.characters16(), name.length(), rgb);
+}
+
int differenceSquared(const Color& c1, const Color& c2)
{
int dR = c1.red() - c2.red();
@@ -226,7 +236,7 @@
Color::Color(const char* name)
{
if (name[0] == '#')
- m_valid = parseHexColor(&name[1], m_color);
+ m_valid = parseHexColor((String)&name[1], m_color);
else {
const NamedColor* foundColor = findColor(name, strlen(name));
m_color = foundColor ? foundColor->ARGBValue : 0;
Modified: trunk/Source/WebCore/platform/graphics/Color.h (206042 => 206043)
--- trunk/Source/WebCore/platform/graphics/Color.h 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/platform/graphics/Color.h 2016-09-16 20:24:23 UTC (rev 206043)
@@ -175,6 +175,7 @@
#endif
static bool parseHexColor(const String&, RGBA32&);
+ static bool parseHexColor(const StringView&, RGBA32&);
static bool parseHexColor(const LChar*, unsigned, RGBA32&);
static bool parseHexColor(const UChar*, unsigned, RGBA32&);
Modified: trunk/Source/WebCore/rendering/style/BasicShapes.cpp (206042 => 206043)
--- trunk/Source/WebCore/rendering/style/BasicShapes.cpp 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Source/WebCore/rendering/style/BasicShapes.cpp 2016-09-16 20:24:23 UTC (rev 206043)
@@ -60,7 +60,7 @@
auto lhs = std::make_unique<CalcExpressionLength>(Length(100, Percent));
auto rhs = std::make_unique<CalcExpressionLength>(m_length);
auto op = std::make_unique<CalcExpressionBinaryOperation>(WTFMove(lhs), WTFMove(rhs), CalcSubtract);
- m_computedLength = Length(CalculationValue::create(WTFMove(op), CalculationRangeAll));
+ m_computedLength = Length(CalculationValue::create(WTFMove(op), ValueRangeAll));
}
struct SVGPathTranslatedByteStream {
Modified: trunk/Tools/ChangeLog (206042 => 206043)
--- trunk/Tools/ChangeLog 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Tools/ChangeLog 2016-09-16 20:24:23 UTC (rev 206043)
@@ -1,3 +1,14 @@
+2016-09-16 Dave Hyatt <hy...@apple.com>
+
+ [CSS Parser] Get CSSPropertyParserHelpers.cpp compiling
+ https://bugs.webkit.org/show_bug.cgi?id=162078
+
+ Reviewed by Dean Jackson.
+
+ * TestWebKitAPI/Tests/WebCore/CalculationValue.cpp:
+ (TestWebKitAPI::createTestValue):
+ Convert to ValueRange.
+
2016-09-16 Alex Christensen <achristen...@webkit.org>
Fix API tests after r206036
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/CalculationValue.cpp (206042 => 206043)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/CalculationValue.cpp 2016-09-16 20:19:02 UTC (rev 206042)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/CalculationValue.cpp 2016-09-16 20:24:23 UTC (rev 206043)
@@ -45,7 +45,7 @@
static Ref<WebCore::CalculationValue> createTestValue()
{
auto node = std::make_unique<CalculationDeletionTestNode>();
- return WebCore::CalculationValue::create(WTFMove(node), WebCore::CalculationRangeAll);
+ return WebCore::CalculationValue::create(WTFMove(node), WebCore::ValueRangeAll);
}
TEST(CalculationValue, LengthConstruction)