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