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 e3c41b2ec5d7302c1a113db7b5443f08a4d38d6a..04699821fd86048d37303e5eaafed4ebdaafd0fe 100644 |
--- a/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp |
+++ b/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp |
@@ -27,25 +27,14 @@ |
#include "core/css/parser/CSSPropertyParser.h" |
#include "core/StylePropertyShorthand.h" |
-#include "core/css/CSSBorderImage.h" |
#include "core/css/CSSCrossfadeValue.h" |
#include "core/css/CSSCustomIdentValue.h" |
#include "core/css/CSSFunctionValue.h" |
#include "core/css/CSSGridLineNamesValue.h" |
#include "core/css/CSSImageSetValue.h" |
#include "core/css/CSSPrimitiveValueMappings.h" |
-#include "core/css/CSSProperty.h" |
-#include "core/css/CSSPropertyMetadata.h" |
-#include "core/css/CSSQuadValue.h" |
-#include "core/css/CSSReflectValue.h" |
-#include "core/css/CSSShadowValue.h" |
-#include "core/css/CSSStringValue.h" |
-#include "core/css/CSSTimingFunctionValue.h" |
-#include "core/css/CSSURIValue.h" |
#include "core/css/CSSValuePair.h" |
#include "core/css/CSSValuePool.h" |
-#include "core/css/CSSVariableReferenceValue.h" |
-#include "core/css/parser/CSSParserFastPaths.h" |
#include "core/css/parser/CSSParserValues.h" |
#include "core/frame/UseCounter.h" |
#include "core/style/GridArea.h" |
@@ -357,16 +346,6 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::legacyParseValue(CSSProperty |
validPrimitive = validUnit(value, FLength | FPercent | FUnitlessQuirk); |
break; |
- case CSSPropertyWebkitBorderImage: |
- parsedValue = parseBorderImage(propId); |
- break; |
- |
- case CSSPropertyWebkitBoxReflect: |
- if (id == CSSValueNone) |
- validPrimitive = true; |
- else |
- parsedValue = parseReflect(); |
- break; |
case CSSPropertyFontSizeAdjust: // none | <number> |
ASSERT(RuntimeEnabledFeatures::cssFontSizeAdjustEnabled()); |
validPrimitive = (id == CSSValueNone) ? true : validUnit(value, FNumber | FNonNeg); |
@@ -465,10 +444,6 @@ bool CSSPropertyParser::legacyParseShorthand(CSSPropertyID propertyID, bool impo |
return true; |
} |
- case CSSPropertyBorderImage: |
- case CSSPropertyWebkitMaskBoxImage: |
- return parseBorderImageShorthand(propertyID, important); |
- |
case CSSPropertyGridGap: |
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
return parseGridGapShorthand(important); |
@@ -2395,517 +2370,6 @@ bool CSSPropertyParser::parseColorFromValue(const CSSParserValue* value, RGBA32& |
return true; |
} |
-PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseReflect() |
-{ |
- // box-reflect: <direction> <offset> <mask> |
- |
- // Direction comes first. |
- CSSParserValue* val = m_valueList->current(); |
- RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr; |
- switch (val->id) { |
- case CSSValueAbove: |
- case CSSValueBelow: |
- case CSSValueLeft: |
- case CSSValueRight: |
- direction = cssValuePool().createIdentifierValue(val->id); |
- break; |
- default: |
- return nullptr; |
- } |
- |
- // The offset comes next. |
- val = m_valueList->next(); |
- RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr; |
- if (!val) |
- offset = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Pixels); |
- else { |
- if (!validUnit(val, FLength | FPercent)) |
- return nullptr; |
- offset = createPrimitiveNumericValue(val); |
- } |
- |
- // Now for the mask. |
- RefPtrWillBeRawPtr<CSSValue> mask = nullptr; |
- val = m_valueList->next(); |
- if (val) { |
- mask = parseBorderImage(CSSPropertyWebkitBoxReflect); |
- if (!mask) |
- return nullptr; |
- } |
- |
- return CSSReflectValue::create(direction.release(), offset.release(), mask.release()); |
-} |
- |
-class BorderImageParseContext { |
- STACK_ALLOCATED(); |
-public: |
- BorderImageParseContext() |
- : m_canAdvance(false) |
- , m_allowCommit(true) |
- , m_allowImage(true) |
- , m_allowImageSlice(true) |
- , m_allowRepeat(true) |
- , m_allowForwardSlashOperator(false) |
- , m_allowWidth(false) |
- , m_requireOutset(false) |
- {} |
- |
- bool canAdvance() const { return m_canAdvance; } |
- void setCanAdvance(bool canAdvance) { m_canAdvance = canAdvance; } |
- |
- bool allowCommit() const { return m_allowCommit; } |
- bool allowImage() const { return m_allowImage; } |
- bool allowImageSlice() const { return m_allowImageSlice; } |
- bool allowRepeat() const { return m_allowRepeat; } |
- bool allowForwardSlashOperator() const { return m_allowForwardSlashOperator; } |
- |
- bool allowWidth() const { return m_allowWidth; } |
- bool requireOutset() const { return m_requireOutset; } |
- |
- void commitImage(PassRefPtrWillBeRawPtr<CSSValue> image) |
- { |
- m_image = image; |
- m_canAdvance = true; |
- m_allowCommit = true; |
- m_allowImage = false; |
- m_allowForwardSlashOperator = false; |
- m_allowWidth = false; |
- m_requireOutset = false; |
- m_allowImageSlice = !m_imageSlice; |
- m_allowRepeat = !m_repeat; |
- } |
- void commitImageSlice(PassRefPtrWillBeRawPtr<CSSBorderImageSliceValue> slice) |
- { |
- m_imageSlice = slice; |
- m_canAdvance = true; |
- m_allowCommit = true; |
- m_allowForwardSlashOperator = true; |
- m_allowImageSlice = false; |
- m_allowWidth = false; |
- m_requireOutset = false; |
- m_allowImage = !m_image; |
- m_allowRepeat = !m_repeat; |
- } |
- void commitForwardSlashOperator() |
- { |
- m_canAdvance = true; |
- m_allowCommit = false; |
- m_allowImage = false; |
- m_allowImageSlice = false; |
- m_allowRepeat = false; |
- if (!m_borderWidth && !m_allowWidth) { |
- m_allowForwardSlashOperator = true; |
- m_allowWidth = true; |
- m_requireOutset = false; |
- } else { |
- m_allowForwardSlashOperator = false; |
- m_requireOutset = true; |
- m_allowWidth = false; |
- } |
- } |
- void commitBorderWidth(PassRefPtrWillBeRawPtr<CSSQuadValue> width) |
- { |
- m_borderWidth = width; |
- m_canAdvance = true; |
- m_allowCommit = true; |
- m_allowForwardSlashOperator = true; |
- m_allowImageSlice = false; |
- m_allowWidth = false; |
- m_requireOutset = false; |
- m_allowImage = !m_image; |
- m_allowRepeat = !m_repeat; |
- } |
- void commitBorderOutset(PassRefPtrWillBeRawPtr<CSSQuadValue> outset) |
- { |
- m_outset = outset; |
- m_canAdvance = true; |
- m_allowCommit = true; |
- m_allowImageSlice = false; |
- m_allowForwardSlashOperator = false; |
- m_allowWidth = false; |
- m_requireOutset = false; |
- m_allowImage = !m_image; |
- m_allowRepeat = !m_repeat; |
- } |
- void commitRepeat(PassRefPtrWillBeRawPtr<CSSValue> repeat) |
- { |
- m_repeat = repeat; |
- m_canAdvance = true; |
- m_allowCommit = true; |
- m_allowRepeat = false; |
- m_allowForwardSlashOperator = false; |
- m_allowWidth = false; |
- m_requireOutset = false; |
- m_allowImageSlice = !m_imageSlice; |
- m_allowImage = !m_image; |
- } |
- |
- PassRefPtrWillBeRawPtr<CSSValue> commitCSSValue() |
- { |
- return createBorderImageValue(m_image, m_imageSlice.get(), m_borderWidth.get(), m_outset.get(), m_repeat.get()); |
- } |
- |
- bool m_canAdvance; |
- |
- bool m_allowCommit; |
- bool m_allowImage; |
- bool m_allowImageSlice; |
- bool m_allowRepeat; |
- bool m_allowForwardSlashOperator; |
- |
- bool m_allowWidth; |
- bool m_requireOutset; |
- |
- RefPtrWillBeMember<CSSValue> m_image; |
- RefPtrWillBeMember<CSSBorderImageSliceValue> m_imageSlice; |
- RefPtrWillBeMember<CSSQuadValue> m_borderWidth; |
- RefPtrWillBeMember<CSSQuadValue> m_outset; |
- |
- RefPtrWillBeMember<CSSValue> m_repeat; |
-}; |
- |
-bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, BorderImageParseContext& context) |
-{ |
- CSSPropertyParser::ShorthandScope scope(this, propId); |
- while (CSSParserValue* val = m_valueList->current()) { |
- context.setCanAdvance(false); |
- |
- if (!context.canAdvance() && context.allowForwardSlashOperator() && isForwardSlashOperator(val)) |
- context.commitForwardSlashOperator(); |
- |
- if (!context.canAdvance() && context.allowImage()) { |
- if (val->m_unit == CSSParserValue::URI) { |
- context.commitImage(createCSSImageValueWithReferrer(val->string, m_context)); |
- } else if (val->m_unit == CSSParserValue::Function) { |
- if (CSSPropertyParser::isGeneratedImage(val->function->id)) { |
- RefPtrWillBeRawPtr<CSSValue> value = nullptr; |
- if (parseGeneratedImage(m_valueList, value)) |
- context.commitImage(value.release()); |
- else |
- return false; |
- } else if (val->function->id == CSSValueWebkitImageSet) { |
- RefPtrWillBeRawPtr<CSSValue> value = parseImageSet(m_valueList); |
- if (value) |
- context.commitImage(value.release()); |
- else |
- return false; |
- } |
- } else if (val->id == CSSValueNone) |
- context.commitImage(cssValuePool().createIdentifierValue(CSSValueNone)); |
- } |
- |
- if (!context.canAdvance() && context.allowImageSlice()) { |
- RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr; |
- if (parseBorderImageSlice(propId, imageSlice)) |
- context.commitImageSlice(imageSlice.release()); |
- } |
- |
- if (!context.canAdvance() && context.allowRepeat()) { |
- RefPtrWillBeRawPtr<CSSValue> repeat = nullptr; |
- if (parseBorderImageRepeat(repeat)) |
- context.commitRepeat(repeat.release()); |
- } |
- |
- if (!context.canAdvance() && context.allowWidth()) { |
- RefPtrWillBeRawPtr<CSSQuadValue> borderWidth = nullptr; |
- if (parseBorderImageWidth(borderWidth)) |
- context.commitBorderWidth(borderWidth.release()); |
- } |
- |
- if (!context.canAdvance() && context.requireOutset()) { |
- RefPtrWillBeRawPtr<CSSQuadValue> borderOutset = nullptr; |
- if (parseBorderImageOutset(borderOutset)) |
- context.commitBorderOutset(borderOutset.release()); |
- } |
- |
- if (!context.canAdvance()) |
- return false; |
- |
- m_valueList->next(); |
- } |
- |
- return context.allowCommit(); |
-} |
- |
-void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr<CSSValue> value, bool important) |
-{ |
- if (value) |
- addProperty(propId, value, important); |
- else |
- addProperty(propId, cssValuePool().createImplicitInitialValue(), important, true); |
-} |
- |
-bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool important) |
-{ |
- BorderImageParseContext context; |
- if (buildBorderImageParseContext(propId, context)) { |
- switch (propId) { |
- case CSSPropertyWebkitMaskBoxImage: |
- commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSource, context.m_image, important); |
- commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSlice, context.m_imageSlice.get(), important); |
- commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageWidth, context.m_borderWidth.get(), important); |
- commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageOutset, context.m_outset.get(), important); |
- commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageRepeat, context.m_repeat.get(), important); |
- return true; |
- case CSSPropertyBorderImage: |
- commitBorderImageProperty(CSSPropertyBorderImageSource, context.m_image, important); |
- commitBorderImageProperty(CSSPropertyBorderImageSlice, context.m_imageSlice.get(), important); |
- commitBorderImageProperty(CSSPropertyBorderImageWidth, context.m_borderWidth.get(), important); |
- commitBorderImageProperty(CSSPropertyBorderImageOutset, context.m_outset.get(), important); |
- commitBorderImageProperty(CSSPropertyBorderImageRepeat, context.m_repeat, important); |
- return true; |
- default: |
- ASSERT_NOT_REACHED(); |
- return false; |
- } |
- } |
- return false; |
-} |
- |
-PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBorderImage(CSSPropertyID propId) |
-{ |
- BorderImageParseContext context; |
- if (buildBorderImageParseContext(propId, context)) { |
- return context.commitCSSValue(); |
- } |
- return nullptr; |
-} |
- |
-static bool isBorderImageRepeatKeyword(int id) |
-{ |
- return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace || id == CSSValueRound; |
-} |
- |
-bool CSSPropertyParser::parseBorderImageRepeat(RefPtrWillBeRawPtr<CSSValue>& result) |
-{ |
- RefPtrWillBeRawPtr<CSSPrimitiveValue> firstValue = nullptr; |
- RefPtrWillBeRawPtr<CSSPrimitiveValue> secondValue = nullptr; |
- CSSParserValue* val = m_valueList->current(); |
- if (!val) |
- return false; |
- if (isBorderImageRepeatKeyword(val->id)) |
- firstValue = cssValuePool().createIdentifierValue(val->id); |
- else |
- return false; |
- |
- val = m_valueList->next(); |
- if (val) { |
- if (isBorderImageRepeatKeyword(val->id)) |
- secondValue = cssValuePool().createIdentifierValue(val->id); |
- else if (!inShorthand()) { |
- // If we're not parsing a shorthand then we are invalid. |
- return false; |
- } else { |
- // We need to rewind the value list, so that when its advanced we'll |
- // end up back at this value. |
- m_valueList->previous(); |
- secondValue = firstValue; |
- } |
- } else |
- secondValue = firstValue; |
- |
- result = CSSValuePair::create(firstValue, secondValue, CSSValuePair::DropIdenticalValues); |
- return true; |
-} |
- |
-class BorderImageSliceParseContext { |
- STACK_ALLOCATED(); |
-public: |
- BorderImageSliceParseContext() |
- : m_allowNumber(true) |
- , m_allowFill(true) |
- , m_allowFinalCommit(false) |
- , m_fill(false) |
- { } |
- |
- bool allowNumber() const { return m_allowNumber; } |
- bool allowFill() const { return m_allowFill; } |
- bool allowFinalCommit() const { return m_allowFinalCommit; } |
- CSSPrimitiveValue* top() const { return m_top.get(); } |
- |
- void commitNumber(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) |
- { |
- if (!m_top) |
- m_top = val; |
- else if (!m_right) |
- m_right = val; |
- else if (!m_bottom) |
- m_bottom = val; |
- else { |
- ASSERT(!m_left); |
- m_left = val; |
- } |
- |
- m_allowNumber = !m_left; |
- m_allowFinalCommit = true; |
- } |
- |
- void commitFill() { m_fill = true; m_allowFill = false; m_allowNumber = !m_top; } |
- |
- PassRefPtrWillBeRawPtr<CSSBorderImageSliceValue> commitBorderImageSlice() |
- { |
- // We need to clone and repeat values for any omissions. |
- ASSERT(m_top); |
- if (!m_right) { |
- m_right = m_top; |
- m_bottom = m_top; |
- m_left = m_top; |
- } |
- if (!m_bottom) { |
- m_bottom = m_top; |
- m_left = m_right; |
- } |
- if (!m_left) |
- m_left = m_right; |
- |
- return CSSBorderImageSliceValue::create(CSSQuadValue::create(m_top.release(), m_right.release(), m_bottom.release(), m_left.release(), CSSQuadValue::SerializeAsQuad), m_fill); |
- } |
- |
-private: |
- bool m_allowNumber; |
- bool m_allowFill; |
- bool m_allowFinalCommit; |
- |
- RefPtrWillBeMember<CSSPrimitiveValue> m_top; |
- RefPtrWillBeMember<CSSPrimitiveValue> m_right; |
- RefPtrWillBeMember<CSSPrimitiveValue> m_bottom; |
- RefPtrWillBeMember<CSSPrimitiveValue> m_left; |
- |
- bool m_fill; |
-}; |
- |
-bool CSSPropertyParser::parseBorderImageSlice(CSSPropertyID propId, RefPtrWillBeRawPtr<CSSBorderImageSliceValue>& result) |
-{ |
- BorderImageSliceParseContext context; |
- for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->next()) { |
- // FIXME calc() http://webkit.org/b/16662 : calc is parsed but values are not created yet. |
- if (context.allowNumber() && !isCalculation(val) && validUnit(val, FNumber | FNonNeg | FPercent)) { |
- context.commitNumber(createPrimitiveNumericValue(val)); |
- } else if (context.allowFill() && val->id == CSSValueFill) { |
- context.commitFill(); |
- } else if (!inShorthand()) { |
- // If we're not parsing a shorthand then we are invalid. |
- return false; |
- } else { |
- if (context.allowFinalCommit()) { |
- // We're going to successfully parse, but we don't want to consume this token. |
- m_valueList->previous(); |
- } |
- break; |
- } |
- } |
- |
- if (context.allowFinalCommit()) { |
- // FIXME: For backwards compatibility, -webkit-border-image, -webkit-mask-box-image and -webkit-box-reflect have to do a fill by default. |
- // FIXME: What do we do with -webkit-box-reflect and -webkit-mask-box-image? Probably just have to leave them filling... |
- if (propId == CSSPropertyWebkitBorderImage || propId == CSSPropertyWebkitMaskBoxImage || propId == CSSPropertyWebkitBoxReflect) |
- context.commitFill(); |
- |
- // Need to fully commit as a single value. |
- result = context.commitBorderImageSlice(); |
- return true; |
- } |
- |
- return false; |
-} |
- |
-class BorderImageQuadParseContext { |
- STACK_ALLOCATED(); |
-public: |
- BorderImageQuadParseContext() |
- : m_allowNumber(true) |
- , m_allowFinalCommit(false) |
- { } |
- |
- bool allowNumber() const { return m_allowNumber; } |
- bool allowFinalCommit() const { return m_allowFinalCommit; } |
- CSSPrimitiveValue* top() const { return m_top.get(); } |
- |
- void commitNumber(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) |
- { |
- if (!m_top) |
- m_top = val; |
- else if (!m_right) |
- m_right = val; |
- else if (!m_bottom) |
- m_bottom = val; |
- else { |
- ASSERT(!m_left); |
- m_left = val; |
- } |
- |
- m_allowNumber = !m_left; |
- m_allowFinalCommit = true; |
- } |
- |
- void setTop(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_top = val; } |
- |
- PassRefPtrWillBeRawPtr<CSSQuadValue> commitBorderImageQuad() |
- { |
- // We need to clone and repeat values for any omissions. |
- ASSERT(m_top); |
- if (!m_right) { |
- m_right = m_top; |
- m_bottom = m_top; |
- m_left = m_top; |
- } |
- if (!m_bottom) { |
- m_bottom = m_top; |
- m_left = m_right; |
- } |
- if (!m_left) |
- m_left = m_right; |
- |
- return CSSQuadValue::create(m_top.release(), m_right.release(), m_bottom.release(), m_left.release(), CSSQuadValue::SerializeAsQuad); |
- } |
- |
-private: |
- bool m_allowNumber; |
- bool m_allowFinalCommit; |
- |
- RefPtrWillBeMember<CSSPrimitiveValue> m_top; |
- RefPtrWillBeMember<CSSPrimitiveValue> m_right; |
- RefPtrWillBeMember<CSSPrimitiveValue> m_bottom; |
- RefPtrWillBeMember<CSSPrimitiveValue> m_left; |
-}; |
- |
-bool CSSPropertyParser::parseBorderImageQuad(Units validUnits, RefPtrWillBeRawPtr<CSSQuadValue>& result) |
-{ |
- BorderImageQuadParseContext context; |
- for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->next()) { |
- if (context.allowNumber() && (validUnit(val, validUnits, HTMLStandardMode) || val->id == CSSValueAuto)) { |
- if (val->id == CSSValueAuto) |
- context.commitNumber(cssValuePool().createIdentifierValue(val->id)); |
- else |
- context.commitNumber(createPrimitiveNumericValue(val)); |
- } else if (!inShorthand()) { |
- // If we're not parsing a shorthand then we are invalid. |
- return false; |
- } else { |
- if (context.allowFinalCommit()) |
- m_valueList->previous(); // The shorthand loop will advance back to this point. |
- break; |
- } |
- } |
- |
- if (context.allowFinalCommit()) { |
- // Need to fully commit as a single value. |
- result = context.commitBorderImageQuad(); |
- return true; |
- } |
- return false; |
-} |
- |
-bool CSSPropertyParser::parseBorderImageWidth(RefPtrWillBeRawPtr<CSSQuadValue>& result) |
-{ |
- return parseBorderImageQuad(FLength | FNumber | FNonNeg | FPercent, result); |
-} |
- |
-bool CSSPropertyParser::parseBorderImageOutset(RefPtrWillBeRawPtr<CSSQuadValue>& result) |
-{ |
- return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); |
-} |
- |
// This should go away once we drop support for -webkit-gradient |
static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CSSParserValue* a, bool horizontal) |
{ |