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 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 break; | 1130 break; |
1131 | 1131 |
1132 case CSSPropertyGridTemplate: | 1132 case CSSPropertyGridTemplate: |
1133 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 1133 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
1134 return parseGridTemplateShorthand(important); | 1134 return parseGridTemplateShorthand(important); |
1135 | 1135 |
1136 case CSSPropertyGrid: | 1136 case CSSPropertyGrid: |
1137 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 1137 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
1138 return parseGridShorthand(important); | 1138 return parseGridShorthand(important); |
1139 | 1139 |
1140 case CSSPropertyWebkitColumnCount: | |
1141 parsedValue = parseColumnCount(); | |
1142 break; | |
1143 case CSSPropertyWebkitColumnGap: // normal | <length> | |
1144 if (id == CSSValueNormal) | |
1145 validPrimitive = true; | |
1146 else | |
1147 validPrimitive = validUnit(value, FLength | FNonNeg); | |
1148 break; | |
1149 case CSSPropertyWebkitColumnSpan: // none | all | 1 (will be dropped in the
unprefixed property) | |
1150 validPrimitive = id == CSSValueAll || id == CSSValueNone || (value->unit
() == CSSPrimitiveValue::UnitType::Number && value->fValue == 1); | |
1151 break; | |
1152 case CSSPropertyWebkitColumnWidth: // auto | <length> | |
1153 parsedValue = parseColumnWidth(); | |
1154 break; | |
1155 // End of CSS3 properties | 1140 // End of CSS3 properties |
1156 | 1141 |
1157 // Apple specific properties. These will never be standardized and are pure
ly to | 1142 // Apple specific properties. These will never be standardized and are pure
ly to |
1158 // support custom WebKit-based Apple applications. | 1143 // support custom WebKit-based Apple applications. |
1159 case CSSPropertyWebkitLineClamp: | 1144 case CSSPropertyWebkitLineClamp: |
1160 // When specifying number of lines, don't allow 0 as a valid value | 1145 // When specifying number of lines, don't allow 0 as a valid value |
1161 // When specifying either type of unit, require non-negative integers | 1146 // When specifying either type of unit, require non-negative integers |
1162 validPrimitive = (!id && !isCalculation(value) && validUnit(value, FInte
ger | FPercent | FNonNeg) && (value->unit() == CSSPrimitiveValue::UnitType::Perc
entage || value->fValue)); | 1147 validPrimitive = (!id && !isCalculation(value) && validUnit(value, FInte
ger | FPercent | FNonNeg) && (value->unit() == CSSPrimitiveValue::UnitType::Perc
entage || value->fValue)); |
1163 break; | 1148 break; |
1164 | 1149 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 case CSSPropertyMargin: | 1234 case CSSPropertyMargin: |
1250 // <margin-width>{1,4} | inherit | 1235 // <margin-width>{1,4} | inherit |
1251 return parse4Values(propId, marginShorthand().properties(), important); | 1236 return parse4Values(propId, marginShorthand().properties(), important); |
1252 case CSSPropertyPadding: | 1237 case CSSPropertyPadding: |
1253 // <padding-width>{1,4} | inherit | 1238 // <padding-width>{1,4} | inherit |
1254 return parse4Values(propId, paddingShorthand().properties(), important); | 1239 return parse4Values(propId, paddingShorthand().properties(), important); |
1255 case CSSPropertyFlexFlow: | 1240 case CSSPropertyFlexFlow: |
1256 return parseShorthand(propId, flexFlowShorthand(), important); | 1241 return parseShorthand(propId, flexFlowShorthand(), important); |
1257 case CSSPropertyListStyle: | 1242 case CSSPropertyListStyle: |
1258 return parseShorthand(propId, listStyleShorthand(), important); | 1243 return parseShorthand(propId, listStyleShorthand(), important); |
1259 case CSSPropertyWebkitColumns: | |
1260 return parseColumnsShorthand(important); | |
1261 case CSSPropertyWebkitColumnRule: | 1244 case CSSPropertyWebkitColumnRule: |
1262 return parseShorthand(propId, webkitColumnRuleShorthand(), important); | 1245 return parseShorthand(propId, webkitColumnRuleShorthand(), important); |
1263 case CSSPropertyWebkitTextStroke: | 1246 case CSSPropertyWebkitTextStroke: |
1264 return parseShorthand(propId, webkitTextStrokeShorthand(), important); | 1247 return parseShorthand(propId, webkitTextStrokeShorthand(), important); |
1265 case CSSPropertyAnimation: | 1248 case CSSPropertyAnimation: |
1266 return parseAnimationShorthand(unresolvedProperty == CSSPropertyAliasWeb
kitAnimation, important); | 1249 return parseAnimationShorthand(unresolvedProperty == CSSPropertyAliasWeb
kitAnimation, important); |
1267 case CSSPropertyTransition: | 1250 case CSSPropertyTransition: |
1268 return parseTransitionShorthand(important); | 1251 return parseTransitionShorthand(important); |
1269 case CSSPropertyInvalid: | 1252 case CSSPropertyInvalid: |
1270 return false; | 1253 return false; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 case CSSPropertyTabSize: | 1333 case CSSPropertyTabSize: |
1351 case CSSPropertyFontSize: | 1334 case CSSPropertyFontSize: |
1352 case CSSPropertyLineHeight: | 1335 case CSSPropertyLineHeight: |
1353 case CSSPropertyRotate: | 1336 case CSSPropertyRotate: |
1354 case CSSPropertyFont: | 1337 case CSSPropertyFont: |
1355 case CSSPropertyWebkitBorderHorizontalSpacing: | 1338 case CSSPropertyWebkitBorderHorizontalSpacing: |
1356 case CSSPropertyWebkitBorderVerticalSpacing: | 1339 case CSSPropertyWebkitBorderVerticalSpacing: |
1357 case CSSPropertyBorderSpacing: | 1340 case CSSPropertyBorderSpacing: |
1358 case CSSPropertyCounterIncrement: | 1341 case CSSPropertyCounterIncrement: |
1359 case CSSPropertyCounterReset: | 1342 case CSSPropertyCounterReset: |
| 1343 case CSSPropertyWebkitColumnWidth: |
| 1344 case CSSPropertyWebkitColumnCount: |
| 1345 case CSSPropertyWebkitColumns: |
| 1346 case CSSPropertyWebkitColumnGap: |
| 1347 case CSSPropertyWebkitColumnSpan: |
1360 validPrimitive = false; | 1348 validPrimitive = false; |
1361 break; | 1349 break; |
1362 | 1350 |
1363 case CSSPropertyScrollSnapPointsX: | 1351 case CSSPropertyScrollSnapPointsX: |
1364 case CSSPropertyScrollSnapPointsY: | 1352 case CSSPropertyScrollSnapPointsY: |
1365 parsedValue = parseScrollSnapPoints(); | 1353 parsedValue = parseScrollSnapPoints(); |
1366 break; | 1354 break; |
1367 case CSSPropertyScrollSnapCoordinate: | 1355 case CSSPropertyScrollSnapCoordinate: |
1368 parsedValue = parseScrollSnapCoordinate(); | 1356 parsedValue = parseScrollSnapCoordinate(); |
1369 break; | 1357 break; |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1692 // Fill in any remaining properties with the initial value and add | 1680 // Fill in any remaining properties with the initial value and add |
1693 for (size_t i = 0; i < numProperties; ++i) { | 1681 for (size_t i = 0; i < numProperties; ++i) { |
1694 if (!parsedProperty[i]) | 1682 if (!parsedProperty[i]) |
1695 values[i]->append(cssValuePool().createImplicitInitialValue()); | 1683 values[i]->append(cssValuePool().createImplicitInitialValue()); |
1696 addProperty(shorthand.properties()[i], values[i].release(), important); | 1684 addProperty(shorthand.properties()[i], values[i].release(), important); |
1697 } | 1685 } |
1698 | 1686 |
1699 return true; | 1687 return true; |
1700 } | 1688 } |
1701 | 1689 |
1702 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnWidth() | |
1703 { | |
1704 CSSParserValue* value = m_valueList->current(); | |
1705 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in | |
1706 // the 'columns' shorthand property. | |
1707 if (value->id == CSSValueAuto || (validUnit(value, FLength | FNonNeg, HTMLSt
andardMode) && (m_parsedCalculation || value->fValue != 0))) { | |
1708 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); | |
1709 m_valueList->next(); | |
1710 return parsedValue; | |
1711 } | |
1712 return nullptr; | |
1713 } | |
1714 | |
1715 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnCount() | |
1716 { | |
1717 CSSParserValue* value = m_valueList->current(); | |
1718 if (value->id == CSSValueAuto || validUnit(value, FPositiveInteger)) { | |
1719 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); | |
1720 m_valueList->next(); | |
1721 return parsedValue; | |
1722 } | |
1723 return nullptr; | |
1724 } | |
1725 | |
1726 bool CSSPropertyParser::parseColumnsShorthand(bool important) | |
1727 { | |
1728 RefPtrWillBeRawPtr<CSSValue> columnWidth = nullptr; | |
1729 RefPtrWillBeRawPtr<CSSValue> columnCount = nullptr; | |
1730 | |
1731 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur
rent(); propertiesParsed++) { | |
1732 if (propertiesParsed >= 2) | |
1733 return false; // Too many values for this shorthand. Invalid declara
tion. | |
1734 if (value->id == CSSValueAuto) { | |
1735 // Skip 'auto' as we will use it for initial value if no width/count
was parsed. | |
1736 m_valueList->next(); | |
1737 } else { | |
1738 if (!columnWidth) { | |
1739 if ((columnWidth = parseColumnWidth())) | |
1740 continue; | |
1741 } | |
1742 if (!columnCount) { | |
1743 if ((columnCount = parseColumnCount())) | |
1744 continue; | |
1745 } | |
1746 // If we didn't find at least one match, this is an | |
1747 // invalid shorthand and we have to ignore it. | |
1748 return false; | |
1749 } | |
1750 } | |
1751 | |
1752 if (!columnWidth) | |
1753 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto); | |
1754 addProperty(CSSPropertyWebkitColumnWidth, columnWidth, important); | |
1755 if (!columnCount) | |
1756 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto); | |
1757 addProperty(CSSPropertyWebkitColumnCount, columnCount, important); | |
1758 return true; | |
1759 } | |
1760 | |
1761 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty
Shorthand& shorthand, bool important) | 1690 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty
Shorthand& shorthand, bool important) |
1762 { | 1691 { |
1763 // We try to match as many properties as possible | 1692 // We try to match as many properties as possible |
1764 // We set up an array of booleans to mark which property has been found, | 1693 // We set up an array of booleans to mark which property has been found, |
1765 // and we try to search for properties until it makes no longer any sense. | 1694 // and we try to search for properties until it makes no longer any sense. |
1766 ShorthandScope scope(this, propId); | 1695 ShorthandScope scope(this, propId); |
1767 | 1696 |
1768 bool found = false; | 1697 bool found = false; |
1769 unsigned propertiesParsed = 0; | 1698 unsigned propertiesParsed = 0; |
1770 bool propertyFound[6] = { false, false, false, false, false, false }; // 6 i
s enough size. | 1699 bool propertyFound[6] = { false, false, false, false, false, false }; // 6 i
s enough size. |
(...skipping 5289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7060 } | 6989 } |
7061 } | 6990 } |
7062 | 6991 |
7063 if (!list->length()) | 6992 if (!list->length()) |
7064 return nullptr; | 6993 return nullptr; |
7065 | 6994 |
7066 return list.release(); | 6995 return list.release(); |
7067 } | 6996 } |
7068 | 6997 |
7069 } // namespace blink | 6998 } // namespace blink |
OLD | NEW |