summaryrefslogtreecommitdiff
path: root/fpdfsdk/pdfwindow
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-21 13:42:38 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-21 22:34:49 +0000
commit52f69b39403b1ac0df0fdf45698e80e60c0f2def (patch)
tree75c62cdb179bc287f283794600f252783603ad9f /fpdfsdk/pdfwindow
parent7dd72a3f39c09a7fdc34558061831620bc149420 (diff)
downloadpdfium-52f69b39403b1ac0df0fdf45698e80e60c0f2def.tar.xz
Make CPVT_WordPlace more conformant with the prevailing idioms.
Add relational operators to replace CmpWord(). Leave CmpLine() for the moment as it saves some work. Remove CmpSec() and just inline comparison of the one member. Invert IsExist() as IsEmpty(). There is a big philosophical discussion as to whether things that are empty exist. I say they do, but they're just empty. Rename Default() to Reset(). Default sounds like a noun. Add AdvanceSection() method and call as appropriate. Change-Id: I01d9479f63a4860e0fd228255540d6d94dc24a9f Reviewed-on: https://pdfium-review.googlesource.com/3139 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/pdfwindow')
-rw-r--r--fpdfsdk/pdfwindow/PWL_Edit.cpp18
-rw-r--r--fpdfsdk/pdfwindow/PWL_Utils.cpp25
2 files changed, 8 insertions, 35 deletions
diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp
index f84c38e23b..4b9e0d2f49 100644
--- a/fpdfsdk/pdfwindow/PWL_Edit.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp
@@ -6,6 +6,7 @@
#include "fpdfsdk/pdfwindow/PWL_Edit.h"
+#include <algorithm>
#include <memory>
#include <vector>
@@ -791,21 +792,8 @@ void CPWL_Edit::OnInsertText(const CPVT_WordPlace& place,
CPVT_WordRange CPWL_Edit::CombineWordRange(const CPVT_WordRange& wr1,
const CPVT_WordRange& wr2) {
- CPVT_WordRange wrRet;
-
- if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) {
- wrRet.BeginPos = wr1.BeginPos;
- } else {
- wrRet.BeginPos = wr2.BeginPos;
- }
-
- if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) {
- wrRet.EndPos = wr2.EndPos;
- } else {
- wrRet.EndPos = wr1.EndPos;
- }
-
- return wrRet;
+ return CPVT_WordRange(std::min(wr1.BeginPos, wr2.BeginPos),
+ std::max(wr1.EndPos, wr2.EndPos));
}
CPVT_WordRange CPWL_Edit::GetLatinWordsRange(const CFX_PointF& point) const {
diff --git a/fpdfsdk/pdfwindow/PWL_Utils.cpp b/fpdfsdk/pdfwindow/PWL_Utils.cpp
index f78b590150..08b5e3013a 100644
--- a/fpdfsdk/pdfwindow/PWL_Utils.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Utils.cpp
@@ -26,28 +26,13 @@ CFX_FloatRect CPWL_Utils::OffsetRect(const CFX_FloatRect& rect,
CPVT_WordRange CPWL_Utils::OverlapWordRange(const CPVT_WordRange& wr1,
const CPVT_WordRange& wr2) {
- CPVT_WordRange wrRet;
-
- if (wr2.EndPos.WordCmp(wr1.BeginPos) < 0 ||
- wr2.BeginPos.WordCmp(wr1.EndPos) > 0)
- return wrRet;
- if (wr1.EndPos.WordCmp(wr2.BeginPos) < 0 ||
- wr1.BeginPos.WordCmp(wr2.EndPos) > 0)
- return wrRet;
-
- if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) {
- wrRet.BeginPos = wr2.BeginPos;
- } else {
- wrRet.BeginPos = wr1.BeginPos;
+ if (wr2.EndPos < wr1.BeginPos || wr2.BeginPos > wr1.EndPos ||
+ wr1.EndPos < wr2.BeginPos || wr1.BeginPos > wr2.EndPos) {
+ return CPVT_WordRange();
}
- if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) {
- wrRet.EndPos = wr1.EndPos;
- } else {
- wrRet.EndPos = wr2.EndPos;
- }
-
- return wrRet;
+ return CPVT_WordRange(std::max(wr1.BeginPos, wr2.BeginPos),
+ std::min(wr1.EndPos, wr2.EndPos));
}
CFX_ByteString CPWL_Utils::GetAP_Check(const CFX_FloatRect& crBBox) {