OLD | NEW |
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_EventHandler.h" | 9 #include "../../include/javascript/JS_EventHandler.h" |
10 #include "../../include/javascript/JS_Context.h" | 10 #include "../../include/javascript/JS_Context.h" |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 | 608 |
609 FX_BOOL CJS_EventHandler::Shift() { | 609 FX_BOOL CJS_EventHandler::Shift() { |
610 return m_bShift; | 610 return m_bShift; |
611 } | 611 } |
612 | 612 |
613 Field* CJS_EventHandler::Source() { | 613 Field* CJS_EventHandler::Source() { |
614 ASSERT(m_pJSContext != NULL); | 614 ASSERT(m_pJSContext != NULL); |
615 | 615 |
616 CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime(); | 616 CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime(); |
617 | 617 |
618 v8::Local<v8::Object> pDocObj = | 618 v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj( |
619 JS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext, | 619 pRuntime->GetIsolate(), m_pJSContext, |
620 JS_GetObjDefnID(pRuntime->GetIsolate(), L"Document")); | 620 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Document")); |
621 ASSERT(pDocObj.IsEmpty() == FALSE); | 621 ASSERT(pDocObj.IsEmpty() == FALSE); |
622 v8::Local<v8::Object> pFieldObj = | 622 v8::Local<v8::Object> pFieldObj = |
623 JS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext, | 623 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext, |
624 JS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); | 624 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); |
625 ASSERT(pFieldObj.IsEmpty() == FALSE); | 625 ASSERT(pFieldObj.IsEmpty() == FALSE); |
626 | 626 |
627 CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pDocObj); | 627 CJS_Document* pJSDocument = (CJS_Document*)FXJS_GetPrivate(pDocObj); |
628 ASSERT(pJSDocument != NULL); | |
629 Document* pDocument = (Document*)pJSDocument->GetEmbedObject(); | 628 Document* pDocument = (Document*)pJSDocument->GetEmbedObject(); |
630 ASSERT(pDocument != NULL); | |
631 if (m_pTargetDoc != NULL) | 629 if (m_pTargetDoc != NULL) |
632 pDocument->AttachDoc(m_pTargetDoc); | 630 pDocument->AttachDoc(m_pTargetDoc); |
633 else | 631 else |
634 pDocument->AttachDoc(m_pJSContext->GetReaderDocument()); | 632 pDocument->AttachDoc(m_pJSContext->GetReaderDocument()); |
635 | 633 |
636 // if (m_pSourceField == NULL) | 634 // if (m_pSourceField == NULL) |
637 // return NULL; | 635 // return NULL; |
638 // CRAO_Widget *pWidget = IBCL_Widget::GetWidget(m_pSourceField); | 636 // CRAO_Widget *pWidget = IBCL_Widget::GetWidget(m_pSourceField); |
639 // CPDF_FormField* pFormField = pWidget->GetFormField(); | 637 // CPDF_FormField* pFormField = pWidget->GetFormField(); |
640 // ASSERT(pFormField); | 638 // ASSERT(pFormField); |
641 // CFX_WideString csFieldName = pFormField->GetFullName(); | 639 // CFX_WideString csFieldName = pFormField->GetFullName(); |
642 CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(pFieldObj); | 640 CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(pFieldObj); |
643 ASSERT(pJSField != NULL); | 641 ASSERT(pJSField != NULL); |
644 Field* pField = (Field*)pJSField->GetEmbedObject(); | 642 Field* pField = (Field*)pJSField->GetEmbedObject(); |
645 ASSERT(pField != NULL); | 643 ASSERT(pField != NULL); |
646 pField->AttachField(pDocument, m_strSourceName); | 644 pField->AttachField(pDocument, m_strSourceName); |
647 return pField; | 645 return pField; |
648 } | 646 } |
649 | 647 |
650 Field* CJS_EventHandler::Target_Field() { | 648 Field* CJS_EventHandler::Target_Field() { |
651 ASSERT(m_pJSContext != NULL); | 649 ASSERT(m_pJSContext != NULL); |
652 | 650 |
653 CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime(); | 651 CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime(); |
654 | 652 |
655 v8::Local<v8::Object> pDocObj = | 653 v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj( |
656 JS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext, | 654 pRuntime->GetIsolate(), m_pJSContext, |
657 JS_GetObjDefnID(pRuntime->GetIsolate(), L"Document")); | 655 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Document")); |
658 ASSERT(pDocObj.IsEmpty() == FALSE); | 656 ASSERT(pDocObj.IsEmpty() == FALSE); |
659 v8::Local<v8::Object> pFieldObj = | 657 v8::Local<v8::Object> pFieldObj = |
660 JS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext, | 658 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext, |
661 JS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); | 659 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); |
662 ASSERT(pFieldObj.IsEmpty() == FALSE); | 660 ASSERT(pFieldObj.IsEmpty() == FALSE); |
663 | 661 |
664 CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pDocObj); | 662 CJS_Document* pJSDocument = (CJS_Document*)FXJS_GetPrivate(pDocObj); |
665 ASSERT(pJSDocument != NULL); | |
666 Document* pDocument = (Document*)pJSDocument->GetEmbedObject(); | 663 Document* pDocument = (Document*)pJSDocument->GetEmbedObject(); |
667 ASSERT(pDocument != NULL); | |
668 if (m_pTargetDoc != NULL) | 664 if (m_pTargetDoc != NULL) |
669 pDocument->AttachDoc(m_pTargetDoc); | 665 pDocument->AttachDoc(m_pTargetDoc); |
670 else | 666 else |
671 pDocument->AttachDoc(m_pJSContext->GetReaderDocument()); | 667 pDocument->AttachDoc(m_pJSContext->GetReaderDocument()); |
672 | 668 |
673 CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(pFieldObj); | 669 CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(pFieldObj); |
674 ASSERT(pJSField != NULL); | 670 ASSERT(pJSField != NULL); |
675 | 671 |
676 Field* pField = (Field*)pJSField->GetEmbedObject(); | 672 Field* pField = (Field*)pJSField->GetEmbedObject(); |
677 ASSERT(pField != NULL); | 673 ASSERT(pField != NULL); |
678 | 674 |
679 pField->AttachField(pDocument, m_strTargetName); | 675 pField->AttachField(pDocument, m_strTargetName); |
680 return pField; | 676 return pField; |
681 } | 677 } |
682 | 678 |
683 CFX_WideString& CJS_EventHandler::Value() { | 679 CFX_WideString& CJS_EventHandler::Value() { |
684 return *m_pValue; | 680 return *m_pValue; |
685 } | 681 } |
686 | 682 |
687 FX_BOOL CJS_EventHandler::WillCommit() { | 683 FX_BOOL CJS_EventHandler::WillCommit() { |
688 return m_bWillCommit; | 684 return m_bWillCommit; |
689 } | 685 } |
690 | 686 |
691 CFX_WideString CJS_EventHandler::TargetName() { | 687 CFX_WideString CJS_EventHandler::TargetName() { |
692 return m_strTargetName; | 688 return m_strTargetName; |
693 } | 689 } |
OLD | NEW |