Chromium Code Reviews| 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 #ifndef CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ | 7 #ifndef CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ |
| 8 #define CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ | 8 #define CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ |
| 9 | 9 |
| 10 #include "core/fxcrt/include/fx_basic.h" | 10 #include "core/fxcrt/include/fx_basic.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 | 143 |
| 144 FX_RECT(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {} | 144 FX_RECT(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {} |
| 145 | 145 |
| 146 explicit FX_RECT(const FX_SMALL_RECT& other) | 146 explicit FX_RECT(const FX_SMALL_RECT& other) |
| 147 : FX_RECT(other.left, other.top, other.right, other.bottom) {} | 147 : FX_RECT(other.left, other.top, other.right, other.bottom) {} |
| 148 | 148 |
| 149 int Width() const { return right - left; } | 149 int Width() const { return right - left; } |
| 150 int Height() const { return bottom - top; } | 150 int Height() const { return bottom - top; } |
| 151 bool IsEmpty() const { return right <= left || bottom <= top; } | 151 bool IsEmpty() const { return right <= left || bottom <= top; } |
| 152 | 152 |
| 153 bool Valid() const { | |
| 154 pdfium::base::CheckedNumeric<int> w = right; | |
|
Tom Sepez
2016/08/08 21:09:45
nit: I might write this as
pdfium::base::CheckedN
dsinclair
2016/08/09 13:35:19
Done.
| |
| 155 w -= left; | |
| 156 if (!w.IsValid()) | |
| 157 return false; | |
| 158 | |
| 159 pdfium::base::CheckedNumeric<int> h = bottom; | |
| 160 h -= top; | |
| 161 if (!h.IsValid()) | |
| 162 return false; | |
| 163 | |
| 164 return true; | |
| 165 } | |
| 166 | |
| 153 void Normalize(); | 167 void Normalize(); |
| 154 | 168 |
| 155 void Intersect(const FX_RECT& src); | 169 void Intersect(const FX_RECT& src); |
| 156 void Intersect(int l, int t, int r, int b) { Intersect(FX_RECT(l, t, r, b)); } | 170 void Intersect(int l, int t, int r, int b) { Intersect(FX_RECT(l, t, r, b)); } |
| 157 | 171 |
| 158 void Union(const FX_RECT& other_rect); | 172 void Union(const FX_RECT& other_rect); |
| 159 void Union(int l, int t, int r, int b) { Union(FX_RECT(l, t, r, b)); } | 173 void Union(int l, int t, int r, int b) { Union(FX_RECT(l, t, r, b)); } |
| 160 | 174 |
| 161 void Offset(int dx, int dy) { | 175 void Offset(int dx, int dy) { |
| 162 left += dx; | 176 left += dx; |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 677 public: | 691 public: |
| 678 FX_FLOAT a; | 692 FX_FLOAT a; |
| 679 FX_FLOAT b; | 693 FX_FLOAT b; |
| 680 FX_FLOAT c; | 694 FX_FLOAT c; |
| 681 FX_FLOAT d; | 695 FX_FLOAT d; |
| 682 FX_FLOAT e; | 696 FX_FLOAT e; |
| 683 FX_FLOAT f; | 697 FX_FLOAT f; |
| 684 }; | 698 }; |
| 685 | 699 |
| 686 #endif // CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ | 700 #endif // CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ |
| OLD | NEW |