Revert "Make CFX_FontMgr member variables private."
[pdfium.git] / fpdfsdk / src / fsdk_mgr.cpp
index 9cbb9de..883ad60 100644 (file)
@@ -6,9 +6,9 @@
 
 #include "../../public/fpdf_ext.h"
 #include "../../third_party/base/nonstd_unique_ptr.h"
+#include "../include/formfiller/FFL_FormFiller.h"
 #include "../include/fsdk_define.h"
 #include "../include/fsdk_mgr.h"
-#include "../include/formfiller/FFL_FormFiller.h"
 #include "../include/javascript/IJavaScript.h"
 
 #if _FX_OS_ == _FX_ANDROID_
@@ -203,37 +203,27 @@ FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime() {
   return m_pEnv->FFI_GetLocalTime();
 }
 
-CJS_RuntimeFactory* GetJSRuntimeFactory() {
-  static CJS_RuntimeFactory s_JSRuntimeFactory;
-  return &s_JSRuntimeFactory;
-}
-
 CPDFDoc_Environment::CPDFDoc_Environment(CPDF_Document* pDoc,
                                          FPDF_FORMFILLINFO* pFFinfo)
     : m_pAnnotHandlerMgr(NULL),
       m_pActionHandler(NULL),
-      m_pJSRuntime(NULL),
       m_pInfo(pFFinfo),
       m_pSDKDoc(NULL),
       m_pPDFDoc(pDoc),
       m_pIFormFiller(NULL) {
   m_pSysHandler = new CFX_SystemHandler(this);
-  m_pJSRuntimeFactory = GetJSRuntimeFactory();
-  m_pJSRuntimeFactory->AddRef();
 }
 
 CPDFDoc_Environment::~CPDFDoc_Environment() {
   delete m_pIFormFiller;
   m_pIFormFiller = NULL;
-  if (m_pJSRuntime && m_pJSRuntimeFactory)
-    m_pJSRuntimeFactory->DeleteJSRuntime(m_pJSRuntime);
-  m_pJSRuntimeFactory->Release();
 
   delete m_pSysHandler;
   m_pSysHandler = NULL;
 
   delete m_pAnnotHandlerMgr;
   m_pAnnotHandlerMgr = NULL;
+
   delete m_pActionHandler;
   m_pActionHandler = NULL;
 }
@@ -380,12 +370,12 @@ void CPDFDoc_Environment::JS_docmailForm(void* mailData,
   }
 }
 
-IFXJS_Runtime* CPDFDoc_Environment::GetJSRuntime() {
+IJS_Runtime* CPDFDoc_Environment::GetJSRuntime() {
   if (!IsJSInitiated())
     return NULL;
   if (!m_pJSRuntime)
-    m_pJSRuntime = m_pJSRuntimeFactory->NewJSRuntime(this);
-  return m_pJSRuntime;
+    m_pJSRuntime.reset(IJS_Runtime::Create(this));
+  return m_pJSRuntime.get();
 }
 
 CPDFSDK_AnnotHandlerMgr* CPDFDoc_Environment::GetAnnotHandlerMgr() {
@@ -604,7 +594,7 @@ FX_BOOL CPDFSDK_Document::GetPermissions(int nFlag) {
   return dwPermissions & nFlag;
 }
 
-IFXJS_Runtime* CPDFSDK_Document::GetJsRuntime() {
+IJS_Runtime* CPDFSDK_Document::GetJsRuntime() {
   ASSERT(m_pEnv != NULL);
   return m_pEnv->GetJSRuntime();
 }
@@ -670,11 +660,9 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
 
   CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
   CPDFSDK_AnnotIterator annotIterator(this, TRUE);
-  CPDFSDK_Annot* pSDKAnnot = nullptr;
   int index = -1;
-  while ((pSDKAnnot = annotIterator.Next(index))) {
+  while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next(index)) {
     CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
-    ASSERT(pAnnotHandlerMgr);
     pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0);
   }
 }