Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 #include "RuntimeEnabledFeatures.h" | 31 #include "RuntimeEnabledFeatures.h" |
| 32 #include "core/css/CSSArrayFunctionValue.h" | 32 #include "core/css/CSSArrayFunctionValue.h" |
| 33 #include "core/css/CSSAspectRatioValue.h" | 33 #include "core/css/CSSAspectRatioValue.h" |
| 34 #include "core/css/CSSBasicShapes.h" | 34 #include "core/css/CSSBasicShapes.h" |
| 35 #include "core/css/CSSBorderImage.h" | 35 #include "core/css/CSSBorderImage.h" |
| 36 #include "core/css/CSSCanvasValue.h" | 36 #include "core/css/CSSCanvasValue.h" |
| 37 #include "core/css/CSSCrossfadeValue.h" | 37 #include "core/css/CSSCrossfadeValue.h" |
| 38 #include "core/css/CSSCursorImageValue.h" | 38 #include "core/css/CSSCursorImageValue.h" |
| 39 #include "core/css/CSSFontFaceSrcValue.h" | 39 #include "core/css/CSSFontFaceSrcValue.h" |
| 40 #include "core/css/CSSGradientValue.h" | 40 #include "core/css/CSSGradientValue.h" |
| 41 #include "core/css/CSSGridTemplateValue.h" | |
| 41 #include "core/css/CSSImageSetValue.h" | 42 #include "core/css/CSSImageSetValue.h" |
| 42 #include "core/css/CSSImageValue.h" | 43 #include "core/css/CSSImageValue.h" |
| 43 #include "core/css/CSSInheritedValue.h" | 44 #include "core/css/CSSInheritedValue.h" |
| 44 #include "core/css/CSSInitialValue.h" | 45 #include "core/css/CSSInitialValue.h" |
| 45 #include "core/css/CSSKeyframeRule.h" | 46 #include "core/css/CSSKeyframeRule.h" |
| 46 #include "core/css/CSSKeyframesRule.h" | 47 #include "core/css/CSSKeyframesRule.h" |
| 47 #include "core/css/CSSLineBoxContainValue.h" | 48 #include "core/css/CSSLineBoxContainValue.h" |
| 48 #include "core/css/CSSMixFunctionValue.h" | 49 #include "core/css/CSSMixFunctionValue.h" |
| 49 #include "core/css/CSSPrimitiveValue.h" | 50 #include "core/css/CSSPrimitiveValue.h" |
| 50 #include "core/css/CSSPropertySourceData.h" | 51 #include "core/css/CSSPropertySourceData.h" |
| (...skipping 2399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2450 parsedValue = parseGridPosition(); | 2451 parsedValue = parseGridPosition(); |
| 2451 break; | 2452 break; |
| 2452 | 2453 |
| 2453 case CSSPropertyGridColumn: | 2454 case CSSPropertyGridColumn: |
| 2454 case CSSPropertyGridRow: | 2455 case CSSPropertyGridRow: |
| 2455 case CSSPropertyGridArea: | 2456 case CSSPropertyGridArea: |
| 2456 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | 2457 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) |
| 2457 return false; | 2458 return false; |
| 2458 return parseGridItemPositionShorthand(propId, important); | 2459 return parseGridItemPositionShorthand(propId, important); |
| 2459 | 2460 |
| 2461 case CSSPropertyGridTemplate: | |
| 2462 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | |
| 2463 return false; | |
| 2464 parsedValue = parseGridTemplate(); | |
| 2465 break; | |
| 2466 | |
| 2460 case CSSPropertyWebkitMarginCollapse: { | 2467 case CSSPropertyWebkitMarginCollapse: { |
| 2461 if (num == 1) { | 2468 if (num == 1) { |
| 2462 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); | 2469 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); |
| 2463 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant)) | 2470 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant)) |
| 2464 return false; | 2471 return false; |
| 2465 CSSValue* value = m_parsedProperties.last().value(); | 2472 CSSValue* value = m_parsedProperties.last().value(); |
| 2466 addProperty(webkitMarginCollapseShorthand().properties()[1], value, important); | 2473 addProperty(webkitMarginCollapseShorthand().properties()[1], value, important); |
| 2467 return true; | 2474 return true; |
| 2468 } | 2475 } |
| 2469 else if (num == 2) { | 2476 else if (num == 2) { |
| (...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4720 | 4727 |
| 4721 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR); | 4728 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR); |
| 4722 } | 4729 } |
| 4723 | 4730 |
| 4724 if (!validUnit(currentValue, FLength | FPercent)) | 4731 if (!validUnit(currentValue, FLength | FPercent)) |
| 4725 return 0; | 4732 return 0; |
| 4726 | 4733 |
| 4727 return createPrimitiveNumericValue(currentValue); | 4734 return createPrimitiveNumericValue(currentValue); |
| 4728 } | 4735 } |
| 4729 | 4736 |
| 4737 PassRefPtr<CSSValue> CSSParser::parseGridTemplate() | |
| 4738 { | |
| 4739 NamedGridAreaMap gridAreaMap; | |
| 4740 size_t rowCount = 0; | |
| 4741 size_t columnCount = 0; | |
| 4742 | |
| 4743 while (CSSParserValue* currentValue = m_valueList->current()) { | |
| 4744 if (currentValue->unit != CSSPrimitiveValue::CSS_STRING) | |
| 4745 return 0; | |
| 4746 | |
| 4747 String gridRowNames = currentValue->string; | |
| 4748 if (!gridRowNames.length()) | |
| 4749 return 0; | |
| 4750 | |
| 4751 Vector<String> columnNames; | |
| 4752 gridRowNames.split(' ', columnNames); | |
|
ojan
2013/07/29 23:03:28
Does the spec say what to do if there are multiple
Julien - ping for review
2013/07/30 18:43:33
Not explicitly (the grammar is <string>+). It woul
ojan
2013/07/30 18:53:48
Makes sense to me. We should make the spec explici
| |
| 4753 | |
| 4754 if (!columnCount) { | |
| 4755 columnCount = columnNames.size(); | |
| 4756 ASSERT(columnCount); | |
| 4757 } else if (columnCount != columnNames.size()) { | |
| 4758 // The declaration is invalid is all the rows don't have the number of columns. | |
| 4759 return 0; | |
| 4760 } | |
| 4761 | |
| 4762 for (size_t currentCol = 0; currentCol < columnCount; ++currentCol) { | |
| 4763 const String& gridAreaName = columnNames[currentCol]; | |
| 4764 | |
| 4765 // Unamed areas are always valid (we consider them to be 1x1). | |
| 4766 DEFINE_STATIC_LOCAL(String, unamedAreaPlaceholder, (ASCIILiteral("." ))); | |
| 4767 if (gridAreaName == unamedAreaPlaceholder) | |
|
esprehn
2013/07/29 23:27:36
This is overly complex, just check if gridAreaName
Julien - ping for review
2013/07/30 18:43:33
I thought it would be more readable but apparently
| |
| 4768 continue; | |
| 4769 | |
| 4770 // We handle several grid areas with the same name at once to simpli fy the validation code. | |
| 4771 size_t lookAheadCol; | |
| 4772 for (lookAheadCol = currentCol; lookAheadCol < (columnCount - 1); ++ lookAheadCol) { | |
| 4773 if (columnNames[lookAheadCol + 1] != gridAreaName) | |
| 4774 break; | |
| 4775 } | |
| 4776 | |
| 4777 NamedGridAreaMap::iterator gridAreaIt = gridAreaMap.find(gridAreaNam e); | |
| 4778 if (gridAreaIt == gridAreaMap.end()) { | |
| 4779 gridAreaMap.add(gridAreaName, GridCoordinate(GridSpan(rowCount, rowCount), GridSpan(currentCol, lookAheadCol))); | |
| 4780 } else { | |
| 4781 GridCoordinate& gridCoordinate = gridAreaIt->value; | |
| 4782 | |
| 4783 // The following checks test that the grid area is a single fill ed-in rectangle. | |
| 4784 // 1. The new row is adjacent to the previously parsed row. | |
| 4785 if (rowCount != gridCoordinate.rows.initialPositionIndex + 1) | |
| 4786 return 0; | |
| 4787 | |
| 4788 // 2. The new area starts at the same position as the previously parsed area. | |
| 4789 if (currentCol != gridCoordinate.columns.initialPositionIndex) | |
| 4790 return 0; | |
| 4791 | |
| 4792 // 3. The new area ends at the same position as the previously p arsed area. | |
| 4793 if (lookAheadCol != gridCoordinate.columns.finalPositionIndex) | |
| 4794 return 0; | |
| 4795 | |
| 4796 ++gridCoordinate.rows.finalPositionIndex; | |
| 4797 } | |
| 4798 currentCol = lookAheadCol; | |
| 4799 } | |
| 4800 | |
| 4801 ++rowCount; | |
| 4802 m_valueList->next(); | |
| 4803 } | |
| 4804 | |
| 4805 if (!rowCount || !columnCount) | |
| 4806 return 0; | |
| 4807 | |
| 4808 return CSSGridTemplateValue::create(gridAreaMap, rowCount, columnCount); | |
| 4809 } | |
| 4810 | |
| 4730 PassRefPtr<CSSValue> CSSParser::parseCounterContent(CSSParserValueList* args, bo ol counters) | 4811 PassRefPtr<CSSValue> CSSParser::parseCounterContent(CSSParserValueList* args, bo ol counters) |
| 4731 { | 4812 { |
| 4732 unsigned numArgs = args->size(); | 4813 unsigned numArgs = args->size(); |
| 4733 if (counters && numArgs != 3 && numArgs != 5) | 4814 if (counters && numArgs != 3 && numArgs != 5) |
| 4734 return 0; | 4815 return 0; |
| 4735 if (!counters && numArgs != 1 && numArgs != 3) | 4816 if (!counters && numArgs != 1 && numArgs != 3) |
| 4736 return 0; | 4817 return 0; |
| 4737 | 4818 |
| 4738 CSSParserValue* i = args->current(); | 4819 CSSParserValue* i = args->current(); |
| 4739 if (i->unit != CSSPrimitiveValue::CSS_IDENT) | 4820 if (i->unit != CSSPrimitiveValue::CSS_IDENT) |
| (...skipping 6981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11721 { | 11802 { |
| 11722 // The tokenizer checks for the construct of an+b. | 11803 // The tokenizer checks for the construct of an+b. |
| 11723 // However, since the {ident} rule precedes the {nth} rule, some of those | 11804 // However, since the {ident} rule precedes the {nth} rule, some of those |
| 11724 // tokens are identified as string literal. Furthermore we need to accept | 11805 // tokens are identified as string literal. Furthermore we need to accept |
| 11725 // "odd" and "even" which does not match to an+b. | 11806 // "odd" and "even" which does not match to an+b. |
| 11726 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11807 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
| 11727 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11808 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
| 11728 } | 11809 } |
| 11729 | 11810 |
| 11730 } | 11811 } |
| OLD | NEW |