summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fxcrt/fx_basic_util.cpp81
-rw-r--r--core/fxcrt/include/fx_basic.h48
-rw-r--r--xfa/fwl/core/fwl_widgetimp.cpp37
-rw-r--r--xfa/fwl/core/fwl_widgetimp.h8
-rw-r--r--xfa/fwl/core/ifwl_widget.h13
-rw-r--r--xfa/fwl/lightwidget/cfwl_widget.cpp26
6 files changed, 31 insertions, 182 deletions
diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp
index 02e09ce057..8eba2cce0e 100644
--- a/core/fxcrt/fx_basic_util.cpp
+++ b/core/fxcrt/fx_basic_util.cpp
@@ -18,87 +18,6 @@
#include <cctype>
#include <memory>
-#ifdef PDF_ENABLE_XFA
-CFX_PrivateData::CFX_PrivateData() {}
-
-CFX_PrivateData::~CFX_PrivateData() {
- ClearAll();
-}
-void FX_PRIVATEDATA::FreeData() {
- if (!m_pData) {
- return;
- }
- if (m_bSelfDestruct) {
- delete static_cast<CFX_Deletable*>(m_pData);
- } else if (m_pCallback) {
- m_pCallback(m_pData);
- }
-}
-void CFX_PrivateData::AddData(void* pModuleId,
- void* pData,
- PD_CALLBACK_FREEDATA callback,
- FX_BOOL bSelfDestruct) {
- if (!pModuleId) {
- return;
- }
- FX_PRIVATEDATA* pList = m_DataList.GetData();
- int count = m_DataList.GetSize();
- for (int i = 0; i < count; i++) {
- if (pList[i].m_pModuleId == pModuleId) {
- pList[i].FreeData();
- pList[i].m_pData = pData;
- pList[i].m_pCallback = callback;
- return;
- }
- }
- FX_PRIVATEDATA data = {pModuleId, pData, callback, bSelfDestruct};
- m_DataList.Add(data);
-}
-void CFX_PrivateData::SetPrivateData(void* pModuleId,
- void* pData,
- PD_CALLBACK_FREEDATA callback) {
- AddData(pModuleId, pData, callback, FALSE);
-}
-void CFX_PrivateData::SetPrivateObj(void* pModuleId, CFX_Deletable* pObj) {
- AddData(pModuleId, pObj, NULL, TRUE);
-}
-FX_BOOL CFX_PrivateData::RemovePrivateData(void* pModuleId) {
- if (!pModuleId) {
- return FALSE;
- }
- FX_PRIVATEDATA* pList = m_DataList.GetData();
- int count = m_DataList.GetSize();
- for (int i = 0; i < count; i++) {
- if (pList[i].m_pModuleId == pModuleId) {
- m_DataList.RemoveAt(i);
- return TRUE;
- }
- }
- return FALSE;
-}
-void* CFX_PrivateData::GetPrivateData(void* pModuleId) {
- if (!pModuleId) {
- return NULL;
- }
- FX_PRIVATEDATA* pList = m_DataList.GetData();
- int count = m_DataList.GetSize();
- for (int i = 0; i < count; i++) {
- if (pList[i].m_pModuleId == pModuleId) {
- return pList[i].m_pData;
- }
- }
- return NULL;
-}
-void CFX_PrivateData::ClearAll() {
- FX_PRIVATEDATA* pList = m_DataList.GetData();
- int count = m_DataList.GetSize();
- for (int i = 0; i < count; i++) {
- pList[i].FreeData();
- }
- m_DataList.RemoveAll();
-}
-#endif // PDF_ENABLE_XFA
-
void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) {
if (strc.Find('.') == -1) {
bInteger = TRUE;
diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h
index 73cb648a46..13b51bd3fa 100644
--- a/core/fxcrt/include/fx_basic.h
+++ b/core/fxcrt/include/fx_basic.h
@@ -324,9 +324,7 @@ typedef CFX_ArrayTemplate<CFX_WideStringC> CFX_WideStringCArray;
typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray;
typedef CFX_ArrayTemplate<uint8_t> CFX_ByteArray;
typedef CFX_ArrayTemplate<int32_t> CFX_Int32Array;
-#endif // PDF_ENABLE_XFA
-#ifdef PDF_ENABLE_XFA
template <class ObjectClass>
class CFX_ObjectArray : public CFX_BasicArray {
public:
@@ -621,52 +619,6 @@ class CFX_PtrList {
#ifdef PDF_ENABLE_XFA
typedef void (*PD_CALLBACK_FREEDATA)(void* pData);
-struct FX_PRIVATEDATA {
- void FreeData();
-
- void* m_pModuleId;
- void* m_pData;
- PD_CALLBACK_FREEDATA m_pCallback;
- FX_BOOL m_bSelfDestruct;
-};
-
-class CFX_PrivateData {
- public:
- CFX_PrivateData();
- ~CFX_PrivateData();
-
- void ClearAll();
-
- void SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback);
- void SetPrivateObj(void* module_id, CFX_Deletable* pObj);
-
- void* GetPrivateData(void* module_id);
- FX_BOOL LookupPrivateData(void* module_id, void*& pData) const {
- if (!module_id) {
- return FALSE;
- }
- uint32_t nCount = m_DataList.GetSize();
- for (uint32_t n = 0; n < nCount; n++) {
- if (m_DataList[n].m_pModuleId == module_id) {
- pData = m_DataList[n].m_pData;
- return TRUE;
- }
- }
- return FALSE;
- }
-
- FX_BOOL RemovePrivateData(void* module_id);
-
- protected:
- CFX_ArrayTemplate<FX_PRIVATEDATA> m_DataList;
-
- void AddData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback,
- FX_BOOL bSelfDestruct);
-};
#endif // PDF_ENABLE_XFA
class CFX_BitStream {
diff --git a/xfa/fwl/core/fwl_widgetimp.cpp b/xfa/fwl/core/fwl_widgetimp.cpp
index 38e3a1ff28..1c0d28379d 100644
--- a/xfa/fwl/core/fwl_widgetimp.cpp
+++ b/xfa/fwl/core/fwl_widgetimp.cpp
@@ -111,14 +111,14 @@ void IFWL_Widget::SetLayoutItem(void* pItem) {
GetImpl()->SetLayoutItem(pItem);
}
-FWL_Error IFWL_Widget::SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback) {
- return GetImpl()->SetPrivateData(module_id, pData, callback);
+void* IFWL_Widget::GetAssociateWidget() const {
+ return GetImpl()->GetAssociateWidget();
}
-void* IFWL_Widget::GetPrivateData(void* module_id) {
- return GetImpl()->GetPrivateData(module_id);
+
+void IFWL_Widget::SetAssociateWidget(void* pAssociate) {
+ GetImpl()->SetAssociateWidget(pAssociate);
}
+
FWL_Error IFWL_Widget::Update() {
return GetImpl()->Update();
}
@@ -330,20 +330,6 @@ void CFWL_WidgetImp::SetStates(uint32_t dwStates, FX_BOOL bSet) {
}
return;
}
-FWL_Error CFWL_WidgetImp::SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback) {
- if (!m_pPrivateData) {
- m_pPrivateData = new CFX_PrivateData;
- }
- m_pPrivateData->SetPrivateData(module_id, pData, callback);
- return FWL_Error::Succeeded;
-}
-void* CFWL_WidgetImp::GetPrivateData(void* module_id) {
- if (!m_pPrivateData)
- return NULL;
- return m_pPrivateData->GetPrivateData(module_id);
-}
FWL_Error CFWL_WidgetImp::Update() {
return FWL_Error::Succeeded;
}
@@ -533,15 +519,23 @@ void CFWL_WidgetImp::SetLayoutItem(void* pItem) {
m_pLayoutItem = pItem;
}
+void* CFWL_WidgetImp::GetAssociateWidget() const {
+ return m_pAssociate;
+}
+
+void CFWL_WidgetImp::SetAssociateWidget(void* pAssociate) {
+ m_pAssociate = pAssociate;
+}
+
CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: m_pProperties(new CFWL_WidgetImpProperties),
- m_pPrivateData(nullptr),
m_pDelegate(nullptr),
m_pCurDelegate(nullptr),
m_pOuter(pOuter),
m_pInterface(nullptr),
m_pLayoutItem(nullptr),
+ m_pAssociate(nullptr),
m_iLock(0),
m_nEventKey(0) {
*m_pProperties = properties;
@@ -550,7 +544,6 @@ CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
}
CFWL_WidgetImp::~CFWL_WidgetImp() {
- delete m_pPrivateData;
delete m_pProperties;
}
diff --git a/xfa/fwl/core/fwl_widgetimp.h b/xfa/fwl/core/fwl_widgetimp.h
index 8a887126e3..be97c060f2 100644
--- a/xfa/fwl/core/fwl_widgetimp.h
+++ b/xfa/fwl/core/fwl_widgetimp.h
@@ -52,10 +52,6 @@ class CFWL_WidgetImp {
uint32_t dwStylesExRemoved);
virtual uint32_t GetStates();
virtual void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
- virtual FWL_Error SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback);
- virtual void* GetPrivateData(void* module_id);
virtual FWL_Error Update();
virtual FWL_Error LockUpdate();
virtual FWL_Error UnlockUpdate();
@@ -82,6 +78,8 @@ class CFWL_WidgetImp {
void SetEventKey(uint32_t key);
void* GetLayoutItem() const;
void SetLayoutItem(void* pItem);
+ void* GetAssociateWidget() const;
+ void SetAssociateWidget(void* pAssociate);
protected:
friend class CFWL_WidgetImpDelegate;
@@ -159,12 +157,12 @@ class CFWL_WidgetImp {
CFWL_WidgetMgr* m_pWidgetMgr;
CFWL_AppImp* m_pOwnerApp;
CFWL_WidgetImpProperties* m_pProperties;
- CFX_PrivateData* m_pPrivateData;
IFWL_WidgetDelegate* m_pDelegate;
IFWL_WidgetDelegate* m_pCurDelegate;
IFWL_Widget* m_pOuter;
IFWL_Widget* m_pInterface;
void* m_pLayoutItem;
+ void* m_pAssociate;
int32_t m_iLock;
uint32_t m_nEventKey;
};
diff --git a/xfa/fwl/core/ifwl_widget.h b/xfa/fwl/core/ifwl_widget.h
index e9da806291..0b864fee7d 100644
--- a/xfa/fwl/core/ifwl_widget.h
+++ b/xfa/fwl/core/ifwl_widget.h
@@ -18,13 +18,16 @@
// FWL contains three parallel inheritance hierarchies, which reference each
// other via pointers as follows:
//
-// m_pIface m_pImpl
+// m_pAssociate
+// <----------------------------------
// CFWL_Widget ----------> IFWL_Widget ----------> CFWL_WidgetImp
-// | | |
+// | m_pIface | m_pImpl |
// A A A
// | | |
// CFWL_... IFWL_... CFWL_...Imp
//
+// TODO(tsepez): Collapse these into a single hierarchy.
+//
enum class FWL_Type {
Unknown = 0,
@@ -79,10 +82,8 @@ class IFWL_Widget {
void SetEventKey(uint32_t key);
void* GetLayoutItem() const;
void SetLayoutItem(void* pItem);
- FWL_Error SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback);
- void* GetPrivateData(void* module_id);
+ void* GetAssociateWidget() const;
+ void SetAssociateWidget(void* pAssociate);
FWL_Error Update();
FWL_Error LockUpdate();
FWL_Error UnlockUpdate();
diff --git a/xfa/fwl/lightwidget/cfwl_widget.cpp b/xfa/fwl/lightwidget/cfwl_widget.cpp
index 239796d03a..8022f0afb0 100644
--- a/xfa/fwl/lightwidget/cfwl_widget.cpp
+++ b/xfa/fwl/lightwidget/cfwl_widget.cpp
@@ -41,12 +41,11 @@ FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const {
return m_pIface->IsInstance(wsClass);
}
-static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't');
-
FWL_Error CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) {
if (!m_pIface)
return FWL_Error::Indefinite;
- return m_pIface->SetPrivateData(gs_pFWLWidget, this, nullptr);
+ m_pIface->SetAssociateWidget(this);
+ return FWL_Error::Succeeded;
}
FWL_Error CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
@@ -78,9 +77,10 @@ CFWL_Widget* CFWL_Widget::GetParent() {
return nullptr;
IFWL_Widget* parent = m_pIface->GetParent();
- if (parent)
- return static_cast<CFWL_Widget*>(parent->GetPrivateData(gs_pFWLWidget));
- return nullptr;
+ if (!parent)
+ return nullptr;
+
+ return static_cast<CFWL_Widget*>(parent->GetAssociateWidget());
}
FWL_Error CFWL_Widget::SetParent(CFWL_Widget* pParent) {
@@ -141,20 +141,6 @@ void CFWL_Widget::SetLayoutItem(void* pItem) {
m_pIface->SetLayoutItem(pItem);
}
-FWL_Error CFWL_Widget::SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback) {
- if (!m_pIface)
- return FWL_Error::Indefinite;
- return m_pIface->SetPrivateData(module_id, pData, callback);
-}
-
-void* CFWL_Widget::GetPrivateData(void* module_id) {
- if (!m_pIface)
- return nullptr;
- return m_pIface->GetPrivateData(module_id);
-}
-
FWL_Error CFWL_Widget::Update() {
if (!m_pIface)
return FWL_Error::Indefinite;