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

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

Issue 1647313003: Continue converting to explicit LayoutUnit constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@explicitContstructors
Patch Set: Add TODO Created 4 years, 10 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) 2012, Google Inc. All rights reserved. 2 * Copyright (c) 2012, 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 151 }
152 152
153 int floor() const 153 int floor() const
154 { 154 {
155 if (UNLIKELY(m_value <= INT_MIN + kFixedPointDenominator - 1)) 155 if (UNLIKELY(m_value <= INT_MIN + kFixedPointDenominator - 1))
156 return intMinForLayoutUnit; 156 return intMinForLayoutUnit;
157 157
158 return m_value >> kLayoutUnitFractionalBits; 158 return m_value >> kLayoutUnitFractionalBits;
159 } 159 }
160 160
161 LayoutUnit clampToZero() const 161 LayoutUnit clampNegativeToZero() const
162 { 162 {
163 return std::max(*this, LayoutUnit()); 163 return std::max(*this, LayoutUnit());
164 } 164 }
165 165
166 LayoutUnit clampPositiveToZero() const
167 {
168 return std::min(*this, LayoutUnit());
169 }
170
166 LayoutUnit fraction() const 171 LayoutUnit fraction() const
167 { 172 {
168 // Add the fraction to the size (as opposed to the full location) to avo id overflows. 173 // Add the fraction to the size (as opposed to the full location) to avo id overflows.
169 // Compute fraction using the mod operator to preserve the sign of the v alue as it may affect rounding. 174 // Compute fraction using the mod operator to preserve the sign of the v alue as it may affect rounding.
170 LayoutUnit fraction; 175 LayoutUnit fraction;
171 fraction.setRawValue(rawValue() % kFixedPointDenominator); 176 fraction.setRawValue(rawValue() % kFixedPointDenominator);
172 return fraction; 177 return fraction;
173 } 178 }
174 179
175 bool mightBeSaturated() const 180 bool mightBeSaturated() const
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 if (value >= max) 802 if (value >= max)
798 return max; 803 return max;
799 if (value <= min) 804 if (value <= min)
800 return min; 805 return min;
801 return value; 806 return value;
802 } 807 }
803 808
804 } // namespace blink 809 } // namespace blink
805 810
806 #endif // LayoutUnit_h 811 #endif // LayoutUnit_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintInfoTest.cpp ('k') | third_party/WebKit/Source/platform/geometry/LayoutRect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698