| 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 "fpdfsdk/javascript/Document.h" | 7 #include "fpdfsdk/javascript/Document.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 11 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
| 12 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 12 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
| 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 14 #include "fpdfsdk/include/fsdk_mgr.h" | 14 #include "fpdfsdk/include/fsdk_mgr.h" |
| 15 #include "fpdfsdk/include/javascript/IJavaScript.h" | |
| 16 #include "fpdfsdk/javascript/Field.h" | 15 #include "fpdfsdk/javascript/Field.h" |
| 17 #include "fpdfsdk/javascript/Icon.h" | 16 #include "fpdfsdk/javascript/Icon.h" |
| 18 #include "fpdfsdk/javascript/JS_Context.h" | |
| 19 #include "fpdfsdk/javascript/JS_Define.h" | 17 #include "fpdfsdk/javascript/JS_Define.h" |
| 20 #include "fpdfsdk/javascript/JS_EventHandler.h" | 18 #include "fpdfsdk/javascript/JS_EventHandler.h" |
| 21 #include "fpdfsdk/javascript/JS_Object.h" | 19 #include "fpdfsdk/javascript/JS_Object.h" |
| 22 #include "fpdfsdk/javascript/JS_Runtime.h" | |
| 23 #include "fpdfsdk/javascript/JS_Value.h" | 20 #include "fpdfsdk/javascript/JS_Value.h" |
| 24 #include "fpdfsdk/javascript/app.h" | 21 #include "fpdfsdk/javascript/app.h" |
| 22 #include "fpdfsdk/javascript/cjs_context.h" |
| 23 #include "fpdfsdk/javascript/cjs_runtime.h" |
| 25 #include "fpdfsdk/javascript/resource.h" | 24 #include "fpdfsdk/javascript/resource.h" |
| 26 #include "third_party/base/numerics/safe_math.h" | 25 #include "third_party/base/numerics/safe_math.h" |
| 27 | 26 |
| 28 static v8::Isolate* GetIsolate(IJS_Context* cc) { | 27 static v8::Isolate* GetIsolate(IJS_Context* cc) { |
| 29 CJS_Context* pContext = (CJS_Context*)cc; | 28 CJS_Context* pContext = (CJS_Context*)cc; |
| 30 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 29 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 31 return pRuntime->GetIsolate(); | 30 return pRuntime->GetIsolate(); |
| 32 } | 31 } |
| 33 | 32 |
| 34 BEGIN_JS_STATIC_CONST(CJS_PrintParamsObj) | 33 BEGIN_JS_STATIC_CONST(CJS_PrintParamsObj) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 47 bUI = TRUE; | 46 bUI = TRUE; |
| 48 nStart = 0; | 47 nStart = 0; |
| 49 nEnd = 0; | 48 nEnd = 0; |
| 50 bSilent = FALSE; | 49 bSilent = FALSE; |
| 51 bShrinkToFit = FALSE; | 50 bShrinkToFit = FALSE; |
| 52 bPrintAsImage = FALSE; | 51 bPrintAsImage = FALSE; |
| 53 bReverse = FALSE; | 52 bReverse = FALSE; |
| 54 bAnnotations = TRUE; | 53 bAnnotations = TRUE; |
| 55 } | 54 } |
| 56 | 55 |
| 57 /* ---------------------- Document ---------------------- */ | |
| 58 | |
| 59 #define MINWIDTH 5.0f | 56 #define MINWIDTH 5.0f |
| 60 #define MINHEIGHT 5.0f | 57 #define MINHEIGHT 5.0f |
| 61 | 58 |
| 62 BEGIN_JS_STATIC_CONST(CJS_Document) | 59 BEGIN_JS_STATIC_CONST(CJS_Document) |
| 63 END_JS_STATIC_CONST() | 60 END_JS_STATIC_CONST() |
| 64 | 61 |
| 65 BEGIN_JS_STATIC_PROP(CJS_Document) | 62 BEGIN_JS_STATIC_PROP(CJS_Document) |
| 66 JS_STATIC_PROP_ENTRY(ADBE) | 63 JS_STATIC_PROP_ENTRY(ADBE) |
| 67 JS_STATIC_PROP_ENTRY(author) | 64 JS_STATIC_PROP_ENTRY(author) |
| 68 JS_STATIC_PROP_ENTRY(baseURL) | 65 JS_STATIC_PROP_ENTRY(baseURL) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 138 |
| 142 IMPLEMENT_JS_CLASS(CJS_Document, Document) | 139 IMPLEMENT_JS_CLASS(CJS_Document, Document) |
| 143 | 140 |
| 144 void CJS_Document::InitInstance(IJS_Runtime* pIRuntime) { | 141 void CJS_Document::InitInstance(IJS_Runtime* pIRuntime) { |
| 145 CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime); | 142 CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime); |
| 146 Document* pDoc = static_cast<Document*>(GetEmbedObject()); | 143 Document* pDoc = static_cast<Document*>(GetEmbedObject()); |
| 147 pDoc->AttachDoc(pRuntime->GetReaderDocument()); | 144 pDoc->AttachDoc(pRuntime->GetReaderDocument()); |
| 148 pDoc->SetIsolate(pRuntime->GetIsolate()); | 145 pDoc->SetIsolate(pRuntime->GetIsolate()); |
| 149 } | 146 } |
| 150 | 147 |
| 151 /* --------------------------------- Document --------------------------------- | |
| 152 */ | |
| 153 | |
| 154 Document::Document(CJS_Object* pJSObject) | 148 Document::Document(CJS_Object* pJSObject) |
| 155 : CJS_EmbedObj(pJSObject), | 149 : CJS_EmbedObj(pJSObject), |
| 156 m_isolate(NULL), | 150 m_isolate(NULL), |
| 157 m_pDocument(NULL), | 151 m_pDocument(NULL), |
| 158 m_cwBaseURL(L""), | 152 m_cwBaseURL(L""), |
| 159 m_bDelay(FALSE) {} | 153 m_bDelay(FALSE) {} |
| 160 | 154 |
| 161 Document::~Document() { | 155 Document::~Document() { |
| 162 } | 156 } |
| 163 | 157 |
| (...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 } | 1590 } |
| 1597 } | 1591 } |
| 1598 | 1592 |
| 1599 for (const auto& pData : DelayDataForFieldAndControlIndex) | 1593 for (const auto& pData : DelayDataForFieldAndControlIndex) |
| 1600 Field::DoDelay(m_pDocument, pData.get()); | 1594 Field::DoDelay(m_pDocument, pData.get()); |
| 1601 } | 1595 } |
| 1602 | 1596 |
| 1603 CJS_Document* Document::GetCJSDoc() const { | 1597 CJS_Document* Document::GetCJSDoc() const { |
| 1604 return static_cast<CJS_Document*>(m_pJSObject); | 1598 return static_cast<CJS_Document*>(m_pJSObject); |
| 1605 } | 1599 } |
| OLD | NEW |