summaryrefslogtreecommitdiff
path: root/fpdfsdk/pdfwindow
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 /fpdfsdk/pdfwindow
parentf86ca3884886506c999a3b521078151e7cda0bf9 (diff)
downloadpdfium-63f545c485c063831ecb58fb492f96fe5f462fd1.tar.xz
CFX_FloatPoint default constructor and equals operatorschromium/2860
Review-Url: https://codereview.chromium.org/2341453002
Diffstat (limited to 'fpdfsdk/pdfwindow')
-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
5 files changed, 19 insertions, 44 deletions
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) {}
};