| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012, Google Inc. All rights reserved. | 2 * Copyright (c) 2012, Google Inc. All rights reserved. |
| 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 && y() <= other.y() && maxY() >= other.maxY(); | 64 && y() <= other.y() && maxY() >= other.maxY(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void LayoutRect::intersect(const LayoutRect& other) | 67 void LayoutRect::intersect(const LayoutRect& other) |
| 68 { | 68 { |
| 69 LayoutPoint newLocation(std::max(x(), other.x()), std::max(y(), other.y())); | 69 LayoutPoint newLocation(std::max(x(), other.x()), std::max(y(), other.y())); |
| 70 LayoutPoint newMaxPoint(std::min(maxX(), other.maxX()), std::min(maxY(), oth
er.maxY())); | 70 LayoutPoint newMaxPoint(std::min(maxX(), other.maxX()), std::min(maxY(), oth
er.maxY())); |
| 71 | 71 |
| 72 // Return a clean empty rectangle for non-intersecting cases. | 72 // Return a clean empty rectangle for non-intersecting cases. |
| 73 if (newLocation.x() >= newMaxPoint.x() || newLocation.y() >= newMaxPoint.y()
) { | 73 if (newLocation.x() >= newMaxPoint.x() || newLocation.y() >= newMaxPoint.y()
) { |
| 74 newLocation = LayoutPoint(0, 0); | 74 newLocation = LayoutPoint(); |
| 75 newMaxPoint = LayoutPoint(0, 0); | 75 newMaxPoint = LayoutPoint(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 m_location = newLocation; | 78 m_location = newLocation; |
| 79 m_size = newMaxPoint - newLocation; | 79 m_size = newMaxPoint - newLocation; |
| 80 } | 80 } |
| 81 | 81 |
| 82 void LayoutRect::unite(const LayoutRect& other) | 82 void LayoutRect::unite(const LayoutRect& other) |
| 83 { | 83 { |
| 84 // Handle empty special cases first. | 84 // Handle empty special cases first. |
| 85 if (other.isEmpty()) | 85 if (other.isEmpty()) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 169 } |
| 170 | 170 |
| 171 LayoutRect enclosingLayoutRect(const FloatRect& rect) | 171 LayoutRect enclosingLayoutRect(const FloatRect& rect) |
| 172 { | 172 { |
| 173 LayoutPoint location = flooredLayoutPoint(rect.minXMinYCorner()); | 173 LayoutPoint location = flooredLayoutPoint(rect.minXMinYCorner()); |
| 174 LayoutPoint maxPoint = ceiledLayoutPoint(rect.maxXMaxYCorner()); | 174 LayoutPoint maxPoint = ceiledLayoutPoint(rect.maxXMaxYCorner()); |
| 175 return LayoutRect(location, maxPoint - location); | 175 return LayoutRect(location, maxPoint - location); |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |