OLD | NEW |
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 15 matching lines...) Expand all Loading... |
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 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 RefPtrWillBeRawPtr<CSSValue> cssValue = CSSParser::parseSingleValue(CSSPrope
rtyLeft, text); | 36 RefPtr<CSSValue> cssValue = CSSParser::parseSingleValue(CSSPropertyLeft, tex
t); |
37 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(cssValue.get()); | 37 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(cssValue.get()); |
38 if (primitiveValue) | 38 if (primitiveValue) |
39 primitiveValue->accumulateLengthArray(lengthArray); | 39 primitiveValue->accumulateLengthArray(lengthArray); |
40 else | 40 else |
41 ASSERT_EQ(valid, false); | 41 ASSERT_EQ(valid, false); |
42 float length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels); | 42 float length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels); |
43 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize; | 43 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize; |
44 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportWidth) * viewpor
tWidth / 100.0; | 44 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportWidth) * viewpor
tWidth / 100.0; |
45 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportHeight) * viewpo
rtHeight / 100.0; | 45 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportHeight) * viewpo
rtHeight / 100.0; |
46 ASSERT_EQ(value, length); | 46 ASSERT_EQ(value, length); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 124 } |
125 | 125 |
126 for (unsigned i = 0; testCases[i].input; ++i) { | 126 for (unsigned i = 0; testCases[i].input; ++i) { |
127 if (testCases[i].dontRunInCSSCalc) | 127 if (testCases[i].dontRunInCSSCalc) |
128 continue; | 128 continue; |
129 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali
d, data.defaultFontSize, data.viewportWidth, data.viewportHeight); | 129 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali
d, data.defaultFontSize, data.viewportWidth, data.viewportHeight); |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 } // namespace | 133 } // namespace |
OLD | NEW |