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

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

Issue 1225553002: CSSValue Immediates: Make CSSPrimitiveValue a container (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_1
Patch Set: Rebase Created 5 years, 4 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/css/parser/SizesCalcParser.h" 6 #include "core/css/parser/SizesCalcParser.h"
7 7
8 #include "core/MediaTypeNames.h" 8 #include "core/MediaTypeNames.h"
9 #include "core/css/CSSPrimitiveValue.h" 9 #include "core/css/CSSPrimitiveValue.h"
10 #include "core/css/MediaValuesCached.h" 10 #include "core/css/MediaValuesCached.h"
(...skipping 16 matching lines...) Expand all
27 lengthArray.resize(CSSPrimitiveValue::LengthUnitTypeCount); 27 lengthArray.resize(CSSPrimitiveValue::LengthUnitTypeCount);
28 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) 28 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i)
29 lengthArray.at(i) = 0; 29 lengthArray.at(i) = 0;
30 } 30 }
31 31
32 static void verifyCSSCalc(String text, double value, bool valid, unsigned fontSi ze, unsigned viewportWidth, unsigned viewportHeight) 32 static void verifyCSSCalc(String text, double value, bool valid, unsigned fontSi ze, unsigned viewportWidth, unsigned viewportHeight)
33 { 33 {
34 CSSLengthArray lengthArray; 34 CSSLengthArray lengthArray;
35 initLengthArray(lengthArray); 35 initLengthArray(lengthArray);
36 NullableCSSValue cssValue = CSSParser::parseSingleValue(CSSPropertyLeft, tex t); 36 NullableCSSValue cssValue = CSSParser::parseSingleValue(CSSPropertyLeft, tex t);
37 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(cssValue); 37 if (cssValue)
38 if (primitiveValue) 38 toCSSPrimitiveValue(*cssValue).accumulateLengthArray(lengthArray);
39 primitiveValue->accumulateLengthArray(lengthArray);
40 else 39 else
41 ASSERT_EQ(valid, false); 40 ASSERT_EQ(valid, false);
42 float length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels); 41 float length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels);
43 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize; 42 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize;
44 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportWidth) * viewpor tWidth / 100.0; 43 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportWidth) * viewpor tWidth / 100.0;
45 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportHeight) * viewpo rtHeight / 100.0; 44 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportHeight) * viewpo rtHeight / 100.0;
46 ASSERT_EQ(value, length); 45 ASSERT_EQ(value, length);
47 } 46 }
48 47
49 48
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 123 }
125 124
126 for (unsigned i = 0; testCases[i].input; ++i) { 125 for (unsigned i = 0; testCases[i].input; ++i) {
127 if (testCases[i].dontRunInCSSCalc) 126 if (testCases[i].dontRunInCSSCalc)
128 continue; 127 continue;
129 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali d, data.defaultFontSize, data.viewportWidth, data.viewportHeight); 128 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali d, data.defaultFontSize, data.viewportWidth, data.viewportHeight);
130 } 129 }
131 } 130 }
132 131
133 } // namespace 132 } // namespace
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.cpp ('k') | Source/core/css/resolver/CSSToStyleMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698