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

Side by Side Diff: Source/wtf/MathExtras.h

Issue 663993003: Don't calculate a top controls adjustment if pinch viewport size is uninitialized. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Feedback Created 6 years, 2 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
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 346
347 template<typename T> inline T defaultMaximumForClamp() { return std::numeric_lim its<T>::max(); } 347 template<typename T> inline T defaultMaximumForClamp() { return std::numeric_lim its<T>::max(); }
348 // This basically reimplements C++11's std::numeric_limits<T>::lowest(). 348 // This basically reimplements C++11's std::numeric_limits<T>::lowest().
349 template<typename T> inline T defaultMinimumForClamp() { return std::numeric_lim its<T>::min(); } 349 template<typename T> inline T defaultMinimumForClamp() { return std::numeric_lim its<T>::min(); }
350 template<> inline float defaultMinimumForClamp<float>() { return -std::numeric_l imits<float>::max(); } 350 template<> inline float defaultMinimumForClamp<float>() { return -std::numeric_l imits<float>::max(); }
351 template<> inline double defaultMinimumForClamp<double>() { return -std::numeric _limits<double>::max(); } 351 template<> inline double defaultMinimumForClamp<double>() { return -std::numeric _limits<double>::max(); }
352 352
353 // And, finally, the actual function for people to call. 353 // And, finally, the actual function for people to call.
354 template<typename LimitType, typename ValueType> inline LimitType clampTo(ValueT ype value, LimitType min = defaultMinimumForClamp<LimitType>(), LimitType max = defaultMaximumForClamp<LimitType>()) 354 template<typename LimitType, typename ValueType> inline LimitType clampTo(ValueT ype value, LimitType min = defaultMinimumForClamp<LimitType>(), LimitType max = defaultMaximumForClamp<LimitType>())
355 { 355 {
356 // FIXME: Uncomment this after fixing all callsites which violate it. 356 ASSERT(!std::isnan(static_cast<double>(value)));
357 // ASSERT(!std::isnan(static_cast<double>(value)));
358 ASSERT(min <= max); // This also ensures |min| and |max| aren't NaN. 357 ASSERT(min <= max); // This also ensures |min| and |max| aren't NaN.
359 return ClampToHelper<LimitType, ValueType>::clampTo(value, min, max); 358 return ClampToHelper<LimitType, ValueType>::clampTo(value, min, max);
360 } 359 }
361 360
362 inline bool isWithinIntRange(float x) 361 inline bool isWithinIntRange(float x)
363 { 362 {
364 return x > static_cast<float>(std::numeric_limits<int>::min()) && x < static _cast<float>(std::numeric_limits<int>::max()); 363 return x > static_cast<float>(std::numeric_limits<int>::min()) && x < static _cast<float>(std::numeric_limits<int>::max());
365 } 364 }
366 365
367 static size_t greatestCommonDivisor(size_t a, size_t b) 366 static size_t greatestCommonDivisor(size_t a, size_t b)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 if (i >> 2) 420 if (i >> 2)
422 log2 += 2, i >>= 2; 421 log2 += 2, i >>= 2;
423 if (i >> 1) 422 if (i >> 1)
424 log2 += 1; 423 log2 += 1;
425 return log2; 424 return log2;
426 } 425 }
427 426
428 } // namespace WTF 427 } // namespace WTF
429 428
430 #endif // #ifndef WTF_MathExtras_h 429 #endif // #ifndef WTF_MathExtras_h
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698