| 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 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "platform/geometry/FloatRect.h" | 27 #include "platform/geometry/FloatRect.h" |
| 28 | 28 |
| 29 #include "platform/FloatConversion.h" | 29 #include "platform/FloatConversion.h" |
| 30 #include "platform/geometry/IntRect.h" | 30 #include "platform/geometry/IntRect.h" |
| 31 #include "platform/geometry/LayoutRect.h" | 31 #include "platform/geometry/LayoutRect.h" |
| 32 #include "third_party/skia/include/core/SkRect.h" | 32 #include "third_party/skia/include/core/SkRect.h" |
| 33 #include "ui/gfx/geometry/rect_f.h" | 33 #include "ui/gfx/geometry/rect_f.h" |
| 34 #include "wtf/MathExtras.h" | 34 #include "wtf/MathExtras.h" |
| 35 #include "wtf/text/WTFString.h" | 35 #include <ostream> // NOLINT |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 FloatRect::FloatRect(const IntRect& r) : m_location(r.location()), m_size(r.size
()) | 39 FloatRect::FloatRect(const IntRect& r) : m_location(r.location()), m_size(r.size
()) |
| 40 { | 40 { |
| 41 } | 41 } |
| 42 | 42 |
| 43 FloatRect::FloatRect(const LayoutRect& r) : m_location(r.location()), m_size(r.s
ize()) | 43 FloatRect::FloatRect(const LayoutRect& r) : m_location(r.location()), m_size(r.s
ize()) |
| 44 { | 44 { |
| 45 } | 45 } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 { | 190 { |
| 191 FloatRect result; | 191 FloatRect result; |
| 192 | 192 |
| 193 size_t count = rects.size(); | 193 size_t count = rects.size(); |
| 194 for (size_t i = 0; i < count; ++i) | 194 for (size_t i = 0; i < count; ++i) |
| 195 result.unite(rects[i]); | 195 result.unite(rects[i]); |
| 196 | 196 |
| 197 return result; | 197 return result; |
| 198 } | 198 } |
| 199 | 199 |
| 200 #ifndef NDEBUG | |
| 201 void FloatRect::show() const | |
| 202 { | |
| 203 LayoutRect(*this).show(); | |
| 204 } | |
| 205 | |
| 206 String FloatRect::toString() const | |
| 207 { | |
| 208 return String::format("%s %s", location().toString().ascii().data(), size().
toString().ascii().data()); | |
| 209 } | |
| 210 #endif | |
| 211 | 200 |
| 212 IntRect enclosingIntRect(const FloatRect& rect) | 201 IntRect enclosingIntRect(const FloatRect& rect) |
| 213 { | 202 { |
| 214 IntPoint location = flooredIntPoint(rect.minXMinYCorner()); | 203 IntPoint location = flooredIntPoint(rect.minXMinYCorner()); |
| 215 IntPoint maxPoint = ceiledIntPoint(rect.maxXMaxYCorner()); | 204 IntPoint maxPoint = ceiledIntPoint(rect.maxXMaxYCorner()); |
| 216 | 205 |
| 217 return IntRect(location, maxPoint - location); | 206 return IntRect(location, maxPoint - location); |
| 218 } | 207 } |
| 219 | 208 |
| 220 IntRect enclosedIntRect(const FloatRect& rect) | 209 IntRect enclosedIntRect(const FloatRect& rect) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 237 if (!srcRect.width() || !srcRect.height()) | 226 if (!srcRect.width() || !srcRect.height()) |
| 238 return FloatRect(); | 227 return FloatRect(); |
| 239 | 228 |
| 240 float widthScale = destRect.width() / srcRect.width(); | 229 float widthScale = destRect.width() / srcRect.width(); |
| 241 float heightScale = destRect.height() / srcRect.height(); | 230 float heightScale = destRect.height() / srcRect.height(); |
| 242 return FloatRect(destRect.x() + (r.x() - srcRect.x()) * widthScale, | 231 return FloatRect(destRect.x() + (r.x() - srcRect.x()) * widthScale, |
| 243 destRect.y() + (r.y() - srcRect.y()) * heightScale, | 232 destRect.y() + (r.y() - srcRect.y()) * heightScale, |
| 244 r.width() * widthScale, r.height() * heightScale); | 233 r.width() * widthScale, r.height() * heightScale); |
| 245 } | 234 } |
| 246 | 235 |
| 236 std::ostream& operator<<(std::ostream& os, const FloatRect& rect) |
| 237 { |
| 238 os << "FloatRect(" |
| 239 << "x=" << rect.x() << ", " |
| 240 << "y=" << rect.y() << ", " |
| 241 << "width=" << rect.width() << ", " |
| 242 << "height=" << rect.height() << ")"; |
| 243 return os; |
| 244 } |
| 245 |
| 247 } // namespace blink | 246 } // namespace blink |
| OLD | NEW |