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

Side by Side Diff: third_party/WebKit/Source/platform/Length.h

Issue 2846303002: Replace ASSERT with DCHECK in platform/ (Closed)
Patch Set: rebase Created 3 years, 7 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) 1999 Lars Knoll (knoll@kde.org) 2 Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 Copyright (C) 2006, 2008 Apple Inc. All rights reserved. 3 Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
4 Copyright (C) 2011 Rik Cabanier (cabanier@adobe.com) 4 Copyright (C) 2011 Rik Cabanier (cabanier@adobe.com)
5 Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 5 Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 float_value_ = static_cast<float>(float_value_ * v); 134 float_value_ = static_cast<float>(float_value_ * v);
135 else 135 else
136 int_value_ = static_cast<int>(int_value_ * v); 136 int_value_ = static_cast<int>(int_value_ * v);
137 137
138 return *this; 138 return *this;
139 } 139 }
140 140
141 // FIXME: Make this private (if possible) or at least rename it 141 // FIXME: Make this private (if possible) or at least rename it
142 // (http://crbug.com/432707). 142 // (http://crbug.com/432707).
143 inline float Value() const { 143 inline float Value() const {
144 ASSERT(!IsCalculated()); 144 DCHECK(!IsCalculated());
145 return GetFloatValue(); 145 return GetFloatValue();
146 } 146 }
147 147
148 int IntValue() const { 148 int IntValue() const {
149 if (IsCalculated()) { 149 if (IsCalculated()) {
150 ASSERT_NOT_REACHED(); 150 ASSERT_NOT_REACHED();
151 return 0; 151 return 0;
152 } 152 }
153 return GetIntValue(); 153 return GetIntValue();
154 } 154 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 void SetValue(float value) { *this = Length(value, kFixed); } 201 void SetValue(float value) { *this = Length(value, kFixed); }
202 202
203 bool IsMaxSizeNone() const { return GetType() == kMaxSizeNone; } 203 bool IsMaxSizeNone() const { return GetType() == kMaxSizeNone; }
204 204
205 // FIXME calc: https://bugs.webkit.org/show_bug.cgi?id=80357. A calculated 205 // FIXME calc: https://bugs.webkit.org/show_bug.cgi?id=80357. A calculated
206 // Length always contains a percentage, and without a maxValue passed to these 206 // Length always contains a percentage, and without a maxValue passed to these
207 // functions it's impossible to determine the sign or zero-ness. We assume all 207 // functions it's impossible to determine the sign or zero-ness. We assume all
208 // calc values are positive and non-zero for now. 208 // calc values are positive and non-zero for now.
209 bool IsZero() const { 209 bool IsZero() const {
210 ASSERT(!IsMaxSizeNone()); 210 DCHECK(!IsMaxSizeNone());
211 if (IsCalculated()) 211 if (IsCalculated())
212 return false; 212 return false;
213 213
214 return is_float_ ? !float_value_ : !int_value_; 214 return is_float_ ? !float_value_ : !int_value_;
215 } 215 }
216 bool IsPositive() const { 216 bool IsPositive() const {
217 if (IsMaxSizeNone()) 217 if (IsMaxSizeNone())
218 return false; 218 return false;
219 if (IsCalculated()) 219 if (IsCalculated())
220 return true; 220 return true;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 if (IsZero()) 273 if (IsZero())
274 result_type = from.GetType(); 274 result_type = from.GetType();
275 275
276 float blended_value = blink::Blend(from.Value(), Value(), progress); 276 float blended_value = blink::Blend(from.Value(), Value(), progress);
277 if (range == kValueRangeNonNegative) 277 if (range == kValueRangeNonNegative)
278 blended_value = clampTo<float>(blended_value, 0); 278 blended_value = clampTo<float>(blended_value, 0);
279 return Length(blended_value, result_type); 279 return Length(blended_value, result_type);
280 } 280 }
281 281
282 float GetFloatValue() const { 282 float GetFloatValue() const {
283 ASSERT(!IsMaxSizeNone()); 283 DCHECK(!IsMaxSizeNone());
284 return is_float_ ? float_value_ : int_value_; 284 return is_float_ ? float_value_ : int_value_;
285 } 285 }
286 float NonNanCalculatedValue(LayoutUnit max_value) const; 286 float NonNanCalculatedValue(LayoutUnit max_value) const;
287 287
288 Length SubtractFromOneHundredPercent() const; 288 Length SubtractFromOneHundredPercent() const;
289 289
290 Length Zoom(double factor) const; 290 Length Zoom(double factor) const;
291 291
292 private: 292 private:
293 int GetIntValue() const { 293 int GetIntValue() const {
294 ASSERT(!IsMaxSizeNone()); 294 DCHECK(!IsMaxSizeNone());
295 return is_float_ ? static_cast<int>(float_value_) : int_value_; 295 return is_float_ ? static_cast<int>(float_value_) : int_value_;
296 } 296 }
297 297
298 Length BlendMixedTypes(const Length& from, double progress, ValueRange) const; 298 Length BlendMixedTypes(const Length& from, double progress, ValueRange) const;
299 299
300 int CalculationHandle() const { 300 int CalculationHandle() const {
301 ASSERT(IsCalculated()); 301 DCHECK(IsCalculated());
302 return GetIntValue(); 302 return GetIntValue();
303 } 303 }
304 void IncrementCalculatedRef() const; 304 void IncrementCalculatedRef() const;
305 void DecrementCalculatedRef() const; 305 void DecrementCalculatedRef() const;
306 306
307 union { 307 union {
308 int int_value_; 308 int int_value_;
309 float float_value_; 309 float float_value_;
310 }; 310 };
311 bool quirk_; 311 bool quirk_;
312 unsigned char type_; 312 unsigned char type_;
313 bool is_float_; 313 bool is_float_;
314 }; 314 };
315 315
316 } // namespace blink 316 } // namespace blink
317 317
318 #endif // Length_h 318 #endif // Length_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/LayoutTestSupport.cpp ('k') | third_party/WebKit/Source/platform/Length.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698