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

Side by Side Diff: fpdfsdk/fsdk_actionhandler.cpp

Issue 2399943002: Remove CPDFSDK_Document from IJS_Context (Closed)
Patch Set: Rebase to master Created 4 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 | « no previous file | fpdfsdk/javascript/Document.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 "fpdfsdk/fsdk_actionhandler.h" 7 #include "fpdfsdk/fsdk_actionhandler.h"
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction( 141 FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(
142 const CPDF_Action& action, 142 const CPDF_Action& action,
143 CPDFSDK_Document* pDocument, 143 CPDFSDK_Document* pDocument,
144 std::set<CPDF_Dictionary*>* visited) { 144 std::set<CPDF_Dictionary*>* visited) {
145 CPDF_Dictionary* pDict = action.GetDict(); 145 CPDF_Dictionary* pDict = action.GetDict();
146 if (pdfium::ContainsKey(*visited, pDict)) 146 if (pdfium::ContainsKey(*visited, pDict))
147 return FALSE; 147 return FALSE;
148 148
149 visited->insert(pDict); 149 visited->insert(pDict);
150 150
151 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv(); 151 CPDFSDK_FormFillEnvironment* pFormFillEnv = pDocument->GetEnv();
152 ASSERT(pEnv); 152 ASSERT(pFormFillEnv);
153 if (action.GetType() == CPDF_Action::JavaScript) { 153 if (action.GetType() == CPDF_Action::JavaScript) {
154 if (pEnv->IsJSInitiated()) { 154 if (pFormFillEnv->IsJSInitiated()) {
155 CFX_WideString swJS = action.GetJavaScript(); 155 CFX_WideString swJS = action.GetJavaScript();
156 if (!swJS.IsEmpty()) { 156 if (!swJS.IsEmpty()) {
157 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); 157 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
158 pRuntime->SetReaderDocument(pDocument); 158 pRuntime->SetReaderDocument(pDocument);
159 159
160 IJS_Context* pContext = pRuntime->NewContext(); 160 IJS_Context* pContext = pRuntime->NewContext();
161 pContext->OnLink_MouseUp(pDocument); 161 pContext->OnLink_MouseUp(pFormFillEnv);
162 162
163 CFX_WideString csInfo; 163 CFX_WideString csInfo;
164 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); 164 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo);
165 if (!bRet) { 165 if (!bRet) {
166 // FIXME: return error. 166 // FIXME: return error.
167 } 167 }
168 168
169 pRuntime->ReleaseContext(pContext); 169 pRuntime->ReleaseContext(pContext);
170 } 170 }
171 } 171 }
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 pRuntime->ReleaseContext(pContext); 527 pRuntime->ReleaseContext(pContext);
528 } 528 }
529 529
530 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript( 530 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript(
531 CPDFSDK_Document* pDocument, 531 CPDFSDK_Document* pDocument,
532 const CFX_WideString& sScriptName, 532 const CFX_WideString& sScriptName,
533 const CFX_WideString& script) { 533 const CFX_WideString& script) {
534 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); 534 IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
535 pRuntime->SetReaderDocument(pDocument); 535 pRuntime->SetReaderDocument(pDocument);
536 IJS_Context* pContext = pRuntime->NewContext(); 536 IJS_Context* pContext = pRuntime->NewContext();
537 pContext->OnDoc_Open(pDocument, sScriptName); 537 pContext->OnDoc_Open(pDocument->GetEnv(), sScriptName);
538 538
539 CFX_WideString csInfo; 539 CFX_WideString csInfo;
540 FX_BOOL bRet = pContext->RunScript(script, &csInfo); 540 FX_BOOL bRet = pContext->RunScript(script, &csInfo);
541 if (!bRet) { 541 if (!bRet) {
542 // FIXME: return error. 542 // FIXME: return error.
543 } 543 }
544 544
545 pRuntime->ReleaseContext(pContext); 545 pRuntime->ReleaseContext(pContext);
546 } 546 }
547 547
548 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( 548 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript(
549 CPDFSDK_Document* pDocument, 549 CPDFSDK_Document* pDocument,
550 CPDF_AAction::AActionType type, 550 CPDF_AAction::AActionType type,
551 const CFX_WideString& script) { 551 const CFX_WideString& script) {
552 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); 552 IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
553 pRuntime->SetReaderDocument(pDocument); 553 pRuntime->SetReaderDocument(pDocument);
554 554
555 IJS_Context* pContext = pRuntime->NewContext(); 555 IJS_Context* pContext = pRuntime->NewContext();
556 switch (type) { 556 switch (type) {
557 case CPDF_AAction::OpenPage: 557 case CPDF_AAction::OpenPage:
558 pContext->OnPage_Open(pDocument); 558 pContext->OnPage_Open(pDocument->GetEnv());
559 break; 559 break;
560 case CPDF_AAction::ClosePage: 560 case CPDF_AAction::ClosePage:
561 pContext->OnPage_Close(pDocument); 561 pContext->OnPage_Close(pDocument->GetEnv());
562 break; 562 break;
563 case CPDF_AAction::CloseDocument: 563 case CPDF_AAction::CloseDocument:
564 pContext->OnDoc_WillClose(pDocument); 564 pContext->OnDoc_WillClose(pDocument->GetEnv());
565 break; 565 break;
566 case CPDF_AAction::SaveDocument: 566 case CPDF_AAction::SaveDocument:
567 pContext->OnDoc_WillSave(pDocument); 567 pContext->OnDoc_WillSave(pDocument->GetEnv());
568 break; 568 break;
569 case CPDF_AAction::DocumentSaved: 569 case CPDF_AAction::DocumentSaved:
570 pContext->OnDoc_DidSave(pDocument); 570 pContext->OnDoc_DidSave(pDocument->GetEnv());
571 break; 571 break;
572 case CPDF_AAction::PrintDocument: 572 case CPDF_AAction::PrintDocument:
573 pContext->OnDoc_WillPrint(pDocument); 573 pContext->OnDoc_WillPrint(pDocument->GetEnv());
574 break; 574 break;
575 case CPDF_AAction::DocumentPrinted: 575 case CPDF_AAction::DocumentPrinted:
576 pContext->OnDoc_DidPrint(pDocument); 576 pContext->OnDoc_DidPrint(pDocument->GetEnv());
577 break; 577 break;
578 case CPDF_AAction::PageVisible: 578 case CPDF_AAction::PageVisible:
579 pContext->OnPage_InView(pDocument); 579 pContext->OnPage_InView(pDocument->GetEnv());
580 break; 580 break;
581 case CPDF_AAction::PageInvisible: 581 case CPDF_AAction::PageInvisible:
582 pContext->OnPage_OutView(pDocument); 582 pContext->OnPage_OutView(pDocument->GetEnv());
583 break; 583 break;
584 default: 584 default:
585 ASSERT(FALSE); 585 ASSERT(FALSE);
586 break; 586 break;
587 } 587 }
588 588
589 CFX_WideString csInfo; 589 CFX_WideString csInfo;
590 FX_BOOL bRet = pContext->RunScript(script, &csInfo); 590 FX_BOOL bRet = pContext->RunScript(script, &csInfo);
591 if (!bRet) { 591 if (!bRet) {
592 // FIXME: return error. 592 // FIXME: return error.
(...skipping 30 matching lines...) Expand all
623 const CPDF_Action& action, 623 const CPDF_Action& action,
624 CPDFSDK_Document* pDocument) { 624 CPDFSDK_Document* pDocument) {
625 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); 625 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
626 if (pInterForm->DoAction_ImportData(action)) { 626 if (pInterForm->DoAction_ImportData(action)) {
627 pDocument->SetChangeMark(); 627 pDocument->SetChangeMark();
628 return TRUE; 628 return TRUE;
629 } 629 }
630 630
631 return FALSE; 631 return FALSE;
632 } 632 }
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/javascript/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698