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

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

Issue 251643002: [CSS Grid Layout] Clamping the number of repetitions when using the repeat() function. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 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
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 #include "wtf/text/StringImpl.h" 83 #include "wtf/text/StringImpl.h"
84 #include "wtf/text/TextEncoding.h" 84 #include "wtf/text/TextEncoding.h"
85 #include <limits.h> 85 #include <limits.h>
86 86
87 using namespace std; 87 using namespace std;
88 88
89 namespace WebCore { 89 namespace WebCore {
90 90
91 static const double MAX_SCALE = 1000000; 91 static const double MAX_SCALE = 1000000;
92 92
93 #define MAX_REPETITIONS 10000
Julien - ping for review 2014/04/25 15:50:34 Let's use a static constant.
94
93 template <unsigned N> 95 template <unsigned N>
94 static bool equal(const CSSParserString& a, const char (&b)[N]) 96 static bool equal(const CSSParserString& a, const char (&b)[N])
95 { 97 {
96 unsigned length = N - 1; // Ignore the trailing null character 98 unsigned length = N - 1; // Ignore the trailing null character
97 if (a.length() != length) 99 if (a.length() != length)
98 return false; 100 return false;
99 101
100 return a.is8Bit() ? WTF::equal(a.characters8(), reinterpret_cast<const LChar *>(b), length) : WTF::equal(a.characters16(), reinterpret_cast<const LChar*>(b), length); 102 return a.is8Bit() ? WTF::equal(a.characters8(), reinterpret_cast<const LChar *>(b), length) : WTF::equal(a.characters16(), reinterpret_cast<const LChar*>(b), length);
101 } 103 }
102 104
(...skipping 3687 matching lines...) Expand 10 before | Expand all | Expand 10 after
3790 } 3792 }
3791 3793
3792 bool CSSPropertyParser::parseGridTrackRepeatFunction(CSSValueList& list) 3794 bool CSSPropertyParser::parseGridTrackRepeatFunction(CSSValueList& list)
3793 { 3795 {
3794 CSSParserValueList* arguments = m_valueList->current()->function->args.get() ; 3796 CSSParserValueList* arguments = m_valueList->current()->function->args.get() ;
3795 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0), FPositiveInteger) || !isComma(arguments->valueAt(1))) 3797 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0), FPositiveInteger) || !isComma(arguments->valueAt(1)))
3796 return false; 3798 return false;
3797 3799
3798 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0); 3800 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0);
3799 size_t repetitions = arguments->valueAt(0)->fValue; 3801 size_t repetitions = arguments->valueAt(0)->fValue;
3802 // Clamp repetitions at MAX_REPETITIONS.
3803 if (repetitions > MAX_REPETITIONS)
3804 repetitions = MAX_REPETITIONS;
Julien - ping for review 2014/04/25 15:50:34 Let's use min as this is our preferred way to do c
3800 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS eparated(); 3805 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS eparated();
3801 arguments->next(); // Skip the repetition count. 3806 arguments->next(); // Skip the repetition count.
3802 arguments->next(); // Skip the comma. 3807 arguments->next(); // Skip the comma.
3803 3808
3804 // Handle leading <ident>*. 3809 // Handle leading <ident>*.
3805 CSSParserValue* currentValue = arguments->current(); 3810 CSSParserValue* currentValue = arguments->current();
3806 if (currentValue && currentValue->unit == CSSParserValue::ValueList) 3811 if (currentValue && currentValue->unit == CSSParserValue::ValueList)
3807 parseGridLineNames(*arguments, *repeatedValues); 3812 parseGridLineNames(*arguments, *repeatedValues);
3808 3813
3809 while (arguments->current()) { 3814 while (arguments->current()) {
(...skipping 4677 matching lines...) Expand 10 before | Expand all | Expand 10 after
8487 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); 8492 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill));
8488 if (!seenStroke) 8493 if (!seenStroke)
8489 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); 8494 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) );
8490 if (!seenMarkers) 8495 if (!seenMarkers)
8491 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); 8496 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers ));
8492 8497
8493 return parsedValues.release(); 8498 return parsedValues.release();
8494 } 8499 }
8495 8500
8496 } // namespace WebCore 8501 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698