Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| index 45ffcb58c7501647e7497c3f7466e4822a37651c..15023e3cfc25830fd7453542a4b475c7bfd61be8 100644 |
| --- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| +++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| @@ -4223,6 +4223,101 @@ bool CSSPropertyParser::consumeBorderImage(CSSPropertyID property, bool importan |
| return false; |
| } |
| +static inline CSSValueID mapFromPageBreakBetween(CSSValueID value) |
| +{ |
| + if (value == CSSValueAlways) |
| + return CSSValuePage; |
| + // TODO(mstensho): "avoid" should just return "avoid", not "avoid-page", according to the spec. |
| + if (value == CSSValueAvoid) |
| + return CSSValueAvoidPage; |
| + if (value == CSSValueAuto || value == CSSValueLeft || value == CSSValueRight) |
| + return value; |
| + return CSSValueInvalid; |
| +} |
| + |
| +static inline CSSValueID mapFromColumnBreakBetween(CSSValueID value) |
| +{ |
| + if (value == CSSValueAlways) |
| + return CSSValueColumn; |
| + // TODO(mstensho): "avoid" should just return "avoid", not "avoid-column". |
| + if (value == CSSValueAvoid) |
| + return CSSValueAvoidColumn; |
| + // TODO(mstensho): column break properties shouldn't take 'left' and 'right' values (but |
| + // allowing it for now, since that's what we've always done). |
| + if (value == CSSValueAuto || value == CSSValueLeft || value == CSSValueRight) |
| + return value; |
| + return CSSValueInvalid; |
| +} |
| + |
| +static inline CSSValueID mapFromPageBreakInside(CSSValueID value) |
| +{ |
| + // TODO(mstensho): "avoid" should just return "avoid", not "avoid-page", according to the spec. |
| + if (value == CSSValueAvoid) |
| + return CSSValueAvoidPage; |
| + if (value == CSSValueAuto) |
| + return value; |
| + return CSSValueInvalid; |
| +} |
| + |
| +static inline CSSValueID mapFromColumnBreakInside(CSSValueID value) |
| +{ |
| + // TODO(mstensho): "avoid" should just return "avoid", not "avoid-column". |
| + if (value == CSSValueAvoid) |
| + return CSSValueAvoidColumn; |
| + if (value == CSSValueAuto) |
| + return value; |
| + return CSSValueInvalid; |
| +} |
| + |
| +static inline CSSPropertyID mapFromLegacyBreakProperty(CSSPropertyID property) |
| +{ |
| + if (property == CSSPropertyPageBreakAfter || property == CSSPropertyWebkitColumnBreakAfter) |
| + return CSSPropertyBreakAfter; |
| + if (property == CSSPropertyPageBreakBefore || property == CSSPropertyWebkitColumnBreakBefore) |
| + return CSSPropertyBreakBefore; |
| + if (property == CSSPropertyPageBreakInside || property == CSSPropertyWebkitColumnBreakInside) |
|
Timothy Loh
2016/02/18 06:25:45
I prefer the style of having the last if just be a
mstensho (USE GERRIT)
2016/02/18 09:05:26
I like it!
Done.
|
| + return CSSPropertyBreakInside; |
| + ASSERT_NOT_REACHED(); |
| + return property; |
| +} |
| + |
| +bool CSSPropertyParser::consumeLegacyBreakProperty(CSSPropertyID property, bool important) |
| +{ |
| + // The fragmentation spec says that page-break-(after|before|inside) are to be treated as |
| + // shorthands for their break-(after|before|inside) counterparts. We'll do the same for the |
| + // non-standard properties -webkit-column-break-(after|before|inside). |
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> keyword = consumeIdent(m_range); |
| + if (!keyword) |
| + return false; |
| + if (!m_range.atEnd()) |
| + return false; |
| + CSSValueID value = keyword->getValueID(); |
| + switch (property) { |
| + case CSSPropertyPageBreakAfter: |
| + case CSSPropertyPageBreakBefore: |
| + value = mapFromPageBreakBetween(value); |
| + break; |
| + case CSSPropertyWebkitColumnBreakAfter: |
| + case CSSPropertyWebkitColumnBreakBefore: |
| + value = mapFromColumnBreakBetween(value); |
| + break; |
| + case CSSPropertyPageBreakInside: |
| + value = mapFromPageBreakInside(value); |
| + break; |
| + case CSSPropertyWebkitColumnBreakInside: |
| + value = mapFromColumnBreakInside(value); |
| + break; |
| + default: |
| + ASSERT_NOT_REACHED(); |
| + } |
| + if (value == CSSValueInvalid) |
| + return false; |
| + |
| + CSSPropertyID genericBreakProperty = mapFromLegacyBreakProperty(property); |
| + addProperty(genericBreakProperty, cssValuePool().createIdentifierValue(value), important); |
| + return true; |
| +} |
| + |
| bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool important) |
| { |
| CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
| @@ -4357,6 +4452,13 @@ bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool im |
| case CSSPropertyBorderImage: |
| case CSSPropertyWebkitMaskBoxImage: |
| return consumeBorderImage(property, important); |
| + case CSSPropertyPageBreakAfter: |
| + case CSSPropertyPageBreakBefore: |
| + case CSSPropertyPageBreakInside: |
| + case CSSPropertyWebkitColumnBreakAfter: |
| + case CSSPropertyWebkitColumnBreakBefore: |
| + case CSSPropertyWebkitColumnBreakInside: |
| + return consumeLegacyBreakProperty(property, important); |
| default: |
| m_currentShorthand = oldShorthand; |
| CSSParserValueList valueList(m_range); |