| 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/css/CSSPrimitiveValue.h" | 8 #include "core/css/CSSPrimitiveValue.h" |
| 9 #include "core/css/MediaValuesCached.h" | 9 #include "core/css/MediaValuesCached.h" |
| 10 #include "core/css/StylePropertySet.h" | 10 #include "core/css/StylePropertySet.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 { | 25 { |
| 26 lengthArray.resize(CSSPrimitiveValue::LengthUnitTypeCount); | 26 lengthArray.resize(CSSPrimitiveValue::LengthUnitTypeCount); |
| 27 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) | 27 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) |
| 28 lengthArray.at(i) = 0; | 28 lengthArray.at(i) = 0; |
| 29 } | 29 } |
| 30 | 30 |
| 31 static void verifyCSSCalc(String text, double value, bool valid, unsigned fontSi
ze, unsigned viewportWidth, unsigned viewportHeight) | 31 static void verifyCSSCalc(String text, double value, bool valid, unsigned fontSi
ze, unsigned viewportWidth, unsigned viewportHeight) |
| 32 { | 32 { |
| 33 CSSLengthArray lengthArray; | 33 CSSLengthArray lengthArray; |
| 34 initLengthArray(lengthArray); | 34 initLengthArray(lengthArray); |
| 35 RefPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::creat
e(); | 35 RefPtrWillBeRawPtr<MutableStylePropertySet> propertySet = MutableStyleProper
tySet::create(); |
| 36 propertySet->setProperty(CSSPropertyLeft, text); | 36 propertySet->setProperty(CSSPropertyLeft, text); |
| 37 RefPtrWillBeRawPtr<CSSValue> cssValue = propertySet->getPropertyCSSValue(CSS
PropertyLeft); | 37 RefPtrWillBeRawPtr<CSSValue> cssValue = propertySet->getPropertyCSSValue(CSS
PropertyLeft); |
| 38 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(cssValue.get()); | 38 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(cssValue.get()); |
| 39 if (primitiveValue) | 39 if (primitiveValue) |
| 40 primitiveValue->accumulateLengthArray(lengthArray); | 40 primitiveValue->accumulateLengthArray(lengthArray); |
| 41 else | 41 else |
| 42 ASSERT_EQ(valid, false); | 42 ASSERT_EQ(valid, false); |
| 43 int length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels); | 43 int length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels); |
| 44 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize; | 44 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize; |
| 45 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportWidth) * viewpor
tWidth / 100.0; | 45 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportWidth) * viewpor
tWidth / 100.0; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 | 128 |
| 129 for (unsigned i = 0; testCases[i].input; ++i) { | 129 for (unsigned i = 0; testCases[i].input; ++i) { |
| 130 if (testCases[i].dontRunInCSSCalc) | 130 if (testCases[i].dontRunInCSSCalc) |
| 131 continue; | 131 continue; |
| 132 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali
d, data.defaultFontSize, data.viewportWidth, data.viewportHeight); | 132 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali
d, data.defaultFontSize, data.viewportWidth, data.viewportHeight); |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace | 136 } // namespace |
| OLD | NEW |