Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2005 Nokia. All rights reserved. | 3 * Copyright (C) 2005 Nokia. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef FloatRect_h | 27 #ifndef FloatRect_h |
| 28 #define FloatRect_h | 28 #define FloatRect_h |
| 29 | 29 |
| 30 #include "core/platform/graphics/FloatPoint.h" | 30 #include "platform/geometry/FloatPoint.h" |
| 31 #include "wtf/Vector.h" | 31 #include "wtf/Vector.h" |
| 32 | 32 |
| 33 #if OS(MACOSX) | 33 #if OS(MACOSX) |
| 34 typedef struct CGRect CGRect; | 34 typedef struct CGRect CGRect; |
| 35 #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES | 35 #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES |
| 36 typedef struct CGRect NSRect; | 36 typedef struct CGRect NSRect; |
| 37 #else | 37 #else |
| 38 typedef struct _NSRect NSRect; | 38 typedef struct _NSRect NSRect; |
| 39 #endif | 39 #endif |
| 40 #endif | 40 #endif |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 | 132 |
| 133 void intersect(const FloatRect&); | 133 void intersect(const FloatRect&); |
| 134 void unite(const FloatRect&); | 134 void unite(const FloatRect&); |
| 135 void uniteEvenIfEmpty(const FloatRect&); | 135 void uniteEvenIfEmpty(const FloatRect&); |
| 136 void uniteIfNonZero(const FloatRect&); | 136 void uniteIfNonZero(const FloatRect&); |
| 137 void extend(const FloatPoint&); | 137 void extend(const FloatPoint&); |
| 138 | 138 |
| 139 // Note, this doesn't match what IntRect::contains(IntPoint&) does; the int version | 139 // Note, this doesn't match what IntRect::contains(IntPoint&) does; the int version |
| 140 // is really checking for containment of 1x1 rect, but that doesn't make sen se with floats. | 140 // is really checking for containment of 1x1 rect, but that doesn't make sen se with floats. |
| 141 bool contains(float px, float py) const | 141 bool contains(float px, float py) const |
| 142 { return px >= x() && px <= maxX() && py >= y() && py <= maxY(); } | 142 { |
| 143 return px >= x() && px <= maxX() && py >= y() && py <= maxY(); | |
| 144 } | |
| 143 | 145 |
| 144 void inflateX(float dx) { | 146 void inflateX(float dx) |
| 147 { | |
| 145 m_location.setX(m_location.x() - dx); | 148 m_location.setX(m_location.x() - dx); |
| 146 m_size.setWidth(m_size.width() + dx + dx); | 149 m_size.setWidth(m_size.width() + dx + dx); |
| 147 } | 150 } |
| 148 void inflateY(float dy) { | 151 void inflateY(float dy) |
| 152 { | |
| 149 m_location.setY(m_location.y() - dy); | 153 m_location.setY(m_location.y() - dy); |
| 150 m_size.setHeight(m_size.height() + dy + dy); | 154 m_size.setHeight(m_size.height() + dy + dy); |
| 151 } | 155 } |
| 152 void inflate(float d) { inflateX(d); inflateY(d); } | 156 void inflate(float d) { inflateX(d); inflateY(d); } |
| 153 void scale(float s) { scale(s, s); } | 157 void scale(float s) { scale(s, s); } |
| 154 void scale(float sx, float sy); | 158 void scale(float sx, float sy); |
| 155 | 159 |
| 156 FloatRect transposedRect() const { return FloatRect(m_location.transposedPoi nt(), m_size.transposedSize()); } | 160 FloatRect transposedRect() const { return FloatRect(m_location.transposedPoi nt(), m_size.transposedSize()); } |
| 157 | 161 |
| 158 // Re-initializes this rectangle to fit the sets of passed points. | 162 // Re-initializes this rectangle to fit the sets of passed points. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 return a.location() != b.location() || a.size() != b.size(); | 228 return a.location() != b.location() || a.size() != b.size(); |
| 225 } | 229 } |
| 226 | 230 |
| 227 IntRect enclosingIntRect(const FloatRect&); | 231 IntRect enclosingIntRect(const FloatRect&); |
| 228 | 232 |
| 229 // Returns a valid IntRect contained within the given FloatRect. | 233 // Returns a valid IntRect contained within the given FloatRect. |
| 230 IntRect enclosedIntRect(const FloatRect&); | 234 IntRect enclosedIntRect(const FloatRect&); |
| 231 | 235 |
| 232 IntRect roundedIntRect(const FloatRect&); | 236 IntRect roundedIntRect(const FloatRect&); |
| 233 | 237 |
| 234 // Map rect r from srcRect to an equivalent rect in destRect. | 238 // Map rect r from srcRect to an equivalent rect in destRect. |
|
pdr.
2013/10/01 23:21:28
Please update the comment
| |
| 235 FloatRect mapRect(const FloatRect& r, const FloatRect& srcRect, const FloatRect& destRect); | 239 FloatRect mapRect(const FloatRect&, const FloatRect& srcRect, const FloatRect& d estRect); |
| 236 | 240 |
| 237 } | 241 } |
| 238 | 242 |
| 239 #endif | 243 #endif |
| OLD | NEW |