From 96660d6f382204339d6b1aadc3913303d436e252 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 14 Dec 2015 18:27:25 -0800 Subject: Merge to XFA: Get rid of most instance of 'foo != NULL' TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1512763013 . (cherry picked from commit e3c7c2b54348da4a6939f6672f6c6bff126815a7) Review URL: https://codereview.chromium.org/1529553003 . --- fpdfsdk/src/javascript/Document.cpp | 39 ------ fpdfsdk/src/javascript/Field.cpp | 183 ++++++----------------------- fpdfsdk/src/javascript/JS_Context.cpp | 2 - fpdfsdk/src/javascript/JS_EventHandler.cpp | 10 -- fpdfsdk/src/javascript/JS_GlobalData.cpp | 26 ++-- fpdfsdk/src/javascript/JS_Object.cpp | 2 - fpdfsdk/src/javascript/PublicMethods.cpp | 24 +--- fpdfsdk/src/javascript/app.cpp | 9 +- fpdfsdk/src/javascript/event.cpp | 35 ------ fpdfsdk/src/javascript/global.cpp | 8 -- 10 files changed, 47 insertions(+), 291 deletions(-) (limited to 'fpdfsdk/src/javascript') diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp index 1fa88f9b12..b0ca69b5ba 100644 --- a/fpdfsdk/src/javascript/Document.cpp +++ b/fpdfsdk/src/javascript/Document.cpp @@ -22,11 +22,7 @@ static v8::Isolate* GetIsolate(IJS_Context* cc) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); - CJS_Runtime* pRuntime = pContext->GetJSRuntime(); - ASSERT(pRuntime != NULL); - return pRuntime->GetIsolate(); } @@ -194,8 +190,6 @@ FX_BOOL Document::numFields(IJS_Context* cc, FX_BOOL Document::dirty(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (vp.IsGetting()) { if (m_pDocument->GetChangeMark()) vp << true; @@ -218,8 +212,6 @@ FX_BOOL Document::dirty(IJS_Context* cc, FX_BOOL Document::ADBE(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (vp.IsGetting()) { vp.SetNull(); } else { @@ -231,8 +223,6 @@ FX_BOOL Document::ADBE(IJS_Context* cc, FX_BOOL Document::pageNum(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (vp.IsGetting()) { if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView()) { vp << pPageView->GetPageIndex(); @@ -394,8 +384,6 @@ FX_BOOL Document::mailForm(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; @@ -410,18 +398,13 @@ FX_BOOL Document::mailForm(IJS_Context* cc, CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); - ASSERT(pInterForm != NULL); - CFX_ByteTextBuf textBuf; if (!pInterForm->ExportFormToFDFTextBuf(textBuf)) return FALSE; CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CPDFDoc_Environment* pEnv = pContext->GetReaderApp(); - ASSERT(pEnv != NULL); CJS_Runtime* pRuntime = pContext->GetJSRuntime(); - ASSERT(pRuntime != NULL); pRuntime->BeginBlock(); pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, @@ -485,8 +468,6 @@ FX_BOOL Document::print(IJS_Context* cc, bAnnotations = params[7].ToBool(); } - ASSERT(m_pDocument != NULL); - if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv()) { pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotations); @@ -503,8 +484,6 @@ FX_BOOL Document::removeField(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return FALSE; @@ -518,7 +497,6 @@ FX_BOOL Document::removeField(IJS_Context* cc, CFX_WideString sFieldName = params[0].ToCFXWideString(); CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); - ASSERT(pInterForm != NULL); std::vector widgets; pInterForm->GetWidgets(sFieldName, &widgets); @@ -1100,11 +1078,8 @@ FX_BOOL Document::baseURL(IJS_Context* cc, FX_BOOL Document::calculate(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); - ASSERT(pInterForm != NULL); if (vp.IsGetting()) { if (pInterForm->IsCalculateEnabled()) @@ -1220,7 +1195,6 @@ FX_BOOL Document::closeDoc(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); return TRUE; } @@ -1479,8 +1453,6 @@ FX_BOOL Document::calculateNow(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) @@ -1488,7 +1460,6 @@ FX_BOOL Document::calculateNow(IJS_Context* cc, CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); - ASSERT(pInterForm != NULL); pInterForm->OnCalculate(); return TRUE; } @@ -1503,8 +1474,6 @@ FX_BOOL Document::getPageNthWord(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; @@ -1565,8 +1534,6 @@ FX_BOOL Document::getPageNthWordQuads(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; @@ -1577,16 +1544,12 @@ FX_BOOL Document::getPageNumWords(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); - ASSERT(pDocument != NULL); - CJS_Context* pContext = static_cast(cc); if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); @@ -1673,8 +1636,6 @@ int Document::CountWords(CPDF_TextObject* pTextObj) { CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex) { - ASSERT(pTextObj != NULL); - CFX_WideString swRet; CPDF_Font* pFont = pTextObj->GetFont(); diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp index d3531a4aa3..89725ffb7f 100644 --- a/fpdfsdk/src/javascript/Field.cpp +++ b/fpdfsdk/src/javascript/Field.cpp @@ -19,8 +19,6 @@ #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. #include "fpdfsdk/include/javascript/IJavaScript.h" -/* ---------------------- Field ---------------------- */ - BEGIN_JS_STATIC_CONST(CJS_Field) END_JS_STATIC_CONST() @@ -156,22 +154,14 @@ void Field::ParseFieldName(const std::wstring& strFieldNameParsed, FX_BOOL Field::AttachField(Document* pDocument, const CFX_WideString& csFieldName) { - ASSERT(pDocument != NULL); m_pJSDoc = pDocument; - m_pDocument = pDocument->GetReaderDoc(); - ASSERT(m_pDocument != NULL); - m_bCanSet = m_pDocument->GetPermissions(FPDFPERM_FILL_FORM) || m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || m_pDocument->GetPermissions(FPDFPERM_MODIFY); CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm(); - ASSERT(pRDInterForm != NULL); - CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); - ASSERT(pInterForm != NULL); - CFX_WideString swFieldNameTemp = csFieldName; swFieldNameTemp.Replace(L"..", L"."); @@ -251,12 +241,9 @@ void Field::UpdateFormControl(CPDFSDK_Document* pDocument, FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefresh) { - ASSERT(pDocument != NULL); - ASSERT(pFormControl != NULL); + ASSERT(pFormControl); CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); - ASSERT(pInterForm != NULL); - CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl); if (pWidget) { @@ -278,7 +265,6 @@ void Field::UpdateFormControl(CPDFSDK_Document* pDocument, if (bRefresh) { CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); CPDFSDK_Document* pDoc = pInterForm->GetDocument(); - ASSERT(pDoc != NULL); pDoc->UpdateAllViews(NULL, pWidget); } } @@ -296,8 +282,6 @@ CPDFSDK_Widget* Field::GetWidget(CPDFSDK_Document* pDocument, FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel) { - ASSERT(pFormField != NULL); - for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) { if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0) return TRUE; @@ -317,13 +301,10 @@ CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField) { return pFormField->GetControl(m_nFormControlIndex); } -/* ---------------------------------------- property - * ---------------------------------------- */ - FX_BOOL Field::alignment(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -379,7 +360,7 @@ void Field::SetAlignment(CPDFSDK_Document* pDocument, FX_BOOL Field::borderStyle(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -439,7 +420,7 @@ void Field::SetBorderStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string) { - ASSERT(pDocument != NULL); + ASSERT(pDocument); int nBorderStyle = 0; @@ -491,7 +472,7 @@ void Field::SetBorderStyle(CPDFSDK_Document* pDocument, FX_BOOL Field::buttonAlignX(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -540,7 +521,7 @@ void Field::SetButtonAlignX(CPDFSDK_Document* pDocument, FX_BOOL Field::buttonAlignY(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -589,7 +570,7 @@ void Field::SetButtonAlignY(CPDFSDK_Document* pDocument, FX_BOOL Field::buttonFitBounds(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -634,7 +615,7 @@ void Field::SetButtonFitBounds(CPDFSDK_Document* pDocument, FX_BOOL Field::buttonPosition(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -677,7 +658,7 @@ void Field::SetButtonPosition(CPDFSDK_Document* pDocument, FX_BOOL Field::buttonScaleHow(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -725,7 +706,7 @@ void Field::SetButtonScaleHow(CPDFSDK_Document* pDocument, FX_BOOL Field::buttonScaleWhen(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -784,7 +765,7 @@ void Field::SetButtonScaleWhen(CPDFSDK_Document* pDocument, FX_BOOL Field::calcOrderIndex(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -811,11 +792,7 @@ FX_BOOL Field::calcOrderIndex(IJS_Context* cc, } CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm(); - ASSERT(pRDInterForm != NULL); - CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); - ASSERT(pInterForm != NULL); - vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField); } @@ -832,7 +809,7 @@ void Field::SetCalcOrderIndex(CPDFSDK_Document* pDocument, FX_BOOL Field::charLimit(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -870,7 +847,7 @@ void Field::SetCharLimit(CPDFSDK_Document* pDocument, FX_BOOL Field::comb(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -912,7 +889,7 @@ void Field::SetComb(CPDFSDK_Document* pDocument, FX_BOOL Field::commitOnSelChange(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -1019,7 +996,7 @@ void Field::SetCurrentValueIndices(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_DWordArray& array) { - ASSERT(pDocument != NULL); + ASSERT(pDocument); std::vector FieldArray = GetFormFields(pDocument, swFieldName); @@ -1059,7 +1036,7 @@ void Field::SetDefaultStyle(CPDFSDK_Document* pDocument, FX_BOOL Field::defaultValue(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -1100,7 +1077,7 @@ void Field::SetDefaultValue(CPDFSDK_Document* pDocument, FX_BOOL Field::doNotScroll(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -1142,7 +1119,7 @@ void Field::SetDoNotScroll(CPDFSDK_Document* pDocument, FX_BOOL Field::doNotSpellCheck(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -1199,8 +1176,6 @@ FX_BOOL Field::delay(IJS_Context* cc, FX_BOOL Field::display(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (vp.IsSetting()) { if (!m_bCanSet) return FALSE; @@ -1251,11 +1226,7 @@ void Field::SetDisplay(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number) { - ASSERT(pDocument != NULL); - CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); - ASSERT(pInterForm != NULL); - std::vector FieldArray = GetFormFields(pDocument, swFieldName); for (CPDF_FormField* pFormField : FieldArray) { @@ -1263,7 +1234,7 @@ void Field::SetDisplay(CPDFSDK_Document* pDocument, FX_BOOL bSet = FALSE; for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { CPDF_FormControl* pFormControl = pFormField->GetControl(i); - ASSERT(pFormControl != NULL); + ASSERT(pFormControl); if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { FX_DWORD dwFlag = pWidget->GetFlags(); @@ -1353,7 +1324,6 @@ FX_BOOL Field::doc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { FX_BOOL Field::editable(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); if (vp.IsSetting()) { if (!m_bCanSet) return FALSE; @@ -1426,8 +1396,6 @@ FX_BOOL Field::exportValues(IJS_Context* cc, FX_BOOL Field::fileSelect(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - std::vector FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return FALSE; @@ -1524,8 +1492,6 @@ void Field::SetFillColor(CPDFSDK_Document* pDocument, FX_BOOL Field::hidden(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (vp.IsSetting()) { if (!m_bCanSet) return FALSE; @@ -1567,11 +1533,7 @@ void Field::SetHidden(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b) { - ASSERT(pDocument != NULL); - CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); - ASSERT(pInterForm != NULL); - std::vector FieldArray = GetFormFields(pDocument, swFieldName); for (CPDF_FormField* pFormField : FieldArray) { @@ -1634,7 +1596,7 @@ void Field::SetHidden(CPDFSDK_Document* pDocument, FX_BOOL Field::highlight(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -1695,8 +1657,6 @@ void Field::SetHighlight(CPDFSDK_Document* pDocument, FX_BOOL Field::lineWidth(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (vp.IsSetting()) { if (!m_bCanSet) return FALSE; @@ -1723,8 +1683,6 @@ FX_BOOL Field::lineWidth(IJS_Context* cc, CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); - ASSERT(pInterForm != NULL); - if (!pFormField->CountControls()) return FALSE; @@ -1742,10 +1700,7 @@ void Field::SetLineWidth(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number) { - ASSERT(pDocument != NULL); - CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); - ASSERT(pInterForm != NULL); std::vector FieldArray = GetFormFields(pDocument, swFieldName); @@ -1754,7 +1709,7 @@ void Field::SetLineWidth(CPDFSDK_Document* pDocument, FX_BOOL bSet = FALSE; for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { CPDF_FormControl* pFormControl = pFormField->GetControl(i); - ASSERT(pFormControl != NULL); + ASSERT(pFormControl); if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { if (number != pWidget->GetBorderWidth()) { @@ -1784,7 +1739,7 @@ void Field::SetLineWidth(CPDFSDK_Document* pDocument, FX_BOOL Field::multiline(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -1826,7 +1781,7 @@ void Field::SetMultiline(CPDFSDK_Document* pDocument, FX_BOOL Field::multipleSelection(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -1941,7 +1896,7 @@ FX_BOOL Field::page(IJS_Context* cc, FX_BOOL Field::password(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -1983,12 +1938,8 @@ void Field::SetPassword(CPDFSDK_Document* pDocument, FX_BOOL Field::print(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); - ASSERT(pInterForm != NULL); - std::vector FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return FALSE; @@ -2062,8 +2013,6 @@ FX_BOOL Field::print(IJS_Context* cc, FX_BOOL Field::radiosInUnison(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - std::vector FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return FALSE; @@ -2092,8 +2041,6 @@ FX_BOOL Field::radiosInUnison(IJS_Context* cc, FX_BOOL Field::readonly(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - std::vector FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return FALSE; @@ -2183,10 +2130,7 @@ void Field::SetRect(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPDF_Rect& rect) { - ASSERT(pDocument != NULL); - CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); - ASSERT(pInterForm != NULL); std::vector FieldArray = GetFormFields(pDocument, swFieldName); @@ -2195,7 +2139,7 @@ void Field::SetRect(CPDFSDK_Document* pDocument, FX_BOOL bSet = FALSE; for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { CPDF_FormControl* pFormControl = pFormField->GetControl(i); - ASSERT(pFormControl != NULL); + ASSERT(pFormControl); if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { CPDF_Rect crRect = rect; @@ -2225,11 +2169,6 @@ void Field::SetRect(CPDFSDK_Document* pDocument, CPDF_Rect crRect = rect; CPDF_Page* pPDFPage = pWidget->GetPDFPage(); - ASSERT(pPDFPage != NULL); - - // CPDF_Page* pPDFPage = pPage->GetPage(); - // ASSERT(pPDFPage != NULL); - crRect.Intersect(pPDFPage->GetPageBBox()); if (!crRect.IsEmpty()) { @@ -2249,8 +2188,6 @@ void Field::SetRect(CPDFSDK_Document* pDocument, FX_BOOL Field::required(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - std::vector FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return FALSE; @@ -2279,7 +2216,7 @@ FX_BOOL Field::required(IJS_Context* cc, FX_BOOL Field::richText(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -2333,7 +2270,7 @@ void Field::SetRichValue(CPDFSDK_Document* pDocument, FX_BOOL Field::rotation(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -2443,7 +2380,7 @@ void Field::SetStrokeColor(CPDFSDK_Document* pDocument, FX_BOOL Field::style(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -2578,7 +2515,7 @@ void Field::SetTextColor(CPDFSDK_Document* pDocument, FX_BOOL Field::textFont(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -2634,7 +2571,7 @@ void Field::SetTextFont(CPDFSDK_Document* pDocument, FX_BOOL Field::textSize(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -2682,8 +2619,6 @@ void Field::SetTextSize(CPDFSDK_Document* pDocument, FX_BOOL Field::type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (!vp.IsGetting()) return FALSE; @@ -2728,7 +2663,7 @@ FX_BOOL Field::type(IJS_Context* cc, FX_BOOL Field::userName(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (vp.IsSetting()) { if (!m_bCanSet) @@ -2881,7 +2816,7 @@ void Field::SetValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CJS_WideStringArray& strArray) { - ASSERT(pDocument != NULL); + ASSERT(pDocument); if (strArray.GetSize() < 1) return; @@ -2940,8 +2875,6 @@ void Field::SetValue(CPDFSDK_Document* pDocument, FX_BOOL Field::valueAsString(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (!vp.IsGetting()) return FALSE; @@ -2981,15 +2914,10 @@ FX_BOOL Field::valueAsString(IJS_Context* cc, return TRUE; } -/* --------------------------------- methods --------------------------------- - */ - FX_BOOL Field::browseForFileToSubmit(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - std::vector FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return FALSE; @@ -3012,8 +2940,6 @@ FX_BOOL Field::buttonGetCaption(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - int nface = 0; int iSize = params.size(); if (iSize >= 1) @@ -3047,8 +2973,6 @@ FX_BOOL Field::buttonGetIcon(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - int nface = 0; int iSize = params.size(); if (iSize >= 1) @@ -3116,7 +3040,7 @@ FX_BOOL Field::checkThisBox(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); if (!m_bCanSet) return FALSE; @@ -3161,8 +3085,6 @@ FX_BOOL Field::defaultIsChecked(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - if (!m_bCanSet) return FALSE; @@ -3195,9 +3117,6 @@ FX_BOOL Field::deleteItemAt(IJS_Context* cc, } int JS_COMPARESTRING(CFX_WideString* ps1, CFX_WideString* ps2) { - ASSERT(ps1 != NULL); - ASSERT(ps2 != NULL); - return ps1->Compare(*ps2); } @@ -3205,8 +3124,6 @@ FX_BOOL Field::getArray(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - std::vector FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return FALSE; @@ -3247,7 +3164,6 @@ FX_BOOL Field::getItemAt(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); int iSize = params.size(); int nIdx = -1; @@ -3301,8 +3217,6 @@ FX_BOOL Field::isBoxChecked(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - int nIndex = -1; if (params.size() >= 1) nIndex = params[0].ToInt(); @@ -3334,8 +3248,6 @@ FX_BOOL Field::isDefaultChecked(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - int nIndex = -1; if (params.size() >= 1) nIndex = params[0].ToInt(); @@ -3373,8 +3285,6 @@ FX_BOOL Field::setFocus(IJS_Context* cc, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - ASSERT(m_pDocument != NULL); - std::vector FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return FALSE; @@ -3386,8 +3296,6 @@ FX_BOOL Field::setFocus(IJS_Context* cc, CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); - ASSERT(pInterForm != NULL); - CPDFSDK_Widget* pWidget = NULL; if (nCount == 1) { pWidget = pInterForm->GetWidget(pFormField->GetControl(0)); @@ -3483,12 +3391,7 @@ FX_BOOL Field::source(IJS_Context* cc, return TRUE; } -/////////////////////////////////////////// delay -//////////////////////////////////////////////// - void Field::AddDelay_Int(enum FIELD_PROP prop, int32_t n) { - ASSERT(m_pJSDoc != NULL); - CJS_DelayData* pNewData = new CJS_DelayData; pNewData->sFieldName = m_FieldName; pNewData->nControlIndex = m_nFormControlIndex; @@ -3499,8 +3402,6 @@ void Field::AddDelay_Int(enum FIELD_PROP prop, int32_t n) { } void Field::AddDelay_Bool(enum FIELD_PROP prop, bool b) { - ASSERT(m_pJSDoc != NULL); - CJS_DelayData* pNewData = new CJS_DelayData; pNewData->sFieldName = m_FieldName; pNewData->nControlIndex = m_nFormControlIndex; @@ -3512,8 +3413,6 @@ void Field::AddDelay_Bool(enum FIELD_PROP prop, bool b) { void Field::AddDelay_String(enum FIELD_PROP prop, const CFX_ByteString& string) { - ASSERT(m_pJSDoc != NULL); - CJS_DelayData* pNewData = new CJS_DelayData; pNewData->sFieldName = m_FieldName; pNewData->nControlIndex = m_nFormControlIndex; @@ -3525,8 +3424,6 @@ void Field::AddDelay_String(enum FIELD_PROP prop, void Field::AddDelay_WideString(enum FIELD_PROP prop, const CFX_WideString& string) { - ASSERT(m_pJSDoc != NULL); - CJS_DelayData* pNewData = new CJS_DelayData; pNewData->sFieldName = m_FieldName; pNewData->nControlIndex = m_nFormControlIndex; @@ -3537,8 +3434,6 @@ void Field::AddDelay_WideString(enum FIELD_PROP prop, } void Field::AddDelay_Rect(enum FIELD_PROP prop, const CPDF_Rect& rect) { - ASSERT(m_pJSDoc != NULL); - CJS_DelayData* pNewData = new CJS_DelayData; pNewData->sFieldName = m_FieldName; pNewData->nControlIndex = m_nFormControlIndex; @@ -3549,8 +3444,6 @@ void Field::AddDelay_Rect(enum FIELD_PROP prop, const CPDF_Rect& rect) { } void Field::AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color) { - ASSERT(m_pJSDoc != NULL); - CJS_DelayData* pNewData = new CJS_DelayData; pNewData->sFieldName = m_FieldName; pNewData->nControlIndex = m_nFormControlIndex; @@ -3562,8 +3455,6 @@ void Field::AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color) { void Field::AddDelay_WordArray(enum FIELD_PROP prop, const CFX_DWordArray& array) { - ASSERT(m_pJSDoc != NULL); - CJS_DelayData* pNewData = new CJS_DelayData; pNewData->sFieldName = m_FieldName; pNewData->nControlIndex = m_nFormControlIndex; @@ -3577,8 +3468,6 @@ void Field::AddDelay_WordArray(enum FIELD_PROP prop, void Field::AddDelay_WideStringArray(enum FIELD_PROP prop, const CJS_WideStringArray& array) { - ASSERT(m_pJSDoc != NULL); - CJS_DelayData* pNewData = new CJS_DelayData; pNewData->sFieldName = m_FieldName; pNewData->nControlIndex = m_nFormControlIndex; @@ -3590,8 +3479,7 @@ void Field::AddDelay_WideStringArray(enum FIELD_PROP prop, } void Field::DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData) { - ASSERT(pDocument != NULL); - ASSERT(pData != NULL); + ASSERT(pDocument); switch (pData->eProp) { case FP_ALIGNMENT: @@ -3731,9 +3619,6 @@ void Field::DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData) { } } -#define JS_FIELD_MINWIDTH 1 -#define JS_FIELD_MINHEIGHT 1 - void Field::AddField(CPDFSDK_Document* pDocument, int nPageIndex, int nFieldType, diff --git a/fpdfsdk/src/javascript/JS_Context.cpp b/fpdfsdk/src/javascript/JS_Context.cpp index d520c86942..9dbf5ed50a 100644 --- a/fpdfsdk/src/javascript/JS_Context.cpp +++ b/fpdfsdk/src/javascript/JS_Context.cpp @@ -27,8 +27,6 @@ CPDFSDK_Document* CJS_Context::GetReaderDocument() { } CPDFDoc_Environment* CJS_Context::GetReaderApp() { - ASSERT(m_pRuntime != NULL); - return m_pRuntime->GetReaderApp(); } diff --git a/fpdfsdk/src/javascript/JS_EventHandler.cpp b/fpdfsdk/src/javascript/JS_EventHandler.cpp index df7f9791c2..e413166328 100644 --- a/fpdfsdk/src/javascript/JS_EventHandler.cpp +++ b/fpdfsdk/src/javascript/JS_EventHandler.cpp @@ -115,7 +115,6 @@ void CJS_EventHandler::OnField_MouseEnter(FX_BOOL bModifier, m_bModifier = bModifier; m_bShift = bShift; - ASSERT(pTarget != NULL); m_strTargetName = pTarget->GetFullName(); } @@ -126,7 +125,6 @@ void CJS_EventHandler::OnField_MouseExit(FX_BOOL bModifier, m_bModifier = bModifier; m_bShift = bShift; - ASSERT(pTarget != NULL); m_strTargetName = pTarget->GetFullName(); } @@ -138,7 +136,6 @@ void CJS_EventHandler::OnField_MouseDown(FX_BOOL bModifier, m_bModifier = bModifier; m_bShift = bShift; - ASSERT(pTarget != NULL); m_strTargetName = pTarget->GetFullName(); } @@ -149,7 +146,6 @@ void CJS_EventHandler::OnField_MouseUp(FX_BOOL bModifier, m_bModifier = bModifier; m_bShift = bShift; - ASSERT(pTarget != NULL); m_strTargetName = pTarget->GetFullName(); } @@ -161,7 +157,6 @@ void CJS_EventHandler::OnField_Focus(FX_BOOL bModifier, m_bModifier = bModifier; m_bShift = bShift; - ASSERT(pTarget != NULL); m_strTargetName = pTarget->GetFullName(); m_pValue = (CFX_WideString*)&Value; } @@ -174,7 +169,6 @@ void CJS_EventHandler::OnField_Blur(FX_BOOL bModifier, m_bModifier = bModifier; m_bShift = bShift; - ASSERT(pTarget != NULL); m_strTargetName = pTarget->GetFullName(); m_pValue = (CFX_WideString*)&Value; } @@ -201,7 +195,6 @@ void CJS_EventHandler::OnField_Keystroke(CFX_WideString& strChange, m_pISelEnd = &nSelEnd; m_pISelStart = &nSelStart; m_bShift = bShift; - ASSERT(pTarget != NULL); m_strTargetName = pTarget->GetFullName(); m_pValue = &Value; m_bWillCommit = bWillCommit; @@ -224,7 +217,6 @@ void CJS_EventHandler::OnField_Validate(CFX_WideString& strChange, m_bKeyDown = bKeyDown; m_bModifier = bModifier; m_bShift = bShift; - ASSERT(pTarget != NULL); m_strTargetName = pTarget->GetFullName(); m_pValue = &Value; m_pbRc = &bRc; @@ -238,7 +230,6 @@ void CJS_EventHandler::OnField_Calculate(CPDF_FormField* pSource, if (pSource) m_strSourceName = pSource->GetFullName(); - ASSERT(pTarget != NULL); m_strTargetName = pTarget->GetFullName(); m_pValue = &Value; m_pbRc = &bRc; @@ -250,7 +241,6 @@ void CJS_EventHandler::OnField_Format(CPDF_FormField* pTarget, Initial(JET_FIELD_FORMAT); m_nCommitKey = 0; - ASSERT(pTarget != NULL); m_strTargetName = pTarget->GetFullName(); m_pValue = &Value; m_bWillCommit = bWillCommit; diff --git a/fpdfsdk/src/javascript/JS_GlobalData.cpp b/fpdfsdk/src/javascript/JS_GlobalData.cpp index d9a07a8507..474886c484 100644 --- a/fpdfsdk/src/javascript/JS_GlobalData.cpp +++ b/fpdfsdk/src/javascript/JS_GlobalData.cpp @@ -23,8 +23,6 @@ void CJS_GlobalVariableArray::Copy(const CJS_GlobalVariableArray& array) { Empty(); for (int i = 0, sz = array.Count(); i < sz; i++) { CJS_KeyValue* pOldObjData = array.GetAt(i); - ASSERT(pOldObjData != NULL); - switch (pOldObjData->nType) { case JS_GLOBALDATA_TYPE_NUMBER: { CJS_KeyValue* pNewObjData = new CJS_KeyValue; @@ -141,19 +139,15 @@ int CJS_GlobalData::FindGlobalVariable(const FX_CHAR* propname) { CJS_GlobalData_Element* CJS_GlobalData::GetGlobalVariable( const FX_CHAR* propname) { - ASSERT(propname != NULL); + ASSERT(propname); int nFind = FindGlobalVariable(propname); - if (nFind >= 0) - return m_arrayGlobalData.GetAt(nFind); - - return NULL; + return nFind >= 0 ? m_arrayGlobalData.GetAt(nFind) : nullptr; } void CJS_GlobalData::SetGlobalVariableNumber(const FX_CHAR* propname, double dData) { - ASSERT(propname != NULL); - + ASSERT(propname); CFX_ByteString sPropName = propname; sPropName.TrimLeft(); sPropName.TrimRight(); @@ -174,7 +168,7 @@ void CJS_GlobalData::SetGlobalVariableNumber(const FX_CHAR* propname, void CJS_GlobalData::SetGlobalVariableBoolean(const FX_CHAR* propname, bool bData) { - ASSERT(propname != NULL); + ASSERT(propname); CFX_ByteString sPropName = propname; sPropName.TrimLeft(); @@ -198,7 +192,7 @@ void CJS_GlobalData::SetGlobalVariableBoolean(const FX_CHAR* propname, void CJS_GlobalData::SetGlobalVariableString(const FX_CHAR* propname, const CFX_ByteString& sData) { - ASSERT(propname != NULL); + ASSERT(propname); CFX_ByteString sPropName = propname; sPropName.TrimLeft(); @@ -223,7 +217,7 @@ void CJS_GlobalData::SetGlobalVariableString(const FX_CHAR* propname, void CJS_GlobalData::SetGlobalVariableObject( const FX_CHAR* propname, const CJS_GlobalVariableArray& array) { - ASSERT(propname != NULL); + ASSERT(propname); CFX_ByteString sPropName = propname; sPropName.TrimLeft(); @@ -246,7 +240,7 @@ void CJS_GlobalData::SetGlobalVariableObject( } void CJS_GlobalData::SetGlobalVariableNull(const FX_CHAR* propname) { - ASSERT(propname != NULL); + ASSERT(propname); CFX_ByteString sPropName = propname; sPropName.TrimLeft(); @@ -268,7 +262,7 @@ void CJS_GlobalData::SetGlobalVariableNull(const FX_CHAR* propname) { FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent(const FX_CHAR* propname, FX_BOOL bPersistent) { - ASSERT(propname != NULL); + ASSERT(propname); CFX_ByteString sPropName = propname; sPropName.TrimLeft(); @@ -286,7 +280,7 @@ FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent(const FX_CHAR* propname, } FX_BOOL CJS_GlobalData::DeleteGlobalVariable(const FX_CHAR* propname) { - ASSERT(propname != NULL); + ASSERT(propname); CFX_ByteString sPropName = propname; sPropName.TrimLeft(); @@ -409,8 +403,6 @@ void CJS_GlobalData::SaveGlobalPersisitentVariables() { for (int i = 0, sz = m_arrayGlobalData.GetSize(); i < sz; i++) { CJS_GlobalData_Element* pElement = m_arrayGlobalData.GetAt(i); - ASSERT(pElement != NULL); - if (pElement->bPersistent) { CFX_BinaryBuf sElement; MakeByteString(pElement->data.sKey, &pElement->data, sElement); diff --git a/fpdfsdk/src/javascript/JS_Object.cpp b/fpdfsdk/src/javascript/JS_Object.cpp index 529b540237..058ec02925 100644 --- a/fpdfsdk/src/javascript/JS_Object.cpp +++ b/fpdfsdk/src/javascript/JS_Object.cpp @@ -86,8 +86,6 @@ int CJS_Object::MsgBox(CPDFDoc_Environment* pApp, } void CJS_Object::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg) { - ASSERT(pContext != NULL); - if (pContext->IsMsgBoxEnabled()) { CPDFDoc_Environment* pApp = pContext->GetReaderApp(); if (pApp) diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp index 094f3e7dd7..c2e15fb116 100644 --- a/fpdfsdk/src/javascript/PublicMethods.cpp +++ b/fpdfsdk/src/javascript/PublicMethods.cpp @@ -1096,9 +1096,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke( CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); if (params.size() < 2) return FALSE; @@ -1217,9 +1215,7 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format( CFX_WideString& sError) { #if _FX_OS_ != _FX_ANDROID_ CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); if (params.size() != 2) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); @@ -1319,9 +1315,7 @@ FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IJS_Context* cc, CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); if (params.size() != 1) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); @@ -1436,9 +1430,7 @@ FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx( CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); if (params.size() != 1) { sError = L"AFDate_KeystrokeEx's parameters' size r not correct"; @@ -1609,7 +1601,6 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Format( CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); if (params.size() != 1) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); @@ -1620,8 +1611,6 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Format( int iIndex = params[0].ToInt(); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); - if (!pEvent->m_pValue) return FALSE; CFX_WideString& Value = pEvent->Value(); @@ -1661,11 +1650,8 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx( CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); - if (params.size() < 1) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); return FALSE; @@ -1805,9 +1791,7 @@ FX_BOOL CJS_PublicMethods::AFMergeChange(IJS_Context* cc, CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEventHandler = pContext->GetEventHandler(); - ASSERT(pEventHandler != NULL); if (params.size() != 1) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); @@ -1847,7 +1831,7 @@ FX_BOOL CJS_PublicMethods::AFParseDateEx(IJS_Context* cc, CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); + ASSERT(pContext); if (params.size() != 2) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); @@ -1878,7 +1862,7 @@ FX_BOOL CJS_PublicMethods::AFSimple(IJS_Context* cc, CFX_WideString& sError) { if (params.size() != 3) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); + ASSERT(pContext); sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); return FALSE; @@ -1895,7 +1879,7 @@ FX_BOOL CJS_PublicMethods::AFMakeNumber(IJS_Context* cc, CFX_WideString& sError) { if (params.size() != 1) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); + ASSERT(pContext); sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); return FALSE; @@ -2011,9 +1995,7 @@ FX_BOOL CJS_PublicMethods::AFRange_Validate( CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); if (params.size() != 4) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp index cb1cc9b592..34b51310ce 100644 --- a/fpdfsdk/src/javascript/app.cpp +++ b/fpdfsdk/src/javascript/app.cpp @@ -129,7 +129,7 @@ FX_BOOL app::activeDocs(IJS_Context* cc, pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID); pJSDocument = (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); - ASSERT(pJSDocument != NULL); + ASSERT(pJSDocument); } aDocs.SetElement(0, CJS_Value(pRuntime, pJSDocument)); } @@ -450,9 +450,7 @@ FX_BOOL app::setTimeOut(IJS_Context* cc, } CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_Runtime* pRuntime = pContext->GetJSRuntime(); - ASSERT(pRuntime != NULL); CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString() : L""; if (script.IsEmpty()) { @@ -561,8 +559,6 @@ FX_BOOL app::execMenuItem(IJS_Context* cc, } void app::TimerProc(CJS_Timer* pTimer) { - ASSERT(pTimer != NULL); - CJS_Runtime* pRuntime = pTimer->GetRuntime(); switch (pTimer->GetType()) { @@ -804,10 +800,7 @@ FX_BOOL app::response(IJS_Context* cc, } CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); - CPDFDoc_Environment* pApp = pContext->GetReaderApp(); - ASSERT(pApp != NULL); const int MAX_INPUT_BYTES = 2048; nonstd::unique_ptr pBuff(new char[MAX_INPUT_BYTES + 2]); diff --git a/fpdfsdk/src/javascript/event.cpp b/fpdfsdk/src/javascript/event.cpp index 5ad1ca513f..2362c01287 100644 --- a/fpdfsdk/src/javascript/event.cpp +++ b/fpdfsdk/src/javascript/event.cpp @@ -56,10 +56,7 @@ FX_BOOL event::change(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); - CFX_WideString& wChange = pEvent->Change(); if (vp.IsSetting()) { if (vp.GetType() == CJS_Value::VT_string) @@ -77,9 +74,7 @@ FX_BOOL event::changeEx(IJS_Context* cc, return FALSE; CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); vp << pEvent->ChangeEx(); return TRUE; @@ -92,9 +87,7 @@ FX_BOOL event::commitKey(IJS_Context* cc, return FALSE; CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); vp << pEvent->CommitKey(); return TRUE; @@ -104,9 +97,7 @@ FX_BOOL event::fieldFull(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); if (!vp.IsGetting() && wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) @@ -126,9 +117,7 @@ FX_BOOL event::keyDown(IJS_Context* cc, return FALSE; CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); if (pEvent->KeyDown()) vp << TRUE; @@ -144,9 +133,7 @@ FX_BOOL event::modifier(IJS_Context* cc, return FALSE; CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); if (pEvent->Modifier()) vp << TRUE; @@ -162,9 +149,7 @@ FX_BOOL event::name(IJS_Context* cc, return FALSE; CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); vp << pEvent->Name(); return TRUE; @@ -172,9 +157,7 @@ FX_BOOL event::name(IJS_Context* cc, FX_BOOL event::rc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); FX_BOOL& bRc = pEvent->Rc(); if (vp.IsSetting()) { @@ -222,9 +205,7 @@ FX_BOOL event::selEnd(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) { return TRUE; @@ -243,9 +224,7 @@ FX_BOOL event::selStart(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) { return TRUE; @@ -266,9 +245,7 @@ FX_BOOL event::shift(IJS_Context* cc, return FALSE; CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); if (pEvent->Shift()) vp << TRUE; @@ -284,9 +261,7 @@ FX_BOOL event::source(IJS_Context* cc, return FALSE; CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); vp << pEvent->Source()->GetJSObject(); return TRUE; @@ -299,9 +274,7 @@ FX_BOOL event::target(IJS_Context* cc, return FALSE; CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); vp << pEvent->Target_Field()->GetJSObject(); return TRUE; @@ -314,9 +287,7 @@ FX_BOOL event::targetName(IJS_Context* cc, return FALSE; CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); vp << pEvent->TargetName(); return TRUE; @@ -329,9 +300,7 @@ FX_BOOL event::type(IJS_Context* cc, return FALSE; CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); vp << pEvent->Type(); return TRUE; @@ -341,9 +310,7 @@ FX_BOOL event::value(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0) return FALSE; @@ -365,9 +332,7 @@ FX_BOOL event::willCommit(IJS_Context* cc, return FALSE; CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); CJS_EventHandler* pEvent = pContext->GetEventHandler(); - ASSERT(pEvent != NULL); if (pEvent->WillCommit()) vp << TRUE; diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp index 2d9799dd4e..7a43b677e9 100644 --- a/fpdfsdk/src/javascript/global.cpp +++ b/fpdfsdk/src/javascript/global.cpp @@ -227,12 +227,8 @@ FX_BOOL JSGlobalAlternate::setPersistent(IJS_Context* cc, } void JSGlobalAlternate::UpdateGlobalPersistentVariables() { - ASSERT(m_pGlobalData != NULL); - for (int i = 0, sz = m_pGlobalData->GetSize(); i < sz; i++) { CJS_GlobalData_Element* pData = m_pGlobalData->GetAt(i); - ASSERT(pData != NULL); - switch (pData->data.nType) { case JS_GLOBALDATA_TYPE_NUMBER: SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NUMBER, @@ -380,12 +376,8 @@ void JSGlobalAlternate::ObjectToArray(IJS_Context* cc, void JSGlobalAlternate::PutObjectProperty(v8::Local pObj, CJS_KeyValue* pData) { - ASSERT(pData != NULL); - for (int i = 0, sz = pData->objData.Count(); i < sz; i++) { CJS_KeyValue* pObjData = pData->objData.GetAt(i); - ASSERT(pObjData != NULL); - switch (pObjData->nType) { case JS_GLOBALDATA_TYPE_NUMBER: FXJS_PutObjectNumber(NULL, pObj, pObjData->sKey.UTF8Decode().c_str(), -- cgit v1.2.3