| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include "core/include/fxcrt/fx_coordinates.h" | 9 #include "core/include/fxcrt/fx_coordinates.h" |
| 10 #include "core/include/fxcrt/fx_ext.h" | 10 #include "core/include/fxcrt/fx_ext.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 i2 = i1 + length; | 180 i2 = i1 + length; |
| 181 } | 181 } |
| 182 FX_RECT CFX_FloatRect::GetClosestRect() const { | 182 FX_RECT CFX_FloatRect::GetClosestRect() const { |
| 183 CFX_FloatRect rect1 = *this; | 183 CFX_FloatRect rect1 = *this; |
| 184 FX_RECT rect; | 184 FX_RECT rect; |
| 185 _MatchFloatRange(rect1.left, rect1.right, rect.left, rect.right); | 185 _MatchFloatRange(rect1.left, rect1.right, rect.left, rect.right); |
| 186 _MatchFloatRange(rect1.bottom, rect1.top, rect.top, rect.bottom); | 186 _MatchFloatRange(rect1.bottom, rect1.top, rect.top, rect.bottom); |
| 187 rect.Normalize(); | 187 rect.Normalize(); |
| 188 return rect; | 188 return rect; |
| 189 } | 189 } |
| 190 FX_BOOL CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const { | 190 |
| 191 CFX_FloatRect n1 = *this; | 191 bool CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const { |
| 192 CFX_FloatRect n1(*this); |
| 193 CFX_FloatRect n2(other_rect); |
| 192 n1.Normalize(); | 194 n1.Normalize(); |
| 193 CFX_FloatRect n2 = other_rect; | |
| 194 n2.Normalize(); | 195 n2.Normalize(); |
| 195 if (n2.left >= n1.left && n2.right <= n1.right && n2.bottom >= n1.bottom && | 196 return n2.left >= n1.left && n2.right <= n1.right && n2.bottom >= n1.bottom && |
| 196 n2.top <= n1.top) { | 197 n2.top <= n1.top; |
| 197 return TRUE; | |
| 198 } | |
| 199 return FALSE; | |
| 200 } | 198 } |
| 201 FX_BOOL CFX_FloatRect::Contains(FX_FLOAT x, FX_FLOAT y) const { | 199 |
| 202 CFX_FloatRect n1 = *this; | 200 bool CFX_FloatRect::Contains(FX_FLOAT x, FX_FLOAT y) const { |
| 201 CFX_FloatRect n1(*this); |
| 203 n1.Normalize(); | 202 n1.Normalize(); |
| 204 return x <= n1.right && x >= n1.left && y <= n1.top && y >= n1.bottom; | 203 return x <= n1.right && x >= n1.left && y <= n1.top && y >= n1.bottom; |
| 205 } | 204 } |
| 205 |
| 206 void CFX_FloatRect::UpdateRect(FX_FLOAT x, FX_FLOAT y) { | 206 void CFX_FloatRect::UpdateRect(FX_FLOAT x, FX_FLOAT y) { |
| 207 if (left > x) { | 207 if (left > x) { |
| 208 left = x; | 208 left = x; |
| 209 } | 209 } |
| 210 if (right < x) { | 210 if (right < x) { |
| 211 right = x; | 211 right = x; |
| 212 } | 212 } |
| 213 if (bottom > y) { | 213 if (bottom > y) { |
| 214 bottom = y; | 214 bottom = y; |
| 215 } | 215 } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 left = x[i]; | 508 left = x[i]; |
| 509 } | 509 } |
| 510 if (top < y[i]) { | 510 if (top < y[i]) { |
| 511 top = y[i]; | 511 top = y[i]; |
| 512 } | 512 } |
| 513 if (bottom > y[i]) { | 513 if (bottom > y[i]) { |
| 514 bottom = y[i]; | 514 bottom = y[i]; |
| 515 } | 515 } |
| 516 } | 516 } |
| 517 } | 517 } |
| OLD | NEW |