| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 ASSERT(!m_parsedCalculation); | 258 ASSERT(!m_parsedCalculation); |
| 259 | 259 |
| 260 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 260 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
| 261 | 261 |
| 262 switch (propId) { | 262 switch (propId) { |
| 263 case CSSPropertyGridAutoFlow: | 263 case CSSPropertyGridAutoFlow: |
| 264 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 264 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 265 parsedValue = parseGridAutoFlow(*m_valueList); | 265 parsedValue = parseGridAutoFlow(*m_valueList); |
| 266 break; | 266 break; |
| 267 | 267 |
| 268 case CSSPropertyGridTemplateAreas: | |
| 269 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | |
| 270 parsedValue = parseGridTemplateAreas(); | |
| 271 break; | |
| 272 | |
| 273 // Everything else is handled in CSSPropertyParser.cpp | 268 // Everything else is handled in CSSPropertyParser.cpp |
| 274 default: | 269 default: |
| 275 return nullptr; | 270 return nullptr; |
| 276 } | 271 } |
| 277 | 272 |
| 278 ASSERT(!m_parsedCalculation); | 273 ASSERT(!m_parsedCalculation); |
| 279 if (parsedValue) { | 274 if (parsedValue) { |
| 280 if (!m_valueList->current() || inShorthand()) | 275 if (!m_valueList->current() || inShorthand()) |
| 281 return parsedValue.release(); | 276 return parsedValue.release(); |
| 282 } | 277 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 // At least template-areas strings must be defined. | 330 // At least template-areas strings must be defined. |
| 336 if (!m_valueList->current() || isForwardSlashOperator(m_valueList->current()
)) | 331 if (!m_valueList->current() || isForwardSlashOperator(m_valueList->current()
)) |
| 337 return false; | 332 return false; |
| 338 | 333 |
| 339 while (m_valueList->current() && !isForwardSlashOperator(m_valueList->curren
t())) { | 334 while (m_valueList->current() && !isForwardSlashOperator(m_valueList->curren
t())) { |
| 340 // Handle leading <custom-ident>*. | 335 // Handle leading <custom-ident>*. |
| 341 if (!parseGridLineNames(*m_valueList, *templateRows, trailingIdentWasAdd
ed ? toCSSGridLineNamesValue(templateRows->item(templateRows->length() - 1)) : n
ullptr)) | 336 if (!parseGridLineNames(*m_valueList, *templateRows, trailingIdentWasAdd
ed ? toCSSGridLineNamesValue(templateRows->item(templateRows->length() - 1)) : n
ullptr)) |
| 342 return false; | 337 return false; |
| 343 | 338 |
| 344 // Handle a template-area's row. | 339 // Handle a template-area's row. |
| 345 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) | 340 CSSParserValue* currentValue = m_valueList->current(); |
| 341 if (!currentValue || currentValue->m_unit != CSSParserValue::String) |
| 346 return false; | 342 return false; |
| 343 if (!parseGridTemplateAreasRow(currentValue->string, gridAreaMap, rowCou
nt, columnCount)) |
| 344 return false; |
| 345 m_valueList->next(); |
| 347 ++rowCount; | 346 ++rowCount; |
| 348 | 347 |
| 349 // Handle template-rows's track-size. | 348 // Handle template-rows's track-size. |
| 350 if (m_valueList->current() && m_valueList->current()->m_unit != CSSParse
rValue::Operator && m_valueList->current()->m_unit != CSSParserValue::String) { | 349 if (m_valueList->current() && m_valueList->current()->m_unit != CSSParse
rValue::Operator && m_valueList->current()->m_unit != CSSParserValue::String) { |
| 351 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList
); | 350 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList
); |
| 352 if (!value) | 351 if (!value) |
| 353 return false; | 352 return false; |
| 354 templateRows->append(value); | 353 templateRows->append(value); |
| 355 } else { | 354 } else { |
| 356 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu
to)); | 355 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu
to)); |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 | 759 |
| 761 areaName.append(text[i]); | 760 areaName.append(text[i]); |
| 762 } | 761 } |
| 763 | 762 |
| 764 if (!areaName.isEmpty()) | 763 if (!areaName.isEmpty()) |
| 765 columnNames.append(areaName.toString()); | 764 columnNames.append(areaName.toString()); |
| 766 | 765 |
| 767 return columnNames; | 766 return columnNames; |
| 768 } | 767 } |
| 769 | 768 |
| 770 bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap,
const size_t rowCount, size_t& columnCount) | 769 bool parseGridTemplateAreasRow(const String& gridRowNames, NamedGridAreaMap& gri
dAreaMap, const size_t rowCount, size_t& columnCount) |
| 771 { | 770 { |
| 772 CSSParserValue* currentValue = m_valueList->current(); | |
| 773 if (!currentValue || currentValue->m_unit != CSSParserValue::String) | |
| 774 return false; | |
| 775 | |
| 776 String gridRowNames = currentValue->string; | |
| 777 if (gridRowNames.isEmpty() || gridRowNames.containsOnlyWhitespace()) | 771 if (gridRowNames.isEmpty() || gridRowNames.containsOnlyWhitespace()) |
| 778 return false; | 772 return false; |
| 779 | 773 |
| 780 Vector<String> columnNames = parseGridTemplateAreasColumnNames(gridRowNames)
; | 774 Vector<String> columnNames = parseGridTemplateAreasColumnNames(gridRowNames)
; |
| 781 if (!columnCount) { | 775 if (!columnCount) { |
| 782 columnCount = columnNames.size(); | 776 columnCount = columnNames.size(); |
| 783 ASSERT(columnCount); | 777 ASSERT(columnCount); |
| 784 } else if (columnCount != columnNames.size()) { | 778 } else if (columnCount != columnNames.size()) { |
| 785 // The declaration is invalid is all the rows don't have the number of c
olumns. | 779 // The declaration is invalid is all the rows don't have the number of c
olumns. |
| 786 return false; | 780 return false; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 817 | 811 |
| 818 // 3. The new area ends at the same position as the previously parse
d area. | 812 // 3. The new area ends at the same position as the previously parse
d area. |
| 819 if (lookAheadCol != gridArea.columns.endLine()) | 813 if (lookAheadCol != gridArea.columns.endLine()) |
| 820 return false; | 814 return false; |
| 821 | 815 |
| 822 gridArea.rows = GridSpan::translatedDefiniteGridSpan(gridArea.rows.s
tartLine(), gridArea.rows.endLine() + 1); | 816 gridArea.rows = GridSpan::translatedDefiniteGridSpan(gridArea.rows.s
tartLine(), gridArea.rows.endLine() + 1); |
| 823 } | 817 } |
| 824 currentCol = lookAheadCol - 1; | 818 currentCol = lookAheadCol - 1; |
| 825 } | 819 } |
| 826 | 820 |
| 827 m_valueList->next(); | |
| 828 return true; | 821 return true; |
| 829 } | 822 } |
| 830 | 823 |
| 831 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTemplateAreas() | |
| 832 { | |
| 833 if (m_valueList->current() && m_valueList->current()->id == CSSValueNone) { | |
| 834 m_valueList->next(); | |
| 835 return cssValuePool().createIdentifierValue(CSSValueNone); | |
| 836 } | |
| 837 | |
| 838 NamedGridAreaMap gridAreaMap; | |
| 839 size_t rowCount = 0; | |
| 840 size_t columnCount = 0; | |
| 841 | |
| 842 while (m_valueList->current()) { | |
| 843 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) | |
| 844 return nullptr; | |
| 845 ++rowCount; | |
| 846 } | |
| 847 | |
| 848 if (!rowCount || !columnCount) | |
| 849 return nullptr; | |
| 850 | |
| 851 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount)
; | |
| 852 } | |
| 853 | |
| 854 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridAutoFlow(CSSParserV
alueList& list) | 824 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridAutoFlow(CSSParserV
alueList& list) |
| 855 { | 825 { |
| 856 // [ row | column ] || dense | 826 // [ row | column ] || dense |
| 857 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 827 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 858 | 828 |
| 859 CSSParserValue* value = list.current(); | 829 CSSParserValue* value = list.current(); |
| 860 if (!value) | 830 if (!value) |
| 861 return nullptr; | 831 return nullptr; |
| 862 | 832 |
| 863 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); | 833 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 ASSERT(!m_parsedCalculation); | 870 ASSERT(!m_parsedCalculation); |
| 901 m_parsedCalculation = CSSCalcValue::create(args, range); | 871 m_parsedCalculation = CSSCalcValue::create(args, range); |
| 902 | 872 |
| 903 if (!m_parsedCalculation) | 873 if (!m_parsedCalculation) |
| 904 return false; | 874 return false; |
| 905 | 875 |
| 906 return true; | 876 return true; |
| 907 } | 877 } |
| 908 | 878 |
| 909 } // namespace blink | 879 } // namespace blink |
| OLD | NEW |