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

Side by Side Diff: fpdfsdk/javascript/JS_EventHandler.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 | « fpdfsdk/javascript/JS_EventHandler.h ('k') | fpdfsdk/javascript/JS_Runtime_Stub.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/javascript/JS_EventHandler.h" 7 #include "fpdfsdk/javascript/JS_EventHandler.h"
8 8
9 #include "fpdfsdk/javascript/Document.h" 9 #include "fpdfsdk/javascript/Document.h"
10 #include "fpdfsdk/javascript/Field.h" 10 #include "fpdfsdk/javascript/Field.h"
(...skipping 14 matching lines...) Expand all
25 m_bShift(FALSE), 25 m_bShift(FALSE),
26 m_pISelEnd(nullptr), 26 m_pISelEnd(nullptr),
27 m_nSelEndDu(0), 27 m_nSelEndDu(0),
28 m_pISelStart(nullptr), 28 m_pISelStart(nullptr),
29 m_nSelStartDu(0), 29 m_nSelStartDu(0),
30 m_bWillCommit(FALSE), 30 m_bWillCommit(FALSE),
31 m_pValue(nullptr), 31 m_pValue(nullptr),
32 m_bFieldFull(FALSE), 32 m_bFieldFull(FALSE),
33 m_pbRc(nullptr), 33 m_pbRc(nullptr),
34 m_bRcDu(FALSE), 34 m_bRcDu(FALSE),
35 m_pSourceDoc(nullptr),
36 m_pTargetBookMark(nullptr), 35 m_pTargetBookMark(nullptr),
37 m_pTargetDoc(nullptr), 36 m_pTargetFormFillEnv(nullptr),
38 m_pTargetAnnot(nullptr) {} 37 m_pTargetAnnot(nullptr) {}
39 38
40 CJS_EventHandler::~CJS_EventHandler() {} 39 CJS_EventHandler::~CJS_EventHandler() {}
41 40
42 void CJS_EventHandler::OnApp_Init() { 41 void CJS_EventHandler::OnApp_Init() {
43 Initial(JET_APP_INIT); 42 Initial(JET_APP_INIT);
44 } 43 }
45 44
46 void CJS_EventHandler::OnDoc_Open(CPDFSDK_Document* pDoc, 45 void CJS_EventHandler::OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
47 const CFX_WideString& strTargetName) { 46 const CFX_WideString& strTargetName) {
48 Initial(JET_DOC_OPEN); 47 Initial(JET_DOC_OPEN);
49 48 m_pTargetFormFillEnv = pFormFillEnv;
50 m_pTargetDoc = pDoc;
51 m_strTargetName = strTargetName; 49 m_strTargetName = strTargetName;
52 } 50 }
53 51
54 void CJS_EventHandler::OnDoc_WillPrint(CPDFSDK_Document* pDoc) { 52 void CJS_EventHandler::OnDoc_WillPrint(
53 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
55 Initial(JET_DOC_WILLPRINT); 54 Initial(JET_DOC_WILLPRINT);
56 55 m_pTargetFormFillEnv = pFormFillEnv;
57 m_pTargetDoc = pDoc;
58 } 56 }
59 57
60 void CJS_EventHandler::OnDoc_DidPrint(CPDFSDK_Document* pDoc) { 58 void CJS_EventHandler::OnDoc_DidPrint(
59 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
61 Initial(JET_DOC_DIDPRINT); 60 Initial(JET_DOC_DIDPRINT);
62 61 m_pTargetFormFillEnv = pFormFillEnv;
63 m_pTargetDoc = pDoc;
64 } 62 }
65 63
66 void CJS_EventHandler::OnDoc_WillSave(CPDFSDK_Document* pDoc) { 64 void CJS_EventHandler::OnDoc_WillSave(
65 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
67 Initial(JET_DOC_WILLSAVE); 66 Initial(JET_DOC_WILLSAVE);
68 m_pTargetDoc = pDoc; 67 m_pTargetFormFillEnv = pFormFillEnv;
69 } 68 }
70 69
71 void CJS_EventHandler::OnDoc_DidSave(CPDFSDK_Document* pDoc) { 70 void CJS_EventHandler::OnDoc_DidSave(
71 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
72 Initial(JET_DOC_DIDSAVE); 72 Initial(JET_DOC_DIDSAVE);
73 73 m_pTargetFormFillEnv = pFormFillEnv;
74 m_pTargetDoc = pDoc;
75 } 74 }
76 75
77 void CJS_EventHandler::OnDoc_WillClose(CPDFSDK_Document* pDoc) { 76 void CJS_EventHandler::OnDoc_WillClose(
77 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
78 Initial(JET_DOC_WILLCLOSE); 78 Initial(JET_DOC_WILLCLOSE);
79 79 m_pTargetFormFillEnv = pFormFillEnv;
80 m_pTargetDoc = pDoc;
81 } 80 }
82 81
83 void CJS_EventHandler::OnPage_Open(CPDFSDK_Document* pDoc) { 82 void CJS_EventHandler::OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
84 Initial(JET_PAGE_OPEN); 83 Initial(JET_PAGE_OPEN);
85 84 m_pTargetFormFillEnv = pFormFillEnv;
86 m_pTargetDoc = pDoc;
87 } 85 }
88 86
89 void CJS_EventHandler::OnPage_Close(CPDFSDK_Document* pDoc) { 87 void CJS_EventHandler::OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
90 Initial(JET_PAGE_CLOSE); 88 Initial(JET_PAGE_CLOSE);
91 89 m_pTargetFormFillEnv = pFormFillEnv;
92 m_pTargetDoc = pDoc;
93 } 90 }
94 91
95 void CJS_EventHandler::OnPage_InView(CPDFSDK_Document* pDoc) { 92 void CJS_EventHandler::OnPage_InView(
93 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
96 Initial(JET_PAGE_INVIEW); 94 Initial(JET_PAGE_INVIEW);
97 95 m_pTargetFormFillEnv = pFormFillEnv;
98 m_pTargetDoc = pDoc;
99 } 96 }
100 97
101 void CJS_EventHandler::OnPage_OutView(CPDFSDK_Document* pDoc) { 98 void CJS_EventHandler::OnPage_OutView(
99 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
102 Initial(JET_PAGE_OUTVIEW); 100 Initial(JET_PAGE_OUTVIEW);
103 101 m_pTargetFormFillEnv = pFormFillEnv;
104 m_pTargetDoc = pDoc;
105 } 102 }
106 103
107 void CJS_EventHandler::OnField_MouseEnter(FX_BOOL bModifier, 104 void CJS_EventHandler::OnField_MouseEnter(FX_BOOL bModifier,
108 FX_BOOL bShift, 105 FX_BOOL bShift,
109 CPDF_FormField* pTarget) { 106 CPDF_FormField* pTarget) {
110 Initial(JET_FIELD_MOUSEENTER); 107 Initial(JET_FIELD_MOUSEENTER);
111 108
112 m_bModifier = bModifier; 109 m_bModifier = bModifier;
113 m_bShift = bShift; 110 m_bShift = bShift;
114 111
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 void CJS_EventHandler::OnScreen_OutView(FX_BOOL bModifier, 333 void CJS_EventHandler::OnScreen_OutView(FX_BOOL bModifier,
337 FX_BOOL bShift, 334 FX_BOOL bShift,
338 CPDFSDK_Annot* pScreen) { 335 CPDFSDK_Annot* pScreen) {
339 Initial(JET_SCREEN_OUTVIEW); 336 Initial(JET_SCREEN_OUTVIEW);
340 337
341 m_bModifier = bModifier; 338 m_bModifier = bModifier;
342 m_bShift = bShift; 339 m_bShift = bShift;
343 m_pTargetAnnot = pScreen; 340 m_pTargetAnnot = pScreen;
344 } 341 }
345 342
346 void CJS_EventHandler::OnLink_MouseUp(CPDFSDK_Document* pTarget) { 343 void CJS_EventHandler::OnLink_MouseUp(
344 CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) {
347 Initial(JET_LINK_MOUSEUP); 345 Initial(JET_LINK_MOUSEUP);
348 346 m_pTargetFormFillEnv = pTargetFormFillEnv;
349 m_pTargetDoc = pTarget;
350 } 347 }
351 348
352 void CJS_EventHandler::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) { 349 void CJS_EventHandler::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) {
353 Initial(JET_BOOKMARK_MOUSEUP); 350 Initial(JET_BOOKMARK_MOUSEUP);
354 351
355 m_pTargetBookMark = pBookMark; 352 m_pTargetBookMark = pBookMark;
356 } 353 }
357 354
358 void CJS_EventHandler::OnMenu_Exec(CPDFSDK_Document* pTarget, 355 void CJS_EventHandler::OnMenu_Exec(
359 const CFX_WideString& strTargetName) { 356 CPDFSDK_FormFillEnvironment* pTargetFormFillEnv,
357 const CFX_WideString& strTargetName) {
360 Initial(JET_MENU_EXEC); 358 Initial(JET_MENU_EXEC);
361 359 m_pTargetFormFillEnv = pTargetFormFillEnv;
362 m_pTargetDoc = pTarget;
363 m_strTargetName = strTargetName; 360 m_strTargetName = strTargetName;
364 } 361 }
365 362
366 void CJS_EventHandler::OnExternal_Exec() { 363 void CJS_EventHandler::OnExternal_Exec() {
367 Initial(JET_EXTERNAL_EXEC); 364 Initial(JET_EXTERNAL_EXEC);
368 } 365 }
369 366
370 void CJS_EventHandler::OnBatchExec(CPDFSDK_Document* pTarget) { 367 void CJS_EventHandler::OnBatchExec(
368 CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) {
371 Initial(JET_BATCH_EXEC); 369 Initial(JET_BATCH_EXEC);
372 370 m_pTargetFormFillEnv = pTargetFormFillEnv;
373 m_pTargetDoc = pTarget;
374 } 371 }
375 372
376 void CJS_EventHandler::OnConsole_Exec() { 373 void CJS_EventHandler::OnConsole_Exec() {
377 Initial(JET_CONSOLE_EXEC); 374 Initial(JET_CONSOLE_EXEC);
378 } 375 }
379 376
380 void CJS_EventHandler::Initial(JS_EVENT_T type) { 377 void CJS_EventHandler::Initial(JS_EVENT_T type) {
381 m_eEventType = type; 378 m_eEventType = type;
382 379
383 m_strTargetName = L""; 380 m_strTargetName = L"";
384 m_strSourceName = L""; 381 m_strSourceName = L"";
385 m_pWideStrChange = nullptr; 382 m_pWideStrChange = nullptr;
386 m_WideStrChangeDu = L""; 383 m_WideStrChangeDu = L"";
387 m_WideStrChangeEx = L""; 384 m_WideStrChangeEx = L"";
388 m_nCommitKey = -1; 385 m_nCommitKey = -1;
389 m_bKeyDown = FALSE; 386 m_bKeyDown = FALSE;
390 m_bModifier = FALSE; 387 m_bModifier = FALSE;
391 m_bShift = FALSE; 388 m_bShift = FALSE;
392 m_pISelEnd = nullptr; 389 m_pISelEnd = nullptr;
393 m_nSelEndDu = 0; 390 m_nSelEndDu = 0;
394 m_pISelStart = nullptr; 391 m_pISelStart = nullptr;
395 m_nSelStartDu = 0; 392 m_nSelStartDu = 0;
396 m_bWillCommit = FALSE; 393 m_bWillCommit = FALSE;
397 m_pValue = nullptr; 394 m_pValue = nullptr;
398 m_bFieldFull = FALSE; 395 m_bFieldFull = FALSE;
399 m_pbRc = nullptr; 396 m_pbRc = nullptr;
400 m_bRcDu = FALSE; 397 m_bRcDu = FALSE;
401 398
402 m_pSourceDoc = nullptr;
403 m_pTargetBookMark = nullptr; 399 m_pTargetBookMark = nullptr;
404 m_pTargetDoc = nullptr; 400 m_pTargetFormFillEnv = nullptr;
405 m_pTargetAnnot = nullptr; 401 m_pTargetAnnot = nullptr;
406 402
407 m_bValid = TRUE; 403 m_bValid = TRUE;
408 } 404 }
409 405
410 void CJS_EventHandler::Destroy() { 406 void CJS_EventHandler::Destroy() {
411 m_bValid = FALSE; 407 m_bValid = FALSE;
412 } 408 }
413 409
414 FX_BOOL CJS_EventHandler::IsValid() { 410 FX_BOOL CJS_EventHandler::IsValid() {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID); 595 pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID);
600 ASSERT(!pDocObj.IsEmpty()); 596 ASSERT(!pDocObj.IsEmpty());
601 597
602 v8::Local<v8::Object> pFieldObj = 598 v8::Local<v8::Object> pFieldObj =
603 pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID); 599 pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID);
604 ASSERT(!pFieldObj.IsEmpty()); 600 ASSERT(!pFieldObj.IsEmpty());
605 601
606 CJS_Document* pJSDocument = 602 CJS_Document* pJSDocument =
607 static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj)); 603 static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj));
608 Document* pDocument = (Document*)pJSDocument->GetEmbedObject(); 604 Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
609 pDocument->AttachDoc(m_pTargetDoc ? m_pTargetDoc 605 pDocument->AttachDoc(m_pTargetFormFillEnv
610 : m_pJSContext->GetReaderDocument()); 606 ? m_pTargetFormFillEnv->GetSDKDocument()
607 : m_pJSContext->GetFormFillEnv()->GetSDKDocument());
611 608
612 CJS_Field* pJSField = 609 CJS_Field* pJSField =
613 static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj)); 610 static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
614 Field* pField = (Field*)pJSField->GetEmbedObject(); 611 Field* pField = (Field*)pJSField->GetEmbedObject();
615 pField->AttachField(pDocument, m_strSourceName); 612 pField->AttachField(pDocument, m_strSourceName);
616 return pField; 613 return pField;
617 } 614 }
618 615
619 Field* CJS_EventHandler::Target_Field() { 616 Field* CJS_EventHandler::Target_Field() {
620 CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime(); 617 CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
621 v8::Local<v8::Object> pDocObj = 618 v8::Local<v8::Object> pDocObj =
622 pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID); 619 pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID);
623 ASSERT(!pDocObj.IsEmpty()); 620 ASSERT(!pDocObj.IsEmpty());
624 621
625 v8::Local<v8::Object> pFieldObj = 622 v8::Local<v8::Object> pFieldObj =
626 pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID); 623 pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID);
627 ASSERT(!pFieldObj.IsEmpty()); 624 ASSERT(!pFieldObj.IsEmpty());
628 625
629 CJS_Document* pJSDocument = 626 CJS_Document* pJSDocument =
630 static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj)); 627 static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj));
631 Document* pDocument = (Document*)pJSDocument->GetEmbedObject(); 628 Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
632 pDocument->AttachDoc(m_pTargetDoc ? m_pTargetDoc 629 pDocument->AttachDoc(m_pTargetFormFillEnv
633 : m_pJSContext->GetReaderDocument()); 630 ? m_pTargetFormFillEnv->GetSDKDocument()
631 : m_pJSContext->GetFormFillEnv()->GetSDKDocument());
634 632
635 CJS_Field* pJSField = 633 CJS_Field* pJSField =
636 static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj)); 634 static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
637 Field* pField = (Field*)pJSField->GetEmbedObject(); 635 Field* pField = (Field*)pJSField->GetEmbedObject();
638 pField->AttachField(pDocument, m_strTargetName); 636 pField->AttachField(pDocument, m_strTargetName);
639 return pField; 637 return pField;
640 } 638 }
641 639
642 CFX_WideString& CJS_EventHandler::Value() { 640 CFX_WideString& CJS_EventHandler::Value() {
643 return *m_pValue; 641 return *m_pValue;
644 } 642 }
645 643
646 FX_BOOL CJS_EventHandler::WillCommit() { 644 FX_BOOL CJS_EventHandler::WillCommit() {
647 return m_bWillCommit; 645 return m_bWillCommit;
648 } 646 }
649 647
650 CFX_WideString CJS_EventHandler::TargetName() { 648 CFX_WideString CJS_EventHandler::TargetName() {
651 return m_strTargetName; 649 return m_strTargetName;
652 } 650 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/JS_EventHandler.h ('k') | fpdfsdk/javascript/JS_Runtime_Stub.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698