summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-09-13 16:08:49 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-13 16:08:49 -0700
commit63f545c485c063831ecb58fb492f96fe5f462fd1 (patch)
tree8c57386bc84f7173b780a7e8bf79a19ec7c3231e
parentf86ca3884886506c999a3b521078151e7cda0bf9 (diff)
downloadpdfium-chromium/2860.tar.xz
CFX_FloatPoint default constructor and equals operatorschromium/2860
Review-Url: https://codereview.chromium.org/2341453002
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp13
-rw-r--r--core/fpdfdoc/include/cpvt_line.h3
-rw-r--r--core/fpdfdoc/include/cpvt_word.h1
-rw-r--r--core/fxcrt/include/fx_coordinates.h6
-rw-r--r--fpdfsdk/cpdfsdk_widget.cpp4
-rw-r--r--fpdfsdk/formfiller/cffl_formfiller.cpp68
-rw-r--r--fpdfsdk/fxedit/fxet_edit.cpp31
-rw-r--r--fpdfsdk/fxedit/fxet_list.cpp1
-rw-r--r--fpdfsdk/pdfwindow/PWL_Caret.cpp24
-rw-r--r--fpdfsdk/pdfwindow/PWL_Caret.h2
-rw-r--r--fpdfsdk/pdfwindow/PWL_Edit.cpp23
-rw-r--r--fpdfsdk/pdfwindow/PWL_EditCtrl.cpp12
-rw-r--r--fpdfsdk/pdfwindow/PWL_Utils.h2
13 files changed, 79 insertions, 111 deletions
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index 741b2365f5..dbfcdbffed 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -237,7 +237,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
vt.SetText(swValue);
vt.RearrangeAll();
CFX_FloatRect rcContent = vt.GetContentRect();
- CFX_FloatPoint ptOffset(0.0f, 0.0f);
+ CFX_FloatPoint ptOffset;
if (!bMultiLine) {
ptOffset =
CFX_FloatPoint(0.0f, (rcContent.Height() - rcBody.Height()) / 2.0f);
@@ -1083,13 +1083,12 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP(
CFX_ByteTextBuf sEditStream;
CFX_ByteTextBuf sLineStream;
CFX_ByteTextBuf sWords;
- CFX_FloatPoint ptOld(0.0f, 0.0f);
- CFX_FloatPoint ptNew(0.0f, 0.0f);
+ CFX_FloatPoint ptOld;
+ CFX_FloatPoint ptNew;
int32_t nCurFontIndex = -1;
+ CPVT_WordPlace oldplace;
pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
while (pIterator->NextWord()) {
CPVT_WordPlace place = pIterator->GetAt();
if (bContinuous) {
@@ -1110,7 +1109,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP(
ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x,
line.ptLine.y + ptOffset.y);
}
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
+ if (ptNew != ptOld) {
sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
<< " Td\n";
ptOld = ptNew;
@@ -1135,7 +1134,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP(
if (pIterator->GetWord(word)) {
ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
word.ptWord.y + ptOffset.y);
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
+ if (ptNew != ptOld) {
sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
<< " Td\n";
ptOld = ptNew;
diff --git a/core/fpdfdoc/include/cpvt_line.h b/core/fpdfdoc/include/cpvt_line.h
index ea0f899e19..d6c74edb4e 100644
--- a/core/fpdfdoc/include/cpvt_line.h
+++ b/core/fpdfdoc/include/cpvt_line.h
@@ -12,8 +12,7 @@
#include "core/fxcrt/include/fx_system.h"
struct CPVT_Line {
- CPVT_Line()
- : ptLine(0, 0), fLineWidth(0.0f), fLineAscent(0.0f), fLineDescent(0.0f) {}
+ CPVT_Line() : fLineWidth(0.0f), fLineAscent(0.0f), fLineDescent(0.0f) {}
CPVT_WordPlace lineplace;
CPVT_WordPlace lineEnd;
diff --git a/core/fpdfdoc/include/cpvt_word.h b/core/fpdfdoc/include/cpvt_word.h
index f7b7b23dac..b2af4ec6fa 100644
--- a/core/fpdfdoc/include/cpvt_word.h
+++ b/core/fpdfdoc/include/cpvt_word.h
@@ -29,7 +29,6 @@ struct CPVT_Word {
inline CPVT_Word::CPVT_Word()
: Word(0),
nCharset(0),
- ptWord(0.0f, 0.0f),
fAscent(0.0f),
fDescent(0.0f),
fWidth(0.0f),
diff --git a/core/fxcrt/include/fx_coordinates.h b/core/fxcrt/include/fx_coordinates.h
index 7da6057ed4..bfdc46cbf2 100644
--- a/core/fxcrt/include/fx_coordinates.h
+++ b/core/fxcrt/include/fx_coordinates.h
@@ -179,8 +179,14 @@ struct FX_RECT {
// LBRT rectangles (y-axis runs upwards).
class CFX_FloatPoint {
public:
+ CFX_FloatPoint() : x(0.0f), y(0.0f) {}
CFX_FloatPoint(FX_FLOAT xx, FX_FLOAT yy) : x(xx), y(yy) {}
+ bool operator==(const CFX_FloatPoint& that) const {
+ return x == that.x && y == that.y;
+ }
+ bool operator!=(const CFX_FloatPoint& that) const { return !(*this == that); }
+
FX_FLOAT x;
FX_FLOAT y;
};
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index 11e9883272..78cb1bf752 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -1402,7 +1402,7 @@ void CPDFSDK_Widget::ResetAppearance_ComboBox(const CFX_WideString* sValue) {
CFX_FloatRect rcContent = pEdit->GetContentRect();
CFX_ByteString sEdit =
- CPWL_Utils::GetEditAppStream(pEdit.get(), CFX_FloatPoint(0.0f, 0.0f));
+ CPWL_Utils::GetEditAppStream(pEdit.get(), CFX_FloatPoint());
if (sEdit.GetLength() > 0) {
sBody << "/Tx BMC\n"
<< "q\n";
@@ -1585,7 +1585,7 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const CFX_WideString* sValue) {
CFX_FloatRect rcContent = pEdit->GetContentRect();
CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(
- pEdit.get(), CFX_FloatPoint(0.0f, 0.0f), nullptr, !bCharArray, subWord);
+ pEdit.get(), CFX_FloatPoint(), nullptr, !bCharArray, subWord);
if (sEdit.GetLength() > 0) {
sBody << "/Tx BMC\n"
diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp
index 4b33c38b52..595f4121f3 100644
--- a/fpdfsdk/formfiller/cffl_formfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_formfiller.cpp
@@ -24,8 +24,8 @@
CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp,
CPDFSDK_Annot* pAnnot)
- : m_pApp(pApp), m_pAnnot(pAnnot), m_bValid(FALSE), m_ptOldPos(0, 0) {
- m_pWidget = (CPDFSDK_Widget*)pAnnot;
+ : m_pApp(pApp), m_pAnnot(pAnnot), m_bValid(FALSE) {
+ m_pWidget = static_cast<CPDFSDK_Widget*>(pAnnot);
}
CFFL_FormFiller::~CFFL_FormFiller() {
@@ -145,42 +145,41 @@ FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
FX_UINT nFlags,
const CFX_FloatPoint& point) {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot);
- InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom);
- pWnd->OnLButtonUp(WndtoPWL(pPageView, point), nFlags);
- return TRUE;
- }
+ CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE);
+ if (!pWnd)
+ return FALSE;
- return FALSE;
+ FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot);
+ InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom);
+ pWnd->OnLButtonUp(WndtoPWL(pPageView, point), nFlags);
+ return TRUE;
}
FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
FX_UINT nFlags,
const CFX_FloatPoint& point) {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point), nFlags);
- return TRUE;
- }
+ CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE);
+ if (!pWnd)
+ return FALSE;
- return FALSE;
+ pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point), nFlags);
+ return TRUE;
}
FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
FX_UINT nFlags,
const CFX_FloatPoint& point) {
- if ((m_ptOldPos.x != point.x) || (m_ptOldPos.y != point.y)) {
+ if (m_ptOldPos != point)
m_ptOldPos = point;
- }
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- pWnd->OnMouseMove(WndtoPWL(pPageView, point), nFlags);
- return TRUE;
- }
+ CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE);
+ if (!pWnd)
+ return FALSE;
- return FALSE;
+ pWnd->OnMouseMove(WndtoPWL(pPageView, point), nFlags);
+ return TRUE;
}
FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView,
@@ -191,35 +190,32 @@ FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView,
if (!IsValid())
return FALSE;
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) {
- return pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point), nFlags);
- }
-
- return FALSE;
+ CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE);
+ return pWnd && pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point), nFlags);
}
FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
FX_UINT nFlags,
const CFX_FloatPoint& point) {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) {
- pWnd->OnRButtonDown(WndtoPWL(pPageView, point), nFlags);
- return TRUE;
- }
+ CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE);
+ if (!pWnd)
+ return FALSE;
- return FALSE;
+ pWnd->OnRButtonDown(WndtoPWL(pPageView, point), nFlags);
+ return TRUE;
}
FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
FX_UINT nFlags,
const CFX_FloatPoint& point) {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- pWnd->OnRButtonUp(WndtoPWL(pPageView, point), nFlags);
- return TRUE;
- }
+ CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE);
+ if (!pWnd)
+ return FALSE;
- return FALSE;
+ pWnd->OnRButtonUp(WndtoPWL(pPageView, point), nFlags);
+ return TRUE;
}
FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot,
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index 8912fa5fd8..df8d9ca51d 100644
--- a/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -75,7 +75,8 @@ void DrawTextString(CFX_RenderDevice* pDevice,
ro.m_ColorMode = RENDER_COLOR_NORMAL;
if (crTextStroke != 0) {
- CFX_FloatPoint pt1(0, 0), pt2(1, 0);
+ CFX_FloatPoint pt1;
+ CFX_FloatPoint pt2;
pUser2Device->Transform(pt1.x, pt1.y);
pUser2Device->Transform(pt2.x, pt2.y);
CFX_GraphStateData gsd;
@@ -95,7 +96,8 @@ void DrawTextString(CFX_RenderDevice* pDevice,
ro.m_ColorMode = RENDER_COLOR_NORMAL;
if (crTextStroke != 0) {
- CFX_FloatPoint pt1(0, 0), pt2(1, 0);
+ CFX_FloatPoint pt1;
+ CFX_FloatPoint pt2;
pUser2Device->Transform(pt1.x, pt1.y);
pUser2Device->Transform(pt2.x, pt2.y);
CFX_GraphStateData gsd;
@@ -682,12 +684,12 @@ CFX_ByteString CFX_Edit::GetEditAppearanceStream(CFX_Edit* pEdit,
CFX_ByteTextBuf sEditStream;
CFX_ByteTextBuf sWords;
int32_t nCurFontIndex = -1;
- CFX_FloatPoint ptOld(0.0f, 0.0f);
- CFX_FloatPoint ptNew(0.0f, 0.0f);
+ CFX_FloatPoint ptOld;
+ CFX_FloatPoint ptNew;
CPVT_WordPlace oldplace;
+
while (pIterator->NextWord()) {
CPVT_WordPlace place = pIterator->GetAt();
-
if (pRange && place.WordCmp(pRange->EndPos) > 0)
break;
@@ -837,10 +839,8 @@ void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
CFX_ByteTextBuf sTextBuf;
int32_t nFontIndex = -1;
- CFX_FloatPoint ptBT(0.0f, 0.0f);
-
+ CFX_FloatPoint ptBT;
pDevice->SaveState();
-
if (!rcClip.IsEmpty()) {
CFX_FloatRect rcTemp = rcClip;
pUser2Device->TransformRect(rcTemp);
@@ -1005,10 +1005,7 @@ CFX_Edit::CFX_Edit()
m_wpCaret(-1, -1, -1),
m_wpOldCaret(-1, -1, -1),
m_SelState(),
- m_ptScrollPos(0, 0),
- m_ptRefreshScrollPos(0, 0),
m_bEnableScroll(FALSE),
- m_ptCaret(0.0f, 0.0f),
m_Undo(kEditUndoMaxItems),
m_nAlignment(0),
m_bNotifyFlag(FALSE),
@@ -1576,12 +1573,11 @@ void CFX_Edit::ScrollToCaret() {
if (!m_pVT->IsValid())
return;
- CFX_FloatPoint ptHead(0, 0);
- CFX_FloatPoint ptFoot(0, 0);
-
CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
pIterator->SetAt(m_wpCaret);
+ CFX_FloatPoint ptHead;
+ CFX_FloatPoint ptFoot;
CPVT_Word word;
CPVT_Line line;
if (pIterator->GetWord(word)) {
@@ -1598,9 +1594,7 @@ void CFX_Edit::ScrollToCaret() {
CFX_FloatPoint ptHeadEdit = VTToEdit(ptHead);
CFX_FloatPoint ptFootEdit = VTToEdit(ptFoot);
-
CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
-
if (!IsFloatEqual(rcPlate.left, rcPlate.right)) {
if (IsFloatSmaller(ptHeadEdit.x, rcPlate.left) ||
IsFloatEqual(ptHeadEdit.x, rcPlate.left)) {
@@ -1738,10 +1732,11 @@ void CFX_Edit::SetCaret(const CPVT_WordPlace& place) {
void CFX_Edit::SetCaretInfo() {
if (m_pNotify) {
if (!m_bNotifyFlag) {
- CFX_FloatPoint ptHead(0.0f, 0.0f), ptFoot(0.0f, 0.0f);
-
CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
pIterator->SetAt(m_wpCaret);
+
+ CFX_FloatPoint ptHead;
+ CFX_FloatPoint ptFoot;
CPVT_Word word;
CPVT_Line line;
if (pIterator->GetWord(word)) {
diff --git a/fpdfsdk/fxedit/fxet_list.cpp b/fpdfsdk/fxedit/fxet_list.cpp
index 7bf1bd8a27..5fb26b119e 100644
--- a/fpdfsdk/fxedit/fxet_list.cpp
+++ b/fpdfsdk/fxedit/fxet_list.cpp
@@ -191,7 +191,6 @@ void CPLST_Select::Done() {
CFX_ListCtrl::CFX_ListCtrl()
: m_pNotify(nullptr),
m_bNotifyFlag(FALSE),
- m_ptScrollPos(0.0f, 0.0f),
m_nSelItem(-1),
m_nFootIndex(-1),
m_bCtrlSel(FALSE),
diff --git a/fpdfsdk/pdfwindow/PWL_Caret.cpp b/fpdfsdk/pdfwindow/PWL_Caret.cpp
index 98b2b3de86..62f424b86e 100644
--- a/fpdfsdk/pdfwindow/PWL_Caret.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Caret.cpp
@@ -14,12 +14,7 @@
#define PWL_CARET_FLASHINTERVAL 500
-CPWL_Caret::CPWL_Caret()
- : m_bFlash(FALSE),
- m_ptHead(0, 0),
- m_ptFoot(0, 0),
- m_fWidth(0.4f),
- m_nDelay(0) {}
+CPWL_Caret::CPWL_Caret() : m_bFlash(FALSE), m_fWidth(0.4f), m_nDelay(0) {}
CPWL_Caret::~CPWL_Caret() {}
@@ -36,15 +31,12 @@ void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice,
if (IsVisible() && m_bFlash) {
CFX_FloatRect rcRect = GetCaretRect();
CFX_FloatRect rcClip = GetClipRect();
-
CFX_PathData path;
-
path.SetPointCount(2);
FX_FLOAT fCaretX = rcRect.left + m_fWidth * 0.5f;
FX_FLOAT fCaretTop = rcRect.top;
FX_FLOAT fCaretBottom = rcRect.bottom;
-
if (!rcClip.IsEmpty()) {
rcRect.Intersect(rcClip);
if (!rcRect.IsEmpty()) {
@@ -62,7 +54,6 @@ void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_GraphStateData gsd;
gsd.m_LineWidth = m_fWidth;
-
pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0),
FXFILL_ALTERNATE);
}
@@ -119,30 +110,24 @@ void CPWL_Caret::SetCaret(FX_BOOL bVisible,
const CFX_FloatPoint& ptFoot) {
if (bVisible) {
if (IsVisible()) {
- if (m_ptHead.x != ptHead.x || m_ptHead.y != ptHead.y ||
- m_ptFoot.x != ptFoot.x || m_ptFoot.y != ptFoot.y) {
+ if (m_ptHead != ptHead || m_ptFoot != ptFoot) {
m_ptHead = ptHead;
m_ptFoot = ptFoot;
-
m_bFlash = TRUE;
Move(m_rcInvalid, FALSE, TRUE);
}
} else {
m_ptHead = ptHead;
m_ptFoot = ptFoot;
-
EndTimer();
BeginTimer(PWL_CARET_FLASHINTERVAL);
-
CPWL_Wnd::SetVisible(TRUE);
m_bFlash = TRUE;
-
Move(m_rcInvalid, FALSE, TRUE);
}
} else {
- m_ptHead = CFX_FloatPoint(0, 0);
- m_ptFoot = CFX_FloatPoint(0, 0);
-
+ m_ptHead = CFX_FloatPoint();
+ m_ptFoot = CFX_FloatPoint();
m_bFlash = FALSE;
if (IsVisible()) {
EndTimer();
@@ -156,7 +141,6 @@ void CPWL_Caret::InvalidateRect(CFX_FloatRect* pRect) {
CFX_FloatRect rcRefresh = CPWL_Utils::InflateRect(*pRect, 0.5f);
rcRefresh.top += 1;
rcRefresh.bottom -= 1;
-
CPWL_Wnd::InvalidateRect(&rcRefresh);
} else {
CPWL_Wnd::InvalidateRect(pRect);
diff --git a/fpdfsdk/pdfwindow/PWL_Caret.h b/fpdfsdk/pdfwindow/PWL_Caret.h
index 0f002a2b4a..2f5c87639e 100644
--- a/fpdfsdk/pdfwindow/PWL_Caret.h
+++ b/fpdfsdk/pdfwindow/PWL_Caret.h
@@ -11,7 +11,7 @@
struct PWL_CARET_INFO {
public:
- PWL_CARET_INFO() : bVisible(FALSE), ptHead(0, 0), ptFoot(0, 0) {}
+ PWL_CARET_INFO() : bVisible(FALSE) {}
FX_BOOL bVisible;
CFX_FloatPoint ptHead;
diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp
index c85993b9cb..4b115d345b 100644
--- a/fpdfsdk/pdfwindow/PWL_Edit.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp
@@ -241,16 +241,14 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
sAppStream << sLine;
CFX_ByteTextBuf sText;
-
- CFX_FloatPoint ptOffset = CFX_FloatPoint(0.0f, 0.0f);
-
+ CFX_FloatPoint ptOffset = CFX_FloatPoint();
CPVT_WordRange wrWhole = m_pEdit->GetWholeWordRange();
CPVT_WordRange wrSelect = GetSelectWordRange();
CPVT_WordRange wrVisible =
- (HasFlag(PES_TEXTOVERFLOW) ? wrWhole : m_pEdit->GetVisibleWordRange());
+ HasFlag(PES_TEXTOVERFLOW) ? wrWhole : m_pEdit->GetVisibleWordRange();
+
CPVT_WordRange wrSelBefore(wrWhole.BeginPos, wrSelect.BeginPos);
CPVT_WordRange wrSelAfter(wrSelect.EndPos, wrWhole.EndPos);
-
CPVT_WordRange wrTemp =
CPWL_Utils::OverlapWordRange(GetSelectWordRange(), wrVisible);
CFX_ByteString sEditSel =
@@ -385,17 +383,17 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_FloatRect rcClip;
CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange();
CPVT_WordRange* pRange = nullptr;
-
if (!HasFlag(PES_TEXTOVERFLOW)) {
rcClip = GetClientRect();
pRange = &wrRange;
}
+
CFX_SystemHandler* pSysHandler = GetSystemHandler();
CFX_Edit::DrawEdit(
pDevice, pUser2Device, m_pEdit.get(),
CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()),
- rcClip, CFX_FloatPoint(0.0f, 0.0f), pRange, pSysHandler, m_pFormFiller);
+ rcClip, CFX_FloatPoint(), pRange, pSysHandler, m_pFormFiller);
}
FX_BOOL CPWL_Edit::OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) {
@@ -445,20 +443,17 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) {
void CPWL_Edit::OnSetFocus() {
SetEditCaret(TRUE);
-
if (!IsReadOnly()) {
if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler())
pFocusHandler->OnSetFocus(this);
}
-
m_bFocus = TRUE;
}
void CPWL_Edit::OnKillFocus() {
ShowVScrollBar(FALSE);
-
m_pEdit->SelectNone();
- SetCaret(FALSE, CFX_FloatPoint(0.0f, 0.0f), CFX_FloatPoint(0.0f, 0.0f));
+ SetCaret(FALSE, CFX_FloatPoint(), CFX_FloatPoint());
SetCharSet(FXFONT_ANSI_CHARSET);
m_bFocus = FALSE;
}
@@ -510,19 +505,17 @@ CFX_ByteString CPWL_Edit::GetCaretAppearanceStream(
CFX_FloatPoint CPWL_Edit::GetWordRightBottomPoint(
const CPVT_WordPlace& wpWord) {
- CFX_FloatPoint pt(0.0f, 0.0f);
-
CFX_Edit_Iterator* pIterator = m_pEdit->GetIterator();
CPVT_WordPlace wpOld = pIterator->GetAt();
pIterator->SetAt(wpWord);
+
+ CFX_FloatPoint pt;
CPVT_Word word;
if (pIterator->GetWord(word)) {
pt = CFX_FloatPoint(word.ptWord.x + word.fWidth,
word.ptWord.y + word.fDescent);
}
-
pIterator->SetAt(wpOld);
-
return pt;
}
diff --git a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp
index 575fd39089..9d8b16a53c 100644
--- a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp
+++ b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp
@@ -328,11 +328,10 @@ CFX_FloatRect CPWL_EditCtrl::GetContentRect() const {
}
void CPWL_EditCtrl::SetEditCaret(FX_BOOL bVisible) {
- CFX_FloatPoint ptHead(0, 0), ptFoot(0, 0);
-
- if (bVisible) {
+ CFX_FloatPoint ptHead;
+ CFX_FloatPoint ptFoot;
+ if (bVisible)
GetCaretInfo(ptHead, ptFoot);
- }
CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace();
IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp);
@@ -358,10 +357,9 @@ void CPWL_EditCtrl::GetCaretInfo(CFX_FloatPoint& ptHead,
}
void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const {
- CFX_FloatPoint ptHead(0, 0), ptFoot(0, 0);
-
+ CFX_FloatPoint ptHead;
+ CFX_FloatPoint ptFoot;
GetCaretInfo(ptHead, ptFoot);
-
PWLtoWnd(ptHead, x, y);
}
diff --git a/fpdfsdk/pdfwindow/PWL_Utils.h b/fpdfsdk/pdfwindow/PWL_Utils.h
index c3acc59918..d7c65d2a8a 100644
--- a/fpdfsdk/pdfwindow/PWL_Utils.h
+++ b/fpdfsdk/pdfwindow/PWL_Utils.h
@@ -76,7 +76,7 @@ T PWL_MAX(const T& i, const T& j) {
class CPWL_Point : public CFX_FloatPoint {
public:
- CPWL_Point() : CFX_FloatPoint(0.0f, 0.0f) {}
+ CPWL_Point() {}
CPWL_Point(FX_FLOAT fx, FX_FLOAT fy) : CFX_FloatPoint(fx, fy) {}
CPWL_Point(const CPWL_Point& point) : CFX_FloatPoint(point.x, point.y) {}
};