| OLD | NEW |
| 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 "../../../third_party/base/nonstd_unique_ptr.h" | 9 #include "../../../third_party/base/nonstd_unique_ptr.h" |
| 10 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. | 10 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. |
| 11 #include "../../include/javascript/IJavaScript.h" | 11 #include "../../include/javascript/IJavaScript.h" |
| 12 #include "Document.h" | 12 #include "Document.h" |
| 13 #include "JS_Context.h" | 13 #include "JS_Context.h" |
| 14 #include "JS_Define.h" | 14 #include "JS_Define.h" |
| 15 #include "JS_EventHandler.h" | 15 #include "JS_EventHandler.h" |
| 16 #include "JS_Object.h" | 16 #include "JS_Object.h" |
| 17 #include "JS_Runtime.h" | 17 #include "JS_Runtime.h" |
| 18 #include "JS_Value.h" | 18 #include "JS_Value.h" |
| 19 #include "resource.h" | 19 #include "resource.h" |
| 20 | 20 |
| 21 static v8::Isolate* GetIsolate(IJS_Context* cc) { | |
| 22 CJS_Context* pContext = (CJS_Context*)cc; | |
| 23 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
| 24 return pRuntime->GetIsolate(); | |
| 25 } | |
| 26 | |
| 27 BEGIN_JS_STATIC_CONST(CJS_TimerObj) | 21 BEGIN_JS_STATIC_CONST(CJS_TimerObj) |
| 28 END_JS_STATIC_CONST() | 22 END_JS_STATIC_CONST() |
| 29 | 23 |
| 30 BEGIN_JS_STATIC_PROP(CJS_TimerObj) | 24 BEGIN_JS_STATIC_PROP(CJS_TimerObj) |
| 31 END_JS_STATIC_PROP() | 25 END_JS_STATIC_PROP() |
| 32 | 26 |
| 33 BEGIN_JS_STATIC_METHOD(CJS_TimerObj) | 27 BEGIN_JS_STATIC_METHOD(CJS_TimerObj) |
| 34 END_JS_STATIC_METHOD() | 28 END_JS_STATIC_METHOD() |
| 35 | 29 |
| 36 IMPLEMENT_JS_CLASS(CJS_TimerObj, TimerObj) | 30 IMPLEMENT_JS_CLASS(CJS_TimerObj, TimerObj) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 FX_BOOL app::activeDocs(IJS_Context* cc, | 106 FX_BOOL app::activeDocs(IJS_Context* cc, |
| 113 CJS_PropValue& vp, | 107 CJS_PropValue& vp, |
| 114 CFX_WideString& sError) { | 108 CFX_WideString& sError) { |
| 115 if (!vp.IsGetting()) | 109 if (!vp.IsGetting()) |
| 116 return FALSE; | 110 return FALSE; |
| 117 | 111 |
| 118 CJS_Context* pContext = (CJS_Context*)cc; | 112 CJS_Context* pContext = (CJS_Context*)cc; |
| 119 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 113 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 120 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 114 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 121 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); | 115 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); |
| 122 CJS_Array aDocs(pRuntime->GetIsolate()); | 116 CJS_Array aDocs(pRuntime); |
| 123 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) { | 117 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) { |
| 124 CJS_Document* pJSDocument = NULL; | 118 CJS_Document* pJSDocument = NULL; |
| 125 if (pDoc == pCurDoc) { | 119 if (pDoc == pCurDoc) { |
| 126 v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate()); | 120 v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate()); |
| 127 if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) | 121 if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) |
| 128 pJSDocument = | 122 pJSDocument = |
| 129 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); | 123 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); |
| 130 } else { | 124 } else { |
| 131 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 125 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
| 132 pRuntime->GetIsolate(), pContext, CJS_Document::g_nObjDefnID); | 126 pRuntime->GetIsolate(), pContext, CJS_Document::g_nObjDefnID); |
| 133 pJSDocument = | 127 pJSDocument = |
| 134 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); | 128 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); |
| 135 ASSERT(pJSDocument != NULL); | 129 ASSERT(pJSDocument != NULL); |
| 136 } | 130 } |
| 137 aDocs.SetElement(0, CJS_Value(pRuntime->GetIsolate(), pJSDocument)); | 131 aDocs.SetElement(0, CJS_Value(pRuntime, pJSDocument)); |
| 138 } | 132 } |
| 139 if (aDocs.GetLength() > 0) | 133 if (aDocs.GetLength() > 0) |
| 140 vp << aDocs; | 134 vp << aDocs; |
| 141 else | 135 else |
| 142 vp.SetNull(); | 136 vp.SetNull(); |
| 143 | 137 |
| 144 return TRUE; | 138 return TRUE; |
| 145 } | 139 } |
| 146 | 140 |
| 147 FX_BOOL app::calculate(IJS_Context* cc, | 141 FX_BOOL app::calculate(IJS_Context* cc, |
| 148 CJS_PropValue& vp, | 142 CJS_PropValue& vp, |
| 149 CFX_WideString& sError) { | 143 CFX_WideString& sError) { |
| 150 if (vp.IsSetting()) { | 144 if (vp.IsSetting()) { |
| 151 bool bVP; | 145 bool bVP; |
| 152 vp >> bVP; | 146 vp >> bVP; |
| 153 m_bCalculate = (FX_BOOL)bVP; | 147 m_bCalculate = (FX_BOOL)bVP; |
| 154 | 148 |
| 155 CJS_Context* pContext = (CJS_Context*)cc; | 149 CJS_Context* pContext = (CJS_Context*)cc; |
| 156 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 150 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 157 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 151 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 158 CJS_Array aDocs(pRuntime->GetIsolate()); | 152 CJS_Array aDocs(pRuntime); |
| 159 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) | 153 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) |
| 160 pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalculate); | 154 pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalculate); |
| 161 } else { | 155 } else { |
| 162 vp << (bool)m_bCalculate; | 156 vp << (bool)m_bCalculate; |
| 163 } | 157 } |
| 164 return TRUE; | 158 return TRUE; |
| 165 } | 159 } |
| 166 | 160 |
| 167 FX_BOOL app::formsVersion(IJS_Context* cc, | 161 FX_BOOL app::formsVersion(IJS_Context* cc, |
| 168 CJS_PropValue& vp, | 162 CJS_PropValue& vp, |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 CFX_WideString& sError) { | 253 CFX_WideString& sError) { |
| 260 int iSize = params.size(); | 254 int iSize = params.size(); |
| 261 if (iSize < 1) | 255 if (iSize < 1) |
| 262 return FALSE; | 256 return FALSE; |
| 263 | 257 |
| 264 CFX_WideString swMsg = L""; | 258 CFX_WideString swMsg = L""; |
| 265 CFX_WideString swTitle = L""; | 259 CFX_WideString swTitle = L""; |
| 266 int iIcon = 0; | 260 int iIcon = 0; |
| 267 int iType = 0; | 261 int iType = 0; |
| 268 | 262 |
| 269 v8::Isolate* isolate = GetIsolate(cc); | 263 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 264 v8::Isolate* isolate = pRuntime->GetIsolate(); |
| 270 | 265 |
| 271 if (iSize == 1) { | 266 if (iSize == 1) { |
| 272 if (params[0].GetType() == CJS_Value::VT_object) { | 267 if (params[0].GetType() == CJS_Value::VT_object) { |
| 273 v8::Local<v8::Object> pObj = params[0].ToV8Object(); | 268 v8::Local<v8::Object> pObj = params[0].ToV8Object(); |
| 274 { | 269 { |
| 275 v8::Local<v8::Value> pValue = | 270 v8::Local<v8::Value> pValue = |
| 276 FXJS_GetObjectElement(isolate, pObj, L"cMsg"); | 271 FXJS_GetObjectElement(isolate, pObj, L"cMsg"); |
| 277 swMsg = | 272 swMsg = CJS_Value(pRuntime, pValue, CJS_Value::VT_unknown) |
| 278 CJS_Value(isolate, pValue, CJS_Value::VT_unknown).ToCFXWideString(); | 273 .ToCFXWideString(); |
| 279 | 274 |
| 280 pValue = FXJS_GetObjectElement(isolate, pObj, L"cTitle"); | 275 pValue = FXJS_GetObjectElement(isolate, pObj, L"cTitle"); |
| 281 swTitle = | 276 swTitle = CJS_Value(pRuntime, pValue, CJS_Value::VT_unknown) |
| 282 CJS_Value(isolate, pValue, CJS_Value::VT_unknown).ToCFXWideString(); | 277 .ToCFXWideString(); |
| 283 | 278 |
| 284 pValue = FXJS_GetObjectElement(isolate, pObj, L"nIcon"); | 279 pValue = FXJS_GetObjectElement(isolate, pObj, L"nIcon"); |
| 285 iIcon = CJS_Value(isolate, pValue, CJS_Value::VT_unknown).ToInt(); | 280 iIcon = CJS_Value(pRuntime, pValue, CJS_Value::VT_unknown).ToInt(); |
| 286 | 281 |
| 287 pValue = FXJS_GetObjectElement(isolate, pObj, L"nType"); | 282 pValue = FXJS_GetObjectElement(isolate, pObj, L"nType"); |
| 288 iType = CJS_Value(isolate, pValue, CJS_Value::VT_unknown).ToInt(); | 283 iType = CJS_Value(pRuntime, pValue, CJS_Value::VT_unknown).ToInt(); |
| 289 } | 284 } |
| 290 | 285 |
| 291 if (swMsg == L"") { | 286 if (swMsg == L"") { |
| 292 CJS_Array carray(isolate); | 287 CJS_Array carray(pRuntime); |
| 293 if (params[0].ConvertToArray(carray)) { | 288 if (params[0].ConvertToArray(carray)) { |
| 294 int iLength = carray.GetLength(); | 289 int iLength = carray.GetLength(); |
| 295 CJS_Value* pValue = new CJS_Value(isolate); | 290 CJS_Value* pValue = new CJS_Value(pRuntime); |
| 296 for (int i = 0; i < iLength; ++i) { | 291 for (int i = 0; i < iLength; ++i) { |
| 297 carray.GetElement(i, *pValue); | 292 carray.GetElement(i, *pValue); |
| 298 swMsg += (*pValue).ToCFXWideString(); | 293 swMsg += (*pValue).ToCFXWideString(); |
| 299 if (i < iLength - 1) | 294 if (i < iLength - 1) |
| 300 swMsg += L", "; | 295 swMsg += L", "; |
| 301 } | 296 } |
| 302 | 297 |
| 303 delete pValue; | 298 delete pValue; |
| 304 } | 299 } |
| 305 } | 300 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 333 for (int i = 1; i < iSize; i++) { | 328 for (int i = 1; i < iSize; i++) { |
| 334 if (i == 1) | 329 if (i == 1) |
| 335 iIcon = params[i].ToInt(); | 330 iIcon = params[i].ToInt(); |
| 336 if (i == 2) | 331 if (i == 2) |
| 337 iType = params[i].ToInt(); | 332 iType = params[i].ToInt(); |
| 338 if (i == 3) | 333 if (i == 3) |
| 339 swTitle = params[i].ToCFXWideString(); | 334 swTitle = params[i].ToCFXWideString(); |
| 340 } | 335 } |
| 341 } | 336 } |
| 342 | 337 |
| 343 CJS_Context* pContext = (CJS_Context*)cc; | |
| 344 ASSERT(pContext != NULL); | |
| 345 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
| 346 ASSERT(pRuntime != NULL); | |
| 347 pRuntime->BeginBlock(); | 338 pRuntime->BeginBlock(); |
| 348 vRet = MsgBox(pRuntime->GetReaderApp(), swMsg.c_str(), swTitle.c_str(), iType, | 339 vRet = MsgBox(pRuntime->GetReaderApp(), swMsg.c_str(), swTitle.c_str(), iType, |
| 349 iIcon); | 340 iIcon); |
| 350 pRuntime->EndBlock(); | 341 pRuntime->EndBlock(); |
| 351 | |
| 352 return TRUE; | 342 return TRUE; |
| 353 } | 343 } |
| 354 | 344 |
| 355 FX_BOOL app::beep(IJS_Context* cc, | 345 FX_BOOL app::beep(IJS_Context* cc, |
| 356 const CJS_Parameters& params, | 346 const CJS_Parameters& params, |
| 357 CJS_Value& vRet, | 347 CJS_Value& vRet, |
| 358 CFX_WideString& sError) { | 348 CFX_WideString& sError) { |
| 359 if (params.size() == 1) { | 349 if (params.size() == 1) { |
| 360 CJS_Context* pContext = (CJS_Context*)cc; | 350 CJS_Context* pContext = (CJS_Context*)cc; |
| 361 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 351 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 CJS_Value& vRet, | 578 CJS_Value& vRet, |
| 589 CFX_WideString& sError) { | 579 CFX_WideString& sError) { |
| 590 // Not supported. | 580 // Not supported. |
| 591 return TRUE; | 581 return TRUE; |
| 592 } | 582 } |
| 593 | 583 |
| 594 FX_BOOL app::mailMsg(IJS_Context* cc, | 584 FX_BOOL app::mailMsg(IJS_Context* cc, |
| 595 const CJS_Parameters& params, | 585 const CJS_Parameters& params, |
| 596 CJS_Value& vRet, | 586 CJS_Value& vRet, |
| 597 CFX_WideString& sError) { | 587 CFX_WideString& sError) { |
| 598 CJS_Context* pContext = (CJS_Context*)cc; | 588 if (params.size() < 1) |
| 599 v8::Isolate* isolate = GetIsolate(cc); | 589 return FALSE; |
| 600 | 590 |
| 601 FX_BOOL bUI = TRUE; | 591 FX_BOOL bUI = TRUE; |
| 602 CFX_WideString cTo = L""; | 592 CFX_WideString cTo = L""; |
| 603 CFX_WideString cCc = L""; | 593 CFX_WideString cCc = L""; |
| 604 CFX_WideString cBcc = L""; | 594 CFX_WideString cBcc = L""; |
| 605 CFX_WideString cSubject = L""; | 595 CFX_WideString cSubject = L""; |
| 606 CFX_WideString cMsg = L""; | 596 CFX_WideString cMsg = L""; |
| 607 | 597 |
| 608 if (params.size() < 1) | 598 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 609 return FALSE; | 599 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 600 v8::Isolate* isolate = pRuntime->GetIsolate(); |
| 610 | 601 |
| 611 if (params[0].GetType() == CJS_Value::VT_object) { | 602 if (params[0].GetType() == CJS_Value::VT_object) { |
| 612 v8::Local<v8::Object> pObj = params[0].ToV8Object(); | 603 v8::Local<v8::Object> pObj = params[0].ToV8Object(); |
| 613 | 604 |
| 614 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"bUI"); | 605 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"bUI"); |
| 615 bUI = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); | 606 bUI = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToBool(); |
| 616 | 607 |
| 617 pValue = FXJS_GetObjectElement(isolate, pObj, L"cTo"); | 608 pValue = FXJS_GetObjectElement(isolate, pObj, L"cTo"); |
| 618 cTo = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 609 cTo = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
| 619 | 610 |
| 620 pValue = FXJS_GetObjectElement(isolate, pObj, L"cCc"); | 611 pValue = FXJS_GetObjectElement(isolate, pObj, L"cCc"); |
| 621 cCc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 612 cCc = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
| 622 | 613 |
| 623 pValue = FXJS_GetObjectElement(isolate, pObj, L"cBcc"); | 614 pValue = FXJS_GetObjectElement(isolate, pObj, L"cBcc"); |
| 624 cBcc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 615 cBcc = |
| 616 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
| 625 | 617 |
| 626 pValue = FXJS_GetObjectElement(isolate, pObj, L"cSubject"); | 618 pValue = FXJS_GetObjectElement(isolate, pObj, L"cSubject"); |
| 627 cSubject = | 619 cSubject = |
| 628 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 620 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
| 629 | 621 |
| 630 pValue = FXJS_GetObjectElement(isolate, pObj, L"cMsg"); | 622 pValue = FXJS_GetObjectElement(isolate, pObj, L"cMsg"); |
| 631 cMsg = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 623 cMsg = |
| 624 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
| 632 } else { | 625 } else { |
| 633 if (params.size() < 2) | 626 if (params.size() < 2) |
| 634 return FALSE; | 627 return FALSE; |
| 635 | 628 |
| 636 bUI = params[0].ToBool(); | 629 bUI = params[0].ToBool(); |
| 637 cTo = params[1].ToCFXWideString(); | 630 cTo = params[1].ToCFXWideString(); |
| 638 | 631 |
| 639 if (params.size() >= 3) | 632 if (params.size() >= 3) |
| 640 cCc = params[2].ToCFXWideString(); | 633 cCc = params[2].ToCFXWideString(); |
| 641 if (params.size() >= 4) | 634 if (params.size() >= 4) |
| 642 cBcc = params[3].ToCFXWideString(); | 635 cBcc = params[3].ToCFXWideString(); |
| 643 if (params.size() >= 5) | 636 if (params.size() >= 5) |
| 644 cSubject = params[4].ToCFXWideString(); | 637 cSubject = params[4].ToCFXWideString(); |
| 645 if (params.size() >= 6) | 638 if (params.size() >= 6) |
| 646 cMsg = params[5].ToCFXWideString(); | 639 cMsg = params[5].ToCFXWideString(); |
| 647 } | 640 } |
| 648 | 641 |
| 649 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
| 650 ASSERT(pRuntime != NULL); | |
| 651 | |
| 652 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | |
| 653 ASSERT(pApp != NULL); | |
| 654 | |
| 655 pRuntime->BeginBlock(); | 642 pRuntime->BeginBlock(); |
| 656 pApp->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), | 643 pContext->GetReaderApp()->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), |
| 657 cBcc.c_str(), cMsg.c_str()); | 644 cSubject.c_str(), cCc.c_str(), |
| 645 cBcc.c_str(), cMsg.c_str()); |
| 658 pRuntime->EndBlock(); | 646 pRuntime->EndBlock(); |
| 659 | 647 |
| 660 return FALSE; | 648 return FALSE; |
| 661 } | 649 } |
| 662 | 650 |
| 663 FX_BOOL app::launchURL(IJS_Context* cc, | 651 FX_BOOL app::launchURL(IJS_Context* cc, |
| 664 const CJS_Parameters& params, | 652 const CJS_Parameters& params, |
| 665 CJS_Value& vRet, | 653 CJS_Value& vRet, |
| 666 CFX_WideString& sError) { | 654 CFX_WideString& sError) { |
| 667 // Unsafe, not supported. | 655 // Unsafe, not supported. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 FX_BOOL app::response(IJS_Context* cc, | 724 FX_BOOL app::response(IJS_Context* cc, |
| 737 const CJS_Parameters& params, | 725 const CJS_Parameters& params, |
| 738 CJS_Value& vRet, | 726 CJS_Value& vRet, |
| 739 CFX_WideString& sError) { | 727 CFX_WideString& sError) { |
| 740 CFX_WideString swQuestion = L""; | 728 CFX_WideString swQuestion = L""; |
| 741 CFX_WideString swLabel = L""; | 729 CFX_WideString swLabel = L""; |
| 742 CFX_WideString swTitle = L"PDF"; | 730 CFX_WideString swTitle = L"PDF"; |
| 743 CFX_WideString swDefault = L""; | 731 CFX_WideString swDefault = L""; |
| 744 bool bPassWord = false; | 732 bool bPassWord = false; |
| 745 | 733 |
| 746 v8::Isolate* isolate = GetIsolate(cc); | 734 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 735 v8::Isolate* isolate = pRuntime->GetIsolate(); |
| 747 | 736 |
| 748 int iLength = params.size(); | 737 int iLength = params.size(); |
| 749 if (iLength > 0 && params[0].GetType() == CJS_Value::VT_object) { | 738 if (iLength > 0 && params[0].GetType() == CJS_Value::VT_object) { |
| 750 v8::Local<v8::Object> pObj = params[0].ToV8Object(); | 739 v8::Local<v8::Object> pObj = params[0].ToV8Object(); |
| 751 v8::Local<v8::Value> pValue = | 740 v8::Local<v8::Value> pValue = |
| 752 FXJS_GetObjectElement(isolate, pObj, L"cQuestion"); | 741 FXJS_GetObjectElement(isolate, pObj, L"cQuestion"); |
| 753 swQuestion = | 742 swQuestion = |
| 754 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 743 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
| 755 | 744 |
| 756 pValue = FXJS_GetObjectElement(isolate, pObj, L"cTitle"); | 745 pValue = FXJS_GetObjectElement(isolate, pObj, L"cTitle"); |
| 757 swTitle = | 746 swTitle = |
| 758 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 747 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
| 759 | 748 |
| 760 pValue = FXJS_GetObjectElement(isolate, pObj, L"cDefault"); | 749 pValue = FXJS_GetObjectElement(isolate, pObj, L"cDefault"); |
| 761 swDefault = | 750 swDefault = |
| 762 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 751 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
| 763 | 752 |
| 764 pValue = FXJS_GetObjectElement(isolate, pObj, L"cLabel"); | 753 pValue = FXJS_GetObjectElement(isolate, pObj, L"cLabel"); |
| 765 swLabel = | 754 swLabel = |
| 766 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 755 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
| 767 | 756 |
| 768 pValue = FXJS_GetObjectElement(isolate, pObj, L"bPassword"); | 757 pValue = FXJS_GetObjectElement(isolate, pObj, L"bPassword"); |
| 769 bPassWord = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); | 758 bPassWord = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToBool(); |
| 770 } else { | 759 } else { |
| 771 switch (iLength) { | 760 switch (iLength) { |
| 772 case 5: | 761 case 5: |
| 773 swLabel = params[4].ToCFXWideString(); | 762 swLabel = params[4].ToCFXWideString(); |
| 774 // FALLTHROUGH | 763 // FALLTHROUGH |
| 775 case 4: | 764 case 4: |
| 776 bPassWord = params[3].ToBool(); | 765 bPassWord = params[3].ToBool(); |
| 777 // FALLTHROUGH | 766 // FALLTHROUGH |
| 778 case 3: | 767 case 3: |
| 779 swDefault = params[2].ToCFXWideString(); | 768 swDefault = params[2].ToCFXWideString(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { | 805 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
| 817 return FALSE; | 806 return FALSE; |
| 818 } | 807 } |
| 819 | 808 |
| 820 FX_BOOL app::execDialog(IJS_Context* cc, | 809 FX_BOOL app::execDialog(IJS_Context* cc, |
| 821 const CJS_Parameters& params, | 810 const CJS_Parameters& params, |
| 822 CJS_Value& vRet, | 811 CJS_Value& vRet, |
| 823 CFX_WideString& sError) { | 812 CFX_WideString& sError) { |
| 824 return TRUE; | 813 return TRUE; |
| 825 } | 814 } |
| OLD | NEW |