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

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

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 | « third_party/WebKit/Source/platform/geometry/FloatRect.h ('k') | no next file » | 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 FloatRect unionRect(const Vector<FloatRect>& rects) { 177 FloatRect unionRect(const Vector<FloatRect>& rects) {
178 FloatRect result; 178 FloatRect result;
179 179
180 size_t count = rects.size(); 180 size_t count = rects.size();
181 for (size_t i = 0; i < count; ++i) 181 for (size_t i = 0; i < count; ++i)
182 result.unite(rects[i]); 182 result.unite(rects[i]);
183 183
184 return result; 184 return result;
185 } 185 }
186 186
187 IntRect enclosingIntRect(const FloatRect& rect) {
188 IntPoint location = flooredIntPoint(rect.minXMinYCorner());
189 IntPoint maxPoint = ceiledIntPoint(rect.maxXMaxYCorner());
190
191 return IntRect(location, maxPoint - location);
192 }
193
194 IntRect enclosedIntRect(const FloatRect& rect) { 187 IntRect enclosedIntRect(const FloatRect& rect) {
195 IntPoint location = ceiledIntPoint(rect.minXMinYCorner()); 188 IntPoint location = ceiledIntPoint(rect.minXMinYCorner());
196 IntPoint maxPoint = flooredIntPoint(rect.maxXMaxYCorner()); 189 IntPoint maxPoint = flooredIntPoint(rect.maxXMaxYCorner());
197 IntSize size = maxPoint - location; 190 IntSize size = maxPoint - location;
198 size.clampNegativeToZero(); 191 size.clampNegativeToZero();
199 192
200 return IntRect(location, size); 193 return IntRect(location, size);
201 } 194 }
202 195
203 IntRect roundedIntRect(const FloatRect& rect) { 196 IntRect roundedIntRect(const FloatRect& rect) {
(...skipping 12 matching lines...) Expand all
216 destRect.y() + (r.y() - srcRect.y()) * heightScale, 209 destRect.y() + (r.y() - srcRect.y()) * heightScale,
217 r.width() * widthScale, r.height() * heightScale); 210 r.width() * widthScale, r.height() * heightScale);
218 } 211 }
219 212
220 String FloatRect::toString() const { 213 String FloatRect::toString() const {
221 return String::format("%s %s", location().toString().ascii().data(), 214 return String::format("%s %s", location().toString().ascii().data(),
222 size().toString().ascii().data()); 215 size().toString().ascii().data());
223 } 216 }
224 217
225 } // namespace blink 218 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/geometry/FloatRect.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698