| 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 17 matching lines...) Expand all Loading... |
| 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 if (cssValue) | 37 if (cssValue) |
| 38 toCSSPrimitiveValue(*cssValue).accumulateLengthArray(lengthArray); | 38 toCSSPrimitiveValue(cssValue).accumulateLengthArray(lengthArray); |
| 39 else | 39 else |
| 40 ASSERT_EQ(valid, false); | 40 ASSERT_EQ(valid, false); |
| 41 float length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels); | 41 float length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels); |
| 42 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize; | 42 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize; |
| 43 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportWidth) * viewpor
tWidth / 100.0; | 43 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportWidth) * viewpor
tWidth / 100.0; |
| 44 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportHeight) * viewpo
rtHeight / 100.0; | 44 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportHeight) * viewpo
rtHeight / 100.0; |
| 45 ASSERT_EQ(value, length); | 45 ASSERT_EQ(value, length); |
| 46 } | 46 } |
| 47 | 47 |
| 48 | 48 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } | 123 } |
| 124 | 124 |
| 125 for (unsigned i = 0; testCases[i].input; ++i) { | 125 for (unsigned i = 0; testCases[i].input; ++i) { |
| 126 if (testCases[i].dontRunInCSSCalc) | 126 if (testCases[i].dontRunInCSSCalc) |
| 127 continue; | 127 continue; |
| 128 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); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 } // namespace | 132 } // namespace |
| OLD | NEW |