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

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

Issue 1399833002: Allow building of XFA branch without XFA (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Keep GN in sync. 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/fsdk_mgr.cpp ('k') | pdfium.gni » ('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 "JS_Runtime.h" 7 #include "JS_Runtime.h"
8 8
9 #include "../../../xfa/src/fxjse/src/value.h" 9 #include "../../../xfa/src/fxjse/src/value.h"
10 #include "../../include/fpdfxfa/fpdfxfa_app.h" 10 #include "../../include/fpdfxfa/fpdfxfa_app.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 return v8::Local<v8::Context>::New(m_isolate, m_context); 215 return v8::Local<v8::Context>::New(m_isolate, m_context);
216 } 216 }
217 217
218 CFX_WideString ChangeObjName(const CFX_WideString& str) { 218 CFX_WideString ChangeObjName(const CFX_WideString& str) {
219 CFX_WideString sRet = str; 219 CFX_WideString sRet = str;
220 sRet.Replace(L"_", L"."); 220 sRet.Replace(L"_", L".");
221 return sRet; 221 return sRet;
222 } 222 }
223 FX_BOOL CJS_Runtime::GetHValueByName(const CFX_ByteStringC& utf8Name, 223 FX_BOOL CJS_Runtime::GetHValueByName(const CFX_ByteStringC& utf8Name,
224 FXJSE_HVALUE hValue) { 224 FXJSE_HVALUE hValue) {
225 #ifdef PDF_ENABLE_XFA
225 const FX_CHAR* name = utf8Name.GetCStr(); 226 const FX_CHAR* name = utf8Name.GetCStr();
226 227
227 v8::Locker lock(GetIsolate()); 228 v8::Locker lock(GetIsolate());
228 v8::Isolate::Scope isolate_scope(GetIsolate()); 229 v8::Isolate::Scope isolate_scope(GetIsolate());
229 v8::HandleScope handle_scope(GetIsolate()); 230 v8::HandleScope handle_scope(GetIsolate());
230 v8::Local<v8::Context> context = 231 v8::Local<v8::Context> context =
231 v8::Local<v8::Context>::New(GetIsolate(), m_context); 232 v8::Local<v8::Context>::New(GetIsolate(), m_context);
232 v8::Context::Scope context_scope(context); 233 v8::Context::Scope context_scope(context);
233 234
234 // v8::Local<v8::Context> tmpCotext = 235 // v8::Local<v8::Context> tmpCotext =
235 // v8::Local<v8::Context>::New(GetIsolate(), m_context); 236 // v8::Local<v8::Context>::New(GetIsolate(), m_context);
236 v8::Local<v8::Value> propvalue = 237 v8::Local<v8::Value> propvalue =
237 context->Global()->Get(v8::String::NewFromUtf8( 238 context->Global()->Get(v8::String::NewFromUtf8(
238 GetIsolate(), name, v8::String::kNormalString, utf8Name.GetLength())); 239 GetIsolate(), name, v8::String::kNormalString, utf8Name.GetLength()));
239 240
240 if (propvalue.IsEmpty()) { 241 if (propvalue.IsEmpty()) {
241 FXJSE_Value_SetUndefined(hValue); 242 FXJSE_Value_SetUndefined(hValue);
242 return FALSE; 243 return FALSE;
243 } 244 }
244 ((CFXJSE_Value*)hValue)->ForceSetValue(propvalue); 245 ((CFXJSE_Value*)hValue)->ForceSetValue(propvalue);
246 #endif
245 247
246 return TRUE; 248 return TRUE;
247 } 249 }
248 FX_BOOL CJS_Runtime::SetHValueByName(const CFX_ByteStringC& utf8Name, 250 FX_BOOL CJS_Runtime::SetHValueByName(const CFX_ByteStringC& utf8Name,
249 FXJSE_HVALUE hValue) { 251 FXJSE_HVALUE hValue) {
252 #ifdef PDF_ENABLE_XFA
250 if (utf8Name.IsEmpty() || hValue == NULL) 253 if (utf8Name.IsEmpty() || hValue == NULL)
251 return FALSE; 254 return FALSE;
252 const FX_CHAR* name = utf8Name.GetCStr(); 255 const FX_CHAR* name = utf8Name.GetCStr();
253 v8::Isolate* pIsolate = GetIsolate(); 256 v8::Isolate* pIsolate = GetIsolate();
254 v8::Locker lock(pIsolate); 257 v8::Locker lock(pIsolate);
255 v8::Isolate::Scope isolate_scope(pIsolate); 258 v8::Isolate::Scope isolate_scope(pIsolate);
256 v8::HandleScope handle_scope(pIsolate); 259 v8::HandleScope handle_scope(pIsolate);
257 v8::Local<v8::Context> context = 260 v8::Local<v8::Context> context =
258 v8::Local<v8::Context>::New(pIsolate, m_context); 261 v8::Local<v8::Context>::New(pIsolate, m_context);
259 v8::Context::Scope context_scope(context); 262 v8::Context::Scope context_scope(context);
260 263
261 // v8::Local<v8::Context> tmpCotext = 264 // v8::Local<v8::Context> tmpCotext =
262 // v8::Local<v8::Context>::New(GetIsolate(), m_context); 265 // v8::Local<v8::Context>::New(GetIsolate(), m_context);
263 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New( 266 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New(
264 GetIsolate(), ((CFXJSE_Value*)hValue)->DirectGetValue()); 267 GetIsolate(), ((CFXJSE_Value*)hValue)->DirectGetValue());
265 context->Global()->Set( 268 context->Global()->Set(
266 v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString, 269 v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString,
267 utf8Name.GetLength()), 270 utf8Name.GetLength()),
268 propvalue); 271 propvalue);
269 272 #endif
270 return TRUE; 273 return TRUE;
271 } 274 }
272 275
273 void CJS_Runtime::AddObserver(Observer* observer) { 276 void CJS_Runtime::AddObserver(Observer* observer) {
274 ASSERT(m_observers.find(observer) == m_observers.end()); 277 ASSERT(m_observers.find(observer) == m_observers.end());
275 m_observers.insert(observer); 278 m_observers.insert(observer);
276 } 279 }
277 280
278 void CJS_Runtime::RemoveObserver(Observer* observer) { 281 void CJS_Runtime::RemoveObserver(Observer* observer) {
279 ASSERT(m_observers.find(observer) != m_observers.end()); 282 ASSERT(m_observers.find(observer) != m_observers.end());
280 m_observers.erase(observer); 283 m_observers.erase(observer);
281 } 284 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fsdk_mgr.cpp ('k') | pdfium.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698