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

Side by Side Diff: fpdfsdk/src/javascript/global.cpp

Issue 1395713002: Merge to XFA: Rename IFXJS_Runtime and IFXJS_Context to IJS_. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 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/src/javascript/global.h ('k') | fpdfsdk/src/javascript/report.h » ('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 "global.h" 7 #include "global.h"
8 8
9 #include "../../../core/include/fxcrt/fx_ext.h" 9 #include "../../../core/include/fxcrt/fx_ext.h"
10 #include "../../include/fpdfxfa/fpdfxfa_app.h" 10 #include "../../include/fpdfxfa/fpdfxfa_app.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 BEGIN_JS_STATIC_PROP(CJS_Global) 82 BEGIN_JS_STATIC_PROP(CJS_Global)
83 END_JS_STATIC_PROP() 83 END_JS_STATIC_PROP()
84 84
85 BEGIN_JS_STATIC_METHOD(CJS_Global) 85 BEGIN_JS_STATIC_METHOD(CJS_Global)
86 JS_STATIC_METHOD_ENTRY(setPersistent) 86 JS_STATIC_METHOD_ENTRY(setPersistent)
87 END_JS_STATIC_METHOD() 87 END_JS_STATIC_METHOD()
88 88
89 IMPLEMENT_SPECIAL_JS_CLASS(CJS_Global, JSGlobalAlternate, global); 89 IMPLEMENT_SPECIAL_JS_CLASS(CJS_Global, JSGlobalAlternate, global);
90 90
91 FX_BOOL CJS_Global::InitInstance(IFXJS_Context* cc) { 91 FX_BOOL CJS_Global::InitInstance(IJS_Context* cc) {
92 CJS_Context* pContext = (CJS_Context*)cc; 92 CJS_Context* pContext = (CJS_Context*)cc;
93 ASSERT(pContext != NULL); 93 ASSERT(pContext != NULL);
94 94
95 JSGlobalAlternate* pGlobal = (JSGlobalAlternate*)GetEmbedObject(); 95 JSGlobalAlternate* pGlobal = (JSGlobalAlternate*)GetEmbedObject();
96 ASSERT(pGlobal != NULL); 96 ASSERT(pGlobal != NULL);
97 97
98 pGlobal->Initial(pContext->GetReaderApp()); 98 pGlobal->Initial(pContext->GetReaderApp());
99 99
100 return TRUE; 100 return TRUE;
101 }; 101 };
(...skipping 10 matching lines...) Expand all
112 void JSGlobalAlternate::Initial(CPDFDoc_Environment* pApp) { 112 void JSGlobalAlternate::Initial(CPDFDoc_Environment* pApp) {
113 m_pApp = pApp; 113 m_pApp = pApp;
114 m_pGlobalData = CJS_GlobalData::GetRetainedInstance(pApp); 114 m_pGlobalData = CJS_GlobalData::GetRetainedInstance(pApp);
115 UpdateGlobalPersistentVariables(); 115 UpdateGlobalPersistentVariables();
116 } 116 }
117 117
118 FX_BOOL JSGlobalAlternate::QueryProperty(const FX_WCHAR* propname) { 118 FX_BOOL JSGlobalAlternate::QueryProperty(const FX_WCHAR* propname) {
119 return CFX_WideString(propname) != L"setPersistent"; 119 return CFX_WideString(propname) != L"setPersistent";
120 } 120 }
121 121
122 FX_BOOL JSGlobalAlternate::DelProperty(IFXJS_Context* cc, 122 FX_BOOL JSGlobalAlternate::DelProperty(IJS_Context* cc,
123 const FX_WCHAR* propname, 123 const FX_WCHAR* propname,
124 CFX_WideString& sError) { 124 CFX_WideString& sError) {
125 auto it = m_mapGlobal.find(CFX_ByteString::FromUnicode(propname)); 125 auto it = m_mapGlobal.find(CFX_ByteString::FromUnicode(propname));
126 if (it == m_mapGlobal.end()) 126 if (it == m_mapGlobal.end())
127 return FALSE; 127 return FALSE;
128 128
129 it->second->bDeleted = TRUE; 129 it->second->bDeleted = TRUE;
130 return TRUE; 130 return TRUE;
131 } 131 }
132 132
133 FX_BOOL JSGlobalAlternate::DoProperty(IFXJS_Context* cc, 133 FX_BOOL JSGlobalAlternate::DoProperty(IJS_Context* cc,
134 const FX_WCHAR* propname, 134 const FX_WCHAR* propname,
135 CJS_PropValue& vp, 135 CJS_PropValue& vp,
136 CFX_WideString& sError) { 136 CFX_WideString& sError) {
137 if (vp.IsSetting()) { 137 if (vp.IsSetting()) {
138 CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname); 138 CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname);
139 switch (vp.GetType()) { 139 switch (vp.GetType()) {
140 case CJS_Value::VT_number: { 140 case CJS_Value::VT_number: {
141 double dData; 141 double dData;
142 vp >> dData; 142 vp >> dData;
143 return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_NUMBER, dData, 143 return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_NUMBER, dData,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 case JS_GLOBALDATA_TYPE_NULL: 202 case JS_GLOBALDATA_TYPE_NULL:
203 vp.SetNull(); 203 vp.SetNull();
204 return TRUE; 204 return TRUE;
205 default: 205 default:
206 break; 206 break;
207 } 207 }
208 } 208 }
209 return FALSE; 209 return FALSE;
210 } 210 }
211 211
212 FX_BOOL JSGlobalAlternate::setPersistent(IFXJS_Context* cc, 212 FX_BOOL JSGlobalAlternate::setPersistent(IJS_Context* cc,
213 const CJS_Parameters& params, 213 const CJS_Parameters& params,
214 CJS_Value& vRet, 214 CJS_Value& vRet,
215 CFX_WideString& sError) { 215 CFX_WideString& sError) {
216 CJS_Context* pContext = static_cast<CJS_Context*>(cc); 216 CJS_Context* pContext = static_cast<CJS_Context*>(cc);
217 if (params.size() != 2) { 217 if (params.size() != 2) {
218 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 218 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
219 return FALSE; 219 return FALSE;
220 } 220 }
221 221
222 auto it = m_mapGlobal.find(params[0].ToCFXByteString()); 222 auto it = m_mapGlobal.find(params[0].ToCFXByteString());
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 return CJS_Value::VT_boolean; 525 return CJS_Value::VT_boolean;
526 if (nHash == JSCONST_nDateHash) 526 if (nHash == JSCONST_nDateHash)
527 return CJS_Value::VT_date; 527 return CJS_Value::VT_date;
528 if (nHash == JSCONST_nObjectHash) 528 if (nHash == JSCONST_nObjectHash)
529 return CJS_Value::VT_object; 529 return CJS_Value::VT_object;
530 if (nHash == JSCONST_nFXobjHash) 530 if (nHash == JSCONST_nFXobjHash)
531 return CJS_Value::VT_fxobject; 531 return CJS_Value::VT_fxobject;
532 532
533 return CJS_Value::VT_unknown; 533 return CJS_Value::VT_unknown;
534 } 534 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/global.h ('k') | fpdfsdk/src/javascript/report.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698