| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 void PrintTo(const CSSLengthArray& lengthArray, ::std::ostream* os) | 42 void PrintTo(const CSSLengthArray& lengthArray, ::std::ostream* os) |
| 43 { | 43 { |
| 44 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) | 44 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) |
| 45 *os << lengthArray.at(i) << ' '; | 45 *os << lengthArray.at(i) << ' '; |
| 46 } | 46 } |
| 47 | 47 |
| 48 namespace { | 48 namespace { |
| 49 | 49 |
| 50 void testAccumulatePixelsAndPercent(const CSSToLengthConversionData& conversionD
ata, PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> expression, float expectedPix
els, float expectedPercent) | 50 void testAccumulatePixelsAndPercent(const CSSToLengthConversionData& conversionD
ata, RawPtr<CSSCalcExpressionNode> expression, float expectedPixels, float expec
tedPercent) |
| 51 { | 51 { |
| 52 PixelsAndPercent value(0, 0); | 52 PixelsAndPercent value(0, 0); |
| 53 expression->accumulatePixelsAndPercent(conversionData, value); | 53 expression->accumulatePixelsAndPercent(conversionData, value); |
| 54 EXPECT_EQ(expectedPixels, value.pixels); | 54 EXPECT_EQ(expectedPixels, value.pixels); |
| 55 EXPECT_EQ(expectedPercent, value.percent); | 55 EXPECT_EQ(expectedPercent, value.percent); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void initLengthArray(CSSLengthArray& lengthArray) | 58 void initLengthArray(CSSLengthArray& lengthArray) |
| 59 { | 59 { |
| 60 lengthArray.resize(CSSPrimitiveValue::LengthUnitTypeCount); | 60 lengthArray.resize(CSSPrimitiveValue::LengthUnitTypeCount); |
| 61 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) | 61 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) |
| 62 lengthArray.at(i) = 0; | 62 lengthArray.at(i) = 0; |
| 63 } | 63 } |
| 64 | 64 |
| 65 CSSLengthArray& setLengthArray(CSSLengthArray& lengthArray, String text) | 65 CSSLengthArray& setLengthArray(CSSLengthArray& lengthArray, String text) |
| 66 { | 66 { |
| 67 initLengthArray(lengthArray); | 67 initLengthArray(lengthArray); |
| 68 RefPtrWillBeRawPtr<MutableStylePropertySet> propertySet = MutableStyleProper
tySet::create(HTMLQuirksMode); | 68 RawPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::creat
e(HTMLQuirksMode); |
| 69 propertySet->setProperty(CSSPropertyLeft, text); | 69 propertySet->setProperty(CSSPropertyLeft, text); |
| 70 toCSSPrimitiveValue(propertySet->getPropertyCSSValue(CSSPropertyLeft).get())
->accumulateLengthArray(lengthArray); | 70 toCSSPrimitiveValue(propertySet->getPropertyCSSValue(CSSPropertyLeft).get())
->accumulateLengthArray(lengthArray); |
| 71 return lengthArray; | 71 return lengthArray; |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool lengthArraysEqual(CSSLengthArray& a, CSSLengthArray& b) | 74 bool lengthArraysEqual(CSSLengthArray& a, CSSLengthArray& b) |
| 75 { | 75 { |
| 76 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) { | 76 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) { |
| 77 if (a.at(i) != b.at(i)) | 77 if (a.at(i) != b.at(i)) |
| 78 return false; | 78 return false; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 expectation.at(CSSPrimitiveValue::UnitTypePixels) = 15; | 185 expectation.at(CSSPrimitiveValue::UnitTypePixels) = 15; |
| 186 expectation.at(CSSPrimitiveValue::UnitTypeFontSize) = 20; | 186 expectation.at(CSSPrimitiveValue::UnitTypeFontSize) = 20; |
| 187 expectation.at(CSSPrimitiveValue::UnitTypePercentage) = -40; | 187 expectation.at(CSSPrimitiveValue::UnitTypePercentage) = -40; |
| 188 EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "calc((1 *
2) * (5px + 20em / 2) - 80% / (3 - 1) + 5px)"))); | 188 EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "calc((1 *
2) * (5px + 20em / 2) - 80% / (3 - 1) + 5px)"))); |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // anonymous namespace | 191 } // anonymous namespace |
| 192 | 192 |
| 193 } // namespace blink | 193 } // namespace blink |
| OLD | NEW |