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

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

Issue 1327473002: Fix two issues shown by bug 489995 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Add test for addIcon() Created 5 years, 3 months 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
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 "../../include/javascript/JavaScript.h" 7 #include "../../include/javascript/JavaScript.h"
8 #include "../../include/javascript/IJavaScript.h" 8 #include "../../include/javascript/IJavaScript.h"
9 #include "../../include/javascript/JS_Define.h" 9 #include "../../include/javascript/JS_Define.h"
10 #include "../../include/javascript/JS_Object.h" 10 #include "../../include/javascript/JS_Object.h"
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 1360
1361 FX_BOOL Document::addIcon(IFXJS_Context* cc, 1361 FX_BOOL Document::addIcon(IFXJS_Context* cc,
1362 const CJS_Parameters& params, 1362 const CJS_Parameters& params,
1363 CJS_Value& vRet, 1363 CJS_Value& vRet,
1364 CFX_WideString& sError) { 1364 CFX_WideString& sError) {
1365 CJS_Context* pContext = (CJS_Context*)cc; 1365 CJS_Context* pContext = (CJS_Context*)cc;
1366 if (params.size() != 2) { 1366 if (params.size() != 2) {
1367 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1367 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1368 return FALSE; 1368 return FALSE;
1369 } 1369 }
1370 CFX_WideString swIconName = params[0].ToCFXWideString();
1370 1371
1371 CFX_WideString swIconName = params[0].ToCFXWideString(); 1372 if (params[1].GetType() != VT_object) {
1373 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
1374 return FALSE;
1375 }
1372 JSFXObject pJSIcon = params[1].ToV8Object(); 1376 JSFXObject pJSIcon = params[1].ToV8Object();
1373 1377
1374 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 1378 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
1375 if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) { 1379 if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) {
1376 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); 1380 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
1377 return FALSE; 1381 return FALSE;
1378 } 1382 }
1379 1383
1380 CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject(); 1384 CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject();
1381 if (!pEmbedObj) { 1385 if (!pEmbedObj) {
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 CFX_DWordArray DelArray; 1848 CFX_DWordArray DelArray;
1845 1849
1846 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { 1850 for (int j = DelArray.GetSize() - 1; j >= 0; j--) {
1847 m_DelayData.RemoveAt(DelArray[j]); 1851 m_DelayData.RemoveAt(DelArray[j]);
1848 } 1852 }
1849 } 1853 }
1850 1854
1851 CJS_Document* Document::GetCJSDoc() const { 1855 CJS_Document* Document::GetCJSDoc() const {
1852 return static_cast<CJS_Document*>(m_pJSObject); 1856 return static_cast<CJS_Document*>(m_pJSObject);
1853 } 1857 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp ('k') | testing/resources/javascript/document_methods.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698