summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-14 14:17:26 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-14 14:17:26 -0700
commitdfbf8e7ba55695c4e6cb30eadbe9c6a2955815ba (patch)
tree58eef2a1e6763f71926524827da0f220f761f960 /fpdfsdk/src
parent758ae14e113c07285126274577d7a5cab559fa65 (diff)
downloadpdfium-dfbf8e7ba55695c4e6cb30eadbe9c6a2955815ba.tar.xz
Next round of XFA changes to match master.
This contains a missed merge of the Document:delay fixes. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1398703009 .
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/formfiller/FFL_FormFiller.cpp4
-rw-r--r--fpdfsdk/src/fpdf_progressive.cpp19
-rw-r--r--fpdfsdk/src/fpdf_transformpage.cpp1
-rw-r--r--fpdfsdk/src/fpdfformfill.cpp4
-rw-r--r--fpdfsdk/src/fpdftext.cpp1
-rw-r--r--fpdfsdk/src/fpdfview.cpp11
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp13
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp31
-rw-r--r--fpdfsdk/src/javascript/Document.cpp117
-rw-r--r--fpdfsdk/src/javascript/Document.h1
-rw-r--r--fpdfsdk/src/javascript/JS_Define.h28
-rw-r--r--fpdfsdk/src/javascript/JS_GlobalData.cpp5
-rw-r--r--fpdfsdk/src/javascript/JS_GlobalData.h4
-rw-r--r--fpdfsdk/src/javascript/PublicMethods.cpp29
-rw-r--r--fpdfsdk/src/javascript/global.cpp1
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp5
16 files changed, 79 insertions, 195 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
index 642e5e8964..30a297dd68 100644
--- a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
@@ -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) {
diff --git a/fpdfsdk/src/fpdf_progressive.cpp b/fpdfsdk/src/fpdf_progressive.cpp
index 65901f86f2..f5e11e8c81 100644
--- a/fpdfsdk/src/fpdf_progressive.cpp
+++ b/fpdfsdk/src/fpdf_progressive.cpp
@@ -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);
}
diff --git a/fpdfsdk/src/fpdf_transformpage.cpp b/fpdfsdk/src/fpdf_transformpage.cpp
index d02876d740..dbf97aa2f0 100644
--- a/fpdfsdk/src/fpdf_transformpage.cpp
+++ b/fpdfsdk/src/fpdf_transformpage.cpp
@@ -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());
diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp
index 07b58c1a68..e86a47be55 100644
--- a/fpdfsdk/src/fpdfformfill.cpp
+++ b/fpdfsdk/src/fpdfformfill.cpp
@@ -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;
}
diff --git a/fpdfsdk/src/fpdftext.cpp b/fpdfsdk/src/fpdftext.cpp
index e589618106..99f282a2b5 100644
--- a/fpdfsdk/src/fpdftext.cpp
+++ b/fpdfsdk/src/fpdftext.cpp
@@ -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) {
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index a5daa8f52e..fc16147cfa 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -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;
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index fb79227df1..3dc48dab53 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -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;
}
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index c1ab1bd780..fb5df1ea5e 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -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();
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index bcf8af6595..4113f60735 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -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) {
diff --git a/fpdfsdk/src/javascript/Document.h b/fpdfsdk/src/javascript/Document.h
index 149102d0d1..4e6fdee218 100644
--- a/fpdfsdk/src/javascript/Document.h
+++ b/fpdfsdk/src/javascript/Document.h
@@ -52,7 +52,6 @@ class IconTree {
public:
void InsertIconElement(IconElement* pNewIcon);
- void DeleteIconElement(CFX_WideString swIconName);
void DeleteIconTree();
int GetLength();
IconElement* operator[](int iIndex);
diff --git a/fpdfsdk/src/javascript/JS_Define.h b/fpdfsdk/src/javascript/JS_Define.h
index 252c50ff1b..174e9aeaee 100644
--- a/fpdfsdk/src/javascript/JS_Define.h
+++ b/fpdfsdk/src/javascript/JS_Define.h
@@ -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;
diff --git a/fpdfsdk/src/javascript/JS_GlobalData.cpp b/fpdfsdk/src/javascript/JS_GlobalData.cpp
index e13b50f5ef..cf5b997dd2 100644
--- a/fpdfsdk/src/javascript/JS_GlobalData.cpp
+++ b/fpdfsdk/src/javascript/JS_GlobalData.cpp
@@ -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();
}
diff --git a/fpdfsdk/src/javascript/JS_GlobalData.h b/fpdfsdk/src/javascript/JS_GlobalData.h
index b174a8d76e..a358e80e55 100644
--- a/fpdfsdk/src/javascript/JS_GlobalData.h
+++ b/fpdfsdk/src/javascript/JS_GlobalData.h
@@ -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_
diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp
index 0b3b38f8f1..71726a2db0 100644
--- a/fpdfsdk/src/javascript/PublicMethods.cpp
+++ b/fpdfsdk/src/javascript/PublicMethods.cpp
@@ -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++;
}
diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp
index 403cf58ebf..cd0048d95b 100644
--- a/fpdfsdk/src/javascript/global.cpp
+++ b/fpdfsdk/src/javascript/global.cpp
@@ -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"
diff --git a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
index 932f8c56d6..2a9afe7dc6 100644
--- a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
@@ -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,