OLD | NEW |
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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 return LayoutUnit(a) - b; | 637 return LayoutUnit(a) - b; |
638 } | 638 } |
639 | 639 |
640 inline float operator-(const float a, const LayoutUnit& b) | 640 inline float operator-(const float a, const LayoutUnit& b) |
641 { | 641 { |
642 return a - b.toFloat(); | 642 return a - b.toFloat(); |
643 } | 643 } |
644 | 644 |
645 inline LayoutUnit operator-(const LayoutUnit& a) | 645 inline LayoutUnit operator-(const LayoutUnit& a) |
646 { | 646 { |
| 647 // -min() is saturated to max(). |
| 648 if (a == LayoutUnit::min()) |
| 649 return LayoutUnit::max(); |
| 650 |
647 LayoutUnit returnVal; | 651 LayoutUnit returnVal; |
648 returnVal.setRawValue(-a.rawValue()); | 652 returnVal.setRawValue(-a.rawValue()); |
649 return returnVal; | 653 return returnVal; |
650 } | 654 } |
651 | 655 |
652 // For returning the remainder after a division with integer results. | 656 // For returning the remainder after a division with integer results. |
653 inline LayoutUnit intMod(const LayoutUnit& a, const LayoutUnit& b) | 657 inline LayoutUnit intMod(const LayoutUnit& a, const LayoutUnit& b) |
654 { | 658 { |
655 // This calculates the modulo so that: a = static_cast<int>(a / b) * b + int
Mod(a, b). | 659 // This calculates the modulo so that: a = static_cast<int>(a / b) * b + int
Mod(a, b). |
656 LayoutUnit returnVal; | 660 LayoutUnit returnVal; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 } | 811 } |
808 | 812 |
809 inline std::ostream& operator<<(std::ostream& stream, const LayoutUnit& value) | 813 inline std::ostream& operator<<(std::ostream& stream, const LayoutUnit& value) |
810 { | 814 { |
811 return stream << value.toDouble(); | 815 return stream << value.toDouble(); |
812 } | 816 } |
813 | 817 |
814 } // namespace blink | 818 } // namespace blink |
815 | 819 |
816 #endif // LayoutUnit_h | 820 #endif // LayoutUnit_h |
OLD | NEW |