Rename CXFA_WidgetData::GetAccess to ::IsOpenAccess

We never use ::GetAccess to get the value in general, just to see if
it's set to Open or not. This CL makes the usage clearer.

Change-Id: I0e978a8b8e642c7441ab2ceb8062f672ceea7d55
Reviewed-on: https://pdfium-review.googlesource.com/19210
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/xfa/fxfa/cxfa_ffbarcode.cpp b/xfa/fxfa/cxfa_ffbarcode.cpp
index 5dd30dc..726f891 100644
--- a/xfa/fxfa/cxfa_ffbarcode.cpp
+++ b/xfa/fxfa/cxfa_ffbarcode.cpp
@@ -211,7 +211,7 @@
   auto* pBarCodeWidget = static_cast<CFWL_Barcode*>(m_pNormalWidget.get());
   if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType())
     return false;
-  if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open)
+  if (!m_pDataAcc->IsOpenAccess())
     return false;
   return CXFA_FFTextEdit::OnLButtonDown(dwFlags, point);
 }
diff --git a/xfa/fxfa/cxfa_ffcombobox.cpp b/xfa/fxfa/cxfa_ffcombobox.cpp
index 87c1c3e..87e14d2 100644
--- a/xfa/fxfa/cxfa_ffcombobox.cpp
+++ b/xfa/fxfa/cxfa_ffcombobox.cpp
@@ -80,7 +80,7 @@
     dwEditStyles &= ~FWL_STYLEEXT_EDT_ReadOnly;
     dwExtendedStyle |= FWL_STYLEEXT_CMB_DropDown;
   }
-  if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open ||
+  if (!m_pDataAcc->IsOpenAccess() ||
       !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
     dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly;
     dwExtendedStyle |= FWL_STYLEEXT_CMB_ReadOnly;
@@ -227,14 +227,13 @@
 }
 
 bool CXFA_FFComboBox::CanCut() {
-  return m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open &&
+  return m_pDataAcc->IsOpenAccess() &&
          m_pDataAcc->IsChoiceListAllowTextEntry() &&
          ToComboBox(m_pNormalWidget.get())->EditCanCut();
 }
 
 bool CXFA_FFComboBox::CanPaste() {
-  return m_pDataAcc->IsChoiceListAllowTextEntry() &&
-         m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open;
+  return m_pDataAcc->IsChoiceListAllowTextEntry() && m_pDataAcc->IsOpenAccess();
 }
 
 bool CXFA_FFComboBox::CanSelectAll() {
diff --git a/xfa/fxfa/cxfa_ffdatetimeedit.cpp b/xfa/fxfa/cxfa_ffdatetimeedit.cpp
index 1b2f6e3..4b8f397 100644
--- a/xfa/fxfa/cxfa_ffdatetimeedit.cpp
+++ b/xfa/fxfa/cxfa_ffdatetimeedit.cpp
@@ -86,7 +86,7 @@
     dwEditStyles |= FWL_STYLEEXT_EDT_CombText;
     pWidget->SetEditLimit(iNumCells);
   }
-  if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open ||
+  if (!m_pDataAcc->IsOpenAccess() ||
       !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
     dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly;
   }
diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp
index ca3d2bb..70b1164 100644
--- a/xfa/fxfa/cxfa_fffield.cpp
+++ b/xfa/fxfa/cxfa_fffield.cpp
@@ -81,11 +81,8 @@
                                  bool bEllipse) {
   if (m_rtUI.IsEmpty() || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive())
     return;
-
-  if (!(dwStatus & XFA_WidgetStatus_Highlight) ||
-      m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) {
+  if (!(dwStatus & XFA_WidgetStatus_Highlight) || !m_pDataAcc->IsOpenAccess())
     return;
-  }
 
   CXFA_FFDoc* pDoc = GetDoc();
   pGS->SetFillColor(
@@ -387,7 +384,7 @@
 bool CXFA_FFField::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) {
   if (!m_pNormalWidget)
     return false;
-  if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open ||
+  if (!m_pDataAcc->IsOpenAccess() ||
       !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
     return false;
   }
@@ -459,7 +456,7 @@
 bool CXFA_FFField::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) {
   if (!m_pNormalWidget)
     return false;
-  if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open ||
+  if (!m_pDataAcc->IsOpenAccess() ||
       !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
     return false;
   }
@@ -558,7 +555,7 @@
     return true;
   if (!m_pNormalWidget)
     return false;
-  if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open)
+  if (!m_pDataAcc->IsOpenAccess())
     return false;
 
   CFWL_MessageKey ms(nullptr, m_pNormalWidget.get());
@@ -627,7 +624,7 @@
 }
 
 bool CXFA_FFField::ProcessCommittedData() {
-  if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open)
+  if (!m_pDataAcc->IsOpenAccess())
     return false;
   if (!IsDataChanged())
     return false;
diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp
index 9a1d1e1..3736997 100644
--- a/xfa/fxfa/cxfa_ffimageedit.cpp
+++ b/xfa/fxfa/cxfa_ffimageedit.cpp
@@ -93,7 +93,7 @@
 
 bool CXFA_FFImageEdit::OnLButtonDown(uint32_t dwFlags,
                                      const CFX_PointF& point) {
-  if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open)
+  if (!m_pDataAcc->IsOpenAccess())
     return false;
   if (!PtInActiveRect(point))
     return false;
diff --git a/xfa/fxfa/cxfa_ffnumericedit.cpp b/xfa/fxfa/cxfa_ffnumericedit.cpp
index f619956..8f02035 100644
--- a/xfa/fxfa/cxfa_ffnumericedit.cpp
+++ b/xfa/fxfa/cxfa_ffnumericedit.cpp
@@ -61,7 +61,7 @@
     pWidget->SetLimit(iNumCells);
   }
   dwExtendedStyle |= GetAlignment();
-  if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open ||
+  if (!m_pDataAcc->IsOpenAccess() ||
       !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
     dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly;
   }
diff --git a/xfa/fxfa/cxfa_ffpasswordedit.cpp b/xfa/fxfa/cxfa_ffpasswordedit.cpp
index 7e2f6cd..8cbe265 100644
--- a/xfa/fxfa/cxfa_ffpasswordedit.cpp
+++ b/xfa/fxfa/cxfa_ffpasswordedit.cpp
@@ -56,7 +56,7 @@
     pWidget->SetAliasChar(wsPassWord[0]);
   if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off)
     dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll;
-  if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open ||
+  if (!m_pDataAcc->IsOpenAccess() ||
       !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
     dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly;
   }
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp
index f3be75d..abc8e99 100644
--- a/xfa/fxfa/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -81,7 +81,7 @@
   } else if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) {
     dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll;
   }
-  if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open ||
+  if (!m_pDataAcc->IsOpenAccess() ||
       !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
     dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly;
     dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine;
@@ -126,7 +126,7 @@
 }
 
 bool CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) {
-  if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open)
+  if (!m_pDataAcc->IsOpenAccess())
     return false;
   if (!PtInActiveRect(point))
     return false;
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 13b1c7a..9b0bbcc 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -219,21 +219,19 @@
   return m_eUIType;
 }
 
-WideString CXFA_WidgetData::GetRawValue() {
+WideString CXFA_WidgetData::GetRawValue() const {
   return m_pNode->JSNode()->GetContent(false);
 }
 
-int32_t CXFA_WidgetData::GetAccess() {
-  CXFA_Node* pNode = m_pNode;
-  while (pNode) {
-    int32_t iAcc = pNode->JSNode()->GetEnum(XFA_Attribute::Access);
+bool CXFA_WidgetData::IsOpenAccess() const {
+  for (CXFA_Node* pNode = m_pNode; pNode;
+       pNode = pNode->GetNodeItem(XFA_NODEITEM_Parent,
+                                  XFA_ObjectType::ContainerNode)) {
+    XFA_ATTRIBUTEENUM iAcc = pNode->JSNode()->GetEnum(XFA_Attribute::Access);
     if (iAcc != XFA_ATTRIBUTEENUM_Open)
-      return iAcc;
-
-    pNode =
-        pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
+      return false;
   }
-  return XFA_ATTRIBUTEENUM_Open;
+  return true;
 }
 
 int32_t CXFA_WidgetData::GetRotate() {
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index 309f00f..c6f07e2 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -44,22 +44,31 @@
 
   CXFA_Node* GetUIChild();
   XFA_Element GetUIType();
-  WideString GetRawValue();
-  int32_t GetAccess();
+  CFX_RectF GetUIMargin();
+
+  WideString GetRawValue() const;
   int32_t GetRotate();
 
+  bool IsOpenAccess() const;
+  bool IsListBox();
+  bool IsAllowNeutral();
+  bool IsRadioButton();
+  bool IsChoiceListAllowTextEntry();
+  bool IsMultiLine();
+
   CXFA_BorderData GetBorderData(bool bModified);
   CXFA_CaptionData GetCaptionData();
   CXFA_FontData GetFontData(bool bModified);
   CXFA_MarginData GetMarginData();
   CXFA_ParaData GetParaData();
-  std::vector<CXFA_Node*> GetEventList();
-  std::vector<CXFA_Node*> GetEventByActivity(int32_t iActivity,
-                                             bool bIsFormReady);
   CXFA_ValueData GetDefaultValueData();
   CXFA_ValueData GetFormValueData();
   CXFA_CalculateData GetCalculateData();
   CXFA_ValidateData GetValidateData(bool bModified);
+  CXFA_BorderData GetUIBorderData();
+
+  std::vector<CXFA_Node*> GetEventByActivity(int32_t iActivity,
+                                             bool bIsFormReady);
 
   pdfium::Optional<float> TryWidth();
   pdfium::Optional<float> TryHeight();
@@ -68,61 +77,66 @@
   pdfium::Optional<float> TryMaxWidth();
   pdfium::Optional<float> TryMaxHeight();
 
-  CXFA_BorderData GetUIBorderData();
-  CFX_RectF GetUIMargin();
   XFA_ATTRIBUTEENUM GetButtonHighlight();
   bool GetButtonRollover(WideString& wsRollover, bool& bRichText);
   bool GetButtonDown(WideString& wsDown, bool& bRichText);
+
   XFA_ATTRIBUTEENUM GetCheckButtonShape();
   XFA_ATTRIBUTEENUM GetCheckButtonMark();
   float GetCheckButtonSize();
-  bool IsAllowNeutral();
-  bool IsRadioButton();
+
   XFA_CHECKSTATE GetCheckState();
   void SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify);
-  CXFA_Node* GetExclGroupNode();
+
   CXFA_Node* GetSelectedMember();
   CXFA_Node* SetSelectedMember(const WideStringView& wsName, bool bNotify);
   void SetSelectedMemberByValue(const WideStringView& wsValue,
                                 bool bNotify,
                                 bool bScriptModify,
                                 bool bSyncData);
+
   CXFA_Node* GetExclGroupFirstMember();
   CXFA_Node* GetExclGroupNextMember(CXFA_Node* pNode);
-  XFA_ATTRIBUTEENUM GetChoiceListCommitOn();
-  bool IsChoiceListAllowTextEntry();
-  XFA_ATTRIBUTEENUM GetChoiceListOpen();
-  bool IsListBox();
+
   int32_t CountChoiceListItems(bool bSaveValue);
   bool GetChoiceListItem(WideString& wsText, int32_t nIndex, bool bSaveValue);
+  XFA_ATTRIBUTEENUM GetChoiceListOpen();
+  XFA_ATTRIBUTEENUM GetChoiceListCommitOn();
   std::vector<WideString> GetChoiceListItems(bool bSaveValue);
+
   int32_t CountSelectedItems();
   int32_t GetSelectedItem(int32_t nIndex);
   std::vector<int32_t> GetSelectedItems();
   std::vector<WideString> GetSelectedItemsValue();
+  void SetSelectedItems(const std::vector<int32_t>& iSelArray,
+                        bool bNotify,
+                        bool bScriptModify,
+                        bool bSyncData);
+  void InsertItem(const WideString& wsLabel,
+                  const WideString& wsValue,
+                  bool bNotify);
+  bool DeleteItem(int32_t nIndex, bool bNotify, bool bScriptModify);
+  void ClearAllSelections();
+
   bool GetItemState(int32_t nIndex);
   void SetItemState(int32_t nIndex,
                     bool bSelected,
                     bool bNotify,
                     bool bScriptModify,
                     bool bSyncData);
-  void SetSelectedItems(const std::vector<int32_t>& iSelArray,
-                        bool bNotify,
-                        bool bScriptModify,
-                        bool bSyncData);
-  void ClearAllSelections();
-  void InsertItem(const WideString& wsLabel,
-                  const WideString& wsValue,
-                  bool bNotify);
-  void GetItemLabel(const WideStringView& wsValue, WideString& wsLabel);
+
   void GetItemValue(const WideStringView& wsLabel, WideString& wsValue);
-  bool DeleteItem(int32_t nIndex, bool bNotify, bool bScriptModify);
+
   int32_t GetHorizontalScrollPolicy();
+  XFA_ATTRIBUTEENUM GetVerticalScrollPolicy();
   int32_t GetNumberOfCells();
+
   bool SetValue(const WideString& wsValue, XFA_VALUEPICTURE eValueType);
+  bool GetValue(WideString& wsValue, XFA_VALUEPICTURE eValueType);
+
   WideString GetPictureContent(XFA_VALUEPICTURE ePicture);
   IFX_Locale* GetLocal();
-  bool GetValue(WideString& wsValue, XFA_VALUEPICTURE eValueType);
+
   bool GetNormalizeDataValue(const WideString& wsValue,
                              WideString& wsNormalizeValue);
   bool GetFormatDataValue(const WideString& wsValue,
@@ -144,8 +158,6 @@
   bool GetBarcodeAttribute_WideNarrowRatio(float* val);
   void GetPasswordChar(WideString& wsPassWord);
 
-  bool IsMultiLine();
-  XFA_ATTRIBUTEENUM GetVerticalScrollPolicy();
   int32_t GetMaxChars(XFA_Element& eType);
   bool GetFracDigits(int32_t& iFracDigits);
   bool GetLeadDigits(int32_t& iLeadDigits);
@@ -166,6 +178,9 @@
   void FormatNumStr(const WideString& wsValue,
                     IFX_Locale* pLocale,
                     WideString& wsOutput);
+  CXFA_Node* GetExclGroupNode();
+  void GetItemLabel(const WideStringView& wsValue, WideString& wsLabel);
+  std::vector<CXFA_Node*> GetEventList();
 
   CXFA_Node* m_pUiChildNode;
   XFA_Element m_eUIType;