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 "JS_EventHandler.h" | 7 #include "JS_EventHandler.h" |
8 | 8 |
9 #include "../../include/javascript/IJavaScript.h" | 9 #include "../../include/javascript/IJavaScript.h" |
10 #include "Document.h" | 10 #include "Document.h" |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime(); | 614 CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime(); |
615 v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj( | 615 v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj( |
616 pRuntime->GetIsolate(), m_pJSContext, | 616 pRuntime->GetIsolate(), m_pJSContext, CJS_Document::g_nObjDefnID); |
617 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Document")); | 617 ASSERT(!pDocObj.IsEmpty()); |
618 ASSERT(pDocObj.IsEmpty() == FALSE); | 618 |
619 v8::Local<v8::Object> pFieldObj = | 619 v8::Local<v8::Object> pFieldObj = FXJS_NewFxDynamicObj( |
620 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext, | 620 pRuntime->GetIsolate(), m_pJSContext, CJS_Field::g_nObjDefnID); |
621 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); | 621 ASSERT(!pFieldObj.IsEmpty()); |
622 ASSERT(pFieldObj.IsEmpty() == FALSE); | |
623 | 622 |
624 CJS_Document* pJSDocument = | 623 CJS_Document* pJSDocument = |
625 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pDocObj); | 624 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pDocObj); |
626 Document* pDocument = (Document*)pJSDocument->GetEmbedObject(); | 625 Document* pDocument = (Document*)pJSDocument->GetEmbedObject(); |
627 pDocument->AttachDoc(m_pTargetDoc ? m_pTargetDoc | 626 pDocument->AttachDoc(m_pTargetDoc ? m_pTargetDoc |
628 : m_pJSContext->GetReaderDocument()); | 627 : m_pJSContext->GetReaderDocument()); |
629 | 628 |
630 CJS_Field* pJSField = | 629 CJS_Field* pJSField = |
631 (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pFieldObj); | 630 (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pFieldObj); |
632 Field* pField = (Field*)pJSField->GetEmbedObject(); | 631 Field* pField = (Field*)pJSField->GetEmbedObject(); |
633 pField->AttachField(pDocument, m_strSourceName); | 632 pField->AttachField(pDocument, m_strSourceName); |
634 return pField; | 633 return pField; |
635 } | 634 } |
636 | 635 |
637 Field* CJS_EventHandler::Target_Field() { | 636 Field* CJS_EventHandler::Target_Field() { |
638 CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime(); | 637 CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime(); |
639 v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj( | 638 v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj( |
640 pRuntime->GetIsolate(), m_pJSContext, | 639 pRuntime->GetIsolate(), m_pJSContext, CJS_Document::g_nObjDefnID); |
641 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Document")); | 640 ASSERT(!pDocObj.IsEmpty()); |
642 ASSERT(pDocObj.IsEmpty() == FALSE); | 641 |
643 v8::Local<v8::Object> pFieldObj = | 642 v8::Local<v8::Object> pFieldObj = FXJS_NewFxDynamicObj( |
644 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext, | 643 pRuntime->GetIsolate(), m_pJSContext, CJS_Field::g_nObjDefnID); |
645 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); | 644 ASSERT(!pFieldObj.IsEmpty()); |
646 ASSERT(pFieldObj.IsEmpty() == FALSE); | |
647 | 645 |
648 CJS_Document* pJSDocument = | 646 CJS_Document* pJSDocument = |
649 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pDocObj); | 647 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pDocObj); |
650 Document* pDocument = (Document*)pJSDocument->GetEmbedObject(); | 648 Document* pDocument = (Document*)pJSDocument->GetEmbedObject(); |
651 pDocument->AttachDoc(m_pTargetDoc ? m_pTargetDoc | 649 pDocument->AttachDoc(m_pTargetDoc ? m_pTargetDoc |
652 : m_pJSContext->GetReaderDocument()); | 650 : m_pJSContext->GetReaderDocument()); |
653 | 651 |
654 CJS_Field* pJSField = | 652 CJS_Field* pJSField = |
655 (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pFieldObj); | 653 (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pFieldObj); |
656 Field* pField = (Field*)pJSField->GetEmbedObject(); | 654 Field* pField = (Field*)pJSField->GetEmbedObject(); |
657 pField->AttachField(pDocument, m_strTargetName); | 655 pField->AttachField(pDocument, m_strTargetName); |
658 return pField; | 656 return pField; |
659 } | 657 } |
660 | 658 |
661 CFX_WideString& CJS_EventHandler::Value() { | 659 CFX_WideString& CJS_EventHandler::Value() { |
662 return *m_pValue; | 660 return *m_pValue; |
663 } | 661 } |
664 | 662 |
665 FX_BOOL CJS_EventHandler::WillCommit() { | 663 FX_BOOL CJS_EventHandler::WillCommit() { |
666 return m_bWillCommit; | 664 return m_bWillCommit; |
667 } | 665 } |
668 | 666 |
669 CFX_WideString CJS_EventHandler::TargetName() { | 667 CFX_WideString CJS_EventHandler::TargetName() { |
670 return m_strTargetName; | 668 return m_strTargetName; |
671 } | 669 } |
OLD | NEW |