summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-10-05 17:10:40 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-05 17:10:40 +0000
commit9934cc2f2f1a6382269d0d2da6886113bfb2c309 (patch)
tree6e4f14e6f5b456a00eeec5aa5ed422e94eabfdc7
parent39cf6a765ae349242289ec3287eaf4d6c5fd57f8 (diff)
downloadpdfium-9934cc2f2f1a6382269d0d2da6886113bfb2c309.tar.xz
Tidy PWL_FLOATRANGE
Remove unused form of constructor. Initialize in header and default constructor (POD). Use std::min/max Change-Id: Ib2a37333d9f57ff2e2139a2cc1dea61416a8614b Reviewed-on: https://pdfium-review.googlesource.com/c/43476 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
-rw-r--r--fpdfsdk/pwl/cpwl_scroll_bar.cpp28
-rw-r--r--fpdfsdk/pwl/cpwl_scroll_bar.h9
2 files changed, 12 insertions, 25 deletions
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.cpp b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
index 472e6afc24..ced049a175 100644
--- a/fpdfsdk/pwl/cpwl_scroll_bar.cpp
+++ b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
@@ -8,6 +8,7 @@
#include <algorithm>
#include <sstream>
+#include <utility>
#include <vector>
#include "core/fxge/cfx_pathdata.h"
@@ -24,27 +25,14 @@ constexpr float kScrollBarTriangleHalfLength = 2.0f;
#define PWL_DEFAULT_HEAVYGRAYCOLOR CFX_Color(CFX_Color::kGray, 0.50)
-PWL_FLOATRANGE::PWL_FLOATRANGE() {
- Default();
-}
-
-PWL_FLOATRANGE::PWL_FLOATRANGE(float min, float max) {
- Set(min, max);
+void PWL_FLOATRANGE::Reset() {
+ fMin = 0.0f;
+ fMax = 0.0f;
}
-void PWL_FLOATRANGE::Default() {
- fMin = 0;
- fMax = 0;
-}
-
-void PWL_FLOATRANGE::Set(float min, float max) {
- if (min > max) {
- fMin = max;
- fMax = min;
- } else {
- fMin = min;
- fMax = max;
- }
+void PWL_FLOATRANGE::Set(float f1, float f2) {
+ fMin = std::min(f1, f2);
+ fMax = std::max(f1, f2);
}
bool PWL_FLOATRANGE::In(float x) const {
@@ -61,7 +49,7 @@ PWL_SCROLL_PRIVATEDATA::PWL_SCROLL_PRIVATEDATA() {
}
void PWL_SCROLL_PRIVATEDATA::Default() {
- ScrollRange.Default();
+ ScrollRange.Reset();
fScrollPos = ScrollRange.fMin;
fClientWidth = 0;
fBigStep = 10;
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.h b/fpdfsdk/pwl/cpwl_scroll_bar.h
index 3c3c56e4bb..3592423a7d 100644
--- a/fpdfsdk/pwl/cpwl_scroll_bar.h
+++ b/fpdfsdk/pwl/cpwl_scroll_bar.h
@@ -64,21 +64,20 @@ class CPWL_SBButton final : public CPWL_Wnd {
struct PWL_FLOATRANGE {
public:
- PWL_FLOATRANGE();
- PWL_FLOATRANGE(float min, float max);
+ PWL_FLOATRANGE() = default;
bool operator==(const PWL_FLOATRANGE& that) const {
return fMin == that.fMin && fMax == that.fMax;
}
bool operator!=(const PWL_FLOATRANGE& that) const { return !(*this == that); }
- void Default();
+ void Reset();
void Set(float min, float max);
bool In(float x) const;
float GetWidth() const;
- float fMin;
- float fMax;
+ float fMin = 0.0f;
+ float fMax = 0.0f;
};
struct PWL_SCROLL_PRIVATEDATA {