| 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 3653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3664 | 3664 |
| 3665 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR); | 3665 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR); |
| 3666 } | 3666 } |
| 3667 | 3667 |
| 3668 if (!validUnit(currentValue, FNonNeg | FLength | FPercent)) | 3668 if (!validUnit(currentValue, FNonNeg | FLength | FPercent)) |
| 3669 return nullptr; | 3669 return nullptr; |
| 3670 | 3670 |
| 3671 return createPrimitiveNumericValue(currentValue); | 3671 return createPrimitiveNumericValue(currentValue); |
| 3672 } | 3672 } |
| 3673 | 3673 |
| 3674 static bool containsOnlyDots(const String& string) | 3674 static Vector<String> parseGridTemplateAreasColumnNames(const String& gridRowNam
es) |
| 3675 { | 3675 { |
| 3676 ASSERT(!string.isEmpty()); | 3676 ASSERT(!gridRowNames.isEmpty()); |
| 3677 StringImpl& text = *string.impl(); | 3677 Vector<String> columnNames; |
| 3678 // Using StringImpl to avoid checks and indirection in every call to String:
:operator[]. |
| 3679 StringImpl& text = *gridRowNames.impl(); |
| 3680 |
| 3681 StringBuilder areaName; |
| 3678 for (unsigned i = 0; i < text.length(); ++i) { | 3682 for (unsigned i = 0; i < text.length(); ++i) { |
| 3679 if (text[i] != '.') | 3683 if (text[i] == ' ') { |
| 3680 return false; | 3684 if (!areaName.isEmpty()) { |
| 3685 columnNames.append(areaName.toString()); |
| 3686 areaName.clear(); |
| 3687 } |
| 3688 continue; |
| 3689 } |
| 3690 if (text[i] == '.') { |
| 3691 if (areaName == ".") |
| 3692 continue; |
| 3693 if (!areaName.isEmpty()) { |
| 3694 columnNames.append(areaName.toString()); |
| 3695 areaName.clear(); |
| 3696 } |
| 3697 } else { |
| 3698 if (areaName == ".") { |
| 3699 columnNames.append(areaName.toString()); |
| 3700 areaName.clear(); |
| 3701 } |
| 3702 } |
| 3703 |
| 3704 areaName.append(text[i]); |
| 3681 } | 3705 } |
| 3682 return true; | 3706 |
| 3707 if (!areaName.isEmpty()) |
| 3708 columnNames.append(areaName.toString()); |
| 3709 |
| 3710 return columnNames; |
| 3683 } | 3711 } |
| 3684 | 3712 |
| 3685 bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap,
const size_t rowCount, size_t& columnCount) | 3713 bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap,
const size_t rowCount, size_t& columnCount) |
| 3686 { | 3714 { |
| 3687 CSSParserValue* currentValue = m_valueList->current(); | 3715 CSSParserValue* currentValue = m_valueList->current(); |
| 3688 if (!currentValue || currentValue->unit != CSSPrimitiveValue::CSS_STRING) | 3716 if (!currentValue || currentValue->unit != CSSPrimitiveValue::CSS_STRING) |
| 3689 return false; | 3717 return false; |
| 3690 | 3718 |
| 3691 String gridRowNames = currentValue->string; | 3719 String gridRowNames = currentValue->string; |
| 3692 if (gridRowNames.isEmpty() || gridRowNames.containsOnlyWhitespace()) | 3720 if (gridRowNames.isEmpty() || gridRowNames.containsOnlyWhitespace()) |
| 3693 return false; | 3721 return false; |
| 3694 | 3722 |
| 3695 Vector<String> columnNames; | 3723 Vector<String> columnNames = parseGridTemplateAreasColumnNames(gridRowNames)
; |
| 3696 gridRowNames.split(' ', columnNames); | |
| 3697 | |
| 3698 if (!columnCount) { | 3724 if (!columnCount) { |
| 3699 columnCount = columnNames.size(); | 3725 columnCount = columnNames.size(); |
| 3700 ASSERT(columnCount); | 3726 ASSERT(columnCount); |
| 3701 } else if (columnCount != columnNames.size()) { | 3727 } else if (columnCount != columnNames.size()) { |
| 3702 // The declaration is invalid is all the rows don't have the number of c
olumns. | 3728 // The declaration is invalid is all the rows don't have the number of c
olumns. |
| 3703 return false; | 3729 return false; |
| 3704 } | 3730 } |
| 3705 | 3731 |
| 3706 for (size_t currentCol = 0; currentCol < columnCount; ++currentCol) { | 3732 for (size_t currentCol = 0; currentCol < columnCount; ++currentCol) { |
| 3707 const String& gridAreaName = columnNames[currentCol]; | 3733 const String& gridAreaName = columnNames[currentCol]; |
| 3708 | 3734 |
| 3709 // Unamed areas are always valid (we consider them to be 1x1). | 3735 // Unamed areas are always valid (we consider them to be 1x1). |
| 3710 if (containsOnlyDots(gridAreaName)) | 3736 if (gridAreaName == ".") |
| 3711 continue; | 3737 continue; |
| 3712 | 3738 |
| 3713 // We handle several grid areas with the same name at once to simplify t
he validation code. | 3739 // We handle several grid areas with the same name at once to simplify t
he validation code. |
| 3714 size_t lookAheadCol; | 3740 size_t lookAheadCol; |
| 3715 for (lookAheadCol = currentCol; lookAheadCol < (columnCount - 1); ++look
AheadCol) { | 3741 for (lookAheadCol = currentCol; lookAheadCol < (columnCount - 1); ++look
AheadCol) { |
| 3716 if (columnNames[lookAheadCol + 1] != gridAreaName) | 3742 if (columnNames[lookAheadCol + 1] != gridAreaName) |
| 3717 break; | 3743 break; |
| 3718 } | 3744 } |
| 3719 | 3745 |
| 3720 NamedGridAreaMap::iterator gridAreaIt = gridAreaMap.find(gridAreaName); | 3746 NamedGridAreaMap::iterator gridAreaIt = gridAreaMap.find(gridAreaName); |
| (...skipping 4755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8476 } | 8502 } |
| 8477 } | 8503 } |
| 8478 | 8504 |
| 8479 if (!list->length()) | 8505 if (!list->length()) |
| 8480 return nullptr; | 8506 return nullptr; |
| 8481 | 8507 |
| 8482 return list.release(); | 8508 return list.release(); |
| 8483 } | 8509 } |
| 8484 | 8510 |
| 8485 } // namespace blink | 8511 } // namespace blink |
| OLD | NEW |