Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(736)

Side by Side Diff: fpdfsdk/src/javascript/app.cpp

Issue 1512763013: Get rid of most instance of 'foo != NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/javascript/PublicMethods.cpp ('k') | fpdfsdk/src/javascript/event.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "app.h" 7 #include "app.h"
8 8
9 #include "Document.h" 9 #include "Document.h"
10 #include "JS_Context.h" 10 #include "JS_Context.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if (pDoc == pCurDoc) { 119 if (pDoc == pCurDoc) {
120 v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate()); 120 v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate());
121 if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) 121 if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID)
122 pJSDocument = 122 pJSDocument =
123 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); 123 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
124 } else { 124 } else {
125 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( 125 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
126 pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID); 126 pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID);
127 pJSDocument = 127 pJSDocument =
128 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); 128 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
129 ASSERT(pJSDocument != NULL); 129 ASSERT(pJSDocument);
130 } 130 }
131 aDocs.SetElement(0, CJS_Value(pRuntime, pJSDocument)); 131 aDocs.SetElement(0, CJS_Value(pRuntime, pJSDocument));
132 } 132 }
133 if (aDocs.GetLength() > 0) 133 if (aDocs.GetLength() > 0)
134 vp << aDocs; 134 vp << aDocs;
135 else 135 else
136 vp.SetNull(); 136 vp.SetNull();
137 137
138 return TRUE; 138 return TRUE;
139 } 139 }
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 FX_BOOL app::setTimeOut(IJS_Context* cc, 409 FX_BOOL app::setTimeOut(IJS_Context* cc,
410 const std::vector<CJS_Value>& params, 410 const std::vector<CJS_Value>& params,
411 CJS_Value& vRet, 411 CJS_Value& vRet,
412 CFX_WideString& sError) { 412 CFX_WideString& sError) {
413 if (params.size() > 2 || params.size() == 0) { 413 if (params.size() > 2 || params.size() == 0) {
414 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); 414 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR);
415 return FALSE; 415 return FALSE;
416 } 416 }
417 417
418 CJS_Context* pContext = (CJS_Context*)cc; 418 CJS_Context* pContext = (CJS_Context*)cc;
419 ASSERT(pContext != NULL);
420 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 419 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
421 ASSERT(pRuntime != NULL);
422 420
423 CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString() : L""; 421 CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString() : L"";
424 if (script.IsEmpty()) { 422 if (script.IsEmpty()) {
425 sError = 423 sError =
426 JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMBER_KEYSTROKE); 424 JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMBER_KEYSTROKE);
427 return TRUE; 425 return TRUE;
428 } 426 }
429 427
430 FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000; 428 FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000;
431 429
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } 518 }
521 519
522 FX_BOOL app::execMenuItem(IJS_Context* cc, 520 FX_BOOL app::execMenuItem(IJS_Context* cc,
523 const std::vector<CJS_Value>& params, 521 const std::vector<CJS_Value>& params,
524 CJS_Value& vRet, 522 CJS_Value& vRet,
525 CFX_WideString& sError) { 523 CFX_WideString& sError) {
526 return FALSE; 524 return FALSE;
527 } 525 }
528 526
529 void app::TimerProc(CJS_Timer* pTimer) { 527 void app::TimerProc(CJS_Timer* pTimer) {
530 ASSERT(pTimer != NULL);
531
532 CJS_Runtime* pRuntime = pTimer->GetRuntime(); 528 CJS_Runtime* pRuntime = pTimer->GetRuntime();
533 529
534 switch (pTimer->GetType()) { 530 switch (pTimer->GetType()) {
535 case 0: // interval 531 case 0: // interval
536 if (pRuntime) 532 if (pRuntime)
537 RunJsScript(pRuntime, pTimer->GetJScript()); 533 RunJsScript(pRuntime, pTimer->GetJScript());
538 break; 534 break;
539 case 1: 535 case 1:
540 if (pTimer->GetTimeOut() > 0) { 536 if (pTimer->GetTimeOut() > 0) {
541 if (pRuntime) 537 if (pRuntime)
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 // FALLTHROUGH 759 // FALLTHROUGH
764 case 1: 760 case 1:
765 swQuestion = params[0].ToCFXWideString(); 761 swQuestion = params[0].ToCFXWideString();
766 // FALLTHROUGH 762 // FALLTHROUGH
767 default: 763 default:
768 break; 764 break;
769 } 765 }
770 } 766 }
771 767
772 CJS_Context* pContext = (CJS_Context*)cc; 768 CJS_Context* pContext = (CJS_Context*)cc;
773 ASSERT(pContext != NULL);
774
775 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); 769 CPDFDoc_Environment* pApp = pContext->GetReaderApp();
776 ASSERT(pApp != NULL);
777 770
778 const int MAX_INPUT_BYTES = 2048; 771 const int MAX_INPUT_BYTES = 2048;
779 nonstd::unique_ptr<char[]> pBuff(new char[MAX_INPUT_BYTES + 2]); 772 nonstd::unique_ptr<char[]> pBuff(new char[MAX_INPUT_BYTES + 2]);
780 memset(pBuff.get(), 0, MAX_INPUT_BYTES + 2); 773 memset(pBuff.get(), 0, MAX_INPUT_BYTES + 2);
781 int nLengthBytes = pApp->JS_appResponse( 774 int nLengthBytes = pApp->JS_appResponse(
782 swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), swLabel.c_str(), 775 swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), swLabel.c_str(),
783 bPassWord, pBuff.get(), MAX_INPUT_BYTES); 776 bPassWord, pBuff.get(), MAX_INPUT_BYTES);
784 if (nLengthBytes <= 0) { 777 if (nLengthBytes <= 0) {
785 vRet.SetNull(); 778 vRet.SetNull();
786 return FALSE; 779 return FALSE;
787 } 780 }
788 nLengthBytes = std::min(nLengthBytes, MAX_INPUT_BYTES); 781 nLengthBytes = std::min(nLengthBytes, MAX_INPUT_BYTES);
789 782
790 CFX_WideString ret_string = CFX_WideString::FromUTF16LE( 783 CFX_WideString ret_string = CFX_WideString::FromUTF16LE(
791 (unsigned short*)pBuff.get(), nLengthBytes / sizeof(unsigned short)); 784 (unsigned short*)pBuff.get(), nLengthBytes / sizeof(unsigned short));
792 vRet = ret_string.c_str(); 785 vRet = ret_string.c_str();
793 return TRUE; 786 return TRUE;
794 } 787 }
795 788
796 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { 789 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
797 return FALSE; 790 return FALSE;
798 } 791 }
799 792
800 FX_BOOL app::execDialog(IJS_Context* cc, 793 FX_BOOL app::execDialog(IJS_Context* cc,
801 const std::vector<CJS_Value>& params, 794 const std::vector<CJS_Value>& params,
802 CJS_Value& vRet, 795 CJS_Value& vRet,
803 CFX_WideString& sError) { 796 CFX_WideString& sError) {
804 return TRUE; 797 return TRUE;
805 } 798 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/PublicMethods.cpp ('k') | fpdfsdk/src/javascript/event.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698