diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-10-09 13:14:47 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-10-09 13:14:47 -0700 |
commit | 848a13b6777cbff8cc4aea3ab3d69eaa0b82ae6c (patch) | |
tree | d2c3a5ee4f67227ac33199f6d10caaf204c92896 /fpdfsdk/src/fsdk_actionhandler.cpp | |
parent | f1c713663192368d26031a4caed1f9705f4510af (diff) | |
download | pdfium-848a13b6777cbff8cc4aea3ab3d69eaa0b82ae6c.tar.xz |
Pass IJS_Runtime, not IJS_Context, to native object constructors.
This better separates the two IJS_ classes, with the IJS_Context
taking on its proper role of describing an event. There's no need
for the event details for object creation, so this gets much
cleaner.
Move some JS error reporting code from CJS_Context to CJS_Runtime.
Make InitInstance() and ExitInstance() voids, they always return
TRUE and we never check the result anyways.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1389163007 .
Diffstat (limited to 'fpdfsdk/src/fsdk_actionhandler.cpp')
-rw-r--r-- | fpdfsdk/src/fsdk_actionhandler.cpp | 85 |
1 files changed, 12 insertions, 73 deletions
diff --git a/fpdfsdk/src/fsdk_actionhandler.cpp b/fpdfsdk/src/fsdk_actionhandler.cpp index 3d1a1571a1..874fcc7ff5 100644 --- a/fpdfsdk/src/fsdk_actionhandler.cpp +++ b/fpdfsdk/src/fsdk_actionhandler.cpp @@ -148,18 +148,14 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(const CPDF_Action& action, if (pEnv->IsJSInitiated()) { CFX_WideString swJS = action.GetJavaScript(); if (!swJS.IsEmpty()) { - IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); //???? - ASSERT(pRuntime != NULL); - + IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); pRuntime->SetReaderDocument(pDocument); IJS_Context* pContext = pRuntime->NewContext(); - ASSERT(pContext != NULL); - pContext->OnLink_MouseUp(pDocument); CFX_WideString csInfo; - FX_BOOL bRet = pContext->RunScript(swJS, csInfo); + FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); if (!bRet) { // FIXME: return error. } @@ -292,65 +288,13 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction( CFX_WideString swJS = action.GetJavaScript(); if (!swJS.IsEmpty()) { IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); - ASSERT(pRuntime != NULL); - pRuntime->SetReaderDocument(pDocument); IJS_Context* pContext = pRuntime->NewContext(); - ASSERT(pContext != NULL); - - // switch (type) - // { - // case CPDF_AAction::CursorEnter: - // pContext->OnScreen_MouseEnter(IsCTRLpressed(), - // IsSHIFTpressed(), pScreen); - // break; - // case CPDF_AAction::CursorExit: - // pContext->OnScreen_MouseExit(IsCTRLpressed(), - // IsSHIFTpressed(), pScreen); - // break; - // case CPDF_AAction::ButtonDown: - // pContext->OnScreen_MouseDown(IsCTRLpressed(), - // IsSHIFTpressed(), pScreen); - // break; - // case CPDF_AAction::ButtonUp: - // pContext->OnScreen_MouseUp(IsCTRLpressed(), - // IsSHIFTpressed(), pScreen); - // break; - // case CPDF_AAction::GetFocus: - // pContext->OnScreen_Focus(IsCTRLpressed(), - // IsSHIFTpressed(), pScreen); - // break; - // case CPDF_AAction::LoseFocus: - // pContext->OnScreen_Blur(IsCTRLpressed(), - // IsSHIFTpressed(), pScreen); - // break; - // case CPDF_AAction::PageOpen: - // pContext->OnScreen_Open(IsCTRLpressed(), - // IsSHIFTpressed(), pScreen); - // break; - // case CPDF_AAction::PageClose: - // pContext->OnScreen_Close(IsCTRLpressed(), - // IsSHIFTpressed(), pScreen); - // break; - // case CPDF_AAction::PageVisible: - // pContext->OnScreen_InView(IsCTRLpressed(), - // IsSHIFTpressed(), pScreen); - // break; - // case CPDF_AAction::PageInvisible: - // pContext->OnScreen_OutView(IsCTRLpressed(), - // IsSHIFTpressed(), pScreen); - // break; - // default: - // ASSERT(FALSE); - // break; - // } - CFX_WideString csInfo; - FX_BOOL bRet = pContext->RunScript(swJS, csInfo); + FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); if (!bRet) { - // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), - // csInfo); + // FIXME: return error. } pRuntime->ReleaseContext(pContext); @@ -388,20 +332,15 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark(const CPDF_Action& action, CFX_WideString swJS = action.GetJavaScript(); if (!swJS.IsEmpty()) { IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); - ASSERT(pRuntime != NULL); - pRuntime->SetReaderDocument(pDocument); IJS_Context* pContext = pRuntime->NewContext(); - ASSERT(pContext != NULL); - pContext->OnBookmark_MouseUp(pBookmark); CFX_WideString csInfo; - FX_BOOL bRet = pContext->RunScript(swJS, csInfo); + FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); if (!bRet) { - // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), - // csInfo); + // FIXME: return error. } pRuntime->ReleaseContext(pContext); @@ -601,9 +540,9 @@ void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument, } CFX_WideString csInfo; - FX_BOOL bRet = pContext->RunScript(script, csInfo); + FX_BOOL bRet = pContext->RunScript(script, &csInfo); if (!bRet) { - // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); + // FIXME: return error. } pRuntime->ReleaseContext(pContext); @@ -626,9 +565,9 @@ void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript( pContext->OnDoc_Open(pDocument, sScriptName); CFX_WideString csInfo; - FX_BOOL bRet = pContext->RunScript(script, csInfo); + FX_BOOL bRet = pContext->RunScript(script, &csInfo); if (!bRet) { - // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); + // FIXME: return error. } pRuntime->ReleaseContext(pContext); @@ -682,9 +621,9 @@ void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( } CFX_WideString csInfo; - FX_BOOL bRet = pContext->RunScript(script, csInfo); + FX_BOOL bRet = pContext->RunScript(script, &csInfo); if (!bRet) { - // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); + // FIXME: return error. } pRuntime->ReleaseContext(pContext); |