Replace CFX_SizeF with discrete floats for ranges in CFWL_ classes.
The CFWL_ScrollBar::GetRange() call returns a min and a max value,
presumably in one dimension, not a width and a height. Using a
CFX_SizeF to store this pair is misleading.
-- remove DCHECK preceding immediate segvs we get for free.
Change-Id: I94ad841dce53853aed95c313a4f70cc72dfe47ab
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/84732
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Hui Yingst <nigi@chromium.org>
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index 59802e2..f9bae92 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -1056,44 +1056,45 @@
bool CFWL_Edit::OnScroll(CFWL_ScrollBar* pScrollBar,
CFWL_EventScroll::Code dwCode,
float fPos) {
- CFX_SizeF fs;
- pScrollBar->GetRange(&fs.width, &fs.height);
+ float fMin;
+ float fMax;
+ pScrollBar->GetRange(&fMin, &fMax);
float iCurPos = pScrollBar->GetPos();
float fStep = pScrollBar->GetStepSize();
switch (dwCode) {
case CFWL_EventScroll::Code::Min: {
- fPos = fs.width;
+ fPos = fMin;
break;
}
case CFWL_EventScroll::Code::Max: {
- fPos = fs.height;
+ fPos = fMax;
break;
}
case CFWL_EventScroll::Code::StepBackward: {
fPos -= fStep;
- if (fPos < fs.width + fStep / 2) {
- fPos = fs.width;
+ if (fPos < fMin + fStep / 2) {
+ fPos = fMin;
}
break;
}
case CFWL_EventScroll::Code::StepForward: {
fPos += fStep;
- if (fPos > fs.height - fStep / 2) {
- fPos = fs.height;
+ if (fPos > fMax - fStep / 2) {
+ fPos = fMax;
}
break;
}
case CFWL_EventScroll::Code::PageBackward: {
fPos -= pScrollBar->GetPageSize();
- if (fPos < fs.width) {
- fPos = fs.width;
+ if (fPos < fMin) {
+ fPos = fMin;
}
break;
}
case CFWL_EventScroll::Code::PageForward: {
fPos += pScrollBar->GetPageSize();
- if (fPos > fs.height) {
- fPos = fs.height;
+ if (fPos > fMax) {
+ fPos = fMax;
}
break;
}
diff --git a/xfa/fwl/cfwl_listbox.cpp b/xfa/fwl/cfwl_listbox.cpp
index b342307..14e6fd4 100644
--- a/xfa/fwl/cfwl_listbox.cpp
+++ b/xfa/fwl/cfwl_listbox.cpp
@@ -450,7 +450,7 @@
if (!bShowVertScr && (m_Properties.m_dwStyles & FWL_STYLE_WGT_VScroll))
bShowVertScr = (fs.height > iHeight);
- CFX_SizeF szRange;
+ float fMax = 0.0f;
if (bShowVertScr) {
if (!m_pVertScrollBar)
InitVerticalScrollBar();
@@ -462,15 +462,13 @@
rtScrollBar.height -= m_fScorllBarWidth;
m_pVertScrollBar->SetWidgetRect(rtScrollBar);
- szRange.width = 0;
- szRange.height = std::max(fs.height - m_ContentRect.height, m_fItemHeight);
+ fMax = std::max(fs.height - m_ContentRect.height, m_fItemHeight);
- m_pVertScrollBar->SetRange(szRange.width, szRange.height);
+ m_pVertScrollBar->SetRange(0.0f, fMax);
m_pVertScrollBar->SetPageSize(rtScrollBar.height * 9 / 10);
m_pVertScrollBar->SetStepSize(m_fItemHeight);
- float fPos =
- pdfium::clamp(m_pVertScrollBar->GetPos(), 0.0f, szRange.height);
+ float fPos = pdfium::clamp(m_pVertScrollBar->GetPos(), 0.0f, fMax);
m_pVertScrollBar->SetPos(fPos);
m_pVertScrollBar->SetTrackPos(fPos);
if ((m_Properties.m_dwStyleExts & FWL_STYLEEXT_LTB_ShowScrollBarFocus) ==
@@ -495,14 +493,12 @@
rtScrollBar.width -= m_fScorllBarWidth;
m_pHorzScrollBar->SetWidgetRect(rtScrollBar);
- szRange.width = 0;
- szRange.height = fs.width - rtScrollBar.width;
- m_pHorzScrollBar->SetRange(szRange.width, szRange.height);
+ fMax = fs.width - rtScrollBar.width;
+ m_pHorzScrollBar->SetRange(0.0f, fMax);
m_pHorzScrollBar->SetPageSize(fWidth * 9 / 10);
m_pHorzScrollBar->SetStepSize(fWidth / 10);
- float fPos =
- pdfium::clamp(m_pHorzScrollBar->GetPos(), 0.0f, szRange.height);
+ float fPos = pdfium::clamp(m_pHorzScrollBar->GetPos(), 0.0f, fMax);
m_pHorzScrollBar->SetPos(fPos);
m_pHorzScrollBar->SetTrackPos(fPos);
if ((m_Properties.m_dwStyleExts & FWL_STYLEEXT_LTB_ShowScrollBarFocus) ==
@@ -767,41 +763,42 @@
bool CFWL_ListBox::OnScroll(CFWL_ScrollBar* pScrollBar,
CFWL_EventScroll::Code dwCode,
float fPos) {
- CFX_SizeF fs;
- pScrollBar->GetRange(&fs.width, &fs.height);
+ float fMin;
+ float fMax;
+ pScrollBar->GetRange(&fMin, &fMax);
float iCurPos = pScrollBar->GetPos();
float fStep = pScrollBar->GetStepSize();
switch (dwCode) {
case CFWL_EventScroll::Code::Min: {
- fPos = fs.width;
+ fPos = fMin;
break;
}
case CFWL_EventScroll::Code::Max: {
- fPos = fs.height;
+ fPos = fMax;
break;
}
case CFWL_EventScroll::Code::StepBackward: {
fPos -= fStep;
- if (fPos < fs.width + fStep / 2)
- fPos = fs.width;
+ if (fPos < fMin + fStep / 2)
+ fPos = fMin;
break;
}
case CFWL_EventScroll::Code::StepForward: {
fPos += fStep;
- if (fPos > fs.height - fStep / 2)
- fPos = fs.height;
+ if (fPos > fMax - fStep / 2)
+ fPos = fMax;
break;
}
case CFWL_EventScroll::Code::PageBackward: {
fPos -= pScrollBar->GetPageSize();
- if (fPos < fs.width)
- fPos = fs.width;
+ if (fPos < fMin)
+ fPos = fMin;
break;
}
case CFWL_EventScroll::Code::PageForward: {
fPos += pScrollBar->GetPageSize();
- if (fPos > fs.height)
- fPos = fs.height;
+ if (fPos > fMax)
+ fPos = fMax;
break;
}
case CFWL_EventScroll::Code::Pos:
diff --git a/xfa/fwl/cfwl_scrollbar.h b/xfa/fwl/cfwl_scrollbar.h
index ab8645a..de82c8e 100644
--- a/xfa/fwl/cfwl_scrollbar.h
+++ b/xfa/fwl/cfwl_scrollbar.h
@@ -39,8 +39,6 @@
void OnTimerFired() override;
void GetRange(float* fMin, float* fMax) const {
- DCHECK(fMin);
- DCHECK(fMax);
*fMin = m_fRangeMin;
*fMax = m_fRangeMax;
}