Move PNM_SETSCROLLINFO out of OnNotify
This CL moves the SETSCROLLINFO from a OnNotify message to a method
which is called directly.
Change-Id: I5d793c1c7a54c0fa3bdadffac72aae934cb9da57
Reviewed-on: https://pdfium-review.googlesource.com/7251
Reviewed-by: Nicolás Peña <npm@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
diff --git a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
index d8a157a..e6076e1 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
@@ -64,6 +64,11 @@
m_pEdit->SetPlateRect(GetClientRect());
}
+void CPWL_EditCtrl::SetScrollInfo(const PWL_SCROLL_INFO& info) {
+ if (CPWL_Wnd* pChild = GetVScrollBar())
+ pChild->SetScrollInfo(info);
+}
+
void CPWL_EditCtrl::OnNotify(CPWL_Wnd* pWnd,
uint32_t msg,
intptr_t wParam,
@@ -71,15 +76,6 @@
CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
switch (msg) {
- case PNM_SETSCROLLINFO:
- switch (wParam) {
- case SBT_VSCROLL:
- if (CPWL_Wnd* pChild = GetVScrollBar()) {
- pChild->OnNotify(pWnd, PNM_SETSCROLLINFO, wParam, lParam);
- }
- break;
- }
- break;
case PNM_SETSCROLLPOS:
switch (wParam) {
case SBT_VSCROLL:
@@ -441,14 +437,12 @@
float fSmallStep,
float fBigStep) {
PWL_SCROLL_INFO Info;
-
Info.fPlateWidth = fPlateMax - fPlateMin;
Info.fContentMin = fContentMin;
Info.fContentMax = fContentMax;
Info.fSmallStep = fSmallStep;
Info.fBigStep = fBigStep;
-
- OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info);
+ SetScrollInfo(Info);
if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) ||
IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) {
diff --git a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h
index 1c4c925..822f527 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h
+++ b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h
@@ -56,6 +56,7 @@
uint32_t msg,
intptr_t wParam = 0,
intptr_t lParam = 0) override;
+ void SetScrollInfo(const PWL_SCROLL_INFO& info) 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 f612c29..25842b3 100644
--- a/fpdfsdk/pdfwindow/cpwl_list_box.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_list_box.cpp
@@ -31,15 +31,12 @@
float fSmallStep,
float fBigStep) {
PWL_SCROLL_INFO Info;
-
Info.fPlateWidth = fPlateMax - fPlateMin;
Info.fContentMin = fContentMin;
Info.fContentMax = fContentMax;
Info.fSmallStep = fSmallStep;
Info.fBigStep = fBigStep;
-
- m_pList->OnNotify(m_pList.Get(), PNM_SETSCROLLINFO, SBT_VSCROLL,
- reinterpret_cast<intptr_t>(&Info));
+ m_pList->SetScrollInfo(Info);
if (CPWL_ScrollBar* pScroll = m_pList->GetVScrollBar()) {
if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) ||
@@ -288,6 +285,11 @@
return true;
}
+void CPWL_ListBox::SetScrollInfo(const PWL_SCROLL_INFO& info) {
+ if (CPWL_Wnd* pChild = GetVScrollBar())
+ pChild->SetScrollInfo(info);
+}
+
void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd,
uint32_t msg,
intptr_t wParam,
@@ -297,15 +299,6 @@
float fPos;
switch (msg) {
- case PNM_SETSCROLLINFO:
- switch (wParam) {
- case SBT_VSCROLL:
- if (CPWL_Wnd* pChild = GetVScrollBar()) {
- pChild->OnNotify(pWnd, PNM_SETSCROLLINFO, wParam, lParam);
- }
- break;
- }
- break;
case PNM_SETSCROLLPOS:
switch (wParam) {
case SBT_VSCROLL:
diff --git a/fpdfsdk/pdfwindow/cpwl_list_box.h b/fpdfsdk/pdfwindow/cpwl_list_box.h
index 3eeed0d..6a2118e 100644
--- a/fpdfsdk/pdfwindow/cpwl_list_box.h
+++ b/fpdfsdk/pdfwindow/cpwl_list_box.h
@@ -69,6 +69,7 @@
uint32_t msg,
intptr_t wParam = 0,
intptr_t lParam = 0) override;
+ void SetScrollInfo(const PWL_SCROLL_INFO& info) 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 33bdedb..45814cf 100644
--- a/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
@@ -6,6 +6,7 @@
#include "fpdfsdk/pdfwindow/cpwl_scroll_bar.h"
+#include <algorithm>
#include <sstream>
#include "core/fxge/cfx_pathdata.h"
@@ -750,6 +751,17 @@
return true;
}
+void CPWL_ScrollBar::SetScrollInfo(const PWL_SCROLL_INFO& info) {
+ if (info == m_OriginInfo)
+ return;
+
+ m_OriginInfo = info;
+ float fMax =
+ std::max(0.0f, info.fContentMax - info.fContentMin - info.fPlateWidth);
+ SetScrollRange(0, fMax, info.fPlateWidth);
+ SetScrollStep(info.fBigStep, info.fSmallStep);
+}
+
void CPWL_ScrollBar::OnNotify(CPWL_Wnd* pWnd,
uint32_t msg,
intptr_t wParam,
@@ -796,17 +808,6 @@
OnPosButtonMouseMove(*(CFX_PointF*)lParam);
}
break;
- case PNM_SETSCROLLINFO: {
- PWL_SCROLL_INFO* pInfo = reinterpret_cast<PWL_SCROLL_INFO*>(lParam);
- if (pInfo && *pInfo != m_OriginInfo) {
- m_OriginInfo = *pInfo;
- float fMax =
- pInfo->fContentMax - pInfo->fContentMin - pInfo->fPlateWidth;
- fMax = fMax > 0.0f ? fMax : 0.0f;
- SetScrollRange(0, fMax, pInfo->fPlateWidth);
- SetScrollStep(pInfo->fBigStep, pInfo->fSmallStep);
- }
- } break;
case PNM_SETSCROLLPOS: {
float fPos = *(float*)lParam;
switch (m_sbType) {
diff --git a/fpdfsdk/pdfwindow/cpwl_scroll_bar.h b/fpdfsdk/pdfwindow/cpwl_scroll_bar.h
index c67109f..a875d6e 100644
--- a/fpdfsdk/pdfwindow/cpwl_scroll_bar.h
+++ b/fpdfsdk/pdfwindow/cpwl_scroll_bar.h
@@ -135,6 +135,7 @@
uint32_t msg,
intptr_t wParam = 0,
intptr_t lParam = 0) override;
+ void SetScrollInfo(const PWL_SCROLL_INFO& info) 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 e99d71b..8ac7d48 100644
--- a/fpdfsdk/pdfwindow/cpwl_wnd.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_wnd.cpp
@@ -427,6 +427,8 @@
intptr_t wParam,
intptr_t lParam) {}
+void CPWL_Wnd::SetScrollInfo(const PWL_SCROLL_INFO& info) {}
+
bool CPWL_Wnd::IsValid() const {
return m_bCreated;
}
diff --git a/fpdfsdk/pdfwindow/cpwl_wnd.h b/fpdfsdk/pdfwindow/cpwl_wnd.h
index 39ed402..9ffae16 100644
--- a/fpdfsdk/pdfwindow/cpwl_wnd.h
+++ b/fpdfsdk/pdfwindow/cpwl_wnd.h
@@ -25,6 +25,7 @@
class CFX_SystemHandler;
class IPVT_FontMap;
class IPWL_Provider;
+struct PWL_SCROLL_INFO;
// window styles
#define PWS_CHILD 0x80000000L
@@ -73,7 +74,6 @@
#define PRES_TEXTOVERFLOW 0x0400L
// notification messages
-#define PNM_SETSCROLLINFO 2
#define PNM_SETSCROLLPOS 3
#define PNM_SCROLLWINDOW 4
#define PNM_LBUTTONDOWN 5
@@ -220,6 +220,7 @@
uint32_t msg,
intptr_t wParam = 0,
intptr_t lParam = 0);
+ virtual void SetScrollInfo(const PWL_SCROLL_INFO& info);
virtual void SetFocus();
virtual void KillFocus();
virtual void SetCursor();