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

Side by Side Diff: fpdfsdk/src/javascript/JS_Object.cpp

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh Created 5 years, 4 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 unified diff | Download patch
OLDNEW
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/JavaScript.h" 7 #include "../../include/javascript/JavaScript.h"
8 #include "../../include/javascript/IJavaScript.h" 8 #include "../../include/javascript/IJavaScript.h"
9 #include "../../include/javascript/JS_Define.h" 9 #include "../../include/javascript/JS_Define.h"
10 #include "../../include/javascript/JS_Object.h" 10 #include "../../include/javascript/JS_Object.h"
11 #include "../../include/javascript/JS_Context.h" 11 #include "../../include/javascript/JS_Context.h"
12 12
13 JS_TIMER_MAPARRAY& GetTimeMap() 13 JS_TIMER_MAPARRAY& GetTimeMap() {
14 {
15 // Leak the timer array at shutdown. 14 // Leak the timer array at shutdown.
16 static auto* timeMap = new JS_TIMER_MAPARRAY; 15 static auto* timeMap = new JS_TIMER_MAPARRAY;
17 return *timeMap; 16 return *timeMap;
18 } 17 }
19 18
20 int FXJS_MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, const FX _WCHAR* swMsg, const FX_WCHAR* swTitle, FX_UINT nType, FX_UINT nIcon) 19 int FXJS_MsgBox(CPDFDoc_Environment* pApp,
21 { 20 CPDFSDK_PageView* pPageView,
22 if (!pApp) 21 const FX_WCHAR* swMsg,
23 return 0; 22 const FX_WCHAR* swTitle,
23 FX_UINT nType,
24 FX_UINT nIcon) {
25 if (!pApp)
26 return 0;
24 27
25 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) 28 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument())
26 pDoc->KillFocusAnnot(); 29 pDoc->KillFocusAnnot();
27 30
28 return pApp->JS_appAlert(swMsg, swTitle, nType, nIcon); 31 return pApp->JS_appAlert(swMsg, swTitle, nType, nIcon);
29 } 32 }
30 33
31 CPDFSDK_PageView* FXJS_GetPageView(IFXJS_Context* cc) 34 CPDFSDK_PageView* FXJS_GetPageView(IFXJS_Context* cc) {
32 { 35 if (CJS_Context* pContext = (CJS_Context*)cc) {
33 if (CJS_Context* pContext = (CJS_Context *)cc) 36 if (pContext->GetReaderDocument())
34 { 37 return NULL;
35 if (pContext->GetReaderDocument()) 38 }
36 return NULL; 39 return NULL;
37 }
38 return NULL;
39 } 40 }
40 41
41 /* --------------------------------- CJS_EmbedObj ----------------------------- ---- */ 42 /* --------------------------------- CJS_EmbedObj
43 * --------------------------------- */
42 44
43 CJS_EmbedObj::CJS_EmbedObj(CJS_Object* pJSObject) : 45 CJS_EmbedObj::CJS_EmbedObj(CJS_Object* pJSObject) : m_pJSObject(pJSObject) {}
44 m_pJSObject(pJSObject) 46
45 { 47 CJS_EmbedObj::~CJS_EmbedObj() {
48 m_pJSObject = NULL;
46 } 49 }
47 50
48 CJS_EmbedObj::~CJS_EmbedObj() 51 CPDFSDK_PageView* CJS_EmbedObj::JSGetPageView(IFXJS_Context* cc) {
49 { 52 return FXJS_GetPageView(cc);
50 m_pJSObject = NULL;
51
52 } 53 }
53 54
54 CPDFSDK_PageView* CJS_EmbedObj::JSGetPageView(IFXJS_Context* cc) 55 int CJS_EmbedObj::MsgBox(CPDFDoc_Environment* pApp,
55 { 56 CPDFSDK_PageView* pPageView,
56 return FXJS_GetPageView(cc); 57 const FX_WCHAR* swMsg,
58 const FX_WCHAR* swTitle,
59 FX_UINT nType,
60 FX_UINT nIcon) {
61 return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon);
57 } 62 }
58 63
59 int CJS_EmbedObj::MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, const FX_WCHAR* swMsg,const FX_WCHAR* swTitle,FX_UINT nType,FX_UINT nIcon) 64 void CJS_EmbedObj::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg) {
60 { 65 CJS_Object::Alert(pContext, swMsg);
61 return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon);
62 } 66 }
63 67
64 void CJS_EmbedObj::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg) 68 CJS_Timer* CJS_EmbedObj::BeginTimer(CPDFDoc_Environment* pApp,
65 { 69 FX_UINT nElapse) {
66 CJS_Object::Alert(pContext, swMsg); 70 CJS_Timer* pTimer = new CJS_Timer(this, pApp);
71 pTimer->SetJSTimer(nElapse);
72
73 return pTimer;
67 } 74 }
68 75
69 CJS_Timer* CJS_EmbedObj::BeginTimer(CPDFDoc_Environment * pApp,FX_UINT nElapse) 76 void CJS_EmbedObj::EndTimer(CJS_Timer* pTimer) {
70 { 77 ASSERT(pTimer != NULL);
71 CJS_Timer* pTimer = new CJS_Timer(this,pApp); 78 pTimer->KillJSTimer();
72 pTimer->SetJSTimer(nElapse); 79 delete pTimer;
73
74 return pTimer;
75 } 80 }
76 81
77 void CJS_EmbedObj::EndTimer(CJS_Timer* pTimer) 82 /* --------------------------------- CJS_Object
78 { 83 * --------------------------------- */
79 ASSERT(pTimer != NULL); 84 void FreeObject(const v8::WeakCallbackInfo<CJS_Object>& data) {
80 pTimer->KillJSTimer(); 85 CJS_Object* pJSObj = data.GetParameter();
81 delete pTimer; 86 pJSObj->ExitInstance();
87 delete pJSObj;
88 JS_FreePrivate(data.GetInternalField(0));
82 } 89 }
83 90
84 /* --------------------------------- CJS_Object ------------------------------- -- */ 91 void DisposeObject(const v8::WeakCallbackInfo<CJS_Object>& data) {
85 void FreeObject(const v8::WeakCallbackInfo<CJS_Object>& data) 92 CJS_Object* pJSObj = data.GetParameter();
86 { 93 pJSObj->Dispose();
87 CJS_Object* pJSObj = data.GetParameter(); 94 data.SetSecondPassCallback(FreeObject);
88 pJSObj->ExitInstance();
89 delete pJSObj;
90 JS_FreePrivate(data.GetInternalField(0));
91 } 95 }
92 96
93 void DisposeObject(const v8::WeakCallbackInfo<CJS_Object>& data) 97 CJS_Object::CJS_Object(JSFXObject pObject) : m_pEmbedObj(NULL) {
94 { 98 v8::Local<v8::Context> context = pObject->CreationContext();
95 CJS_Object* pJSObj = data.GetParameter(); 99 m_pIsolate = context->GetIsolate();
96 pJSObj->Dispose(); 100 m_pObject.Reset(m_pIsolate, pObject);
97 data.SetSecondPassCallback(FreeObject); 101 };
102
103 CJS_Object::~CJS_Object(void) {
104 delete m_pEmbedObj;
105 m_pEmbedObj = NULL;
106
107 m_pObject.Reset();
108 };
109
110 void CJS_Object::MakeWeak() {
111 m_pObject.SetWeak(this, DisposeObject, v8::WeakCallbackType::kInternalFields);
98 } 112 }
99 113
100 CJS_Object::CJS_Object(JSFXObject pObject) :m_pEmbedObj(NULL) 114 void CJS_Object::Dispose() {
101 { 115 m_pObject.Reset();
102 v8::Local<v8::Context> context = pObject->CreationContext();
103 m_pIsolate = context->GetIsolate();
104 m_pObject.Reset(m_pIsolate, pObject);
105 };
106
107 CJS_Object::~CJS_Object(void)
108 {
109 delete m_pEmbedObj;
110 m_pEmbedObj = NULL;
111
112 m_pObject.Reset();
113 };
114
115 void CJS_Object::MakeWeak()
116 {
117 m_pObject.SetWeak(
118 this, DisposeObject, v8::WeakCallbackType::kInternalFields);
119 } 116 }
120 117
121 void CJS_Object::Dispose() 118 CPDFSDK_PageView* CJS_Object::JSGetPageView(IFXJS_Context* cc) {
122 { 119 return FXJS_GetPageView(cc);
123 m_pObject.Reset();
124 } 120 }
125 121
126 CPDFSDK_PageView* CJS_Object::JSGetPageView(IFXJS_Context* cc) 122 int CJS_Object::MsgBox(CPDFDoc_Environment* pApp,
127 { 123 CPDFSDK_PageView* pPageView,
128 return FXJS_GetPageView(cc); 124 const FX_WCHAR* swMsg,
125 const FX_WCHAR* swTitle,
126 FX_UINT nType,
127 FX_UINT nIcon) {
128 return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon);
129 } 129 }
130 130
131 int CJS_Object::MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, c onst FX_WCHAR* swMsg, const FX_WCHAR* swTitle, FX_UINT nType, FX_UINT nIcon) 131 void CJS_Object::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg) {
132 { 132 ASSERT(pContext != NULL);
133 return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon); 133
134 if (pContext->IsMsgBoxEnabled()) {
135 CPDFDoc_Environment* pApp = pContext->GetReaderApp();
136 if (pApp)
137 pApp->JS_appAlert(swMsg, NULL, 0, 3);
138 }
134 } 139 }
135
136 void CJS_Object::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg)
137 {
138 ASSERT(pContext != NULL);
139
140 if (pContext->IsMsgBoxEnabled())
141 {
142 CPDFDoc_Environment* pApp = pContext->GetReaderApp();
143 if(pApp)
144 pApp->JS_appAlert(swMsg, NULL, 0, 3);
145 }
146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698