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

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

Issue 1389163007: Pass IJS_Runtime, not IJS_Context, to native object constructors. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Merge changes into stub. Created 5 years, 2 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/jsapi/fxjs_v8.h ('k') | fpdfsdk/src/fsdk_baseform.cpp » ('j') | 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 "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fsdk_mgr.h" 8 #include "../include/fsdk_mgr.h"
9 #include "../include/fsdk_actionhandler.h" 9 #include "../include/fsdk_actionhandler.h"
10 #include "../include/javascript/IJavaScript.h" 10 #include "../include/javascript/IJavaScript.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 return FALSE; 141 return FALSE;
142 142
143 list.AddTail(pDict); 143 list.AddTail(pDict);
144 144
145 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 145 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
146 ASSERT(pEnv); 146 ASSERT(pEnv);
147 if (action.GetType() == CPDF_Action::JavaScript) { 147 if (action.GetType() == CPDF_Action::JavaScript) {
148 if (pEnv->IsJSInitiated()) { 148 if (pEnv->IsJSInitiated()) {
149 CFX_WideString swJS = action.GetJavaScript(); 149 CFX_WideString swJS = action.GetJavaScript();
150 if (!swJS.IsEmpty()) { 150 if (!swJS.IsEmpty()) {
151 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); //???? 151 IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
152 ASSERT(pRuntime != NULL);
153
154 pRuntime->SetReaderDocument(pDocument); 152 pRuntime->SetReaderDocument(pDocument);
155 153
156 IJS_Context* pContext = pRuntime->NewContext(); 154 IJS_Context* pContext = pRuntime->NewContext();
157 ASSERT(pContext != NULL);
158
159 pContext->OnLink_MouseUp(pDocument); 155 pContext->OnLink_MouseUp(pDocument);
160 156
161 CFX_WideString csInfo; 157 CFX_WideString csInfo;
162 FX_BOOL bRet = pContext->RunScript(swJS, csInfo); 158 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo);
163 if (!bRet) { 159 if (!bRet) {
164 // FIXME: return error. 160 // FIXME: return error.
165 } 161 }
166 162
167 pRuntime->ReleaseContext(pContext); 163 pRuntime->ReleaseContext(pContext);
168 } 164 }
169 } 165 }
170 } else { 166 } else {
171 DoAction_NoJs(action, pDocument); 167 DoAction_NoJs(action, pDocument);
172 } 168 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 281
286 list.AddTail(pDict); 282 list.AddTail(pDict);
287 283
288 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 284 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
289 ASSERT(pEnv); 285 ASSERT(pEnv);
290 if (action.GetType() == CPDF_Action::JavaScript) { 286 if (action.GetType() == CPDF_Action::JavaScript) {
291 if (pEnv->IsJSInitiated()) { 287 if (pEnv->IsJSInitiated()) {
292 CFX_WideString swJS = action.GetJavaScript(); 288 CFX_WideString swJS = action.GetJavaScript();
293 if (!swJS.IsEmpty()) { 289 if (!swJS.IsEmpty()) {
294 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); 290 IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
295 ASSERT(pRuntime != NULL);
296
297 pRuntime->SetReaderDocument(pDocument); 291 pRuntime->SetReaderDocument(pDocument);
298 292
299 IJS_Context* pContext = pRuntime->NewContext(); 293 IJS_Context* pContext = pRuntime->NewContext();
300 ASSERT(pContext != NULL);
301
302 // switch (type)
303 // {
304 // case CPDF_AAction::CursorEnter:
305 // pContext->OnScreen_MouseEnter(IsCTRLpres sed(),
306 // IsSHIFTpressed(), pScreen);
307 // break;
308 // case CPDF_AAction::CursorExit:
309 // pContext->OnScreen_MouseExit(IsCTRLpress ed(),
310 // IsSHIFTpressed(), pScreen);
311 // break;
312 // case CPDF_AAction::ButtonDown:
313 // pContext->OnScreen_MouseDown(IsCTRLpress ed(),
314 // IsSHIFTpressed(), pScreen);
315 // break;
316 // case CPDF_AAction::ButtonUp:
317 // pContext->OnScreen_MouseUp(IsCTRLpressed (),
318 // IsSHIFTpressed(), pScreen);
319 // break;
320 // case CPDF_AAction::GetFocus:
321 // pContext->OnScreen_Focus(IsCTRLpressed() ,
322 // IsSHIFTpressed(), pScreen);
323 // break;
324 // case CPDF_AAction::LoseFocus:
325 // pContext->OnScreen_Blur(IsCTRLpressed(),
326 // IsSHIFTpressed(), pScreen);
327 // break;
328 // case CPDF_AAction::PageOpen:
329 // pContext->OnScreen_Open(IsCTRLpressed(),
330 // IsSHIFTpressed(), pScreen);
331 // break;
332 // case CPDF_AAction::PageClose:
333 // pContext->OnScreen_Close(IsCTRLpressed() ,
334 // IsSHIFTpressed(), pScreen);
335 // break;
336 // case CPDF_AAction::PageVisible:
337 // pContext->OnScreen_InView(IsCTRLpressed( ),
338 // IsSHIFTpressed(), pScreen);
339 // break;
340 // case CPDF_AAction::PageInvisible:
341 // pContext->OnScreen_OutView(IsCTRLpressed (),
342 // IsSHIFTpressed(), pScreen);
343 // break;
344 // default:
345 // ASSERT(FALSE);
346 // break;
347 // }
348
349 CFX_WideString csInfo; 294 CFX_WideString csInfo;
350 FX_BOOL bRet = pContext->RunScript(swJS, csInfo); 295 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo);
351 if (!bRet) { 296 if (!bRet) {
352 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), 297 // FIXME: return error.
353 // csInfo);
354 } 298 }
355 299
356 pRuntime->ReleaseContext(pContext); 300 pRuntime->ReleaseContext(pContext);
357 } 301 }
358 } 302 }
359 } else { 303 } else {
360 DoAction_NoJs(action, pDocument); 304 DoAction_NoJs(action, pDocument);
361 } 305 }
362 306
363 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 307 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
(...skipping 17 matching lines...) Expand all
381 325
382 list.AddTail(pDict); 326 list.AddTail(pDict);
383 327
384 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 328 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
385 ASSERT(pEnv); 329 ASSERT(pEnv);
386 if (action.GetType() == CPDF_Action::JavaScript) { 330 if (action.GetType() == CPDF_Action::JavaScript) {
387 if (pEnv->IsJSInitiated()) { 331 if (pEnv->IsJSInitiated()) {
388 CFX_WideString swJS = action.GetJavaScript(); 332 CFX_WideString swJS = action.GetJavaScript();
389 if (!swJS.IsEmpty()) { 333 if (!swJS.IsEmpty()) {
390 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); 334 IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
391 ASSERT(pRuntime != NULL);
392
393 pRuntime->SetReaderDocument(pDocument); 335 pRuntime->SetReaderDocument(pDocument);
394 336
395 IJS_Context* pContext = pRuntime->NewContext(); 337 IJS_Context* pContext = pRuntime->NewContext();
396 ASSERT(pContext != NULL);
397
398 pContext->OnBookmark_MouseUp(pBookmark); 338 pContext->OnBookmark_MouseUp(pBookmark);
399 339
400 CFX_WideString csInfo; 340 CFX_WideString csInfo;
401 FX_BOOL bRet = pContext->RunScript(swJS, csInfo); 341 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo);
402 if (!bRet) { 342 if (!bRet) {
403 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), 343 // FIXME: return error.
404 // csInfo);
405 } 344 }
406 345
407 pRuntime->ReleaseContext(pContext); 346 pRuntime->ReleaseContext(pContext);
408 } 347 }
409 } 348 }
410 } else { 349 } else {
411 DoAction_NoJs(action, pDocument); 350 DoAction_NoJs(action, pDocument);
412 } 351 }
413 352
414 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 353 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bKeyDown, 533 pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bKeyDown,
595 data.bModifier, data.bShift, pFormField, 534 data.bModifier, data.bShift, pFormField,
596 data.sValue, data.bRC); 535 data.sValue, data.bRC);
597 break; 536 break;
598 default: 537 default:
599 ASSERT(FALSE); 538 ASSERT(FALSE);
600 break; 539 break;
601 } 540 }
602 541
603 CFX_WideString csInfo; 542 CFX_WideString csInfo;
604 FX_BOOL bRet = pContext->RunScript(script, csInfo); 543 FX_BOOL bRet = pContext->RunScript(script, &csInfo);
605 if (!bRet) { 544 if (!bRet) {
606 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); 545 // FIXME: return error.
607 } 546 }
608 547
609 pRuntime->ReleaseContext(pContext); 548 pRuntime->ReleaseContext(pContext);
610 } 549 }
611 550
612 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript( 551 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript(
613 CPDFSDK_Document* pDocument, 552 CPDFSDK_Document* pDocument,
614 const CFX_WideString& sScriptName, 553 const CFX_WideString& sScriptName,
615 const CFX_WideString& script) { 554 const CFX_WideString& script) {
616 ASSERT(pDocument != NULL); 555 ASSERT(pDocument != NULL);
617 556
618 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); 557 IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
619 ASSERT(pRuntime != NULL); 558 ASSERT(pRuntime != NULL);
620 559
621 pRuntime->SetReaderDocument(pDocument); 560 pRuntime->SetReaderDocument(pDocument);
622 561
623 IJS_Context* pContext = pRuntime->NewContext(); 562 IJS_Context* pContext = pRuntime->NewContext();
624 ASSERT(pContext != NULL); 563 ASSERT(pContext != NULL);
625 564
626 pContext->OnDoc_Open(pDocument, sScriptName); 565 pContext->OnDoc_Open(pDocument, sScriptName);
627 566
628 CFX_WideString csInfo; 567 CFX_WideString csInfo;
629 FX_BOOL bRet = pContext->RunScript(script, csInfo); 568 FX_BOOL bRet = pContext->RunScript(script, &csInfo);
630 if (!bRet) { 569 if (!bRet) {
631 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); 570 // FIXME: return error.
632 } 571 }
633 572
634 pRuntime->ReleaseContext(pContext); 573 pRuntime->ReleaseContext(pContext);
635 } 574 }
636 575
637 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( 576 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript(
638 CPDFSDK_Document* pDocument, 577 CPDFSDK_Document* pDocument,
639 CPDF_AAction::AActionType type, 578 CPDF_AAction::AActionType type,
640 const CFX_WideString& script) { 579 const CFX_WideString& script) {
641 ASSERT(pDocument != NULL); 580 ASSERT(pDocument != NULL);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 break; 614 break;
676 case CPDF_AAction::PageInvisible: 615 case CPDF_AAction::PageInvisible:
677 pContext->OnPage_OutView(pDocument); 616 pContext->OnPage_OutView(pDocument);
678 break; 617 break;
679 default: 618 default:
680 ASSERT(FALSE); 619 ASSERT(FALSE);
681 break; 620 break;
682 } 621 }
683 622
684 CFX_WideString csInfo; 623 CFX_WideString csInfo;
685 FX_BOOL bRet = pContext->RunScript(script, csInfo); 624 FX_BOOL bRet = pContext->RunScript(script, &csInfo);
686 if (!bRet) { 625 if (!bRet) {
687 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); 626 // FIXME: return error.
688 } 627 }
689 628
690 pRuntime->ReleaseContext(pContext); 629 pRuntime->ReleaseContext(pContext);
691 } 630 }
692 631
693 FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, 632 FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action,
694 CPDFSDK_Document* pDocument) { 633 CPDFSDK_Document* pDocument) {
695 ASSERT(pDocument != NULL); 634 ASSERT(pDocument != NULL);
696 635
697 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); 636 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); 678 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
740 ASSERT(pInterForm != NULL); 679 ASSERT(pInterForm != NULL);
741 680
742 if (pInterForm->DoAction_ImportData(action)) { 681 if (pInterForm->DoAction_ImportData(action)) {
743 pDocument->SetChangeMark(); 682 pDocument->SetChangeMark();
744 return TRUE; 683 return TRUE;
745 } 684 }
746 685
747 return FALSE; 686 return FALSE;
748 } 687 }
OLDNEW
« no previous file with comments | « fpdfsdk/include/jsapi/fxjs_v8.h ('k') | fpdfsdk/src/fsdk_baseform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698