From 7e0336e278d69f1d66967db7375c75322da55d69 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 5 Jul 2017 09:39:50 -0400 Subject: Move PNM_SETSCROLLPOS to custom method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL splits PNM_SETSCROLLPOS out of OnNotify and places into a method which is called as needed. Change-Id: Ic144bc30bca57869f0679bef40e07b6a130e944c Reviewed-on: https://pdfium-review.googlesource.com/7252 Reviewed-by: Nicolás Peña Commit-Queue: dsinclair --- fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp | 16 ++++++---------- fpdfsdk/pdfwindow/cpwl_edit_ctrl.h | 1 + fpdfsdk/pdfwindow/cpwl_list_box.cpp | 17 ++++++----------- fpdfsdk/pdfwindow/cpwl_list_box.h | 1 + fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp | 26 ++++++++++++-------------- fpdfsdk/pdfwindow/cpwl_scroll_bar.h | 1 + fpdfsdk/pdfwindow/cpwl_wnd.cpp | 2 ++ fpdfsdk/pdfwindow/cpwl_wnd.h | 2 +- 8 files changed, 30 insertions(+), 36 deletions(-) diff --git a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp index e6076e15ae..f18aaaa130 100644 --- a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp +++ b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp @@ -69,6 +69,11 @@ void CPWL_EditCtrl::SetScrollInfo(const PWL_SCROLL_INFO& info) { pChild->SetScrollInfo(info); } +void CPWL_EditCtrl::SetScrollPosition(float pos) { + if (CPWL_Wnd* pChild = GetVScrollBar()) + pChild->SetScrollPosition(pos); +} + void CPWL_EditCtrl::OnNotify(CPWL_Wnd* pWnd, uint32_t msg, intptr_t wParam, @@ -76,15 +81,6 @@ void CPWL_EditCtrl::OnNotify(CPWL_Wnd* pWnd, CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); switch (msg) { - case PNM_SETSCROLLPOS: - switch (wParam) { - case SBT_VSCROLL: - if (CPWL_Wnd* pChild = GetVScrollBar()) { - pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam); - } - break; - } - break; case PNM_SCROLLWINDOW: { float fPos = *(float*)lParam; switch (wParam) { @@ -453,7 +449,7 @@ void CPWL_EditCtrl::IOnSetScrollInfoY(float fPlateMin, } void CPWL_EditCtrl::IOnSetScrollPosY(float fy) { - OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy); + SetScrollPosition(fy); } void CPWL_EditCtrl::IOnSetCaret(bool bVisible, diff --git a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h index 822f527bcd..d8cbc5ee83 100644 --- a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h +++ b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h @@ -57,6 +57,7 @@ class CPWL_EditCtrl : public CPWL_Wnd { intptr_t wParam = 0, intptr_t lParam = 0) override; void SetScrollInfo(const PWL_SCROLL_INFO& info) override; + void SetScrollPosition(float pos) override; void CreateChildWnd(const PWL_CREATEPARAM& cp) override; void RePosChildWnd() override; void SetFontSize(float fFontSize) override; diff --git a/fpdfsdk/pdfwindow/cpwl_list_box.cpp b/fpdfsdk/pdfwindow/cpwl_list_box.cpp index 25842b3d63..be6d00f62b 100644 --- a/fpdfsdk/pdfwindow/cpwl_list_box.cpp +++ b/fpdfsdk/pdfwindow/cpwl_list_box.cpp @@ -55,8 +55,7 @@ void CPWL_List_Notify::IOnSetScrollInfoY(float fPlateMin, } void CPWL_List_Notify::IOnSetScrollPosY(float fy) { - m_pList->OnNotify(m_pList.Get(), PNM_SETSCROLLPOS, SBT_VSCROLL, - reinterpret_cast(&fy)); + m_pList->SetScrollPosition(fy); } void CPWL_List_Notify::IOnInvalidateRect(CFX_FloatRect* pRect) { @@ -290,6 +289,11 @@ void CPWL_ListBox::SetScrollInfo(const PWL_SCROLL_INFO& info) { pChild->SetScrollInfo(info); } +void CPWL_ListBox::SetScrollPosition(float pos) { + if (CPWL_Wnd* pChild = GetVScrollBar()) + pChild->SetScrollPosition(pos); +} + void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd, uint32_t msg, intptr_t wParam, @@ -299,15 +303,6 @@ void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd, float fPos; switch (msg) { - case PNM_SETSCROLLPOS: - switch (wParam) { - case SBT_VSCROLL: - if (CPWL_Wnd* pChild = GetVScrollBar()) { - pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam); - } - break; - } - break; case PNM_SCROLLWINDOW: fPos = *(float*)lParam; switch (wParam) { diff --git a/fpdfsdk/pdfwindow/cpwl_list_box.h b/fpdfsdk/pdfwindow/cpwl_list_box.h index 6a2118e667..9acfd9ddc7 100644 --- a/fpdfsdk/pdfwindow/cpwl_list_box.h +++ b/fpdfsdk/pdfwindow/cpwl_list_box.h @@ -70,6 +70,7 @@ class CPWL_ListBox : public CPWL_Wnd { intptr_t wParam = 0, intptr_t lParam = 0) override; void SetScrollInfo(const PWL_SCROLL_INFO& info) override; + void SetScrollPosition(float pos) override; void RePosChildWnd() override; CFX_FloatRect GetFocusRect() const override; void SetFontSize(float fFontSize) override; diff --git a/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp b/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp index 45814cff2f..9b65cf1695 100644 --- a/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp +++ b/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp @@ -762,6 +762,18 @@ void CPWL_ScrollBar::SetScrollInfo(const PWL_SCROLL_INFO& info) { SetScrollStep(info.fBigStep, info.fSmallStep); } +void CPWL_ScrollBar::SetScrollPosition(float pos) { + switch (m_sbType) { + case SBT_HSCROLL: + pos = pos - m_OriginInfo.fContentMin; + break; + case SBT_VSCROLL: + pos = m_OriginInfo.fContentMax - pos; + break; + } + SetScrollPos(pos); +} + void CPWL_ScrollBar::OnNotify(CPWL_Wnd* pWnd, uint32_t msg, intptr_t wParam, @@ -808,18 +820,6 @@ void CPWL_ScrollBar::OnNotify(CPWL_Wnd* pWnd, OnPosButtonMouseMove(*(CFX_PointF*)lParam); } break; - case PNM_SETSCROLLPOS: { - float fPos = *(float*)lParam; - switch (m_sbType) { - case SBT_HSCROLL: - fPos = fPos - m_OriginInfo.fContentMin; - break; - case SBT_VSCROLL: - fPos = m_OriginInfo.fContentMax - fPos; - break; - } - SetScrollPos(fPos); - } break; } } @@ -874,9 +874,7 @@ void CPWL_ScrollBar::SetScrollRange(float fMin, void CPWL_ScrollBar::SetScrollPos(float fPos) { float fOldPos = m_sData.fScrollPos; - m_sData.SetPos(fPos); - if (!IsFloatEqual(m_sData.fScrollPos, fOldPos)) MovePosButton(true); } diff --git a/fpdfsdk/pdfwindow/cpwl_scroll_bar.h b/fpdfsdk/pdfwindow/cpwl_scroll_bar.h index a875d6ec80..4aebda6609 100644 --- a/fpdfsdk/pdfwindow/cpwl_scroll_bar.h +++ b/fpdfsdk/pdfwindow/cpwl_scroll_bar.h @@ -136,6 +136,7 @@ class CPWL_ScrollBar : public CPWL_Wnd { intptr_t wParam = 0, intptr_t lParam = 0) override; void SetScrollInfo(const PWL_SCROLL_INFO& info) override; + void SetScrollPosition(float pos) override; void CreateChildWnd(const PWL_CREATEPARAM& cp) override; void TimerProc() override; diff --git a/fpdfsdk/pdfwindow/cpwl_wnd.cpp b/fpdfsdk/pdfwindow/cpwl_wnd.cpp index 8ac7d48cba..f407dfc1e9 100644 --- a/fpdfsdk/pdfwindow/cpwl_wnd.cpp +++ b/fpdfsdk/pdfwindow/cpwl_wnd.cpp @@ -429,6 +429,8 @@ void CPWL_Wnd::OnNotify(CPWL_Wnd* pWnd, void CPWL_Wnd::SetScrollInfo(const PWL_SCROLL_INFO& info) {} +void CPWL_Wnd::SetScrollPosition(float pos) {} + bool CPWL_Wnd::IsValid() const { return m_bCreated; } diff --git a/fpdfsdk/pdfwindow/cpwl_wnd.h b/fpdfsdk/pdfwindow/cpwl_wnd.h index 9ffae162f3..c9c4130725 100644 --- a/fpdfsdk/pdfwindow/cpwl_wnd.h +++ b/fpdfsdk/pdfwindow/cpwl_wnd.h @@ -74,7 +74,6 @@ struct PWL_SCROLL_INFO; #define PRES_TEXTOVERFLOW 0x0400L // notification messages -#define PNM_SETSCROLLPOS 3 #define PNM_SCROLLWINDOW 4 #define PNM_LBUTTONDOWN 5 #define PNM_LBUTTONUP 6 @@ -221,6 +220,7 @@ class CPWL_Wnd : public CPWL_TimerHandler { intptr_t wParam = 0, intptr_t lParam = 0); virtual void SetScrollInfo(const PWL_SCROLL_INFO& info); + virtual void SetScrollPosition(float pos); virtual void SetFocus(); virtual void KillFocus(); virtual void SetCursor(); -- cgit v1.2.3