| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/cpp/rect.h" | 5 #include "ppapi/cpp/rect.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 return *this; | 82 return *this; |
| 83 if (rect.Contains(*this)) | 83 if (rect.Contains(*this)) |
| 84 return Rect(); | 84 return Rect(); |
| 85 | 85 |
| 86 int32_t rx = x(); | 86 int32_t rx = x(); |
| 87 int32_t ry = y(); | 87 int32_t ry = y(); |
| 88 int32_t rr = right(); | 88 int32_t rr = right(); |
| 89 int32_t rb = bottom(); | 89 int32_t rb = bottom(); |
| 90 | 90 |
| 91 if (rect.y() <= y() && rect.bottom() >= bottom()) { | 91 if (rect.y() <= y() && rect.bottom() >= bottom()) { |
| 92 // complete int32_tersection in the y-direction | 92 // complete intersection in the y-direction |
| 93 if (rect.x() <= x()) { | 93 if (rect.x() <= x()) { |
| 94 rx = rect.right(); | 94 rx = rect.right(); |
| 95 } else { | 95 } else { |
| 96 rr = rect.x(); | 96 rr = rect.x(); |
| 97 } | 97 } |
| 98 } else if (rect.x() <= x() && rect.right() >= right()) { | 98 } else if (rect.x() <= x() && rect.right() >= right()) { |
| 99 // complete int32_tersection in the x-direction | 99 // complete intersection in the x-direction |
| 100 if (rect.y() <= y()) { | 100 if (rect.y() <= y()) { |
| 101 ry = rect.bottom(); | 101 ry = rect.bottom(); |
| 102 } else { | 102 } else { |
| 103 rb = rect.y(); | 103 rb = rect.y(); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 return Rect(rx, ry, rr - rx, rb - ry); | 106 return Rect(rx, ry, rr - rx, rb - ry); |
| 107 } | 107 } |
| 108 | 108 |
| 109 Rect Rect::AdjustToFit(const Rect& rect) const { | 109 Rect Rect::AdjustToFit(const Rect& rect) const { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 121 } | 121 } |
| 122 | 122 |
| 123 bool Rect::SharesEdgeWith(const Rect& rect) const { | 123 bool Rect::SharesEdgeWith(const Rect& rect) const { |
| 124 return (y() == rect.y() && height() == rect.height() && | 124 return (y() == rect.y() && height() == rect.height() && |
| 125 (x() == rect.right() || right() == rect.x())) || | 125 (x() == rect.right() || right() == rect.x())) || |
| 126 (x() == rect.x() && width() == rect.width() && | 126 (x() == rect.x() && width() == rect.width() && |
| 127 (y() == rect.bottom() || bottom() == rect.y())); | 127 (y() == rect.bottom() || bottom() == rect.y())); |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace pp | 130 } // namespace pp |
| OLD | NEW |