Cleanup default values and methods in CXFA_Widgetdata

Change-Id: Ie591de17aba54d6d0f96b1133be7d899bab577cf
Reviewed-on: https://pdfium-review.googlesource.com/5660
Reviewed-by: Nicolás Peña <npm@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp
index d4b0561..9d9cf07 100644
--- a/xfa/fxfa/app/xfa_ffpushbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp
@@ -115,7 +115,7 @@
   return true;
 }
 float CXFA_FFPushButton::GetLineWidth() {
-  CXFA_Border border = m_pDataAcc->GetBorder();
+  CXFA_Border border = m_pDataAcc->GetBorder(false);
   if (border && border.GetPresence() == XFA_ATTRIBUTEENUM_Visible) {
     CXFA_Edge edge = border.GetEdge(0);
     return edge.GetThickness();
diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
index 2185376..2ac27cf 100644
--- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
@@ -118,11 +118,11 @@
 
 CXFA_Font CXFA_TextProvider::GetFontNode() {
   if (m_eType == XFA_TEXTPROVIDERTYPE_Text)
-    return m_pWidgetAcc->GetFont();
+    return m_pWidgetAcc->GetFont(false);
 
   CXFA_Node* pNode = m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption);
   pNode = pNode->GetChild(0, XFA_Element::Font);
-  return pNode ? CXFA_Font(pNode) : m_pWidgetAcc->GetFont();
+  return pNode ? CXFA_Font(pNode) : m_pWidgetAcc->GetFont(false);
 }
 
 bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() {
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index d021740..d9c97f7 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -223,7 +223,7 @@
   }
   pWidgetAcc->ResetData();
   pWidgetAcc->UpdateUIDisplay();
-  if (CXFA_Validate validate = pWidgetAcc->GetValidate()) {
+  if (CXFA_Validate validate = pWidgetAcc->GetValidate(false)) {
     AddValidateWidget(pWidgetAcc);
     validate.GetNode()->SetFlag(XFA_NodeFlag_NeedsInitApp, false);
   }
@@ -743,7 +743,7 @@
                        XFA_RESOLVENODE_ALL;
     XFA_RESOLVENODE_RS rs;
     pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle);
-    pAcc->DeleteItem(-1);
+    pAcc->DeleteItem(-1, false, false);
     if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || rs.objects.empty())
       continue;
 
@@ -777,7 +777,7 @@
       } else {
         wsLabel = wsValue;
       }
-      pAcc->InsertItem(wsLabel, wsValue);
+      pAcc->InsertItem(wsLabel, wsValue, false);
     }
   }
   m_BindItems.clear();
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 2ea30b5..78bc5ed 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -116,7 +116,7 @@
   if (!IsMatchVisibleStatus(dwStatus))
     return;
 
-  CXFA_Border border = m_pDataAcc->GetBorder();
+  CXFA_Border border = m_pDataAcc->GetBorder(false);
   if (!border)
     return;
 
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp
index ffc1c27..6fe24fe 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp
@@ -177,13 +177,14 @@
       return calc && calc.GetScript();
     }
     case XFA_EVENT_Validate: {
-      CXFA_Validate val = pWidgetAcc->GetValidate();
+      CXFA_Validate val = pWidgetAcc->GetValidate(false);
       return val && val.GetScript();
     }
     default:
       break;
   }
-  return !pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType]).empty();
+  return !pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType], false)
+              .empty();
 }
 
 int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc,
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 3e369d6..9b52f95 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -554,7 +554,7 @@
   if (GetElementType() == XFA_Element::Draw)
     return XFA_EVENTERROR_NotExist;
 
-  CXFA_Validate validate = GetValidate();
+  CXFA_Validate validate = GetValidate(false);
   if (!validate)
     return XFA_EVENTERROR_NotExist;
 
@@ -724,7 +724,7 @@
     float fFontSize = 10.0f;
     if (CXFA_Font font = caption.GetFont())
       fFontSize = font.GetFontSize();
-    else if (CXFA_Font widgetfont = GetFont())
+    else if (CXFA_Font widgetfont = GetFont(false))
       fFontSize = widgetfont.GetFontSize();
 
     if (bVert) {
@@ -1495,7 +1495,7 @@
 CFX_RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont() {
   CFX_WideStringC wsFontName = L"Courier";
   uint32_t dwFontStyle = 0;
-  if (CXFA_Font font = GetFont()) {
+  if (CXFA_Font font = GetFont(false)) {
     if (font.IsBold())
       dwFontStyle |= FX_FONTSTYLE_Bold;
     if (font.IsItalic())
@@ -1510,7 +1510,7 @@
 
 float CXFA_WidgetAcc::GetFontSize() {
   float fFontSize = 10.0f;
-  if (CXFA_Font font = GetFont())
+  if (CXFA_Font font = GetFont(false))
     fFontSize = font.GetFontSize();
   return fFontSize < 0.1f ? 10.0f : fFontSize;
 }
@@ -1525,8 +1525,7 @@
 }
 
 FX_ARGB CXFA_WidgetAcc::GetTextColor() {
-  if (CXFA_Font font = GetFont()) {
+  if (CXFA_Font font = GetFont(false))
     return font.GetColor();
-  }
   return 0xFF000000;
 }
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 3c254ef..e7ec4cf 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1867,7 +1867,7 @@
     return;
   }
   bool bNew = false;
-  CXFA_Validate validate = pWidgetData->GetValidate();
+  CXFA_Validate validate = pWidgetData->GetValidate(false);
   if (!validate) {
     validate = pWidgetData->GetValidate(true);
     bNew = true;
@@ -2349,7 +2349,7 @@
     }
     pWidgetData->SetItemState(iIndex, true, true, true, true);
   } else {
-    pValue->SetInteger(pWidgetData->GetSelectedItem());
+    pValue->SetInteger(pWidgetData->GetSelectedItem(0));
   }
 }
 
@@ -2358,7 +2358,7 @@
   if (!pWidgetData) {
     return;
   }
-  pWidgetData->DeleteItem(-1, true);
+  pWidgetData->DeleteItem(-1, true, false);
 }
 
 void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) {
@@ -2546,7 +2546,7 @@
     CFX_ByteString bsValue = pArguments->GetUTF8String(1);
     wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
   }
-  pWidgetData->InsertItem(wsLabel, wsValue, -1, true);
+  pWidgetData->InsertItem(wsLabel, wsValue, true);
 }
 
 void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) {
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index f11a668..bf9afc0 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -256,13 +256,7 @@
   return m_pNode->GetContent();
 }
 
-int32_t CXFA_WidgetData::GetAccess(bool bTemplate) {
-  if (bTemplate) {
-    CXFA_Node* pNode = m_pNode->GetTemplateNode();
-    if (pNode)
-      return pNode->GetEnum(XFA_ATTRIBUTE_Access);
-    return XFA_ATTRIBUTEENUM_Open;
-  }
+int32_t CXFA_WidgetData::GetAccess() {
   CXFA_Node* pNode = m_pNode;
   while (pNode) {
     int32_t iAcc = pNode->GetEnum(XFA_ATTRIBUTE_Access);
@@ -289,20 +283,20 @@
   return CXFA_Border(m_pNode->GetProperty(0, XFA_Element::Border, bModified));
 }
 
-CXFA_Caption CXFA_WidgetData::GetCaption(bool bModified) {
-  return CXFA_Caption(m_pNode->GetProperty(0, XFA_Element::Caption, bModified));
+CXFA_Caption CXFA_WidgetData::GetCaption() {
+  return CXFA_Caption(m_pNode->GetProperty(0, XFA_Element::Caption, false));
 }
 
 CXFA_Font CXFA_WidgetData::GetFont(bool bModified) {
   return CXFA_Font(m_pNode->GetProperty(0, XFA_Element::Font, bModified));
 }
 
-CXFA_Margin CXFA_WidgetData::GetMargin(bool bModified) {
-  return CXFA_Margin(m_pNode->GetProperty(0, XFA_Element::Margin, bModified));
+CXFA_Margin CXFA_WidgetData::GetMargin() {
+  return CXFA_Margin(m_pNode->GetProperty(0, XFA_Element::Margin, false));
 }
 
-CXFA_Para CXFA_WidgetData::GetPara(bool bModified) {
-  return CXFA_Para(m_pNode->GetProperty(0, XFA_Element::Para, bModified));
+CXFA_Para CXFA_WidgetData::GetPara() {
+  return CXFA_Para(m_pNode->GetProperty(0, XFA_Element::Para, false));
 }
 
 std::vector<CXFA_Node*> CXFA_WidgetData::GetEventList() {
@@ -333,20 +327,18 @@
   return events;
 }
 
-CXFA_Value CXFA_WidgetData::GetDefaultValue(bool bModified) {
+CXFA_Value CXFA_WidgetData::GetDefaultValue() {
   CXFA_Node* pTemNode = m_pNode->GetTemplateNode();
   return CXFA_Value(
-      pTemNode ? pTemNode->GetProperty(0, XFA_Element::Value, bModified)
-               : nullptr);
+      pTemNode ? pTemNode->GetProperty(0, XFA_Element::Value, false) : nullptr);
 }
 
-CXFA_Value CXFA_WidgetData::GetFormValue(bool bModified) {
-  return CXFA_Value(m_pNode->GetProperty(0, XFA_Element::Value, bModified));
+CXFA_Value CXFA_WidgetData::GetFormValue() {
+  return CXFA_Value(m_pNode->GetProperty(0, XFA_Element::Value, false));
 }
 
-CXFA_Calculate CXFA_WidgetData::GetCalculate(bool bModified) {
-  return CXFA_Calculate(
-      m_pNode->GetProperty(0, XFA_Element::Calculate, bModified));
+CXFA_Calculate CXFA_WidgetData::GetCalculate() {
+  return CXFA_Calculate(m_pNode->GetProperty(0, XFA_Element::Calculate, false));
 }
 
 CXFA_Validate CXFA_WidgetData::GetValidate(bool bModified) {
@@ -354,12 +346,12 @@
       m_pNode->GetProperty(0, XFA_Element::Validate, bModified));
 }
 
-CXFA_Bind CXFA_WidgetData::GetBind(bool bModified) {
-  return CXFA_Bind(m_pNode->GetProperty(0, XFA_Element::Bind, bModified));
+CXFA_Bind CXFA_WidgetData::GetBind() {
+  return CXFA_Bind(m_pNode->GetProperty(0, XFA_Element::Bind, false));
 }
 
-CXFA_Assist CXFA_WidgetData::GetAssist(bool bModified) {
-  return CXFA_Assist(m_pNode->GetProperty(0, XFA_Element::Assist, bModified));
+CXFA_Assist CXFA_WidgetData::GetAssist() {
+  return CXFA_Assist(m_pNode->GetProperty(0, XFA_Element::Assist, false));
 }
 
 bool CXFA_WidgetData::GetWidth(float& fWidth) {
@@ -968,8 +960,8 @@
 
 void CXFA_WidgetData::InsertItem(const CFX_WideString& wsLabel,
                                  const CFX_WideString& wsValue,
-                                 int32_t nIndex,
                                  bool bNotify) {
+  int32_t nIndex = -1;
   CFX_WideString wsNewValue(wsValue);
   if (wsNewValue.IsEmpty())
     wsNewValue = wsLabel;
@@ -1114,8 +1106,7 @@
 
 bool CXFA_WidgetData::DeleteItem(int32_t nIndex,
                                  bool bNotify,
-                                 bool bScriptModify,
-                                 bool bSyncData) {
+                                 bool bScriptModify) {
   bool bSetValue = false;
   CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
   for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) {
@@ -1128,7 +1119,7 @@
       }
     } else {
       if (!bSetValue && pItems->GetBoolean(XFA_ATTRIBUTE_Save)) {
-        SetItemState(nIndex, false, true, bScriptModify, bSyncData);
+        SetItemState(nIndex, false, true, bScriptModify, true);
         bSetValue = true;
       }
       int32_t i = 0;
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index c38ea35..f53d926 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -46,28 +46,30 @@
   CXFA_Node* GetUIChild();
   XFA_Element GetUIType();
   CFX_WideString GetRawValue();
-  int32_t GetAccess(bool bTemplate = false);
+  int32_t GetAccess();
   int32_t GetRotate();
-  CXFA_Border GetBorder(bool bModified = false);
-  CXFA_Caption GetCaption(bool bModified = false);
-  CXFA_Font GetFont(bool bModified = false);
-  CXFA_Margin GetMargin(bool bModified = false);
-  CXFA_Para GetPara(bool bModified = false);
+
+  CXFA_Assist GetAssist();
+  CXFA_Border GetBorder(bool bModified);
+  CXFA_Caption GetCaption();
+  CXFA_Font GetFont(bool bModified);
+  CXFA_Margin GetMargin();
+  CXFA_Para GetPara();
   std::vector<CXFA_Node*> GetEventList();
   std::vector<CXFA_Node*> GetEventByActivity(int32_t iActivity,
-                                             bool bIsFormReady = false);
-  CXFA_Value GetDefaultValue(bool bModified = false);
-  CXFA_Value GetFormValue(bool bModified = false);
-  CXFA_Calculate GetCalculate(bool bModified = false);
-  CXFA_Validate GetValidate(bool bModified = false);
-  CXFA_Bind GetBind(bool bModified = false);
-  CXFA_Assist GetAssist(bool bModified = false);
+                                             bool bIsFormReady);
+  CXFA_Value GetDefaultValue();
+  CXFA_Value GetFormValue();
+  CXFA_Calculate GetCalculate();
+  CXFA_Validate GetValidate(bool bModified);
+
   bool GetWidth(float& fWidth);
   bool GetHeight(float& fHeight);
   bool GetMinWidth(float& fMinWidth);
   bool GetMinHeight(float& fMinHeight);
   bool GetMaxWidth(float& fMaxWidth);
   bool GetMaxHeight(float& fMaxHeight);
+
   CXFA_Border GetUIBorder();
   CFX_RectF GetUIMargin();
   int32_t GetButtonHighlight();
@@ -99,7 +101,7 @@
                          bool bSaveValue);
   std::vector<CFX_WideString> GetChoiceListItems(bool bSaveValue);
   int32_t CountSelectedItems();
-  int32_t GetSelectedItem(int32_t nIndex = 0);
+  int32_t GetSelectedItem(int32_t nIndex);
   std::vector<int32_t> GetSelectedItems();
   std::vector<CFX_WideString> GetSelectedItemsValue();
   bool GetItemState(int32_t nIndex);
@@ -115,14 +117,10 @@
   void ClearAllSelections();
   void InsertItem(const CFX_WideString& wsLabel,
                   const CFX_WideString& wsValue,
-                  int32_t nIndex = -1,
-                  bool bNotify = false);
+                  bool bNotify);
   void GetItemLabel(const CFX_WideStringC& wsValue, CFX_WideString& wsLabel);
   void GetItemValue(const CFX_WideStringC& wsLabel, CFX_WideString& wsValue);
-  bool DeleteItem(int32_t nIndex,
-                  bool bNotify = false,
-                  bool bScriptModify = false,
-                  bool bSyncData = true);
+  bool DeleteItem(int32_t nIndex, bool bNotify, bool bScriptModify);
   int32_t GetHorizontalScrollPolicy();
   int32_t GetNumberOfCells();
   bool SetValue(const CFX_WideString& wsValue, XFA_VALUEPICTURE eValueType);
@@ -134,6 +132,7 @@
   bool GetFormatDataValue(const CFX_WideString& wsValue,
                           CFX_WideString& wsFormattedValue);
   void NormalizeNumStr(const CFX_WideString& wsValue, CFX_WideString& wsOutput);
+
   CFX_WideString GetBarcodeType();
   bool GetBarcodeAttribute_CharEncoding(int32_t* val);
   bool GetBarcodeAttribute_Checksum(bool* val);
@@ -148,6 +147,7 @@
   bool GetBarcodeAttribute_Truncate(bool* val);
   bool GetBarcodeAttribute_WideNarrowRatio(float* val);
   void GetPasswordChar(CFX_WideString& wsPassWord);
+
   bool IsMultiLine();
   int32_t GetVerticalScrollPolicy();
   int32_t GetMaxChars(XFA_Element& eType);
@@ -162,10 +162,11 @@
   bool m_bPreNull;
 
  private:
+  CXFA_Bind GetBind();
   void SyncValue(const CFX_WideString& wsValue, bool bNotify);
   void InsertListTextItem(CXFA_Node* pItems,
                           const CFX_WideString& wsText,
-                          int32_t nIndex = -1);
+                          int32_t nIndex);
   void FormatNumStr(const CFX_WideString& wsValue,
                     IFX_Locale* pLocale,
                     CFX_WideString& wsOutput);