| 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 "../../include/javascript/IJavaScript.h" | 7 #include "../../include/javascript/IJavaScript.h" |
| 8 #include "../../include/javascript/JS_Context.h" | 8 #include "../../include/javascript/JS_Context.h" |
| 9 #include "../../include/javascript/JS_EventHandler.h" | 9 #include "../../include/javascript/JS_EventHandler.h" |
| 10 #include "../../include/javascript/JS_Runtime.h" | 10 #include "../../include/javascript/JS_Runtime.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 v8::Local<v8::Context> context = m_pRuntime->NewJSContext(); | 40 v8::Local<v8::Context> context = m_pRuntime->NewJSContext(); |
| 41 v8::Context::Scope context_scope(context); | 41 v8::Context::Scope context_scope(context); |
| 42 | 42 |
| 43 if (m_bBusy) { | 43 if (m_bBusy) { |
| 44 info = JSGetStringFromID(this, IDS_STRING_JSBUSY); | 44 info = JSGetStringFromID(this, IDS_STRING_JSBUSY); |
| 45 return FALSE; | 45 return FALSE; |
| 46 } | 46 } |
| 47 m_bBusy = TRUE; | 47 m_bBusy = TRUE; |
| 48 | 48 |
| 49 ASSERT(m_pEventHandler->IsValid()); | 49 ASSERT(m_pEventHandler->IsValid()); |
| 50 if (!m_pRuntime->AddEventToLoop(m_pEventHandler->TargetName(), | 50 CJS_Runtime::FieldEvent event(m_pEventHandler->TargetName(), |
| 51 m_pEventHandler->EventType())) { | 51 m_pEventHandler->EventType()); |
| 52 if (!m_pRuntime->AddEventToSet(event)) { |
| 52 info = JSGetStringFromID(this, IDS_STRING_JSEVENT); | 53 info = JSGetStringFromID(this, IDS_STRING_JSEVENT); |
| 53 return FALSE; | 54 return FALSE; |
| 54 } | 55 } |
| 55 | 56 |
| 56 FXJSErr error = {NULL, NULL, 0}; | 57 FXJSErr error = {NULL, NULL, 0}; |
| 57 int nRet = 0; | 58 int nRet = 0; |
| 58 if (script.GetLength() > 0) { | 59 if (script.GetLength() > 0) { |
| 59 nRet = FXJS_Execute(m_pRuntime->GetIsolate(), this, script.c_str(), | 60 nRet = FXJS_Execute(m_pRuntime->GetIsolate(), this, script.c_str(), |
| 60 script.GetLength(), &error); | 61 script.GetLength(), &error); |
| 61 } | 62 } |
| 62 | 63 |
| 63 if (nRet < 0) { | 64 if (nRet < 0) { |
| 64 CFX_WideString sLine; | 65 CFX_WideString sLine; |
| 65 sLine.Format(L"[ Line: %05d { %s } ] : %s", error.linnum - 1, error.srcline, | 66 sLine.Format(L"[ Line: %05d { %s } ] : %s", error.linnum - 1, error.srcline, |
| 66 error.message); | 67 error.message); |
| 67 info += sLine; | 68 info += sLine; |
| 68 } else { | 69 } else { |
| 69 info = JSGetStringFromID(this, IDS_STRING_RUN); | 70 info = JSGetStringFromID(this, IDS_STRING_RUN); |
| 70 } | 71 } |
| 71 | 72 |
| 72 m_pRuntime->RemoveEventInLoop(m_pEventHandler->TargetName(), | 73 m_pRuntime->RemoveEventFromSet(event); |
| 73 m_pEventHandler->EventType()); | |
| 74 | |
| 75 m_pEventHandler->Destroy(); | 74 m_pEventHandler->Destroy(); |
| 76 m_bBusy = FALSE; | 75 m_bBusy = FALSE; |
| 77 | 76 |
| 78 return nRet >= 0; | 77 return nRet >= 0; |
| 79 } | 78 } |
| 80 | 79 |
| 81 void CJS_Context::OnApp_Init() { | 80 void CJS_Context::OnApp_Init() { |
| 82 m_pEventHandler->OnApp_Init(); | 81 m_pEventHandler->OnApp_Init(); |
| 83 } | 82 } |
| 84 | 83 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 } | 279 } |
| 281 | 280 |
| 282 void CJS_Context::OnBatchExec(CPDFSDK_Document* pTarget) { | 281 void CJS_Context::OnBatchExec(CPDFSDK_Document* pTarget) { |
| 283 m_pEventHandler->OnBatchExec(pTarget); | 282 m_pEventHandler->OnBatchExec(pTarget); |
| 284 } | 283 } |
| 285 | 284 |
| 286 void CJS_Context::OnMenu_Exec(CPDFSDK_Document* pTarget, | 285 void CJS_Context::OnMenu_Exec(CPDFSDK_Document* pTarget, |
| 287 const CFX_WideString& strTargetName) { | 286 const CFX_WideString& strTargetName) { |
| 288 m_pEventHandler->OnMenu_Exec(pTarget, strTargetName); | 287 m_pEventHandler->OnMenu_Exec(pTarget, strTargetName); |
| 289 } | 288 } |
| OLD | NEW |