Make CPWL_EditImpl::DrawEdit() a non-static method.
It is passed a CWPL_EditImpl* as an arg anyways, and that arg is
immediately de-referenced, so there isn't a null `this` issue to
worry about.
Change-Id: I5748b25ce0c37773c26e234d3c46f5dfc4a59fc7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/85272
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/pwl/cpwl_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp
index a338c66..22a1d94 100644
--- a/fpdfsdk/pwl/cpwl_edit.cpp
+++ b/fpdfsdk/pwl/cpwl_edit.cpp
@@ -211,11 +211,9 @@
rcClip = GetClientRect();
pRange = &wrRange;
}
-
- CPWL_EditImpl::DrawEdit(pDevice, mtUser2Device, m_pEditImpl.get(),
- GetTextColor().ToFXColor(GetTransparency()), rcClip,
- CFX_PointF(), pRange, GetSystemHandler(),
- GetAttachedData());
+ m_pEditImpl->DrawEdit(
+ pDevice, mtUser2Device, GetTextColor().ToFXColor(GetTransparency()),
+ rcClip, CFX_PointF(), pRange, GetSystemHandler(), GetAttachedData());
}
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.cpp b/fpdfsdk/pwl/cpwl_edit_impl.cpp
index 87dcb68..2efa89b 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_impl.cpp
@@ -578,21 +578,18 @@
return 0;
}
-// static
void CPWL_EditImpl::DrawEdit(CFX_RenderDevice* pDevice,
const CFX_Matrix& mtUser2Device,
- CPWL_EditImpl* pEdit,
FX_COLORREF crTextFill,
const CFX_FloatRect& rcClip,
const CFX_PointF& ptOffset,
const CPVT_WordRange* pRange,
IPWL_SystemHandler* pSystemHandler,
IPWL_SystemHandler::PerWindowData* pSystemData) {
- const bool bContinuous =
- pEdit->GetCharArray() == 0 && pEdit->GetCharSpace() <= 0.0f;
- uint16_t SubWord = pEdit->GetPasswordChar();
- float fFontSize = pEdit->GetFontSize();
- CPVT_WordRange wrSelect = pEdit->GetSelectWordRange();
+ const bool bContinuous = GetCharArray() == 0 && GetCharSpace() <= 0.0f;
+ uint16_t SubWord = GetPasswordChar();
+ float fFontSize = GetFontSize();
+ CPVT_WordRange wrSelect = GetSelectWordRange();
FX_COLORREF crCurFill = crTextFill;
FX_COLORREF crOldFill = crCurFill;
bool bSelect = false;
@@ -606,8 +603,8 @@
if (!rcClip.IsEmpty())
pDevice->SetClip_Rect(mtUser2Device.TransformRect(rcClip).ToFxRect());
- Iterator* pIterator = pEdit->GetIterator();
- IPVT_FontMap* pFontMap = pEdit->GetFontMap();
+ Iterator* pIterator = GetIterator();
+ IPVT_FontMap* pFontMap = GetFontMap();
if (!pFontMap)
return;
@@ -669,16 +666,14 @@
crOldFill = crCurFill;
}
- sTextBuf << pEdit->GetPDFWordString(word.nFontIndex, word.Word,
- SubWord);
+ sTextBuf << GetPDFWordString(word.nFontIndex, word.Word, SubWord);
} else {
DrawTextString(
pDevice,
CFX_PointF(word.ptWord.x + ptOffset.x, word.ptWord.y + ptOffset.y),
pFontMap->GetPDFFont(word.nFontIndex).Get(), fFontSize,
mtUser2Device,
- pEdit->GetPDFWordString(word.nFontIndex, word.Word, SubWord),
- crCurFill);
+ GetPDFWordString(word.nFontIndex, word.Word, SubWord), crCurFill);
}
oldplace = place;
}
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.h b/fpdfsdk/pwl/cpwl_edit_impl.h
index 913c93c..88405d5 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.h
+++ b/fpdfsdk/pwl/cpwl_edit_impl.h
@@ -41,19 +41,18 @@
UnownedPtr<CPVT_VariableText::Iterator> m_pVTIterator;
};
- static void DrawEdit(CFX_RenderDevice* pDevice,
- const CFX_Matrix& mtUser2Device,
- CPWL_EditImpl* pEdit,
- FX_COLORREF crTextFill,
- const CFX_FloatRect& rcClip,
- const CFX_PointF& ptOffset,
- const CPVT_WordRange* pRange,
- IPWL_SystemHandler* pSystemHandler,
- IPWL_SystemHandler::PerWindowData* pSystemData);
-
CPWL_EditImpl();
~CPWL_EditImpl();
+ void DrawEdit(CFX_RenderDevice* pDevice,
+ const CFX_Matrix& mtUser2Device,
+ FX_COLORREF crTextFill,
+ const CFX_FloatRect& rcClip,
+ const CFX_PointF& ptOffset,
+ const CPVT_WordRange* pRange,
+ IPWL_SystemHandler* pSystemHandler,
+ IPWL_SystemHandler::PerWindowData* pSystemData);
+
void SetFontMap(IPVT_FontMap* pFontMap);
void SetNotify(CPWL_Edit* pNotify);
diff --git a/fpdfsdk/pwl/cpwl_list_box.cpp b/fpdfsdk/pwl/cpwl_list_box.cpp
index 5ea4972..5777266 100644
--- a/fpdfsdk/pwl/cpwl_list_box.cpp
+++ b/fpdfsdk/pwl/cpwl_list_box.cpp
@@ -64,24 +64,21 @@
IPWL_SystemHandler* pSysHandler = GetSystemHandler();
if (m_pListCtrl->IsItemSelected(i)) {
if (pSysHandler->IsSelectionImplemented()) {
- CPWL_EditImpl::DrawEdit(pDevice, mtUser2Device,
- m_pListCtrl->GetItemEdit(i),
- GetTextColor().ToFXColor(255), rcList, ptOffset,
- nullptr, pSysHandler, GetAttachedData());
+ m_pListCtrl->GetItemEdit(i)->DrawEdit(
+ pDevice, mtUser2Device, GetTextColor().ToFXColor(255), rcList,
+ ptOffset, nullptr, pSysHandler, GetAttachedData());
pSysHandler->OutputSelectedRect(GetAttachedData(), rcItem);
} else {
pDevice->DrawFillRect(&mtUser2Device, rcItem,
ArgbEncode(255, 0, 51, 113));
- CPWL_EditImpl::DrawEdit(
- pDevice, mtUser2Device, m_pListCtrl->GetItemEdit(i),
- ArgbEncode(255, 255, 255, 255), rcList, ptOffset, nullptr,
- pSysHandler, GetAttachedData());
+ m_pListCtrl->GetItemEdit(i)->DrawEdit(
+ pDevice, mtUser2Device, ArgbEncode(255, 255, 255, 255), rcList,
+ ptOffset, nullptr, pSysHandler, GetAttachedData());
}
} else {
- CPWL_EditImpl::DrawEdit(pDevice, mtUser2Device,
- m_pListCtrl->GetItemEdit(i),
- GetTextColor().ToFXColor(255), rcList, ptOffset,
- nullptr, pSysHandler, nullptr);
+ m_pListCtrl->GetItemEdit(i)->DrawEdit(
+ pDevice, mtUser2Device, GetTextColor().ToFXColor(255), rcList,
+ ptOffset, nullptr, pSysHandler, nullptr);
}
}
}