Remove CFFL_ types from pwl layer.
Currently, the FFL layer is attaching up to two pieces of data to
each PWL widget. Consolidate these.
Change-Id: I638d907896d5e4f25ffb0b5d9c4550f6dee777b3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/84811
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index 6e6c70b..bd4e0ef 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -110,9 +110,17 @@
}
void CPDFSDK_FormFillEnvironment::OutputSelectedRect(
- CFFL_FormField* pFormField,
+ PerWindowData* pWidgetData,
const CFX_FloatRect& rect) {
- if (!pFormField || !m_pInfo || !m_pInfo->FFI_OutputSelectedRect)
+ if (!m_pInfo || !m_pInfo->FFI_OutputSelectedRect)
+ return;
+
+ auto* pPrivateData = static_cast<CFFL_PrivateData*>(pWidgetData);
+ if (!pPrivateData)
+ return;
+
+ CFFL_FormField* pFormField = pPrivateData->GetFormField();
+ if (!pFormField)
return;
auto* pPage = FPDFPageFromIPDFPage(pFormField->GetSDKAnnot()->GetPage());
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h
index e505fe1..5fd7f76 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.h
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.h
@@ -63,7 +63,7 @@
// IPWL_SystemHandler:
void InvalidateRect(PerWindowData* pWidgetData,
const CFX_FloatRect& rect) override;
- void OutputSelectedRect(CFFL_FormField* pFormField,
+ void OutputSelectedRect(PerWindowData* pWidgetData,
const CFX_FloatRect& rect) override;
bool IsSelectionImplemented() const override;
void SetCursor(CursorStyle nCursorType) override;
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp
index d61fa89..6d1dba7 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -13,6 +13,7 @@
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_widget.h"
#include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
+#include "fpdfsdk/formfiller/cffl_privatedata.h"
#include "fpdfsdk/pwl/cpwl_combo_box.h"
#include "fpdfsdk/pwl/cpwl_edit.h"
@@ -43,8 +44,8 @@
std::unique_ptr<CPWL_Wnd> CFFL_ComboBox::NewPWLWindow(
const CPWL_Wnd::CreateParams& cp,
std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData) {
+ static_cast<CFFL_PrivateData*>(pAttachedData.get())->SetFormField(this);
auto pWnd = std::make_unique<CPWL_ComboBox>(cp, std::move(pAttachedData));
- pWnd->AttachFFLData(this);
pWnd->Realize();
pWnd->SetFillerNotify(m_pFormFillEnv->GetInteractiveFormFiller());
diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp
index 3a69181..e5fd95f 100644
--- a/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -13,6 +13,7 @@
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_widget.h"
#include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
+#include "fpdfsdk/formfiller/cffl_privatedata.h"
#include "fpdfsdk/pwl/cpwl_list_box.h"
#include "third_party/base/containers/contains.h"
@@ -42,8 +43,8 @@
std::unique_ptr<CPWL_Wnd> CFFL_ListBox::NewPWLWindow(
const CPWL_Wnd::CreateParams& cp,
std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData) {
+ static_cast<CFFL_PrivateData*>(pAttachedData.get())->SetFormField(this);
auto pWnd = std::make_unique<CPWL_ListBox>(cp, std::move(pAttachedData));
- pWnd->AttachFFLData(this);
pWnd->Realize();
pWnd->SetFillerNotify(m_pFormFillEnv->GetInteractiveFormFiller());
diff --git a/fpdfsdk/formfiller/cffl_privatedata.h b/fpdfsdk/formfiller/cffl_privatedata.h
index 5e32a71..4866360 100644
--- a/fpdfsdk/formfiller/cffl_privatedata.h
+++ b/fpdfsdk/formfiller/cffl_privatedata.h
@@ -13,6 +13,7 @@
#include "core/fxcrt/unowned_ptr.h"
#include "fpdfsdk/pwl/ipwl_systemhandler.h"
+class CFFL_FormField;
class CPDFSDK_PageView;
class CPDFSDK_Widget;
@@ -35,11 +36,15 @@
}
uint32_t GetValueAge() const { return m_nValueAge; }
+ void SetFormField(CFFL_FormField* pFormField) { m_pFormField = pFormField; }
+ CFFL_FormField* GetFormField() { return m_pFormField.Get(); }
+
private:
CFFL_PrivateData(const CFFL_PrivateData& that);
ObservedPtr<CPDFSDK_Widget> m_pWidget;
UnownedPtr<const CPDFSDK_PageView> const m_pPageView;
+ UnownedPtr<CFFL_FormField> m_pFormField;
const uint32_t m_nAppearanceAge;
const uint32_t m_nValueAge;
};
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index ac2f152..1d521b2 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -13,6 +13,7 @@
#include "core/fpdfdoc/cpdf_bafontmap.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_widget.h"
+#include "fpdfsdk/formfiller/cffl_privatedata.h"
#include "fpdfsdk/pwl/cpwl_edit.h"
#include "public/fpdf_fwlevent.h"
#include "third_party/base/check.h"
@@ -86,8 +87,8 @@
std::unique_ptr<CPWL_Wnd> CFFL_TextField::NewPWLWindow(
const CPWL_Wnd::CreateParams& cp,
std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData) {
+ static_cast<CFFL_PrivateData*>(pAttachedData.get())->SetFormField(this);
auto pWnd = std::make_unique<CPWL_Edit>(cp, std::move(pAttachedData));
- pWnd->AttachFFLData(this);
pWnd->Realize();
pWnd->SetFillerNotify(m_pFormFillEnv->GetInteractiveFormFiller());
diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp
index 107decc..18fd0c7 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box.cpp
@@ -149,7 +149,6 @@
auto pEdit = std::make_unique<CPWL_Edit>(ecp, CloneAttachedData());
m_pEdit = pEdit.get();
- m_pEdit->AttachFFLData(m_pFormFiller.Get());
AddChild(std::move(pEdit));
m_pEdit->Realize();
}
@@ -194,7 +193,6 @@
auto pList = std::make_unique<CPWL_CBListBox>(lcp, CloneAttachedData());
m_pList = pList.get();
- m_pList->AttachFFLData(m_pFormFiller.Get());
AddChild(std::move(pList));
m_pList->Realize();
}
diff --git a/fpdfsdk/pwl/cpwl_combo_box.h b/fpdfsdk/pwl/cpwl_combo_box.h
index f537129..1da5b09 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.h
+++ b/fpdfsdk/pwl/cpwl_combo_box.h
@@ -13,7 +13,6 @@
#include "fpdfsdk/pwl/cpwl_wnd.h"
#include "fpdfsdk/pwl/ipwl_systemhandler.h"
-class CFFL_FormField;
class CPWL_Edit;
class CPWL_CBButton;
class CPWL_CBListBox;
@@ -60,7 +59,6 @@
void SelectAll();
bool IsPopup() const;
void SetSelectText();
- void AttachFFLData(CFFL_FormField* pData) { m_pFormFiller = pData; }
private:
void CreateEdit(const CreateParams& cp);
@@ -78,7 +76,6 @@
bool m_bBottom = true;
int32_t m_nSelectItem = -1;
UnownedPtr<IPWL_FillerNotify> m_pFillerNotify;
- UnownedPtr<CFFL_FormField> m_pFormFiller;
};
#endif // FPDFSDK_PWL_CPWL_COMBO_BOX_H_
diff --git a/fpdfsdk/pwl/cpwl_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp
index fcec231..a338c66 100644
--- a/fpdfsdk/pwl/cpwl_edit.cpp
+++ b/fpdfsdk/pwl/cpwl_edit.cpp
@@ -215,7 +215,7 @@
CPWL_EditImpl::DrawEdit(pDevice, mtUser2Device, m_pEditImpl.get(),
GetTextColor().ToFXColor(GetTransparency()), rcClip,
CFX_PointF(), pRange, GetSystemHandler(),
- m_pFormFiller.Get());
+ GetAttachedData());
}
diff --git a/fpdfsdk/pwl/cpwl_edit.h b/fpdfsdk/pwl/cpwl_edit.h
index 7d0af0a..41698c2 100644
--- a/fpdfsdk/pwl/cpwl_edit.h
+++ b/fpdfsdk/pwl/cpwl_edit.h
@@ -100,7 +100,6 @@
m_pFillerNotify = pNotify;
}
- void AttachFFLData(CFFL_FormField* pData) { m_pFormFiller = pData; }
bool SetCaret(bool bVisible,
const CFX_PointF& ptHead,
const CFX_PointF& ptFoot);
@@ -138,7 +137,6 @@
std::unique_ptr<CPWL_EditImpl> const m_pEditImpl;
UnownedPtr<CPWL_Caret> m_pCaret;
UnownedPtr<IPWL_FillerNotify> m_pFillerNotify;
- UnownedPtr<CFFL_FormField> m_pFormFiller;
};
#endif // FPDFSDK_PWL_CPWL_EDIT_H_
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.cpp b/fpdfsdk/pwl/cpwl_edit_impl.cpp
index c4583c7..87dcb68 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_impl.cpp
@@ -587,7 +587,7 @@
const CFX_PointF& ptOffset,
const CPVT_WordRange* pRange,
IPWL_SystemHandler* pSystemHandler,
- CFFL_FormField* pFFLData) {
+ IPWL_SystemHandler::PerWindowData* pSystemData) {
const bool bContinuous =
pEdit->GetCharArray() == 0 && pEdit->GetCharSpace() <= 0.0f;
uint16_t SubWord = pEdit->GetPasswordChar();
@@ -641,7 +641,7 @@
word.ptWord.x + word.fWidth,
line.ptLine.y + line.fLineAscent);
rc.Intersect(rcClip);
- pSystemHandler->OutputSelectedRect(pFFLData, rc);
+ pSystemHandler->OutputSelectedRect(pSystemData, rc);
} else {
CFX_Path pathSelBK;
pathSelBK.AppendRect(word.ptWord.x, line.ptLine.y + line.fLineDescent,
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.h b/fpdfsdk/pwl/cpwl_edit_impl.h
index 049359e..913c93c 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.h
+++ b/fpdfsdk/pwl/cpwl_edit_impl.h
@@ -17,11 +17,10 @@
#include "core/fxcrt/fx_codepage_forward.h"
#include "core/fxcrt/unowned_ptr.h"
#include "core/fxge/dib/fx_dib.h"
+#include "fpdfsdk/pwl/ipwl_systemhandler.h"
-class CFFL_FormField;
class CFX_RenderDevice;
class CPWL_Edit;
-class IPWL_SystemHandler;
class CPWL_EditImpl {
public:
@@ -50,7 +49,7 @@
const CFX_PointF& ptOffset,
const CPVT_WordRange* pRange,
IPWL_SystemHandler* pSystemHandler,
- CFFL_FormField* pFFLData);
+ IPWL_SystemHandler::PerWindowData* pSystemData);
CPWL_EditImpl();
~CPWL_EditImpl();
diff --git a/fpdfsdk/pwl/cpwl_list_box.cpp b/fpdfsdk/pwl/cpwl_list_box.cpp
index 7747bb8..5ea4972 100644
--- a/fpdfsdk/pwl/cpwl_list_box.cpp
+++ b/fpdfsdk/pwl/cpwl_list_box.cpp
@@ -67,15 +67,15 @@
CPWL_EditImpl::DrawEdit(pDevice, mtUser2Device,
m_pListCtrl->GetItemEdit(i),
GetTextColor().ToFXColor(255), rcList, ptOffset,
- nullptr, pSysHandler, m_pFormFiller.Get());
- pSysHandler->OutputSelectedRect(m_pFormFiller.Get(), rcItem);
+ 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, m_pFormFiller.Get());
+ pSysHandler, GetAttachedData());
}
} else {
CPWL_EditImpl::DrawEdit(pDevice, mtUser2Device,
diff --git a/fpdfsdk/pwl/cpwl_list_box.h b/fpdfsdk/pwl/cpwl_list_box.h
index d56329f..edef07d 100644
--- a/fpdfsdk/pwl/cpwl_list_box.h
+++ b/fpdfsdk/pwl/cpwl_list_box.h
@@ -82,16 +82,11 @@
m_pFillerNotify = pNotify;
}
- void AttachFFLData(CFFL_FormField* pData) { m_pFormFiller = pData; }
-
protected:
bool m_bMouseDown = false;
bool m_bHoverSel = false;
std::unique_ptr<CPWL_ListCtrl> m_pListCtrl;
UnownedPtr<IPWL_FillerNotify> m_pFillerNotify;
-
- private:
- UnownedPtr<CFFL_FormField> m_pFormFiller;
};
#endif // FPDFSDK_PWL_CPWL_LIST_BOX_H_
diff --git a/fpdfsdk/pwl/cpwl_wnd.h b/fpdfsdk/pwl/cpwl_wnd.h
index 7e73414..99d1834 100644
--- a/fpdfsdk/pwl/cpwl_wnd.h
+++ b/fpdfsdk/pwl/cpwl_wnd.h
@@ -220,7 +220,7 @@
const CFX_FloatRect& GetClipRect() const;
CPWL_Wnd* GetParentWindow() const { return m_pParent.Get(); }
- const IPWL_SystemHandler::PerWindowData* GetAttachedData() const {
+ IPWL_SystemHandler::PerWindowData* GetAttachedData() const {
return m_pAttachedData.get();
}
std::unique_ptr<IPWL_SystemHandler::PerWindowData> CloneAttachedData() const;
diff --git a/fpdfsdk/pwl/ipwl_systemhandler.h b/fpdfsdk/pwl/ipwl_systemhandler.h
index a2e1b0f..e7890e2 100644
--- a/fpdfsdk/pwl/ipwl_systemhandler.h
+++ b/fpdfsdk/pwl/ipwl_systemhandler.h
@@ -9,7 +9,6 @@
#include <memory>
-class CFFL_FormField;
class CFX_FloatRect;
class IPWL_SystemHandler {
@@ -34,7 +33,7 @@
virtual void InvalidateRect(PerWindowData* pWidgetData,
const CFX_FloatRect& rect) = 0;
- virtual void OutputSelectedRect(CFFL_FormField* pFormField,
+ virtual void OutputSelectedRect(PerWindowData* pWidgetData,
const CFX_FloatRect& rect) = 0;
virtual bool IsSelectionImplemented() const = 0;
virtual void SetCursor(CursorStyle nCursorStyle) = 0;