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

Side by Side Diff: third_party/WebKit/Source/platform/geometry/FloatRect.h

Issue 2628903003: Inline FloatRect::enclosingIntRect (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/geometry/FloatRect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 11 matching lines...) Expand all
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 "platform/geometry/FloatPoint.h" 30 #include "platform/geometry/FloatPoint.h"
31 #include "platform/geometry/FloatRectOutsets.h" 31 #include "platform/geometry/FloatRectOutsets.h"
32 #include "platform/geometry/IntRect.h"
32 #include "third_party/skia/include/core/SkRect.h" 33 #include "third_party/skia/include/core/SkRect.h"
33 #include "wtf/Allocator.h" 34 #include "wtf/Allocator.h"
34 #include "wtf/Forward.h" 35 #include "wtf/Forward.h"
35 #include "wtf/Vector.h" 36 #include "wtf/Vector.h"
36 #include <iosfwd> 37 #include <iosfwd>
37 38
38 #if OS(MACOSX) 39 #if OS(MACOSX)
39 typedef struct CGRect CGRect; 40 typedef struct CGRect CGRect;
40 41
41 #ifdef __OBJC__ 42 #ifdef __OBJC__
42 #import <Foundation/Foundation.h> 43 #import <Foundation/Foundation.h>
43 #endif 44 #endif
44 #endif 45 #endif
45 46
46 namespace gfx { 47 namespace gfx {
47 class RectF; 48 class RectF;
48 } 49 }
49 50
50 namespace blink { 51 namespace blink {
51 52
52 class IntRect;
53 class LayoutRect; 53 class LayoutRect;
54 class LayoutSize; 54 class LayoutSize;
55 55
56 class PLATFORM_EXPORT FloatRect { 56 class PLATFORM_EXPORT FloatRect {
57 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 57 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
58 58
59 public: 59 public:
60 enum ContainsMode { InsideOrOnStroke, InsideButNotOnStroke }; 60 enum ContainsMode { InsideOrOnStroke, InsideButNotOnStroke };
61 61
62 FloatRect() {} 62 FloatRect() {}
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 249 }
250 250
251 inline bool operator==(const FloatRect& a, const FloatRect& b) { 251 inline bool operator==(const FloatRect& a, const FloatRect& b) {
252 return a.location() == b.location() && a.size() == b.size(); 252 return a.location() == b.location() && a.size() == b.size();
253 } 253 }
254 254
255 inline bool operator!=(const FloatRect& a, const FloatRect& b) { 255 inline bool operator!=(const FloatRect& a, const FloatRect& b) {
256 return a.location() != b.location() || a.size() != b.size(); 256 return a.location() != b.location() || a.size() != b.size();
257 } 257 }
258 258
259 PLATFORM_EXPORT IntRect enclosingIntRect(const FloatRect&); 259 inline IntRect enclosingIntRect(const FloatRect& rect) {
260 IntPoint location = flooredIntPoint(rect.minXMinYCorner());
261 IntPoint maxPoint = ceiledIntPoint(rect.maxXMaxYCorner());
262
263 return IntRect(location, maxPoint - location);
264 }
260 265
261 // Returns a valid IntRect contained within the given FloatRect. 266 // Returns a valid IntRect contained within the given FloatRect.
262 PLATFORM_EXPORT IntRect enclosedIntRect(const FloatRect&); 267 PLATFORM_EXPORT IntRect enclosedIntRect(const FloatRect&);
263 268
264 PLATFORM_EXPORT IntRect roundedIntRect(const FloatRect&); 269 PLATFORM_EXPORT IntRect roundedIntRect(const FloatRect&);
265 270
266 // Map supplied rect from srcRect to an equivalent rect in destRect. 271 // Map supplied rect from srcRect to an equivalent rect in destRect.
267 PLATFORM_EXPORT FloatRect mapRect(const FloatRect&, 272 PLATFORM_EXPORT FloatRect mapRect(const FloatRect&,
268 const FloatRect& srcRect, 273 const FloatRect& srcRect,
269 const FloatRect& destRect); 274 const FloatRect& destRect);
270 275
271 // Redeclared here to avoid ODR issues. 276 // Redeclared here to avoid ODR issues.
272 // See platform/testing/GeometryPrinters.h. 277 // See platform/testing/GeometryPrinters.h.
273 void PrintTo(const FloatRect&, std::ostream*); 278 void PrintTo(const FloatRect&, std::ostream*);
274 279
275 } // namespace blink 280 } // namespace blink
276 281
277 #endif 282 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/geometry/FloatRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698