summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-07-05 16:00:48 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-05 21:24:34 +0000
commit0fdd1aea658bc65e4d136c58818451b9ddad00e0 (patch)
tree7b435514a01e74198159de880f65408e1b77ab2e
parentd32623b507c7e78221eb9f5f62641e3113501a5c (diff)
downloadpdfium-0fdd1aea658bc65e4d136c58818451b9ddad00e0.tar.xz
Cleanup IOn* methods and CPWL_CBEdit
This CL removes various IOn* methods and consolidates code where possible. The CPWL_CBEdit class is also removed as it was a subclass of CPWL_Edit which added no extra functionality. Change-Id: Ifac579ab252b7ca64f8c9b3caeac443683a39c58 Reviewed-on: https://pdfium-review.googlesource.com/7279 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r--fpdfsdk/fxedit/fxet_edit.cpp41
-rw-r--r--fpdfsdk/pdfwindow/cpwl_combo_box.cpp2
-rw-r--r--fpdfsdk/pdfwindow/cpwl_combo_box.h8
-rw-r--r--fpdfsdk/pdfwindow/cpwl_edit.cpp30
-rw-r--r--fpdfsdk/pdfwindow/cpwl_edit.h1
-rw-r--r--fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp42
-rw-r--r--fpdfsdk/pdfwindow/cpwl_edit_ctrl.h19
-rw-r--r--fpdfsdk/pdfwindow/cpwl_list_box.h5
8 files changed, 37 insertions, 111 deletions
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index 863486bdea..82f82477d8 100644
--- a/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -30,6 +30,7 @@
#include "fpdfsdk/fxedit/fx_edit.h"
#include "fpdfsdk/pdfwindow/cpwl_edit.h"
#include "fpdfsdk/pdfwindow/cpwl_edit_ctrl.h"
+#include "fpdfsdk/pdfwindow/cpwl_scroll_bar.h"
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
@@ -1226,18 +1227,24 @@ CFX_FloatRect CFX_Edit::VTToEdit(const CFX_FloatRect& rect) const {
}
void CFX_Edit::SetScrollInfo() {
- if (m_pNotify) {
- CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
- CFX_FloatRect rcContent = m_pVT->GetContentRect();
+ if (!m_pNotify)
+ return;
- if (!m_bNotifyFlag) {
- CFX_AutoRestorer<bool> restorer(&m_bNotifyFlag);
- m_bNotifyFlag = true;
- m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top,
- rcContent.bottom, rcContent.top,
- rcPlate.Height() / 3, rcPlate.Height());
- }
- }
+ CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
+ CFX_FloatRect rcContent = m_pVT->GetContentRect();
+ if (m_bNotifyFlag)
+ return;
+
+ CFX_AutoRestorer<bool> restorer(&m_bNotifyFlag);
+ m_bNotifyFlag = true;
+
+ PWL_SCROLL_INFO Info;
+ Info.fPlateWidth = rcPlate.top - rcPlate.bottom;
+ Info.fContentMin = rcContent.bottom;
+ Info.fContentMax = rcContent.top;
+ Info.fSmallStep = rcPlate.Height() / 3;
+ Info.fBigStep = rcPlate.Height();
+ m_pNotify->SetScrollInfo(Info);
}
void CFX_Edit::SetScrollPosX(float fx) {
@@ -1265,7 +1272,7 @@ void CFX_Edit::SetScrollPosY(float fy) {
if (!m_bNotifyFlag) {
CFX_AutoRestorer<bool> restorer(&m_bNotifyFlag);
m_bNotifyFlag = true;
- m_pNotify->IOnSetScrollPosY(fy);
+ m_pNotify->SetScrollPosition(fy);
}
}
}
@@ -1377,7 +1384,7 @@ void CFX_Edit::Refresh() {
m_bNotifyFlag = true;
if (const CFX_Edit_RectArray* pRects = m_Refresh.GetRefreshRects()) {
for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++)
- m_pNotify->IOnInvalidateRect(pRects->GetAt(i));
+ m_pNotify->InvalidateRect(pRects->GetAt(i));
}
}
}
@@ -1445,7 +1452,7 @@ void CFX_Edit::RefreshWordRange(const CPVT_WordRange& wr) {
CFX_AutoRestorer<bool> restorer(&m_bNotifyFlag);
m_bNotifyFlag = true;
CFX_FloatRect rcRefresh = VTToEdit(rcWord);
- m_pNotify->IOnInvalidateRect(&rcRefresh);
+ m_pNotify->InvalidateRect(&rcRefresh);
}
}
} else {
@@ -1459,7 +1466,7 @@ void CFX_Edit::RefreshWordRange(const CPVT_WordRange& wr) {
CFX_AutoRestorer<bool> restorer(&m_bNotifyFlag);
m_bNotifyFlag = true;
CFX_FloatRect rcRefresh = VTToEdit(rcLine);
- m_pNotify->IOnInvalidateRect(&rcRefresh);
+ m_pNotify->InvalidateRect(&rcRefresh);
}
}
@@ -1497,8 +1504,8 @@ void CFX_Edit::SetCaretInfo() {
CFX_AutoRestorer<bool> restorer(&m_bNotifyFlag);
m_bNotifyFlag = true;
- m_pNotify->IOnSetCaret(m_SelState.IsEmpty(), VTToEdit(ptHead),
- VTToEdit(ptFoot), m_wpCaret);
+ m_pNotify->SetCaret(m_SelState.IsEmpty(), VTToEdit(ptHead),
+ VTToEdit(ptFoot));
}
}
}
diff --git a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
index ace59a8e13..660f8cd9d3 100644
--- a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
@@ -278,7 +278,7 @@ void CPWL_ComboBox::CreateEdit(const PWL_CREATEPARAM& cp) {
if (m_pEdit)
return;
- m_pEdit = new CPWL_CBEdit();
+ m_pEdit = new CPWL_Edit();
m_pEdit->AttachFFLData(m_pFormFiller.Get());
PWL_CREATEPARAM ecp = cp;
diff --git a/fpdfsdk/pdfwindow/cpwl_combo_box.h b/fpdfsdk/pdfwindow/cpwl_combo_box.h
index 15915e64b4..25f0886fe4 100644
--- a/fpdfsdk/pdfwindow/cpwl_combo_box.h
+++ b/fpdfsdk/pdfwindow/cpwl_combo_box.h
@@ -14,12 +14,6 @@
#include "fpdfsdk/pdfwindow/cpwl_list_box.h"
#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
-class CPWL_CBEdit : public CPWL_Edit {
- public:
- CPWL_CBEdit() {}
- ~CPWL_CBEdit() override {}
-};
-
class CPWL_CBListBox : public CPWL_ListBox {
public:
CPWL_CBListBox() {}
@@ -93,7 +87,7 @@ class CPWL_ComboBox : public CPWL_Wnd {
void CreateListBox(const PWL_CREATEPARAM& cp);
void SetPopup(bool bPopup);
- CFX_UnownedPtr<CPWL_CBEdit> m_pEdit;
+ CFX_UnownedPtr<CPWL_Edit> m_pEdit;
CFX_UnownedPtr<CPWL_CBButton> m_pButton;
CFX_UnownedPtr<CPWL_CBListBox> m_pList;
CFX_FloatRect m_rcOldWindow;
diff --git a/fpdfsdk/pdfwindow/cpwl_edit.cpp b/fpdfsdk/pdfwindow/cpwl_edit.cpp
index 4ad107653d..de21dac144 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_edit.cpp
@@ -451,7 +451,12 @@ void CPWL_Edit::OnSetFocus() {
}
void CPWL_Edit::OnKillFocus() {
- ShowVScrollBar(false);
+ CPWL_ScrollBar* pScroll = GetVScrollBar();
+ if (pScroll && pScroll->IsVisible()) {
+ pScroll->SetVisible(false);
+ Move(m_rcOldWindow, true, true);
+ }
+
m_pEdit->SelectNone();
SetCaret(false, CFX_PointF(), CFX_PointF());
SetCharSet(FX_CHARSET_ANSI);
@@ -569,30 +574,9 @@ CFX_FloatRect CPWL_Edit::GetFocusRect() const {
return CFX_FloatRect();
}
-void CPWL_Edit::ShowVScrollBar(bool bShow) {
- if (CPWL_ScrollBar* pScroll = GetVScrollBar()) {
- if (bShow) {
- if (!pScroll->IsVisible()) {
- pScroll->SetVisible(true);
- CFX_FloatRect rcWindow = GetWindowRect();
- m_rcOldWindow = rcWindow;
- rcWindow.right += PWL_SCROLLBAR_WIDTH;
- Move(rcWindow, true, true);
- }
- } else {
- if (pScroll->IsVisible()) {
- pScroll->SetVisible(false);
- Move(m_rcOldWindow, true, true);
- }
- }
- }
-}
-
bool CPWL_Edit::IsVScrollBarVisible() const {
- if (CPWL_ScrollBar* pScroll = GetVScrollBar()) {
+ if (CPWL_ScrollBar* pScroll = GetVScrollBar())
return pScroll->IsVisible();
- }
-
return false;
}
diff --git a/fpdfsdk/pdfwindow/cpwl_edit.h b/fpdfsdk/pdfwindow/cpwl_edit.h
index 31296f664a..8d549b5f6b 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit.h
+++ b/fpdfsdk/pdfwindow/cpwl_edit.h
@@ -113,7 +113,6 @@ class CPWL_Edit : public CPWL_EditCtrl {
private:
CPVT_WordRange GetSelectWordRange() const;
- virtual void ShowVScrollBar(bool bShow);
bool IsVScrollBarVisible() const;
void SetParamByFlag();
diff --git a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
index 59879bb274..ccc214ab00 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
@@ -299,8 +299,7 @@ void CPWL_EditCtrl::SetEditCaret(bool bVisible) {
if (bVisible)
GetCaretInfo(&ptHead, &ptFoot);
- CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace();
- IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp);
+ SetCaret(bVisible, ptHead, ptFoot);
}
void CPWL_EditCtrl::GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const {
@@ -367,8 +366,6 @@ void CPWL_EditCtrl::PasteText() {}
void CPWL_EditCtrl::CutText() {}
-void CPWL_EditCtrl::ShowVScrollBar(bool bShow) {}
-
void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) {
if (!IsReadOnly())
m_pEdit->InsertWord(word, nCharset);
@@ -407,43 +404,6 @@ void CPWL_EditCtrl::Undo() {
m_pEdit->Undo();
}
-void CPWL_EditCtrl::IOnSetScrollInfoY(float fPlateMin,
- float fPlateMax,
- float fContentMin,
- float fContentMax,
- float fSmallStep,
- float fBigStep) {
- PWL_SCROLL_INFO Info;
- Info.fPlateWidth = fPlateMax - fPlateMin;
- Info.fContentMin = fContentMin;
- Info.fContentMax = fContentMax;
- Info.fSmallStep = fSmallStep;
- Info.fBigStep = fBigStep;
- SetScrollInfo(Info);
-
- if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) ||
- IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) {
- ShowVScrollBar(false);
- } else {
- ShowVScrollBar(true);
- }
-}
-
-void CPWL_EditCtrl::IOnSetScrollPosY(float fy) {
- SetScrollPosition(fy);
-}
-
-void CPWL_EditCtrl::IOnSetCaret(bool bVisible,
- const CFX_PointF& ptHead,
- const CFX_PointF& ptFoot,
- const CPVT_WordPlace& place) {
- SetCaret(bVisible, ptHead, ptFoot);
-}
-
-void CPWL_EditCtrl::IOnInvalidateRect(CFX_FloatRect* pRect) {
- InvalidateRect(pRect);
-}
-
int32_t CPWL_EditCtrl::GetCharSet() const {
return m_nCharSet < 0 ? FX_CHARSET_Default : m_nCharSet;
}
diff --git a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h
index f81def6464..454e579622 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h
+++ b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h
@@ -62,24 +62,14 @@ class CPWL_EditCtrl : public CPWL_Wnd {
void SetCursor() override;
CFX_WideString GetSelectedText() override;
- void IOnSetScrollInfoY(float fPlateMin,
- float fPlateMax,
- float fContentMin,
- float fContentMax,
- float fSmallStep,
- float fBigStep);
- void IOnSetScrollPosY(float fy);
- void IOnSetCaret(bool bVisible,
- const CFX_PointF& ptHead,
- const CFX_PointF& ptFoot,
- const CPVT_WordPlace& place);
- void IOnInvalidateRect(CFX_FloatRect* pRect);
+ void SetCaret(bool bVisible,
+ const CFX_PointF& ptHead,
+ const CFX_PointF& ptFoot);
protected:
void CopyText();
void PasteText();
void CutText();
- void ShowVScrollBar(bool bShow);
void InsertWord(uint16_t word, int32_t nCharset);
void InsertReturn();
@@ -89,9 +79,6 @@ class CPWL_EditCtrl : public CPWL_Wnd {
void Backspace();
void GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const;
- void SetCaret(bool bVisible,
- const CFX_PointF& ptHead,
- const CFX_PointF& ptFoot);
void SetEditCaret(bool bVisible);
diff --git a/fpdfsdk/pdfwindow/cpwl_list_box.h b/fpdfsdk/pdfwindow/cpwl_list_box.h
index f1bfea7779..d97f5ae31a 100644
--- a/fpdfsdk/pdfwindow/cpwl_list_box.h
+++ b/fpdfsdk/pdfwindow/cpwl_list_box.h
@@ -35,11 +35,6 @@ class CPWL_List_Notify {
void IOnSetScrollPosY(float fy);
void IOnInvalidateRect(CFX_FloatRect* pRect);
- void IOnSetCaret(bool bVisible,
- const CFX_PointF& ptHead,
- const CFX_PointF& ptFoot,
- const CPVT_WordPlace& place);
-
private:
CFX_UnownedPtr<CPWL_ListBox> m_pList;
};