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

Side by Side Diff: fpdfsdk/src/fsdk_actionhandler.cpp

Issue 1610303002: Use std::set to track visited dictionaries in fsdk_actionhandler. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « fpdfsdk/include/fsdk_actionhandler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "fpdfsdk/include/fsdk_actionhandler.h" 7 #include "fpdfsdk/include/fsdk_actionhandler.h"
8 #include "fpdfsdk/include/fsdk_define.h" 8 #include "fpdfsdk/include/fsdk_define.h"
9 #include "fpdfsdk/include/fsdk_mgr.h" 9 #include "fpdfsdk/include/fsdk_mgr.h"
10 #include "fpdfsdk/include/javascript/IJavaScript.h" 10 #include "fpdfsdk/include/javascript/IJavaScript.h"
11 #include "third_party/base/stl_util.h"
11 12
12 CPDFSDK_ActionHandler::CPDFSDK_ActionHandler() 13 CPDFSDK_ActionHandler::CPDFSDK_ActionHandler()
13 : m_pFormActionHandler(new CPDFSDK_FormActionHandler) { 14 : m_pFormActionHandler(new CPDFSDK_FormActionHandler) {
14 } 15 }
15 16
16 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, 17 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action,
17 CPDFSDK_Document* pDocument) { 18 CPDFSDK_Document* pDocument) {
18 CFX_PtrList list; 19 std::set<CPDF_Dictionary*> visited;
19 return ExecuteDocumentOpenAction(action, pDocument, list); 20 return ExecuteDocumentOpenAction(action, pDocument, &visited);
20 } 21 }
21 22
22 FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript( 23 FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript(
23 const CPDF_Action& JsAction, 24 const CPDF_Action& JsAction,
24 CFX_WideString csJSName, 25 CFX_WideString csJSName,
25 CPDFSDK_Document* pDocument) { 26 CPDFSDK_Document* pDocument) {
26 if (JsAction.GetType() == CPDF_Action::JavaScript) { 27 if (JsAction.GetType() == CPDF_Action::JavaScript) {
27 CFX_WideString swJS = JsAction.GetJavaScript(); 28 CFX_WideString swJS = JsAction.GetJavaScript();
28 if (!swJS.IsEmpty()) { 29 if (!swJS.IsEmpty()) {
29 RunDocumentOpenJavaScript(pDocument, csJSName, swJS); 30 RunDocumentOpenJavaScript(pDocument, csJSName, swJS);
(...skipping 19 matching lines...) Expand all
49 return TRUE; 50 return TRUE;
50 } 51 }
51 } 52 }
52 return FALSE; 53 return FALSE;
53 } 54 }
54 55
55 FX_BOOL CPDFSDK_ActionHandler::DoAction_Page( 56 FX_BOOL CPDFSDK_ActionHandler::DoAction_Page(
56 const CPDF_Action& action, 57 const CPDF_Action& action,
57 enum CPDF_AAction::AActionType eType, 58 enum CPDF_AAction::AActionType eType,
58 CPDFSDK_Document* pDocument) { 59 CPDFSDK_Document* pDocument) {
59 CFX_PtrList list; 60 std::set<CPDF_Dictionary*> visited;
60 return ExecuteDocumentPageAction(action, eType, pDocument, list); 61 return ExecuteDocumentPageAction(action, eType, pDocument, &visited);
61 } 62 }
62 63
63 FX_BOOL CPDFSDK_ActionHandler::DoAction_Document( 64 FX_BOOL CPDFSDK_ActionHandler::DoAction_Document(
64 const CPDF_Action& action, 65 const CPDF_Action& action,
65 enum CPDF_AAction::AActionType eType, 66 enum CPDF_AAction::AActionType eType,
66 CPDFSDK_Document* pDocument) { 67 CPDFSDK_Document* pDocument) {
67 CFX_PtrList list; 68 std::set<CPDF_Dictionary*> visited;
68 return ExecuteDocumentPageAction(action, eType, pDocument, list); 69 return ExecuteDocumentPageAction(action, eType, pDocument, &visited);
69 } 70 }
70 71
71 FX_BOOL CPDFSDK_ActionHandler::DoAction_BookMark(CPDF_Bookmark* pBookMark, 72 FX_BOOL CPDFSDK_ActionHandler::DoAction_BookMark(CPDF_Bookmark* pBookMark,
72 const CPDF_Action& action, 73 const CPDF_Action& action,
73 CPDF_AAction::AActionType type, 74 CPDF_AAction::AActionType type,
74 CPDFSDK_Document* pDocument) { 75 CPDFSDK_Document* pDocument) {
75 CFX_PtrList list; 76 std::set<CPDF_Dictionary*> visited;
76 return ExecuteBookMark(action, pDocument, pBookMark, list); 77 return ExecuteBookMark(action, pDocument, pBookMark, &visited);
77 } 78 }
78 79
79 FX_BOOL CPDFSDK_ActionHandler::DoAction_Screen(const CPDF_Action& action, 80 FX_BOOL CPDFSDK_ActionHandler::DoAction_Screen(const CPDF_Action& action,
80 CPDF_AAction::AActionType type, 81 CPDF_AAction::AActionType type,
81 CPDFSDK_Document* pDocument, 82 CPDFSDK_Document* pDocument,
82 CPDFSDK_Annot* pScreen) { 83 CPDFSDK_Annot* pScreen) {
83 CFX_PtrList list; 84 std::set<CPDF_Dictionary*> visited;
84 return ExecuteScreenAction(action, type, pDocument, pScreen, list); 85 return ExecuteScreenAction(action, type, pDocument, pScreen, &visited);
85 } 86 }
86 87
87 FX_BOOL CPDFSDK_ActionHandler::DoAction_Link(const CPDF_Action& action, 88 FX_BOOL CPDFSDK_ActionHandler::DoAction_Link(const CPDF_Action& action,
88 CPDFSDK_Document* pDocument) { 89 CPDFSDK_Document* pDocument) {
89 CFX_PtrList list; 90 std::set<CPDF_Dictionary*> visited;
90 return ExecuteLinkAction(action, pDocument, list); 91 return ExecuteLinkAction(action, pDocument, &visited);
91 } 92 }
92 93
93 FX_BOOL CPDFSDK_ActionHandler::DoAction_Field(const CPDF_Action& action, 94 FX_BOOL CPDFSDK_ActionHandler::DoAction_Field(const CPDF_Action& action,
94 CPDF_AAction::AActionType type, 95 CPDF_AAction::AActionType type,
95 CPDFSDK_Document* pDocument, 96 CPDFSDK_Document* pDocument,
96 CPDF_FormField* pFormField, 97 CPDF_FormField* pFormField,
97 PDFSDK_FieldAction& data) { 98 PDFSDK_FieldAction& data) {
98 CFX_PtrList list; 99 std::set<CPDF_Dictionary*> visited;
99 return ExecuteFieldAction(action, type, pDocument, pFormField, data, list); 100 return ExecuteFieldAction(action, type, pDocument, pFormField, data,
101 &visited);
100 } 102 }
101 103
102 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction( 104 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction(
103 const CPDF_Action& action, 105 const CPDF_Action& action,
104 CPDFSDK_Document* pDocument, 106 CPDFSDK_Document* pDocument,
105 CFX_PtrList& list) { 107 std::set<CPDF_Dictionary*>* visited) {
106 CPDF_Dictionary* pDict = action.GetDict(); 108 CPDF_Dictionary* pDict = action.GetDict();
107 if (list.Find(pDict)) 109 if (pdfium::ContainsKey(*visited, pDict))
108 return FALSE; 110 return FALSE;
109 111
110 list.AddTail(pDict); 112 visited->insert(pDict);
111 113
112 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 114 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
113 ASSERT(pEnv); 115 ASSERT(pEnv);
114 if (action.GetType() == CPDF_Action::JavaScript) { 116 if (action.GetType() == CPDF_Action::JavaScript) {
115 if (pEnv->IsJSInitiated()) { 117 if (pEnv->IsJSInitiated()) {
116 CFX_WideString swJS = action.GetJavaScript(); 118 CFX_WideString swJS = action.GetJavaScript();
117 if (!swJS.IsEmpty()) { 119 if (!swJS.IsEmpty()) {
118 RunDocumentOpenJavaScript(pDocument, L"", swJS); 120 RunDocumentOpenJavaScript(pDocument, L"", swJS);
119 } 121 }
120 } 122 }
121 } else { 123 } else {
122 DoAction_NoJs(action, pDocument); 124 DoAction_NoJs(action, pDocument);
123 } 125 }
124 126
125 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 127 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
126 CPDF_Action subaction = action.GetSubAction(i); 128 CPDF_Action subaction = action.GetSubAction(i);
127 if (!ExecuteDocumentOpenAction(subaction, pDocument, list)) 129 if (!ExecuteDocumentOpenAction(subaction, pDocument, visited))
128 return FALSE; 130 return FALSE;
129 } 131 }
130 132
131 return TRUE; 133 return TRUE;
132 } 134 }
133 135
134 FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(const CPDF_Action& action, 136 FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(
135 CPDFSDK_Document* pDocument, 137 const CPDF_Action& action,
136 CFX_PtrList& list) { 138 CPDFSDK_Document* pDocument,
139 std::set<CPDF_Dictionary*>* visited) {
137 CPDF_Dictionary* pDict = action.GetDict(); 140 CPDF_Dictionary* pDict = action.GetDict();
138 if (list.Find(pDict)) 141 if (pdfium::ContainsKey(*visited, pDict))
139 return FALSE; 142 return FALSE;
140 143
141 list.AddTail(pDict); 144 visited->insert(pDict);
142 145
143 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 146 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
144 ASSERT(pEnv); 147 ASSERT(pEnv);
145 if (action.GetType() == CPDF_Action::JavaScript) { 148 if (action.GetType() == CPDF_Action::JavaScript) {
146 if (pEnv->IsJSInitiated()) { 149 if (pEnv->IsJSInitiated()) {
147 CFX_WideString swJS = action.GetJavaScript(); 150 CFX_WideString swJS = action.GetJavaScript();
148 if (!swJS.IsEmpty()) { 151 if (!swJS.IsEmpty()) {
149 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); 152 IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
150 pRuntime->SetReaderDocument(pDocument); 153 pRuntime->SetReaderDocument(pDocument);
151 154
152 IJS_Context* pContext = pRuntime->NewContext(); 155 IJS_Context* pContext = pRuntime->NewContext();
153 pContext->OnLink_MouseUp(pDocument); 156 pContext->OnLink_MouseUp(pDocument);
154 157
155 CFX_WideString csInfo; 158 CFX_WideString csInfo;
156 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); 159 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo);
157 if (!bRet) { 160 if (!bRet) {
158 // FIXME: return error. 161 // FIXME: return error.
159 } 162 }
160 163
161 pRuntime->ReleaseContext(pContext); 164 pRuntime->ReleaseContext(pContext);
162 } 165 }
163 } 166 }
164 } else { 167 } else {
165 DoAction_NoJs(action, pDocument); 168 DoAction_NoJs(action, pDocument);
166 } 169 }
167 170
168 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 171 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
169 CPDF_Action subaction = action.GetSubAction(i); 172 CPDF_Action subaction = action.GetSubAction(i);
170 if (!ExecuteLinkAction(subaction, pDocument, list)) 173 if (!ExecuteLinkAction(subaction, pDocument, visited))
171 return FALSE; 174 return FALSE;
172 } 175 }
173 176
174 return TRUE; 177 return TRUE;
175 } 178 }
176 179
177 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction( 180 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction(
178 const CPDF_Action& action, 181 const CPDF_Action& action,
179 CPDF_AAction::AActionType type, 182 CPDF_AAction::AActionType type,
180 CPDFSDK_Document* pDocument, 183 CPDFSDK_Document* pDocument,
181 CFX_PtrList& list) { 184 std::set<CPDF_Dictionary*>* visited) {
182 CPDF_Dictionary* pDict = action.GetDict(); 185 CPDF_Dictionary* pDict = action.GetDict();
183 if (list.Find(pDict)) 186 if (pdfium::ContainsKey(*visited, pDict))
184 return FALSE; 187 return FALSE;
185 188
186 list.AddTail(pDict); 189 visited->insert(pDict);
187 190
188 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 191 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
189 ASSERT(pEnv); 192 ASSERT(pEnv);
190 if (action.GetType() == CPDF_Action::JavaScript) { 193 if (action.GetType() == CPDF_Action::JavaScript) {
191 if (pEnv->IsJSInitiated()) { 194 if (pEnv->IsJSInitiated()) {
192 CFX_WideString swJS = action.GetJavaScript(); 195 CFX_WideString swJS = action.GetJavaScript();
193 if (!swJS.IsEmpty()) { 196 if (!swJS.IsEmpty()) {
194 RunDocumentPageJavaScript(pDocument, type, swJS); 197 RunDocumentPageJavaScript(pDocument, type, swJS);
195 } 198 }
196 } 199 }
197 } else { 200 } else {
198 DoAction_NoJs(action, pDocument); 201 DoAction_NoJs(action, pDocument);
199 } 202 }
200 203
201 if (!IsValidDocView(pDocument)) 204 if (!IsValidDocView(pDocument))
202 return FALSE; 205 return FALSE;
203 206
204 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 207 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
205 CPDF_Action subaction = action.GetSubAction(i); 208 CPDF_Action subaction = action.GetSubAction(i);
206 if (!ExecuteDocumentPageAction(subaction, type, pDocument, list)) 209 if (!ExecuteDocumentPageAction(subaction, type, pDocument, visited))
207 return FALSE; 210 return FALSE;
208 } 211 }
209 212
210 return TRUE; 213 return TRUE;
211 } 214 }
212 215
213 FX_BOOL CPDFSDK_ActionHandler::IsValidField(CPDFSDK_Document* pDocument, 216 FX_BOOL CPDFSDK_ActionHandler::IsValidField(CPDFSDK_Document* pDocument,
214 CPDF_Dictionary* pFieldDict) { 217 CPDF_Dictionary* pFieldDict) {
215 ASSERT(pFieldDict); 218 ASSERT(pFieldDict);
216 219
217 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); 220 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
218 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); 221 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
219 return pPDFInterForm->GetFieldByDict(pFieldDict) != NULL; 222 return pPDFInterForm->GetFieldByDict(pFieldDict) != NULL;
220 } 223 }
221 224
222 FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction( 225 FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction(
223 const CPDF_Action& action, 226 const CPDF_Action& action,
224 CPDF_AAction::AActionType type, 227 CPDF_AAction::AActionType type,
225 CPDFSDK_Document* pDocument, 228 CPDFSDK_Document* pDocument,
226 CPDF_FormField* pFormField, 229 CPDF_FormField* pFormField,
227 PDFSDK_FieldAction& data, 230 PDFSDK_FieldAction& data,
228 CFX_PtrList& list) { 231 std::set<CPDF_Dictionary*>* visited) {
229 CPDF_Dictionary* pDict = action.GetDict(); 232 CPDF_Dictionary* pDict = action.GetDict();
230 if (list.Find(pDict)) 233 if (pdfium::ContainsKey(*visited, pDict))
231 return FALSE; 234 return FALSE;
232 235
233 list.AddTail(pDict); 236 visited->insert(pDict);
234 237
235 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 238 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
236 ASSERT(pEnv); 239 ASSERT(pEnv);
237 if (action.GetType() == CPDF_Action::JavaScript) { 240 if (action.GetType() == CPDF_Action::JavaScript) {
238 if (pEnv->IsJSInitiated()) { 241 if (pEnv->IsJSInitiated()) {
239 CFX_WideString swJS = action.GetJavaScript(); 242 CFX_WideString swJS = action.GetJavaScript();
240 if (!swJS.IsEmpty()) { 243 if (!swJS.IsEmpty()) {
241 RunFieldJavaScript(pDocument, pFormField, type, data, swJS); 244 RunFieldJavaScript(pDocument, pFormField, type, data, swJS);
242 if (!IsValidField(pDocument, pFormField->GetFieldDict())) 245 if (!IsValidField(pDocument, pFormField->GetFieldDict()))
243 return FALSE; 246 return FALSE;
244 } 247 }
245 } 248 }
246 } else { 249 } else {
247 DoAction_NoJs(action, pDocument); 250 DoAction_NoJs(action, pDocument);
248 } 251 }
249 252
250 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 253 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
251 CPDF_Action subaction = action.GetSubAction(i); 254 CPDF_Action subaction = action.GetSubAction(i);
252 if (!ExecuteFieldAction(subaction, type, pDocument, pFormField, data, list)) 255 if (!ExecuteFieldAction(subaction, type, pDocument, pFormField, data,
256 visited))
253 return FALSE; 257 return FALSE;
254 } 258 }
255 259
256 return TRUE; 260 return TRUE;
257 } 261 }
258 262
259 FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction( 263 FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction(
260 const CPDF_Action& action, 264 const CPDF_Action& action,
261 CPDF_AAction::AActionType type, 265 CPDF_AAction::AActionType type,
262 CPDFSDK_Document* pDocument, 266 CPDFSDK_Document* pDocument,
263 CPDFSDK_Annot* pScreen, 267 CPDFSDK_Annot* pScreen,
264 CFX_PtrList& list) { 268 std::set<CPDF_Dictionary*>* visited) {
265 CPDF_Dictionary* pDict = action.GetDict(); 269 CPDF_Dictionary* pDict = action.GetDict();
266 if (list.Find(pDict)) 270 if (pdfium::ContainsKey(*visited, pDict))
267 return FALSE; 271 return FALSE;
268 272
269 list.AddTail(pDict); 273 visited->insert(pDict);
270 274
271 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 275 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
272 ASSERT(pEnv); 276 ASSERT(pEnv);
273 if (action.GetType() == CPDF_Action::JavaScript) { 277 if (action.GetType() == CPDF_Action::JavaScript) {
274 if (pEnv->IsJSInitiated()) { 278 if (pEnv->IsJSInitiated()) {
275 CFX_WideString swJS = action.GetJavaScript(); 279 CFX_WideString swJS = action.GetJavaScript();
276 if (!swJS.IsEmpty()) { 280 if (!swJS.IsEmpty()) {
277 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); 281 IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
278 pRuntime->SetReaderDocument(pDocument); 282 pRuntime->SetReaderDocument(pDocument);
279 283
280 IJS_Context* pContext = pRuntime->NewContext(); 284 IJS_Context* pContext = pRuntime->NewContext();
281 CFX_WideString csInfo; 285 CFX_WideString csInfo;
282 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); 286 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo);
283 if (!bRet) { 287 if (!bRet) {
284 // FIXME: return error. 288 // FIXME: return error.
285 } 289 }
286 290
287 pRuntime->ReleaseContext(pContext); 291 pRuntime->ReleaseContext(pContext);
288 } 292 }
289 } 293 }
290 } else { 294 } else {
291 DoAction_NoJs(action, pDocument); 295 DoAction_NoJs(action, pDocument);
292 } 296 }
293 297
294 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 298 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
295 CPDF_Action subaction = action.GetSubAction(i); 299 CPDF_Action subaction = action.GetSubAction(i);
296 if (!ExecuteScreenAction(subaction, type, pDocument, pScreen, list)) 300 if (!ExecuteScreenAction(subaction, type, pDocument, pScreen, visited))
297 return FALSE; 301 return FALSE;
298 } 302 }
299 303
300 return TRUE; 304 return TRUE;
301 } 305 }
302 306
303 FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark(const CPDF_Action& action, 307 FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark(
304 CPDFSDK_Document* pDocument, 308 const CPDF_Action& action,
305 CPDF_Bookmark* pBookmark, 309 CPDFSDK_Document* pDocument,
306 CFX_PtrList& list) { 310 CPDF_Bookmark* pBookmark,
311 std::set<CPDF_Dictionary*>* visited) {
307 CPDF_Dictionary* pDict = action.GetDict(); 312 CPDF_Dictionary* pDict = action.GetDict();
308 if (list.Find(pDict)) 313 if (pdfium::ContainsKey(*visited, pDict))
309 return FALSE; 314 return FALSE;
310 315
311 list.AddTail(pDict); 316 visited->insert(pDict);
312 317
313 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 318 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
314 ASSERT(pEnv); 319 ASSERT(pEnv);
315 if (action.GetType() == CPDF_Action::JavaScript) { 320 if (action.GetType() == CPDF_Action::JavaScript) {
316 if (pEnv->IsJSInitiated()) { 321 if (pEnv->IsJSInitiated()) {
317 CFX_WideString swJS = action.GetJavaScript(); 322 CFX_WideString swJS = action.GetJavaScript();
318 if (!swJS.IsEmpty()) { 323 if (!swJS.IsEmpty()) {
319 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); 324 IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
320 pRuntime->SetReaderDocument(pDocument); 325 pRuntime->SetReaderDocument(pDocument);
321 326
322 IJS_Context* pContext = pRuntime->NewContext(); 327 IJS_Context* pContext = pRuntime->NewContext();
323 pContext->OnBookmark_MouseUp(pBookmark); 328 pContext->OnBookmark_MouseUp(pBookmark);
324 329
325 CFX_WideString csInfo; 330 CFX_WideString csInfo;
326 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); 331 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo);
327 if (!bRet) { 332 if (!bRet) {
328 // FIXME: return error. 333 // FIXME: return error.
329 } 334 }
330 335
331 pRuntime->ReleaseContext(pContext); 336 pRuntime->ReleaseContext(pContext);
332 } 337 }
333 } 338 }
334 } else { 339 } else {
335 DoAction_NoJs(action, pDocument); 340 DoAction_NoJs(action, pDocument);
336 } 341 }
337 342
338 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 343 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
339 CPDF_Action subaction = action.GetSubAction(i); 344 CPDF_Action subaction = action.GetSubAction(i);
340 if (!ExecuteBookMark(subaction, pDocument, pBookmark, list)) 345 if (!ExecuteBookMark(subaction, pDocument, pBookmark, visited))
341 return FALSE; 346 return FALSE;
342 } 347 }
343 348
344 return TRUE; 349 return TRUE;
345 } 350 }
346 351
347 void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action, 352 void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action,
348 CPDFSDK_Document* pDocument) { 353 CPDFSDK_Document* pDocument) {
349 ASSERT(pDocument); 354 ASSERT(pDocument);
350 355
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 const CPDF_Action& action, 627 const CPDF_Action& action,
623 CPDFSDK_Document* pDocument) { 628 CPDFSDK_Document* pDocument) {
624 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); 629 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
625 if (pInterForm->DoAction_ImportData(action)) { 630 if (pInterForm->DoAction_ImportData(action)) {
626 pDocument->SetChangeMark(); 631 pDocument->SetChangeMark();
627 return TRUE; 632 return TRUE;
628 } 633 }
629 634
630 return FALSE; 635 return FALSE;
631 } 636 }
OLDNEW
« no previous file with comments | « fpdfsdk/include/fsdk_actionhandler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698