Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Side by Side Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 1160273004: [CSS Grid Layout] Support dots sequences in grid-template-areas (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased patch Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/css-grid-layout/grid-template-areas-get-set-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3595 matching lines...) Expand 10 before | Expand all | Expand 10 after
3606 3606
3607 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR); 3607 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR);
3608 } 3608 }
3609 3609
3610 if (!validUnit(currentValue, FNonNeg | FLength | FPercent)) 3610 if (!validUnit(currentValue, FNonNeg | FLength | FPercent))
3611 return nullptr; 3611 return nullptr;
3612 3612
3613 return createPrimitiveNumericValue(currentValue); 3613 return createPrimitiveNumericValue(currentValue);
3614 } 3614 }
3615 3615
3616 static bool containsOnlyDots(const String& string)
3617 {
3618 ASSERT(!string.isEmpty());
3619 StringImpl& text = *string.impl();
3620 for (unsigned i = 0; i < text.length(); ++i) {
3621 if (text[i] != '.')
3622 return false;
3623 }
3624 return true;
3625 }
3626
3616 bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap, const size_t rowCount, size_t& columnCount) 3627 bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap, const size_t rowCount, size_t& columnCount)
3617 { 3628 {
3618 CSSParserValue* currentValue = m_valueList->current(); 3629 CSSParserValue* currentValue = m_valueList->current();
3619 if (!currentValue || currentValue->unit != CSSPrimitiveValue::CSS_STRING) 3630 if (!currentValue || currentValue->unit != CSSPrimitiveValue::CSS_STRING)
3620 return false; 3631 return false;
3621 3632
3622 String gridRowNames = currentValue->string; 3633 String gridRowNames = currentValue->string;
3623 if (gridRowNames.isEmpty() || gridRowNames.containsOnlyWhitespace()) 3634 if (gridRowNames.isEmpty() || gridRowNames.containsOnlyWhitespace())
3624 return false; 3635 return false;
3625 3636
3626 Vector<String> columnNames; 3637 Vector<String> columnNames;
3627 gridRowNames.split(' ', columnNames); 3638 gridRowNames.split(' ', columnNames);
3628 3639
3629 if (!columnCount) { 3640 if (!columnCount) {
3630 columnCount = columnNames.size(); 3641 columnCount = columnNames.size();
3631 ASSERT(columnCount); 3642 ASSERT(columnCount);
3632 } else if (columnCount != columnNames.size()) { 3643 } else if (columnCount != columnNames.size()) {
3633 // The declaration is invalid is all the rows don't have the number of c olumns. 3644 // The declaration is invalid is all the rows don't have the number of c olumns.
3634 return false; 3645 return false;
3635 } 3646 }
3636 3647
3637 for (size_t currentCol = 0; currentCol < columnCount; ++currentCol) { 3648 for (size_t currentCol = 0; currentCol < columnCount; ++currentCol) {
3638 const String& gridAreaName = columnNames[currentCol]; 3649 const String& gridAreaName = columnNames[currentCol];
3639 3650
3640 // Unamed areas are always valid (we consider them to be 1x1). 3651 // Unamed areas are always valid (we consider them to be 1x1).
3641 if (gridAreaName == ".") 3652 if (containsOnlyDots(gridAreaName))
3642 continue; 3653 continue;
3643 3654
3644 // We handle several grid areas with the same name at once to simplify t he validation code. 3655 // We handle several grid areas with the same name at once to simplify t he validation code.
3645 size_t lookAheadCol; 3656 size_t lookAheadCol;
3646 for (lookAheadCol = currentCol; lookAheadCol < (columnCount - 1); ++look AheadCol) { 3657 for (lookAheadCol = currentCol; lookAheadCol < (columnCount - 1); ++look AheadCol) {
3647 if (columnNames[lookAheadCol + 1] != gridAreaName) 3658 if (columnNames[lookAheadCol + 1] != gridAreaName)
3648 break; 3659 break;
3649 } 3660 }
3650 3661
3651 NamedGridAreaMap::iterator gridAreaIt = gridAreaMap.find(gridAreaName); 3662 NamedGridAreaMap::iterator gridAreaIt = gridAreaMap.find(gridAreaName);
(...skipping 4733 matching lines...) Expand 10 before | Expand all | Expand 10 after
8385 } 8396 }
8386 } 8397 }
8387 8398
8388 if (!list->length()) 8399 if (!list->length())
8389 return nullptr; 8400 return nullptr;
8390 8401
8391 return list.release(); 8402 return list.release();
8392 } 8403 }
8393 8404
8394 } // namespace blink 8405 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/css-grid-layout/grid-template-areas-get-set-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698