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

Unified Diff: fpdfsdk/src/javascript/JS_Object.cpp

Issue 1244503002: Merge to XFA: Tidy up CPDFDOC_Environment. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Address comments, also remove two noisy unused var. Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/src/fsdk_mgr.cpp ('k') | fpdfsdk/src/javascript/app.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/javascript/JS_Object.cpp
diff --git a/fpdfsdk/src/javascript/JS_Object.cpp b/fpdfsdk/src/javascript/JS_Object.cpp
index bb7d6c4108af680911e3195d0e0135292578d0d6..2ee23f8877f4ccc718f30a5297098771af0ed02a 100644
--- a/fpdfsdk/src/javascript/JS_Object.cpp
+++ b/fpdfsdk/src/javascript/JS_Object.cpp
@@ -8,8 +8,6 @@
#include "../../include/javascript/IJavaScript.h"
#include "../../include/javascript/JS_Define.h"
#include "../../include/javascript/JS_Object.h"
-// #include "../../include/javascript/JS_MsgBox.h"
-// #include "../../include/javascript/JS_ResMgr.h"
#include "../../include/javascript/JS_Context.h"
JS_TIMER_MAPARRAY& GetTimeMap()
@@ -21,106 +19,102 @@ JS_TIMER_MAPARRAY& GetTimeMap()
int FXJS_MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, const FX_WCHAR* swMsg, const FX_WCHAR* swTitle, FX_UINT nType, FX_UINT nIcon)
{
- int nRet = 0;
+ if (!pApp)
+ return 0;
- if (pApp)
- {
- CPDFSDK_Document* pDoc = pApp->GetCurrentDoc();
- if(pDoc)
- pDoc->KillFocusAnnot();
- nRet = pApp->JS_appAlert(swMsg, swTitle, nType, nIcon);
- }
+ if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument())
+ pDoc->KillFocusAnnot();
- return nRet;
+ return pApp->JS_appAlert(swMsg, swTitle, nType, nIcon);
}
CPDFSDK_PageView* FXJS_GetPageView(IFXJS_Context* cc)
{
- if (CJS_Context* pContext = (CJS_Context *)cc)
- {
- if (pContext->GetReaderDocument())
- return NULL;
- }
- return NULL;
+ if (CJS_Context* pContext = (CJS_Context *)cc)
+ {
+ if (pContext->GetReaderDocument())
+ return NULL;
+ }
+ return NULL;
}
/* --------------------------------- CJS_EmbedObj --------------------------------- */
CJS_EmbedObj::CJS_EmbedObj(CJS_Object* pJSObject) :
- m_pJSObject(pJSObject)
+ m_pJSObject(pJSObject)
{
}
CJS_EmbedObj::~CJS_EmbedObj()
{
- m_pJSObject = NULL;
+ m_pJSObject = NULL;
}
CPDFSDK_PageView* CJS_EmbedObj::JSGetPageView(IFXJS_Context* cc)
{
- return FXJS_GetPageView(cc);
+ return FXJS_GetPageView(cc);
}
int CJS_EmbedObj::MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView,const FX_WCHAR* swMsg,const FX_WCHAR* swTitle,FX_UINT nType,FX_UINT nIcon)
{
- return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon);
+ return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon);
}
void CJS_EmbedObj::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg)
{
- CJS_Object::Alert(pContext, swMsg);
+ CJS_Object::Alert(pContext, swMsg);
}
CJS_Timer* CJS_EmbedObj::BeginTimer(CPDFDoc_Environment* pApp, FX_UINT nElapse)
{
- CJS_Timer* pTimer = new CJS_Timer(this,pApp);
- pTimer->SetJSTimer(nElapse);
+ CJS_Timer* pTimer = new CJS_Timer(this,pApp);
+ pTimer->SetJSTimer(nElapse);
- return pTimer;
+ return pTimer;
}
void CJS_EmbedObj::EndTimer(CJS_Timer* pTimer)
{
- ASSERT(pTimer != NULL);
- pTimer->KillJSTimer();
- delete pTimer;
+ ASSERT(pTimer != NULL);
+ pTimer->KillJSTimer();
+ delete pTimer;
}
/* --------------------------------- CJS_Object --------------------------------- */
void FreeObject(const v8::WeakCallbackInfo<CJS_Object>& data)
{
- CJS_Object* pJSObj = data.GetParameter();
+ CJS_Object* pJSObj = data.GetParameter();
pJSObj->ExitInstance();
delete pJSObj;
- JS_FreePrivate(data.GetInternalField(0));
+ JS_FreePrivate(data.GetInternalField(0));
}
void DisposeObject(const v8::WeakCallbackInfo<CJS_Object>& data)
{
- CJS_Object* pJSObj = data.GetParameter();
+ CJS_Object* pJSObj = data.GetParameter();
pJSObj->Dispose();
data.SetSecondPassCallback(FreeObject);
}
CJS_Object::CJS_Object(JSFXObject pObject) :m_pEmbedObj(NULL)
{
- v8::Local<v8::Context> context = pObject->CreationContext();
- m_pIsolate = context->GetIsolate();
- m_pObject.Reset(m_pIsolate, pObject);
+ v8::Local<v8::Context> context = pObject->CreationContext();
+ m_pIsolate = context->GetIsolate();
+ m_pObject.Reset(m_pIsolate, pObject);
};
CJS_Object::~CJS_Object(void)
{
- delete m_pEmbedObj;
- m_pEmbedObj = NULL;
+ delete m_pEmbedObj;
+ m_pEmbedObj = NULL;
- m_pObject.Reset();
+ m_pObject.Reset();
};
-void CJS_Object::MakeWeak()
+void CJS_Object::MakeWeak()
{
- m_pObject.SetWeak(
+ m_pObject.SetWeak(
this, DisposeObject, v8::WeakCallbackType::kInternalFields);
}
@@ -131,24 +125,22 @@ void CJS_Object::Dispose()
CPDFSDK_PageView* CJS_Object::JSGetPageView(IFXJS_Context* cc)
{
- return FXJS_GetPageView(cc);
+ return FXJS_GetPageView(cc);
}
int CJS_Object::MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, const FX_WCHAR* swMsg, const FX_WCHAR* swTitle, FX_UINT nType, FX_UINT nIcon)
{
- return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon);
+ return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon);
}
void CJS_Object::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg)
{
- ASSERT(pContext != NULL);
+ ASSERT(pContext != NULL);
- if (pContext->IsMsgBoxEnabled())
- {
- CPDFDoc_Environment* pApp = pContext->GetReaderApp();
- if(pApp)
- pApp->JS_appAlert(swMsg, NULL, 0, 3);
- }
+ if (pContext->IsMsgBoxEnabled())
+ {
+ CPDFDoc_Environment* pApp = pContext->GetReaderApp();
+ if(pApp)
+ pApp->JS_appAlert(swMsg, NULL, 0, 3);
+ }
}
-
-
« no previous file with comments | « fpdfsdk/src/fsdk_mgr.cpp ('k') | fpdfsdk/src/javascript/app.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698