Next round of XFA changes to match master.
authorTom Sepez <tsepez@chromium.org>
Wed, 14 Oct 2015 21:17:26 +0000 (14:17 -0700)
committerTom Sepez <tsepez@chromium.org>
Wed, 14 Oct 2015 21:17:26 +0000 (14:17 -0700)
This contains a missed merge of the Document:delay fixes.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1398703009 .

19 files changed:
fpdfsdk/include/fsdk_define.h
fpdfsdk/include/fsdk_mgr.h
fpdfsdk/include/javascript/IJavaScript.h
fpdfsdk/src/formfiller/FFL_FormFiller.cpp
fpdfsdk/src/fpdf_progressive.cpp
fpdfsdk/src/fpdf_transformpage.cpp
fpdfsdk/src/fpdfformfill.cpp
fpdfsdk/src/fpdftext.cpp
fpdfsdk/src/fpdfview.cpp
fpdfsdk/src/fsdk_baseform.cpp
fpdfsdk/src/fsdk_mgr.cpp
fpdfsdk/src/javascript/Document.cpp
fpdfsdk/src/javascript/Document.h
fpdfsdk/src/javascript/JS_Define.h
fpdfsdk/src/javascript/JS_GlobalData.cpp
fpdfsdk/src/javascript/JS_GlobalData.h
fpdfsdk/src/javascript/PublicMethods.cpp
fpdfsdk/src/javascript/global.cpp
fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp

index 43283c1..8bf64bb 100644 (file)
@@ -61,6 +61,7 @@ class CPDF_CustomAccess final : public IFX_FileRead {
   virtual FX_BOOL GetByte(FX_DWORD pos, uint8_t& ch);
   virtual FX_BOOL GetBlock(FX_DWORD pos, uint8_t* pBuf, FX_DWORD size);
 
+ private:
   FPDF_FILEACCESS m_FileAccess;
   uint8_t m_Buffer[512];
   FX_DWORD m_BufferOffset;
index 01579dc..4c0ce1e 100644 (file)
@@ -35,9 +35,9 @@ class IFX_SystemHandler;
 class CPDFDoc_Environment final {
  public:
   CPDFDoc_Environment(CPDFXFA_Document* pDoc, FPDF_FORMFILLINFO* pFFinfo);
-  virtual ~CPDFDoc_Environment();
+  ~CPDFDoc_Environment();
 
-  virtual void Release() {
+  void Release() {
     if (m_pInfo && m_pInfo->Release)
       m_pInfo->Release(m_pInfo);
     delete this;
@@ -551,7 +551,6 @@ class CPDFSDK_PageView final {
   CPDFSDK_Annot* AddAnnot(CPDF_Annot* pPDFAnnot);
   CPDFSDK_Annot* AddAnnot(IXFA_Widget* pPDFAnnot);
   FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot);
-
   int CountAnnots();
   CPDFSDK_Annot* GetAnnot(int nIndex);
   CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict);
index c8962bd..291b8f1 100644 (file)
@@ -144,7 +144,6 @@ class IJS_Runtime {
   virtual void ReleaseContext(IJS_Context* pContext) = 0;
   virtual IJS_Context* GetCurrentContext() = 0;
   virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0;
-
   virtual CPDFSDK_Document* GetReaderDocument() = 0;
   virtual int Execute(IJS_Context* cc,
                       const wchar_t* script,
index 642e5e8..30a297d 100644 (file)
@@ -464,9 +464,7 @@ CPDF_Rect CFFL_FormFiller::GetPDFWindowRect() const {
 CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView() {
   CPDFXFA_Page* pPage = m_pAnnot->GetPDFXFAPage();
   CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument();
-  if (!pSDKDoc)
-    return NULL;
-  return pSDKDoc->GetPageView(pPage);
+  return pSDKDoc ? pSDKDoc->GetPageView(pPage) : nullptr;
 }
 
 CPDF_Rect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) {
index 65901f8..f5e11e8 100644 (file)
@@ -33,8 +33,6 @@ DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap,
   if (!pPage)
     return FPDF_RENDER_FAILED;
 
-  //   FXMT_CSLOCK_OBJ(&pPage->m_PageLock);
-
   CRenderContext* pContext = new CRenderContext;
   pPage->SetPrivateData((void*)1, pContext, DropContext);
 #ifdef _SKIA_SUPPORT_
@@ -81,8 +79,6 @@ DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page,
   if (!pPage)
     return FPDF_RENDER_FAILED;
 
-  //   FXMT_CSLOCK_OBJ(&pPage->m_PageLock);
-
   CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1);
   if (pContext && pContext->m_pRenderer) {
     IFSDK_PAUSE_Adapter IPauseAdapter(pause);
@@ -97,18 +93,17 @@ DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page,
 }
 
 DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page) {
-  if (page == NULL)
+  if (!page)
     return;
   CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
   if (!pPage)
     return;
 
-  //   FXMT_CSLOCK_OBJ(&pPage->m_PageLock);
-
   CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1);
-  if (pContext) {
-    pContext->m_pDevice->RestoreState();
-    delete pContext;
-    pPage->RemovePrivateData((void*)1);
-  }
+  if (!pContext)
+    return;
+
+  pContext->m_pDevice->RestoreState();
+  delete pContext;
+  pPage->RemovePrivateData((void*)1);
 }
index d02876d..dbf97aa 100644 (file)
@@ -149,7 +149,6 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
         CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
         pContentArray->InsertAt(0, pRef);
         pContentArray->AddReference(pDoc, pEndStream);
-
       } else if (pDirectObj->GetType() == PDFOBJ_STREAM) {
         pContentArray = new CPDF_Array();
         pContentArray->AddReference(pDoc, pStream->GetObjNum());
index 07b58c1..e86a47b 100644 (file)
@@ -6,9 +6,10 @@
 
 #include "../../public/fpdf_formfill.h"
 #include "../../public/fpdfview.h"
+#include "../../third_party/base/nonstd_unique_ptr.h"
 #include "../include/fsdk_define.h"
-#include "../include/fpdfxfa/fpdfxfa_doc.h"
 #include "../include/fsdk_mgr.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
 #include "../include/fpdfxfa/fpdfxfa_page.h"
 #include "../include/fpdfxfa/fpdfxfa_app.h"
 
@@ -321,7 +322,6 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
     pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, &clip);
 
   pDevice->RestoreState();
-
   delete options.m_pOCContext;
   options.m_pOCContext = NULL;
 }
index e589618..99f282a 100644 (file)
@@ -26,7 +26,6 @@ DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page) {
   textpage = IPDF_TextPage::CreateTextPage((CPDF_Page*)pPage->GetPDFPage(),
                                            viewRef.IsDirectionR2L());
   textpage->ParseTextPage();
-
   return textpage;
 }
 DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page) {
index a5daa8f..fc16147 100644 (file)
@@ -166,16 +166,11 @@ void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable) {
 
 FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy) {
   switch (policy) {
-    case FPDF_POLICY_MACHINETIME_ACCESS: {
-      if (foxit_sandbox_policy & 0x01)
-        return TRUE;
-      else
-        return FALSE;
-    } break;
+    case FPDF_POLICY_MACHINETIME_ACCESS:
+      return (foxit_sandbox_policy & 0x01) ? TRUE : FALSE;
     default:
-      break;
+      return FALSE;
   }
-  return FALSE;
 }
 
 CCodec_ModuleMgr* g_pCodecModule = nullptr;
index fb79227..3dc48da 100644 (file)
@@ -961,8 +961,6 @@ void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice,
 
   int nFieldType = GetFieldType();
   if (m_pInterForm->IsNeedHighLight(nFieldType)) {
-    //          if (nFieldType != FIELDTYPE_PUSHBUTTON)
-    //          {
     CPDF_Rect rc = GetRect();
     FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType);
     uint8_t alpha = m_pInterForm->GetHighlightAlpha();
@@ -976,10 +974,6 @@ void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice,
     pPageView->GetCurrentMatrix(page2device);
     page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom),
                           rcDevice.left, rcDevice.bottom);
-    //          pEnv->FFI_PageToDevice(m_pPageView->GetPDFPage(), rc.left,
-    //          rc.bottom, &rcDevice.left, &rcDevice.bottom);
-    //          pEnv->FFI_PageToDevice(m_pPageView->GetPDFPage(), rc.right,
-    //          rc.top, &rcDevice.right, &rcDevice.top);
     page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top),
                           rcDevice.right, rcDevice.top);
 
@@ -989,7 +983,6 @@ void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice,
     FX_RECT rcDev((int)rcDevice.left, (int)rcDevice.top, (int)rcDevice.right,
                   (int)rcDevice.bottom);
     pDevice->FillRect(&rcDev, argb);
-    /*      }*/
   }
 }
 
@@ -2216,7 +2209,6 @@ CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument)
 CPDFSDK_InterForm::~CPDFSDK_InterForm() {
   delete m_pInterForm;
   m_pInterForm = nullptr;
-
   m_Map.clear();
   m_XFAMap.RemoveAll();
 }
@@ -2981,14 +2973,10 @@ int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField,
 }
 
 int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) {
-  ASSERT(pField != NULL);
-
   CPDF_FormField* pFormField = (CPDF_FormField*)pField;
-
   SynchronizeField(pFormField, FALSE);
 
   int nType = pFormField->GetFieldType();
-
   if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) {
     OnCalculate(pFormField);
     FX_BOOL bFormated = FALSE;
@@ -2999,7 +2987,6 @@ int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) {
       ResetFieldAppearance(pFormField, NULL, TRUE);
     UpdateField(pFormField);
   }
-
   return 0;
 }
 
index c1ab1bd..fb5df1e 100644 (file)
@@ -5,14 +5,16 @@
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
 #include "../../public/fpdf_ext.h"
+#include "../../third_party/base/nonstd_unique_ptr.h"
 #include "../include/formfiller/FFL_FormFiller.h"
+#include "../include/fsdk_define.h"
+#include "../include/fsdk_mgr.h"
+#include "../include/javascript/IJavaScript.h"
+
 #include "../include/fpdfxfa/fpdfxfa_app.h"
 #include "../include/fpdfxfa/fpdfxfa_doc.h"
 #include "../include/fpdfxfa/fpdfxfa_page.h"
 #include "../include/fpdfxfa/fpdfxfa_util.h"
-#include "../include/fsdk_define.h"
-#include "../include/fsdk_mgr.h"
-#include "../include/javascript/IJavaScript.h"
 
 #if _FX_OS_ == _FX_ANDROID_
 #include "time.h"
@@ -105,10 +107,6 @@ void CFX_SystemHandler::InvalidateRect(FX_HWND hWnd, FX_RECT rect) {
   device2page.Transform((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, left, top);
   device2page.Transform((FX_FLOAT)rect.right, (FX_FLOAT)rect.bottom, right,
                         bottom);
-  //  m_pEnv->FFI_DeviceToPage(pPage, rect.left, rect.top, (double*)&left,
-  //  (double*)&top);
-  //  m_pEnv->FFI_DeviceToPage(pPage, rect.right, rect.bottom, (double*)&right,
-  //  (double*)&bottom);
   CPDF_Rect rcPDF(left, bottom, right, top);
   rcPDF.Normalize();
 
@@ -687,8 +685,6 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
                                        CPDF_RenderOptions* pOptions,
                                        FX_RECT* pClip) {
   m_curMatrix = *pUser2Device;
-  //  m_pAnnotList->DisplayAnnots(m_page, pDevice, pUser2Device, FALSE,
-  //  pOptions);
   CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
   CPDFXFA_Page* pPage = GetPDFXFAPage();
 
@@ -723,16 +719,13 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
 
   // for pdf/static xfa.
   CPDFSDK_AnnotIterator annotIterator(this, TRUE);
-  CPDFSDK_Annot* pSDKAnnot = NULL;
   int index = -1;
-  pSDKAnnot = annotIterator.Next(index);
-  while (pSDKAnnot) {
+  while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next(index)) {
     CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
-    ASSERT(pAnnotHandlerMgr);
     pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0);
-    pSDKAnnot = annotIterator.Next(index);
   }
 }
+
 CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX,
                                                  FX_FLOAT pageY) {
   int nCount = m_pAnnotList->Count();
@@ -784,10 +777,8 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX,
   CPDFSDK_AnnotIterator annotIterator(this, FALSE);
   CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
   CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
-  CPDFSDK_Annot* pSDKAnnot = NULL;
   int index = -1;
-  pSDKAnnot = annotIterator.Next(index);
-  while (pSDKAnnot) {
+  while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next(index)) {
     if (pSDKAnnot->GetType() == "Widget" ||
         pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME) {
       pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
@@ -795,7 +786,6 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX,
       if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point))
         return pSDKAnnot;
     }
-    pSDKAnnot = annotIterator.Next(index);
   }
 
   return NULL;
@@ -1081,13 +1071,8 @@ FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) {
 }
 
 void CPDFSDK_PageView::LoadFXAnnots() {
-  ASSERT(m_page != NULL);
-
   CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
-  ASSERT(pEnv != NULL);
-
   CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
-  ASSERT(pAnnotHandlerMgr != NULL);
 
   SetLock(TRUE);
   m_page->AddRef();
index bcf8af6..4113f60 100644 (file)
@@ -861,12 +861,9 @@ FX_BOOL Document::info(IJS_Context* cc,
         FXJS_PutObjectBoolean(isolate, pObj, wsKey.c_str(),
                               (bool)pValueObj->GetInteger());
     }
-
     vp << pObj;
-    return TRUE;
-  } else {
-    return TRUE;
   }
+  return TRUE;
 }
 
 FX_BOOL Document::creationDate(IJS_Context* cc,
@@ -929,13 +926,20 @@ FX_BOOL Document::delay(IJS_Context* cc,
 
       m_DelayData.RemoveAll();
     } else {
+      CFX_ArrayTemplate<CJS_DelayData*> DelayDataToProcess;
       for (int i = 0, sz = m_DelayData.GetSize(); i < sz; i++) {
         if (CJS_DelayData* pData = m_DelayData.GetAt(i)) {
-          Field::DoDelay(m_pDocument, pData);
-          delete m_DelayData.GetAt(i);
+          DelayDataToProcess.Add(pData);
+          m_DelayData.SetAt(i, NULL);
         }
       }
       m_DelayData.RemoveAll();
+      for (int i = 0, sz = DelayDataToProcess.GetSize(); i < sz; i++) {
+        CJS_DelayData* pData = DelayDataToProcess.GetAt(i);
+        Field::DoDelay(m_pDocument, pData);
+        DelayDataToProcess.SetAt(i, NULL);
+        delete pData;
+      }
     }
   }
   return TRUE;
@@ -1340,40 +1344,6 @@ IconElement* IconTree::operator[](int iIndex) {
   return NULL;
 }
 
-void IconTree::DeleteIconElement(CFX_WideString swIconName) {
-  IconElement* pTemp = m_pHead;
-  int iLoopCount = m_iLength;
-  for (int i = 0; i < iLoopCount - 1; i++) {
-    if (pTemp == m_pEnd)
-      break;
-
-    if (m_pHead->IconName == swIconName) {
-      m_pHead = m_pHead->NextIcon;
-      delete pTemp;
-      m_iLength--;
-      pTemp = m_pHead;
-    }
-    if (pTemp->NextIcon->IconName == swIconName) {
-      if (pTemp->NextIcon == m_pEnd) {
-        m_pEnd = pTemp;
-        delete pTemp->NextIcon;
-        m_iLength--;
-        pTemp->NextIcon = NULL;
-      } else {
-        IconElement* pElement = pTemp->NextIcon;
-        pTemp->NextIcon = pTemp->NextIcon->NextIcon;
-        delete pElement;
-        m_iLength--;
-        pElement = NULL;
-      }
-
-      continue;
-    }
-
-    pTemp = pTemp->NextIcon;
-  }
-}
-
 FX_BOOL Document::addIcon(IJS_Context* cc,
                           const CJS_Parameters& params,
                           CJS_Value& vRet,
@@ -1505,15 +1475,7 @@ FX_BOOL Document::removeIcon(IJS_Context* cc,
                              const CJS_Parameters& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError) {
-  CJS_Context* pContext = (CJS_Context*)cc;
-  if (params.size() != 1) {
-    sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
-    return FALSE;
-  }
-
-  if (!m_pIconTree)
-    return FALSE;
-  CFX_WideString swIconName = params[0].ToCFXWideString();
+  // Unsafe, no supported.
   return TRUE;
 }
 
@@ -1639,7 +1601,10 @@ FX_BOOL Document::getPageNumWords(IJS_Context* cc,
     return FALSE;
 
   int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0;
+
   CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc();
+  ASSERT(pDocument != NULL);
+
   CJS_Context* pContext = static_cast<CJS_Context*>(cc);
   if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) {
     sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
@@ -1788,47 +1753,7 @@ FX_BOOL Document::deletePages(IJS_Context* cc,
                               const CJS_Parameters& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError) {
-  if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
-        m_pDocument->GetPermissions(FPDFPERM_ASSEMBLE)))
-    return FALSE;
-
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
-  v8::Isolate* isolate = pRuntime->GetIsolate();
-
-  int iSize = params.size();
-  int nStart = 0;
-  int nEnd = 0;
-  if (iSize < 1) {
-  } else if (iSize == 1) {
-    if (params[0].GetType() == CJS_Value::VT_object) {
-      v8::Local<v8::Object> pObj = params[0].ToV8Object();
-      v8::Local<v8::Value> pValue =
-          FXJS_GetObjectElement(isolate, pObj, L"nStart");
-      nStart = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToInt();
-      pValue = FXJS_GetObjectElement(isolate, pObj, L"nEnd");
-      nEnd = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToInt();
-    } else {
-      nStart = params[0].ToInt();
-    }
-  } else {
-    nStart = params[0].ToInt();
-    nEnd = params[1].ToInt();
-  }
-
-  int nTotal = m_pDocument->GetPageCount();
-  if (nStart < 0)
-    nStart = 0;
-  if (nStart >= nTotal)
-    nStart = nTotal - 1;
-
-  if (nEnd < 0)
-    nEnd = 0;
-  if (nEnd >= nTotal)
-    nEnd = nTotal - 1;
-
-  if (nEnd < nStart)
-    nEnd = nStart;
-
+  // Unsafe, no supported.
   return TRUE;
 }
 
@@ -1871,13 +1796,13 @@ void Document::AddDelayData(CJS_DelayData* pData) {
 void Document::DoFieldDelay(const CFX_WideString& sFieldName,
                             int nControlIndex) {
   CFX_DWordArray DelArray;
+  CFX_ArrayTemplate<CJS_DelayData*> DelayDataForFieldAndControlIndex;
 
   for (int i = 0, sz = m_DelayData.GetSize(); i < sz; i++) {
     if (CJS_DelayData* pData = m_DelayData.GetAt(i)) {
       if (pData->sFieldName == sFieldName &&
           pData->nControlIndex == nControlIndex) {
-        Field::DoDelay(m_pDocument, pData);
-        delete pData;
+        DelayDataForFieldAndControlIndex.Add(pData);
         m_DelayData.SetAt(i, NULL);
         DelArray.Add(i);
       }
@@ -1887,6 +1812,14 @@ void Document::DoFieldDelay(const CFX_WideString& sFieldName,
   for (int j = DelArray.GetSize() - 1; j >= 0; j--) {
     m_DelayData.RemoveAt(DelArray[j]);
   }
+
+  for (int i = 0, sz = DelayDataForFieldAndControlIndex.GetSize(); i < sz;
+       i++) {
+    CJS_DelayData* pData = DelayDataForFieldAndControlIndex.GetAt(i);
+    Field::DoDelay(m_pDocument, pData);
+    DelayDataForFieldAndControlIndex.SetAt(i, NULL);
+    delete pData;
+  }
 }
 
 void Document::AddDelayAnnotData(CJS_AnnotObj* pData) {
index 149102d..4e6fdee 100644 (file)
@@ -52,7 +52,6 @@ class IconTree {
 
  public:
   void InsertIconElement(IconElement* pNewIcon);
-  void DeleteIconElement(CFX_WideString swIconName);
   void DeleteIconTree();
   int GetLength();
   IconElement* operator[](int iIndex);
index 252c50f..174e9ae 100644 (file)
@@ -82,13 +82,13 @@ void JSPropGetter(const char* prop_name_string,
       static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate));
   if (!pRuntime)
     return;
-  IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
+  IJS_Context* pContext = pRuntime->GetCurrentContext();
   CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder());
   C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
   CFX_WideString sError;
   CJS_PropValue value(pRuntime);
   value.StartGetting();
-  if (!(pObj->*M)(pRuntimeContext, value, sError)) {
+  if (!(pObj->*M)(pContext, value, sError)) {
     FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string,
                                             sError));
     return;
@@ -108,13 +108,13 @@ void JSPropSetter(const char* prop_name_string,
       static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate));
   if (!pRuntime)
     return;
-  IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
+  IJS_Context* pContext = pRuntime->GetCurrentContext();
   CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder());
   C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
   CFX_WideString sError;
   CJS_PropValue propValue(CJS_Value(pRuntime, value, CJS_Value::VT_unknown));
   propValue.StartSetting();
-  if (!(pObj->*M)(pRuntimeContext, propValue, sError)) {
+  if (!(pObj->*M)(pContext, propValue, sError)) {
     FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string,
                                             sError));
   }
@@ -147,7 +147,7 @@ void JSMethod(const char* method_name_string,
       static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate));
   if (!pRuntime)
     return;
-  IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
+  IJS_Context* pContext = pRuntime->GetCurrentContext();
   CJS_Parameters parameters;
   for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
     parameters.push_back(CJS_Value(pRuntime, info[i], CJS_Value::VT_unknown));
@@ -156,7 +156,7 @@ void JSMethod(const char* method_name_string,
   CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder());
   C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
   CFX_WideString sError;
-  if (!(pObj->*M)(pRuntimeContext, parameters, valueRes, sError)) {
+  if (!(pObj->*M)(pContext, parameters, valueRes, sError)) {
     FXJS_Error(isolate, JSFormatErrorString(class_name_string,
                                             method_name_string, sError));
     return;
@@ -370,7 +370,7 @@ void JSSpecialPropGet(const char* class_name,
       static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate));
   if (!pRuntime)
     return;
-  IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
+  IJS_Context* pContext = pRuntime->GetCurrentContext();
   CJS_Object* pJSObj =
       reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder()));
   Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
@@ -380,7 +380,7 @@ void JSSpecialPropGet(const char* class_name,
   CFX_WideString sError;
   CJS_PropValue value(pRuntime);
   value.StartGetting();
-  if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), value, sError)) {
+  if (!pObj->DoProperty(pContext, propname.c_str(), value, sError)) {
     FXJS_Error(isolate, JSFormatErrorString(class_name, "GetProperty", sError));
     return;
   }
@@ -397,7 +397,7 @@ void JSSpecialPropPut(const char* class_name,
       static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate));
   if (!pRuntime)
     return;
-  IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
+  IJS_Context* pContext = pRuntime->GetCurrentContext();
   CJS_Object* pJSObj =
       reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder()));
   Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
@@ -407,7 +407,7 @@ void JSSpecialPropPut(const char* class_name,
   CFX_WideString sError;
   CJS_PropValue PropValue(CJS_Value(pRuntime, value, CJS_Value::VT_unknown));
   PropValue.StartSetting();
-  if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), PropValue, sError)) {
+  if (!pObj->DoProperty(pContext, propname.c_str(), PropValue, sError)) {
     FXJS_Error(isolate, JSFormatErrorString(class_name, "PutProperty", sError));
   }
 }
@@ -420,7 +420,7 @@ void JSSpecialPropDel(const char* class_name,
   IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate);
   if (!pRuntime)
     return;
-  IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
+  IJS_Context* pContext = pRuntime->GetCurrentContext();
   CJS_Object* pJSObj =
       reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder()));
   Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
@@ -428,7 +428,7 @@ void JSSpecialPropDel(const char* class_name,
   CFX_WideString propname =
       CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
   CFX_WideString sError;
-  if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) {
+  if (!pObj->DelProperty(pContext, propname.c_str(), sError)) {
     CFX_ByteString cbName;
     cbName.Format("%s.%s", class_name, "DelProperty");
     // Probably a missing call to JSFX_Error().
@@ -445,14 +445,14 @@ void JSGlobalFunc(const char* func_name_string,
       static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(info.GetIsolate()));
   if (!pRuntime)
     return;
-  IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
+  IJS_Context* pContext = pRuntime->GetCurrentContext();
   CJS_Parameters parameters;
   for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
     parameters.push_back(CJS_Value(pRuntime, info[i], CJS_Value::VT_unknown));
   }
   CJS_Value valueRes(pRuntime);
   CFX_WideString sError;
-  if (!(*F)(pRuntimeContext, parameters, valueRes, sError)) {
+  if (!(*F)(pContext, parameters, valueRes, sError)) {
     FXJS_Error(pRuntime->GetIsolate(),
                JSFormatErrorString(func_name_string, nullptr, sError));
     return;
index e13b50f..cf5b997 100644 (file)
@@ -104,7 +104,7 @@ CJS_GlobalData* CJS_GlobalData::g_Instance = nullptr;
 // static
 CJS_GlobalData* CJS_GlobalData::GetRetainedInstance(CPDFDoc_Environment* pApp) {
   if (!g_Instance) {
-    g_Instance = new CJS_GlobalData(pApp);
+    g_Instance = new CJS_GlobalData();
   }
   ++g_Instance->m_RefCount;
   return g_Instance;
@@ -117,8 +117,7 @@ void CJS_GlobalData::Release() {
   }
 }
 
-CJS_GlobalData::CJS_GlobalData(CPDFDoc_Environment* pApp)
-    : m_pApp(pApp), m_RefCount(0) {
+CJS_GlobalData::CJS_GlobalData() : m_RefCount(0) {
   m_sFilePath += SDK_JS_GLOBALDATA_FILENAME;
   LoadGlobalPersistentVariables();
 }
index b174a8d..a358e80 100644 (file)
@@ -79,7 +79,7 @@ class CJS_GlobalData {
  private:
   static CJS_GlobalData* g_Instance;
 
-  CJS_GlobalData(CPDFDoc_Environment* pApp);
+  CJS_GlobalData();
   ~CJS_GlobalData();
 
   void LoadGlobalPersistentVariables();
@@ -98,11 +98,9 @@ class CJS_GlobalData {
                       CJS_KeyValue* pData,
                       CFX_BinaryBuf& sData);
 
- private:
   size_t m_RefCount;
   CFX_ArrayTemplate<CJS_GlobalData_Element*> m_arrayGlobalData;
   CFX_WideString m_sFilePath;
-  CPDFDoc_Environment* m_pApp;
 };
 
 #endif  // FPDFSDK_SRC_JAVASCRIPT_JS_GLOBALDATA_H_
index 0b3b38f..71726a2 100644 (file)
@@ -48,9 +48,18 @@ END_JS_STATIC_GLOBAL_FUN()
 
 IMPLEMENT_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods)
 
-static const FX_WCHAR* months[] = {L"Jan", L"Feb", L"Mar", L"Apr",
-                                   L"May", L"Jun", L"Jul", L"Aug",
-                                   L"Sep", L"Oct", L"Nov", L"Dec"};
+static const FX_WCHAR* const months[] = {L"Jan",
+                                         L"Feb",
+                                         L"Mar",
+                                         L"Apr",
+                                         L"May",
+                                         L"Jun",
+                                         L"Jul",
+                                         L"Aug",
+                                         L"Sep",
+                                         L"Oct",
+                                         L"Nov",
+                                         L"Dec"};
 
 static const FX_WCHAR* const fullmonths[] = {
     L"January",   L"February", L"March",    L"April",
@@ -935,7 +944,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
   strValue.Replace(",", ".");
   double dValue = atof(strValue);
   if (iDec > 0)
-    dValue += DOUBLE_CORRECT;  //
+    dValue += DOUBLE_CORRECT;
 
   int iDec2;
   int iNegative = 0;
@@ -984,11 +993,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
     else
       cSeperator = '.';
 
-    int iDecPositive, iDecNegative;
-    iDecPositive = iDec2;
-    iDecNegative = iDec2;
-
-    for (iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) {
+    for (int iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) {
       strValue.Insert(iDecPositive, cSeperator);
       iMax++;
     }
@@ -1274,11 +1279,7 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(IJS_Context* cc,
     else
       cSeperator = '.';
 
-    int iDecPositive, iDecNegative;
-    iDecPositive = iDec2;
-    iDecNegative = iDec2;
-
-    for (iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) {
+    for (int iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) {
       strValue.Insert(iDecPositive, cSeperator);
       iMax++;
     }
index 403cf58..cd0048d 100644 (file)
@@ -7,7 +7,6 @@
 #include "global.h"
 
 #include "../../../core/include/fxcrt/fx_ext.h"
-#include "../../include/fpdfxfa/fpdfxfa_app.h"
 #include "../../include/javascript/IJavaScript.h"
 #include "JS_Context.h"
 #include "JS_Define.h"
index 932f8c5..2a9afe7 100644 (file)
@@ -594,10 +594,7 @@ FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
     if (bExit)
       return FALSE;
   }
-  if (m_pList->OnCharWithExit(nChar, bExit, nFlag))
-    return bExit;
-
-  return FALSE;
+  return m_pList->OnCharWithExit(nChar, bExit, nFlag) ? bExit : FALSE;
 }
 
 void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd,