OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserve
d. | 2 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserve
d. |
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 bool isEmpty() const { return m_width <= 0 || m_height <= 0; } | 73 bool isEmpty() const { return m_width <= 0 || m_height <= 0; } |
74 bool isZero() const { return !m_width && !m_height; } | 74 bool isZero() const { return !m_width && !m_height; } |
75 | 75 |
76 float aspectRatio() const { return static_cast<float>(m_width) / static_cast
<float>(m_height); } | 76 float aspectRatio() const { return static_cast<float>(m_width) / static_cast
<float>(m_height); } |
77 | 77 |
78 void expand(int width, int height) | 78 void expand(int width, int height) |
79 { | 79 { |
80 m_width += width; | 80 m_width += width; |
81 m_height += height; | 81 m_height += height; |
82 } | 82 } |
| 83 |
| 84 void scale(float widthScale, float heightScale) |
| 85 { |
| 86 m_width = static_cast<int>(static_cast<float>(m_width) * widthScale); |
| 87 m_height = static_cast<int>(static_cast<float>(m_height) * heightScale); |
| 88 } |
83 | 89 |
84 void scale(float scale) | 90 void scale(float scale) |
85 { | 91 { |
86 m_width = static_cast<int>(static_cast<float>(m_width) * scale); | 92 this->scale(scale, scale); |
87 m_height = static_cast<int>(static_cast<float>(m_height) * scale); | |
88 } | 93 } |
89 | 94 |
90 IntSize expandedTo(const IntSize& other) const | 95 IntSize expandedTo(const IntSize& other) const |
91 { | 96 { |
92 return IntSize(m_width > other.m_width ? m_width : other.m_width, | 97 return IntSize(m_width > other.m_width ? m_width : other.m_width, |
93 m_height > other.m_height ? m_height : other.m_height); | 98 m_height > other.m_height ? m_height : other.m_height); |
94 } | 99 } |
95 | 100 |
96 IntSize shrunkTo(const IntSize& other) const | 101 IntSize shrunkTo(const IntSize& other) const |
97 { | 102 { |
98 return IntSize(m_width < other.m_width ? m_width : other.m_width, | 103 return IntSize(m_width < other.m_width ? m_width : other.m_width, |
99 m_height < other.m_height ? m_height : other.m_height); | 104 m_height < other.m_height ? m_height : other.m_height); |
100 } | 105 } |
101 | 106 |
102 void clampNegativeToZero() | 107 void clampNegativeToZero() |
103 { | 108 { |
104 *this = expandedTo(IntSize()); | 109 *this = expandedTo(IntSize()); |
105 } | 110 } |
106 | 111 |
| 112 void clampToMinimumSize(const IntSize& minimumSize) |
| 113 { |
| 114 if (m_width < minimumSize.width()) |
| 115 m_width = minimumSize.width(); |
| 116 if (m_height < minimumSize.height()) |
| 117 m_height = minimumSize.height(); |
| 118 } |
| 119 |
107 int diagonalLengthSquared() const | 120 int diagonalLengthSquared() const |
108 { | 121 { |
109 return m_width * m_width + m_height * m_height; | 122 return m_width * m_width + m_height * m_height; |
110 } | 123 } |
111 | 124 |
112 IntSize transposedSize() const | 125 IntSize transposedSize() const |
113 { | 126 { |
114 return IntSize(m_height, m_width); | 127 return IntSize(m_height, m_width); |
115 } | 128 } |
116 | 129 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } | 196 } |
184 | 197 |
185 inline bool operator!=(const IntSize& a, const IntSize& b) | 198 inline bool operator!=(const IntSize& a, const IntSize& b) |
186 { | 199 { |
187 return a.width() != b.width() || a.height() != b.height(); | 200 return a.width() != b.width() || a.height() != b.height(); |
188 } | 201 } |
189 | 202 |
190 } // namespace WebCore | 203 } // namespace WebCore |
191 | 204 |
192 #endif // IntSize_h | 205 #endif // IntSize_h |
OLD | NEW |