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

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

Issue 641643004: Reapply the non-MathExtras parts of (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 LayoutUnit(unsigned short value) { setValue(value); } 67 LayoutUnit(unsigned short value) { setValue(value); }
68 LayoutUnit(unsigned value) { setValue(value); } 68 LayoutUnit(unsigned value) { setValue(value); }
69 LayoutUnit(unsigned long value) { m_value = clampTo<int>(value * kFixedPoint Denominator); } 69 LayoutUnit(unsigned long value) { m_value = clampTo<int>(value * kFixedPoint Denominator); }
70 LayoutUnit(unsigned long long value) { m_value = clampTo<int>(value * kFixed PointDenominator); } 70 LayoutUnit(unsigned long long value) { m_value = clampTo<int>(value * kFixed PointDenominator); }
71 LayoutUnit(float value) { m_value = clampTo<int>(value * kFixedPointDenomina tor); } 71 LayoutUnit(float value) { m_value = clampTo<int>(value * kFixedPointDenomina tor); }
72 LayoutUnit(double value) { m_value = clampTo<int>(value * kFixedPointDenomin ator); } 72 LayoutUnit(double value) { m_value = clampTo<int>(value * kFixedPointDenomin ator); }
73 73
74 static LayoutUnit fromFloatCeil(float value) 74 static LayoutUnit fromFloatCeil(float value)
75 { 75 {
76 LayoutUnit v; 76 LayoutUnit v;
77 v.m_value = clampToInteger(ceilf(value * kFixedPointDenominator)); 77 v.m_value = clampTo<int>(ceilf(value * kFixedPointDenominator));
78 return v; 78 return v;
79 } 79 }
80 80
81 static LayoutUnit fromFloatFloor(float value) 81 static LayoutUnit fromFloatFloor(float value)
82 { 82 {
83 LayoutUnit v; 83 LayoutUnit v;
84 v.m_value = clampToInteger(floorf(value * kFixedPointDenominator)); 84 v.m_value = clampTo<int>(floorf(value * kFixedPointDenominator));
85 return v; 85 return v;
86 } 86 }
87 87
88 static LayoutUnit fromFloatRound(float value) 88 static LayoutUnit fromFloatRound(float value)
89 { 89 {
90 if (value >= 0) 90 if (value >= 0)
91 return clamp(value + epsilon() / 2.0f); 91 return clamp(value + epsilon() / 2.0f);
92 return clamp(value - epsilon() / 2.0f); 92 return clamp(value - epsilon() / 2.0f);
93 } 93 }
94 94
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 if (value >= max) 793 if (value >= max)
794 return max; 794 return max;
795 if (value <= min) 795 if (value <= min)
796 return min; 796 return min;
797 return value; 797 return value;
798 } 798 }
799 799
800 } // namespace blink 800 } // namespace blink
801 801
802 #endif // LayoutUnit_h 802 #endif // LayoutUnit_h
OLDNEW
« no previous file with comments | « Source/core/rendering/style/CounterDirectives.h ('k') | Source/platform/fonts/FontDescription.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698