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 21 matching lines...) Expand all Loading... |
32 #include "StylePropertyShorthand.h" | 32 #include "StylePropertyShorthand.h" |
33 #include "core/css/CSSArrayFunctionValue.h" | 33 #include "core/css/CSSArrayFunctionValue.h" |
34 #include "core/css/CSSAspectRatioValue.h" | 34 #include "core/css/CSSAspectRatioValue.h" |
35 #include "core/css/CSSBasicShapes.h" | 35 #include "core/css/CSSBasicShapes.h" |
36 #include "core/css/CSSBorderImage.h" | 36 #include "core/css/CSSBorderImage.h" |
37 #include "core/css/CSSCanvasValue.h" | 37 #include "core/css/CSSCanvasValue.h" |
38 #include "core/css/CSSCrossfadeValue.h" | 38 #include "core/css/CSSCrossfadeValue.h" |
39 #include "core/css/CSSCursorImageValue.h" | 39 #include "core/css/CSSCursorImageValue.h" |
40 #include "core/css/CSSFontFaceSrcValue.h" | 40 #include "core/css/CSSFontFaceSrcValue.h" |
41 #include "core/css/CSSGradientValue.h" | 41 #include "core/css/CSSGradientValue.h" |
| 42 #include "core/css/CSSGridTemplateValue.h" |
42 #include "core/css/CSSImageSetValue.h" | 43 #include "core/css/CSSImageSetValue.h" |
43 #include "core/css/CSSImageValue.h" | 44 #include "core/css/CSSImageValue.h" |
44 #include "core/css/CSSInheritedValue.h" | 45 #include "core/css/CSSInheritedValue.h" |
45 #include "core/css/CSSInitialValue.h" | 46 #include "core/css/CSSInitialValue.h" |
46 #include "core/css/CSSKeyframeRule.h" | 47 #include "core/css/CSSKeyframeRule.h" |
47 #include "core/css/CSSKeyframesRule.h" | 48 #include "core/css/CSSKeyframesRule.h" |
48 #include "core/css/CSSLineBoxContainValue.h" | 49 #include "core/css/CSSLineBoxContainValue.h" |
49 #include "core/css/CSSMixFunctionValue.h" | 50 #include "core/css/CSSMixFunctionValue.h" |
50 #include "core/css/CSSPrimitiveValue.h" | 51 #include "core/css/CSSPrimitiveValue.h" |
51 #include "core/css/CSSPropertySourceData.h" | 52 #include "core/css/CSSPropertySourceData.h" |
(...skipping 2402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2454 parsedValue = parseGridPosition(); | 2455 parsedValue = parseGridPosition(); |
2455 break; | 2456 break; |
2456 | 2457 |
2457 case CSSPropertyGridColumn: | 2458 case CSSPropertyGridColumn: |
2458 case CSSPropertyGridRow: | 2459 case CSSPropertyGridRow: |
2459 case CSSPropertyGridArea: | 2460 case CSSPropertyGridArea: |
2460 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | 2461 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) |
2461 return false; | 2462 return false; |
2462 return parseGridItemPositionShorthand(propId, important); | 2463 return parseGridItemPositionShorthand(propId, important); |
2463 | 2464 |
| 2465 case CSSPropertyGridTemplate: |
| 2466 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) |
| 2467 return false; |
| 2468 parsedValue = parseGridTemplate(); |
| 2469 break; |
| 2470 |
2464 case CSSPropertyWebkitMarginCollapse: { | 2471 case CSSPropertyWebkitMarginCollapse: { |
2465 if (num == 1) { | 2472 if (num == 1) { |
2466 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); | 2473 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); |
2467 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp
ortant)) | 2474 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp
ortant)) |
2468 return false; | 2475 return false; |
2469 CSSValue* value = m_parsedProperties.last().value(); | 2476 CSSValue* value = m_parsedProperties.last().value(); |
2470 addProperty(webkitMarginCollapseShorthand().properties()[1], value,
important); | 2477 addProperty(webkitMarginCollapseShorthand().properties()[1], value,
important); |
2471 return true; | 2478 return true; |
2472 } | 2479 } |
2473 else if (num == 2) { | 2480 else if (num == 2) { |
(...skipping 2323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4797 | 4804 |
4798 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR); | 4805 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR); |
4799 } | 4806 } |
4800 | 4807 |
4801 if (!validUnit(currentValue, FNonNeg | FLength | FPercent)) | 4808 if (!validUnit(currentValue, FNonNeg | FLength | FPercent)) |
4802 return 0; | 4809 return 0; |
4803 | 4810 |
4804 return createPrimitiveNumericValue(currentValue); | 4811 return createPrimitiveNumericValue(currentValue); |
4805 } | 4812 } |
4806 | 4813 |
| 4814 PassRefPtr<CSSValue> CSSParser::parseGridTemplate() |
| 4815 { |
| 4816 NamedGridAreaMap gridAreaMap; |
| 4817 size_t rowCount = 0; |
| 4818 size_t columnCount = 0; |
| 4819 |
| 4820 while (CSSParserValue* currentValue = m_valueList->current()) { |
| 4821 if (currentValue->unit != CSSPrimitiveValue::CSS_STRING) |
| 4822 return 0; |
| 4823 |
| 4824 String gridRowNames = currentValue->string; |
| 4825 if (!gridRowNames.length()) |
| 4826 return 0; |
| 4827 |
| 4828 Vector<String> columnNames; |
| 4829 gridRowNames.split(' ', columnNames); |
| 4830 |
| 4831 if (!columnCount) { |
| 4832 columnCount = columnNames.size(); |
| 4833 ASSERT(columnCount); |
| 4834 } else if (columnCount != columnNames.size()) { |
| 4835 // The declaration is invalid is all the rows don't have the number
of columns. |
| 4836 return 0; |
| 4837 } |
| 4838 |
| 4839 for (size_t currentCol = 0; currentCol < columnCount; ++currentCol) { |
| 4840 const String& gridAreaName = columnNames[currentCol]; |
| 4841 |
| 4842 // Unamed areas are always valid (we consider them to be 1x1). |
| 4843 if (gridAreaName == ".") |
| 4844 continue; |
| 4845 |
| 4846 // We handle several grid areas with the same name at once to simpli
fy the validation code. |
| 4847 size_t lookAheadCol; |
| 4848 for (lookAheadCol = currentCol; lookAheadCol < (columnCount - 1); ++
lookAheadCol) { |
| 4849 if (columnNames[lookAheadCol + 1] != gridAreaName) |
| 4850 break; |
| 4851 } |
| 4852 |
| 4853 NamedGridAreaMap::iterator gridAreaIt = gridAreaMap.find(gridAreaNam
e); |
| 4854 if (gridAreaIt == gridAreaMap.end()) { |
| 4855 gridAreaMap.add(gridAreaName, GridCoordinate(GridSpan(rowCount,
rowCount), GridSpan(currentCol, lookAheadCol))); |
| 4856 } else { |
| 4857 GridCoordinate& gridCoordinate = gridAreaIt->value; |
| 4858 |
| 4859 // The following checks test that the grid area is a single fill
ed-in rectangle. |
| 4860 // 1. The new row is adjacent to the previously parsed row. |
| 4861 if (rowCount != gridCoordinate.rows.initialPositionIndex + 1) |
| 4862 return 0; |
| 4863 |
| 4864 // 2. The new area starts at the same position as the previously
parsed area. |
| 4865 if (currentCol != gridCoordinate.columns.initialPositionIndex) |
| 4866 return 0; |
| 4867 |
| 4868 // 3. The new area ends at the same position as the previously p
arsed area. |
| 4869 if (lookAheadCol != gridCoordinate.columns.finalPositionIndex) |
| 4870 return 0; |
| 4871 |
| 4872 ++gridCoordinate.rows.finalPositionIndex; |
| 4873 } |
| 4874 currentCol = lookAheadCol; |
| 4875 } |
| 4876 |
| 4877 ++rowCount; |
| 4878 m_valueList->next(); |
| 4879 } |
| 4880 |
| 4881 if (!rowCount || !columnCount) |
| 4882 return 0; |
| 4883 |
| 4884 return CSSGridTemplateValue::create(gridAreaMap, rowCount, columnCount); |
| 4885 } |
| 4886 |
4807 PassRefPtr<CSSValue> CSSParser::parseCounterContent(CSSParserValueList* args, bo
ol counters) | 4887 PassRefPtr<CSSValue> CSSParser::parseCounterContent(CSSParserValueList* args, bo
ol counters) |
4808 { | 4888 { |
4809 unsigned numArgs = args->size(); | 4889 unsigned numArgs = args->size(); |
4810 if (counters && numArgs != 3 && numArgs != 5) | 4890 if (counters && numArgs != 3 && numArgs != 5) |
4811 return 0; | 4891 return 0; |
4812 if (!counters && numArgs != 1 && numArgs != 3) | 4892 if (!counters && numArgs != 1 && numArgs != 3) |
4813 return 0; | 4893 return 0; |
4814 | 4894 |
4815 CSSParserValue* i = args->current(); | 4895 CSSParserValue* i = args->current(); |
4816 if (i->unit != CSSPrimitiveValue::CSS_IDENT) | 4896 if (i->unit != CSSPrimitiveValue::CSS_IDENT) |
(...skipping 6928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11745 { | 11825 { |
11746 // The tokenizer checks for the construct of an+b. | 11826 // The tokenizer checks for the construct of an+b. |
11747 // However, since the {ident} rule precedes the {nth} rule, some of those | 11827 // However, since the {ident} rule precedes the {nth} rule, some of those |
11748 // tokens are identified as string literal. Furthermore we need to accept | 11828 // tokens are identified as string literal. Furthermore we need to accept |
11749 // "odd" and "even" which does not match to an+b. | 11829 // "odd" and "even" which does not match to an+b. |
11750 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11830 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
11751 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11831 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
11752 } | 11832 } |
11753 | 11833 |
11754 } | 11834 } |
OLD | NEW |