| 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 // Apple specific properties. These will never be standardized and are pure
ly to | 1072 // Apple specific properties. These will never be standardized and are pure
ly to |
| 1088 // support custom WebKit-based Apple applications. | 1073 // support custom WebKit-based Apple applications. |
| 1089 case CSSPropertyWebkitLineClamp: | 1074 case CSSPropertyWebkitLineClamp: |
| 1090 // When specifying number of lines, don't allow 0 as a valid value | 1075 // When specifying number of lines, don't allow 0 as a valid value |
| 1091 // When specifying either type of unit, require non-negative integers | 1076 // When specifying either type of unit, require non-negative integers |
| 1092 validPrimitive = (!id && !isCalculation(value) && validUnit(value, FInte
ger | FPercent | FNonNeg) && (value->unit() == CSSPrimitiveValue::UnitType::Perc
entage || value->fValue)); | 1077 validPrimitive = (!id && !isCalculation(value) && validUnit(value, FInte
ger | FPercent | FNonNeg) && (value->unit() == CSSPrimitiveValue::UnitType::Perc
entage || value->fValue)); |
| 1093 break; | 1078 break; |
| 1094 | 1079 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 case CSSPropertyMargin: | 1164 case CSSPropertyMargin: |
| 1180 // <margin-width>{1,4} | inherit | 1165 // <margin-width>{1,4} | inherit |
| 1181 return parse4Values(propId, marginShorthand().properties(), important); | 1166 return parse4Values(propId, marginShorthand().properties(), important); |
| 1182 case CSSPropertyPadding: | 1167 case CSSPropertyPadding: |
| 1183 // <padding-width>{1,4} | inherit | 1168 // <padding-width>{1,4} | inherit |
| 1184 return parse4Values(propId, paddingShorthand().properties(), important); | 1169 return parse4Values(propId, paddingShorthand().properties(), important); |
| 1185 case CSSPropertyFlexFlow: | 1170 case CSSPropertyFlexFlow: |
| 1186 return parseShorthand(propId, flexFlowShorthand(), important); | 1171 return parseShorthand(propId, flexFlowShorthand(), important); |
| 1187 case CSSPropertyListStyle: | 1172 case CSSPropertyListStyle: |
| 1188 return parseShorthand(propId, listStyleShorthand(), important); | 1173 return parseShorthand(propId, listStyleShorthand(), important); |
| 1189 case CSSPropertyWebkitColumns: | |
| 1190 return parseColumnsShorthand(important); | |
| 1191 case CSSPropertyWebkitColumnRule: | 1174 case CSSPropertyWebkitColumnRule: |
| 1192 return parseShorthand(propId, webkitColumnRuleShorthand(), important); | 1175 return parseShorthand(propId, webkitColumnRuleShorthand(), important); |
| 1193 case CSSPropertyWebkitTextStroke: | 1176 case CSSPropertyWebkitTextStroke: |
| 1194 return parseShorthand(propId, webkitTextStrokeShorthand(), important); | 1177 return parseShorthand(propId, webkitTextStrokeShorthand(), important); |
| 1195 case CSSPropertyAnimation: | 1178 case CSSPropertyAnimation: |
| 1196 return parseAnimationShorthand(unresolvedProperty == CSSPropertyAliasWeb
kitAnimation, important); | 1179 return parseAnimationShorthand(unresolvedProperty == CSSPropertyAliasWeb
kitAnimation, important); |
| 1197 case CSSPropertyTransition: | 1180 case CSSPropertyTransition: |
| 1198 return parseTransitionShorthand(important); | 1181 return parseTransitionShorthand(important); |
| 1199 case CSSPropertyInvalid: | 1182 case CSSPropertyInvalid: |
| 1200 return false; | 1183 return false; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 case CSSPropertyMinWidth: | 1275 case CSSPropertyMinWidth: |
| 1293 case CSSPropertyMinHeight: | 1276 case CSSPropertyMinHeight: |
| 1294 case CSSPropertyWidth: | 1277 case CSSPropertyWidth: |
| 1295 case CSSPropertyHeight: | 1278 case CSSPropertyHeight: |
| 1296 case CSSPropertyWebkitMinLogicalWidth: | 1279 case CSSPropertyWebkitMinLogicalWidth: |
| 1297 case CSSPropertyWebkitMinLogicalHeight: | 1280 case CSSPropertyWebkitMinLogicalHeight: |
| 1298 case CSSPropertyWebkitLogicalWidth: | 1281 case CSSPropertyWebkitLogicalWidth: |
| 1299 case CSSPropertyWebkitLogicalHeight: | 1282 case CSSPropertyWebkitLogicalHeight: |
| 1300 case CSSPropertyClip: | 1283 case CSSPropertyClip: |
| 1301 case CSSPropertyTouchAction: | 1284 case CSSPropertyTouchAction: |
| 1285 case CSSPropertyWebkitColumnWidth: |
| 1286 case CSSPropertyWebkitColumnCount: |
| 1287 case CSSPropertyWebkitColumns: |
| 1288 case CSSPropertyWebkitColumnGap: |
| 1289 case CSSPropertyWebkitColumnSpan: |
| 1302 validPrimitive = false; | 1290 validPrimitive = false; |
| 1303 break; | 1291 break; |
| 1304 | 1292 |
| 1305 case CSSPropertyScrollSnapPointsX: | 1293 case CSSPropertyScrollSnapPointsX: |
| 1306 case CSSPropertyScrollSnapPointsY: | 1294 case CSSPropertyScrollSnapPointsY: |
| 1307 parsedValue = parseScrollSnapPoints(); | 1295 parsedValue = parseScrollSnapPoints(); |
| 1308 break; | 1296 break; |
| 1309 case CSSPropertyScrollSnapCoordinate: | 1297 case CSSPropertyScrollSnapCoordinate: |
| 1310 parsedValue = parseScrollSnapCoordinate(); | 1298 parsedValue = parseScrollSnapCoordinate(); |
| 1311 break; | 1299 break; |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 // Fill in any remaining properties with the initial value and add | 1622 // Fill in any remaining properties with the initial value and add |
| 1635 for (size_t i = 0; i < numProperties; ++i) { | 1623 for (size_t i = 0; i < numProperties; ++i) { |
| 1636 if (!parsedProperty[i]) | 1624 if (!parsedProperty[i]) |
| 1637 values[i]->append(cssValuePool().createImplicitInitialValue()); | 1625 values[i]->append(cssValuePool().createImplicitInitialValue()); |
| 1638 addProperty(shorthand.properties()[i], values[i].release(), important); | 1626 addProperty(shorthand.properties()[i], values[i].release(), important); |
| 1639 } | 1627 } |
| 1640 | 1628 |
| 1641 return true; | 1629 return true; |
| 1642 } | 1630 } |
| 1643 | 1631 |
| 1644 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnWidth() | |
| 1645 { | |
| 1646 CSSParserValue* value = m_valueList->current(); | |
| 1647 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in | |
| 1648 // the 'columns' shorthand property. | |
| 1649 if (value->id == CSSValueAuto || (validUnit(value, FLength | FNonNeg, HTMLSt
andardMode) && (m_parsedCalculation || value->fValue != 0))) { | |
| 1650 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); | |
| 1651 m_valueList->next(); | |
| 1652 return parsedValue; | |
| 1653 } | |
| 1654 return nullptr; | |
| 1655 } | |
| 1656 | |
| 1657 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnCount() | |
| 1658 { | |
| 1659 CSSParserValue* value = m_valueList->current(); | |
| 1660 if (value->id == CSSValueAuto || validUnit(value, FPositiveInteger)) { | |
| 1661 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); | |
| 1662 m_valueList->next(); | |
| 1663 return parsedValue; | |
| 1664 } | |
| 1665 return nullptr; | |
| 1666 } | |
| 1667 | |
| 1668 bool CSSPropertyParser::parseColumnsShorthand(bool important) | |
| 1669 { | |
| 1670 RefPtrWillBeRawPtr<CSSValue> columnWidth = nullptr; | |
| 1671 RefPtrWillBeRawPtr<CSSValue> columnCount = nullptr; | |
| 1672 | |
| 1673 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur
rent(); propertiesParsed++) { | |
| 1674 if (propertiesParsed >= 2) | |
| 1675 return false; // Too many values for this shorthand. Invalid declara
tion. | |
| 1676 if (value->id == CSSValueAuto) { | |
| 1677 // Skip 'auto' as we will use it for initial value if no width/count
was parsed. | |
| 1678 m_valueList->next(); | |
| 1679 } else { | |
| 1680 if (!columnWidth) { | |
| 1681 if ((columnWidth = parseColumnWidth())) | |
| 1682 continue; | |
| 1683 } | |
| 1684 if (!columnCount) { | |
| 1685 if ((columnCount = parseColumnCount())) | |
| 1686 continue; | |
| 1687 } | |
| 1688 // If we didn't find at least one match, this is an | |
| 1689 // invalid shorthand and we have to ignore it. | |
| 1690 return false; | |
| 1691 } | |
| 1692 } | |
| 1693 | |
| 1694 if (!columnWidth) | |
| 1695 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto); | |
| 1696 addProperty(CSSPropertyWebkitColumnWidth, columnWidth, important); | |
| 1697 if (!columnCount) | |
| 1698 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto); | |
| 1699 addProperty(CSSPropertyWebkitColumnCount, columnCount, important); | |
| 1700 return true; | |
| 1701 } | |
| 1702 | |
| 1703 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty
Shorthand& shorthand, bool important) | 1632 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty
Shorthand& shorthand, bool important) |
| 1704 { | 1633 { |
| 1705 // We try to match as many properties as possible | 1634 // We try to match as many properties as possible |
| 1706 // We set up an array of booleans to mark which property has been found, | 1635 // We set up an array of booleans to mark which property has been found, |
| 1707 // and we try to search for properties until it makes no longer any sense. | 1636 // and we try to search for properties until it makes no longer any sense. |
| 1708 ShorthandScope scope(this, propId); | 1637 ShorthandScope scope(this, propId); |
| 1709 | 1638 |
| 1710 bool found = false; | 1639 bool found = false; |
| 1711 unsigned propertiesParsed = 0; | 1640 unsigned propertiesParsed = 0; |
| 1712 bool propertyFound[6] = { false, false, false, false, false, false }; // 6 i
s enough size. | 1641 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... |
| 6802 } | 6731 } |
| 6803 } | 6732 } |
| 6804 | 6733 |
| 6805 if (!list->length()) | 6734 if (!list->length()) |
| 6806 return nullptr; | 6735 return nullptr; |
| 6807 | 6736 |
| 6808 return list.release(); | 6737 return list.release(); |
| 6809 } | 6738 } |
| 6810 | 6739 |
| 6811 } // namespace blink | 6740 } // namespace blink |
| OLD | NEW |