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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSCalculationValueTest.cpp

Issue 1858753003: Remove RawPtr from core/css (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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 /* 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
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, RawPtr<CSSCalcExpressionNode> expression, float expectedPixels, float expec tedPercent) 50 void testAccumulatePixelsAndPercent(const CSSToLengthConversionData& conversionD ata, CSSCalcExpressionNode* expression, float expectedPixels, float expectedPerc ent)
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 RawPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::creat e(HTMLQuirksMode); 68 MutableStylePropertySet* propertySet = MutableStylePropertySet::create(HTMLQ uirksMode);
69 propertySet->setProperty(CSSPropertyLeft, text); 69 propertySet->setProperty(CSSPropertyLeft, text);
70 toCSSPrimitiveValue(propertySet->getPropertyCSSValue(CSSPropertyLeft).get()) ->accumulateLengthArray(lengthArray); 70 toCSSPrimitiveValue(propertySet->getPropertyCSSValue(CSSPropertyLeft))->accu mulateLengthArray(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;
79 } 79 }
80 return true; 80 return true;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSCalculationValue.cpp ('k') | third_party/WebKit/Source/core/css/CSSColorValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698