| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
| 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
| 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
| 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
| 10 * | 10 * |
| (...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 break; | 1060 break; |
| 1061 | 1061 |
| 1062 case CSSPropertyGridTemplate: | 1062 case CSSPropertyGridTemplate: |
| 1063 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 1063 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 1064 return parseGridTemplateShorthand(important); | 1064 return parseGridTemplateShorthand(important); |
| 1065 | 1065 |
| 1066 case CSSPropertyGrid: | 1066 case CSSPropertyGrid: |
| 1067 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 1067 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 1068 return parseGridShorthand(important); | 1068 return parseGridShorthand(important); |
| 1069 | 1069 |
| 1070 case CSSPropertyWebkitColumnCount: | |
| 1071 parsedValue = parseColumnCount(); | |
| 1072 break; | |
| 1073 case CSSPropertyWebkitColumnGap: // normal | <length> | |
| 1074 if (id == CSSValueNormal) | |
| 1075 validPrimitive = true; | |
| 1076 else | |
| 1077 validPrimitive = validUnit(value, FLength | FNonNeg); | |
| 1078 break; | |
| 1079 case CSSPropertyWebkitColumnSpan: // none | all | 1 (will be dropped in the
unprefixed property) | |
| 1080 validPrimitive = id == CSSValueAll || id == CSSValueNone || (value->unit
() == CSSPrimitiveValue::UnitType::Number && value->fValue == 1); | |
| 1081 break; | |
| 1082 case CSSPropertyWebkitColumnWidth: // auto | <length> | |
| 1083 parsedValue = parseColumnWidth(); | |
| 1084 break; | |
| 1085 // End of CSS3 properties | 1070 // End of CSS3 properties |
| 1086 | 1071 |
| 1087 case CSSPropertyWebkitAppRegion: | 1072 case CSSPropertyWebkitAppRegion: |
| 1088 if (id >= CSSValueDrag && id <= CSSValueNoDrag) | 1073 if (id >= CSSValueDrag && id <= CSSValueNoDrag) |
| 1089 validPrimitive = true; | 1074 validPrimitive = true; |
| 1090 break; | 1075 break; |
| 1091 | 1076 |
| 1092 case CSSPropertyWebkitTapHighlightColor: | 1077 case CSSPropertyWebkitTapHighlightColor: |
| 1093 parsedValue = parseColor(m_valueList->current()); | 1078 parsedValue = parseColor(m_valueList->current()); |
| 1094 if (parsedValue) | 1079 if (parsedValue) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 case CSSPropertyMargin: | 1140 case CSSPropertyMargin: |
| 1156 // <margin-width>{1,4} | inherit | 1141 // <margin-width>{1,4} | inherit |
| 1157 return parse4Values(propId, marginShorthand().properties(), important); | 1142 return parse4Values(propId, marginShorthand().properties(), important); |
| 1158 case CSSPropertyPadding: | 1143 case CSSPropertyPadding: |
| 1159 // <padding-width>{1,4} | inherit | 1144 // <padding-width>{1,4} | inherit |
| 1160 return parse4Values(propId, paddingShorthand().properties(), important); | 1145 return parse4Values(propId, paddingShorthand().properties(), important); |
| 1161 case CSSPropertyFlexFlow: | 1146 case CSSPropertyFlexFlow: |
| 1162 return parseShorthand(propId, flexFlowShorthand(), important); | 1147 return parseShorthand(propId, flexFlowShorthand(), important); |
| 1163 case CSSPropertyListStyle: | 1148 case CSSPropertyListStyle: |
| 1164 return parseShorthand(propId, listStyleShorthand(), important); | 1149 return parseShorthand(propId, listStyleShorthand(), important); |
| 1165 case CSSPropertyWebkitColumns: | |
| 1166 return parseColumnsShorthand(important); | |
| 1167 case CSSPropertyWebkitColumnRule: | 1150 case CSSPropertyWebkitColumnRule: |
| 1168 return parseShorthand(propId, webkitColumnRuleShorthand(), important); | 1151 return parseShorthand(propId, webkitColumnRuleShorthand(), important); |
| 1169 case CSSPropertyWebkitTextStroke: | 1152 case CSSPropertyWebkitTextStroke: |
| 1170 return parseShorthand(propId, webkitTextStrokeShorthand(), important); | 1153 return parseShorthand(propId, webkitTextStrokeShorthand(), important); |
| 1171 case CSSPropertyAnimation: | 1154 case CSSPropertyAnimation: |
| 1172 return parseAnimationShorthand(unresolvedProperty == CSSPropertyAliasWeb
kitAnimation, important); | 1155 return parseAnimationShorthand(unresolvedProperty == CSSPropertyAliasWeb
kitAnimation, important); |
| 1173 case CSSPropertyTransition: | 1156 case CSSPropertyTransition: |
| 1174 return parseTransitionShorthand(important); | 1157 return parseTransitionShorthand(important); |
| 1175 case CSSPropertyInvalid: | 1158 case CSSPropertyInvalid: |
| 1176 return false; | 1159 return false; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 case CSSPropertyWebkitMinLogicalWidth: | 1255 case CSSPropertyWebkitMinLogicalWidth: |
| 1273 case CSSPropertyWebkitMinLogicalHeight: | 1256 case CSSPropertyWebkitMinLogicalHeight: |
| 1274 case CSSPropertyWebkitLogicalWidth: | 1257 case CSSPropertyWebkitLogicalWidth: |
| 1275 case CSSPropertyWebkitLogicalHeight: | 1258 case CSSPropertyWebkitLogicalHeight: |
| 1276 case CSSPropertyClip: | 1259 case CSSPropertyClip: |
| 1277 case CSSPropertyTouchAction: | 1260 case CSSPropertyTouchAction: |
| 1278 case CSSPropertyWebkitLineClamp: | 1261 case CSSPropertyWebkitLineClamp: |
| 1279 case CSSPropertyWebkitFontSizeDelta: | 1262 case CSSPropertyWebkitFontSizeDelta: |
| 1280 case CSSPropertyWebkitHyphenateCharacter: | 1263 case CSSPropertyWebkitHyphenateCharacter: |
| 1281 case CSSPropertyWebkitLocale: | 1264 case CSSPropertyWebkitLocale: |
| 1265 case CSSPropertyWebkitColumnWidth: |
| 1266 case CSSPropertyWebkitColumnCount: |
| 1267 case CSSPropertyWebkitColumns: |
| 1268 case CSSPropertyWebkitColumnGap: |
| 1269 case CSSPropertyWebkitColumnSpan: |
| 1282 validPrimitive = false; | 1270 validPrimitive = false; |
| 1283 break; | 1271 break; |
| 1284 | 1272 |
| 1285 case CSSPropertyScrollSnapPointsX: | 1273 case CSSPropertyScrollSnapPointsX: |
| 1286 case CSSPropertyScrollSnapPointsY: | 1274 case CSSPropertyScrollSnapPointsY: |
| 1287 parsedValue = parseScrollSnapPoints(); | 1275 parsedValue = parseScrollSnapPoints(); |
| 1288 break; | 1276 break; |
| 1289 case CSSPropertyScrollSnapCoordinate: | 1277 case CSSPropertyScrollSnapCoordinate: |
| 1290 parsedValue = parseScrollSnapCoordinate(); | 1278 parsedValue = parseScrollSnapCoordinate(); |
| 1291 break; | 1279 break; |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 // Fill in any remaining properties with the initial value and add | 1602 // Fill in any remaining properties with the initial value and add |
| 1615 for (size_t i = 0; i < numProperties; ++i) { | 1603 for (size_t i = 0; i < numProperties; ++i) { |
| 1616 if (!parsedProperty[i]) | 1604 if (!parsedProperty[i]) |
| 1617 values[i]->append(cssValuePool().createImplicitInitialValue()); | 1605 values[i]->append(cssValuePool().createImplicitInitialValue()); |
| 1618 addProperty(shorthand.properties()[i], values[i].release(), important); | 1606 addProperty(shorthand.properties()[i], values[i].release(), important); |
| 1619 } | 1607 } |
| 1620 | 1608 |
| 1621 return true; | 1609 return true; |
| 1622 } | 1610 } |
| 1623 | 1611 |
| 1624 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnWidth() | |
| 1625 { | |
| 1626 CSSParserValue* value = m_valueList->current(); | |
| 1627 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in | |
| 1628 // the 'columns' shorthand property. | |
| 1629 if (value->id == CSSValueAuto || (validUnit(value, FLength | FNonNeg, HTMLSt
andardMode) && (m_parsedCalculation || value->fValue != 0))) { | |
| 1630 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); | |
| 1631 m_valueList->next(); | |
| 1632 return parsedValue; | |
| 1633 } | |
| 1634 return nullptr; | |
| 1635 } | |
| 1636 | |
| 1637 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnCount() | |
| 1638 { | |
| 1639 CSSParserValue* value = m_valueList->current(); | |
| 1640 if (value->id == CSSValueAuto || validUnit(value, FPositiveInteger)) { | |
| 1641 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); | |
| 1642 m_valueList->next(); | |
| 1643 return parsedValue; | |
| 1644 } | |
| 1645 return nullptr; | |
| 1646 } | |
| 1647 | |
| 1648 bool CSSPropertyParser::parseColumnsShorthand(bool important) | |
| 1649 { | |
| 1650 RefPtrWillBeRawPtr<CSSValue> columnWidth = nullptr; | |
| 1651 RefPtrWillBeRawPtr<CSSValue> columnCount = nullptr; | |
| 1652 | |
| 1653 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur
rent(); propertiesParsed++) { | |
| 1654 if (propertiesParsed >= 2) | |
| 1655 return false; // Too many values for this shorthand. Invalid declara
tion. | |
| 1656 if (value->id == CSSValueAuto) { | |
| 1657 // Skip 'auto' as we will use it for initial value if no width/count
was parsed. | |
| 1658 m_valueList->next(); | |
| 1659 } else { | |
| 1660 if (!columnWidth) { | |
| 1661 if ((columnWidth = parseColumnWidth())) | |
| 1662 continue; | |
| 1663 } | |
| 1664 if (!columnCount) { | |
| 1665 if ((columnCount = parseColumnCount())) | |
| 1666 continue; | |
| 1667 } | |
| 1668 // If we didn't find at least one match, this is an | |
| 1669 // invalid shorthand and we have to ignore it. | |
| 1670 return false; | |
| 1671 } | |
| 1672 } | |
| 1673 | |
| 1674 if (!columnWidth) | |
| 1675 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto); | |
| 1676 addProperty(CSSPropertyWebkitColumnWidth, columnWidth, important); | |
| 1677 if (!columnCount) | |
| 1678 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto); | |
| 1679 addProperty(CSSPropertyWebkitColumnCount, columnCount, important); | |
| 1680 return true; | |
| 1681 } | |
| 1682 | |
| 1683 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty
Shorthand& shorthand, bool important) | 1612 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty
Shorthand& shorthand, bool important) |
| 1684 { | 1613 { |
| 1685 // We try to match as many properties as possible | 1614 // We try to match as many properties as possible |
| 1686 // We set up an array of booleans to mark which property has been found, | 1615 // We set up an array of booleans to mark which property has been found, |
| 1687 // and we try to search for properties until it makes no longer any sense. | 1616 // and we try to search for properties until it makes no longer any sense. |
| 1688 ShorthandScope scope(this, propId); | 1617 ShorthandScope scope(this, propId); |
| 1689 | 1618 |
| 1690 bool found = false; | 1619 bool found = false; |
| 1691 unsigned propertiesParsed = 0; | 1620 unsigned propertiesParsed = 0; |
| 1692 bool propertyFound[6] = { false, false, false, false, false, false }; // 6 i
s enough size. | 1621 bool propertyFound[6] = { false, false, false, false, false, false }; // 6 i
s enough size. |
| (...skipping 5089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6782 } | 6711 } |
| 6783 } | 6712 } |
| 6784 | 6713 |
| 6785 if (!list->length()) | 6714 if (!list->length()) |
| 6786 return nullptr; | 6715 return nullptr; |
| 6787 | 6716 |
| 6788 return list.release(); | 6717 return list.release(); |
| 6789 } | 6718 } |
| 6790 | 6719 |
| 6791 } // namespace blink | 6720 } // namespace blink |
| OLD | NEW |