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

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

Issue 813233002: Animation: Fix loss of type information when interpolating value of 0 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Attempt no2 at fixing linux oilpan errors Created 6 years 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 11 matching lines...) Expand all
22 const bool dontRunInCSSCalc; 22 const bool dontRunInCSSCalc;
23 }; 23 };
24 24
25 static void initLengthArray(CSSLengthArray& lengthArray) 25 static void initLengthArray(CSSLengthArray& lengthArray)
26 { 26 {
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 initLengthTypeArray(CSSLengthTypeArray& lengthTypeArray)
33 {
34 lengthTypeArray.resize(CSSPrimitiveValue::LengthUnitTypeCount);
35 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i)
36 lengthTypeArray.clear(i);
37 }
38
32 static void verifyCSSCalc(String text, double value, bool valid, unsigned fontSi ze, unsigned viewportWidth, unsigned viewportHeight) 39 static void verifyCSSCalc(String text, double value, bool valid, unsigned fontSi ze, unsigned viewportWidth, unsigned viewportHeight)
33 { 40 {
34 CSSLengthArray lengthArray; 41 CSSLengthArray lengthArray;
35 initLengthArray(lengthArray); 42 initLengthArray(lengthArray);
43 CSSLengthTypeArray lengthTypeArray;
44 initLengthTypeArray(lengthTypeArray);
36 RefPtrWillBeRawPtr<CSSValue> cssValue = CSSParser::parseSingleValue(CSSPrope rtyLeft, text); 45 RefPtrWillBeRawPtr<CSSValue> cssValue = CSSParser::parseSingleValue(CSSPrope rtyLeft, text);
37 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(cssValue.get()); 46 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(cssValue.get());
38 if (primitiveValue) 47 if (primitiveValue)
39 primitiveValue->accumulateLengthArray(lengthArray); 48 primitiveValue->accumulateLengthArray(lengthArray, lengthTypeArray);
samli 2014/12/22 03:38:05 Not actually used here, so we can remove it if we
evemj (not active) 2014/12/22 06:09:06 Done.
40 else 49 else
41 ASSERT_EQ(valid, false); 50 ASSERT_EQ(valid, false);
42 float length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels); 51 float length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels);
43 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize; 52 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize;
44 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportWidth) * viewpor tWidth / 100.0; 53 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportWidth) * viewpor tWidth / 100.0;
45 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportHeight) * viewpo rtHeight / 100.0; 54 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportHeight) * viewpo rtHeight / 100.0;
46 ASSERT_EQ(value, length); 55 ASSERT_EQ(value, length);
47 } 56 }
48 57
49 58
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 134 }
126 135
127 for (unsigned i = 0; testCases[i].input; ++i) { 136 for (unsigned i = 0; testCases[i].input; ++i) {
128 if (testCases[i].dontRunInCSSCalc) 137 if (testCases[i].dontRunInCSSCalc)
129 continue; 138 continue;
130 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali d, data.defaultFontSize, data.viewportWidth, data.viewportHeight); 139 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali d, data.defaultFontSize, data.viewportWidth, data.viewportHeight);
131 } 140 }
132 } 141 }
133 142
134 } // namespace 143 } // namespace
OLDNEW
« Source/core/css/CSSPrimitiveValue.h ('K') | « Source/core/css/CSSPrimitiveValue.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698