Add opaque "layout item" to widgets for caller's use.

This avoids another use of CFX_PrivateData.  Note that in the old
code, we'd be calling through a m_pImpl onto the same underlying
object as we passed as the "key" argument when setting the value,
which explains why the get calls, happening one object lower, pass
the same argument as which they are being inovked against.

Review-Url: https://codereview.chromium.org/2010923002
diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp
index 15cdf03..6d0197e 100644
--- a/xfa/fwl/basewidget/fwl_editimp.cpp
+++ b/xfa/fwl/basewidget/fwl_editimp.cpp
@@ -1637,7 +1637,7 @@
                       FX_BOOL bVisible,
                       const CFX_RectF* pRtAnchor) {
   CXFA_FFWidget* pXFAWidget =
-      static_cast<CXFA_FFWidget*>(pWidget->GetPrivateData(pWidget));
+      static_cast<CXFA_FFWidget*>(pWidget->GetLayoutItem());
   if (!pXFAWidget)
     return FALSE;
 
diff --git a/xfa/fwl/core/fwl_widgetimp.cpp b/xfa/fwl/core/fwl_widgetimp.cpp
index c6070b2..38e3a1f 100644
--- a/xfa/fwl/core/fwl_widgetimp.cpp
+++ b/xfa/fwl/core/fwl_widgetimp.cpp
@@ -103,6 +103,14 @@
   GetImpl()->SetEventKey(key);
 }
 
+void* IFWL_Widget::GetLayoutItem() const {
+  return GetImpl()->GetLayoutItem();
+}
+
+void IFWL_Widget::SetLayoutItem(void* pItem) {
+  GetImpl()->SetLayoutItem(pItem);
+}
+
 FWL_Error IFWL_Widget::SetPrivateData(void* module_id,
                                       void* pData,
                                       PD_CALLBACK_FREEDATA callback) {
@@ -517,30 +525,35 @@
   m_nEventKey = key;
 }
 
+void* CFWL_WidgetImp::GetLayoutItem() const {
+  return m_pLayoutItem;
+}
+
+void CFWL_WidgetImp::SetLayoutItem(void* pItem) {
+  m_pLayoutItem = pItem;
+}
+
 CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
                                IFWL_Widget* pOuter)
     : m_pProperties(new CFWL_WidgetImpProperties),
-      m_pPrivateData(NULL),
-      m_pDelegate(NULL),
-      m_pCurDelegate(NULL),
+      m_pPrivateData(nullptr),
+      m_pDelegate(nullptr),
+      m_pCurDelegate(nullptr),
       m_pOuter(pOuter),
-      m_pInterface(NULL),
+      m_pInterface(nullptr),
+      m_pLayoutItem(nullptr),
       m_iLock(0),
       m_nEventKey(0) {
   *m_pProperties = properties;
   m_pWidgetMgr = CFWL_WidgetMgr::GetInstance();
-  ASSERT(m_pWidgetMgr != NULL);
+  ASSERT(m_pWidgetMgr);
 }
+
 CFWL_WidgetImp::~CFWL_WidgetImp() {
-  if (m_pPrivateData) {
-    delete m_pPrivateData;
-    m_pPrivateData = NULL;
-  }
-  if (m_pProperties) {
-    delete m_pProperties;
-    m_pProperties = NULL;
-  }
+  delete m_pPrivateData;
+  delete m_pProperties;
 }
+
 FX_BOOL CFWL_WidgetImp::IsEnabled() const {
   return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0;
 }
diff --git a/xfa/fwl/core/fwl_widgetimp.h b/xfa/fwl/core/fwl_widgetimp.h
index 3fdef97..8a88712 100644
--- a/xfa/fwl/core/fwl_widgetimp.h
+++ b/xfa/fwl/core/fwl_widgetimp.h
@@ -80,6 +80,8 @@
   CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent);
   uint32_t GetEventKey() const;
   void SetEventKey(uint32_t key);
+  void* GetLayoutItem() const;
+  void SetLayoutItem(void* pItem);
 
  protected:
   friend class CFWL_WidgetImpDelegate;
@@ -162,6 +164,7 @@
   IFWL_WidgetDelegate* m_pCurDelegate;
   IFWL_Widget* m_pOuter;
   IFWL_Widget* m_pInterface;
+  void* m_pLayoutItem;
   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 1c469b2..e9da806 100644
--- a/xfa/fwl/core/ifwl_widget.h
+++ b/xfa/fwl/core/ifwl_widget.h
@@ -77,6 +77,8 @@
   void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
   uint32_t GetEventKey() const;
   void SetEventKey(uint32_t key);
+  void* GetLayoutItem() const;
+  void SetLayoutItem(void* pItem);
   FWL_Error SetPrivateData(void* module_id,
                            void* pData,
                            PD_CALLBACK_FREEDATA callback);
diff --git a/xfa/fwl/lightwidget/cfwl_widget.cpp b/xfa/fwl/lightwidget/cfwl_widget.cpp
index 0258c27..239796d 100644
--- a/xfa/fwl/lightwidget/cfwl_widget.cpp
+++ b/xfa/fwl/lightwidget/cfwl_widget.cpp
@@ -124,9 +124,7 @@
 }
 
 uint32_t CFWL_Widget::GetStates() {
-  if (!m_pIface)
-    return 0;
-  return m_pIface->GetStates();
+  return m_pIface ? m_pIface->GetStates() : 0;
 }
 
 void CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) {
@@ -134,6 +132,15 @@
     m_pIface->SetStates(dwStates, bSet);
 }
 
+void* CFWL_Widget::GetLayoutItem() const {
+  return m_pIface ? m_pIface->GetLayoutItem() : nullptr;
+}
+
+void CFWL_Widget::SetLayoutItem(void* pItem) {
+  if (m_pIface)
+    m_pIface->SetLayoutItem(pItem);
+}
+
 FWL_Error CFWL_Widget::SetPrivateData(void* module_id,
                                       void* pData,
                                       PD_CALLBACK_FREEDATA callback) {
diff --git a/xfa/fwl/lightwidget/cfwl_widget.h b/xfa/fwl/lightwidget/cfwl_widget.h
index 1c29b1f..ea17627 100644
--- a/xfa/fwl/lightwidget/cfwl_widget.h
+++ b/xfa/fwl/lightwidget/cfwl_widget.h
@@ -41,6 +41,9 @@
                            uint32_t dwStylesExRemoved);
   uint32_t GetStates();
   void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
+  void* GetLayoutItem() const;
+  void SetLayoutItem(void* pItem);
+
   FWL_Error SetPrivateData(void* module_id,
                            void* pData,
                            PD_CALLBACK_FREEDATA callback);