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

Side by Side Diff: xfa/fxjse/context.cpp

Issue 1899103002: XFA unused function cleanup (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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
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 "xfa/fxjse/context.h" 7 #include "xfa/fxjse/context.h"
8 8
9 #include "xfa/fxjse/class.h" 9 #include "xfa/fxjse/class.h"
10 #include "xfa/fxjse/scope_inline.h" 10 #include "xfa/fxjse/scope_inline.h"
(...skipping 19 matching lines...) Expand all
30 CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext); 30 CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext);
31 if (!pContext) { 31 if (!pContext) {
32 return NULL; 32 return NULL;
33 } 33 }
34 CFXJSE_Value* lpValue = CFXJSE_Value::Create(pContext->GetRuntime()); 34 CFXJSE_Value* lpValue = CFXJSE_Value::Create(pContext->GetRuntime());
35 ASSERT(lpValue); 35 ASSERT(lpValue);
36 pContext->GetGlobalObject(lpValue); 36 pContext->GetGlobalObject(lpValue);
37 return reinterpret_cast<FXJSE_HVALUE>(lpValue); 37 return reinterpret_cast<FXJSE_HVALUE>(lpValue);
38 } 38 }
39 39
40 FXJSE_HRUNTIME FXJSE_Context_GetRuntime(FXJSE_HCONTEXT hContext) {
41 CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext);
42 return pContext ? reinterpret_cast<FXJSE_HRUNTIME>(pContext->GetRuntime())
43 : NULL;
44 }
45
46 static const FX_CHAR* szCompatibleModeScripts[] = { 40 static const FX_CHAR* szCompatibleModeScripts[] = {
47 "(function(global, list) {\n" 41 "(function(global, list) {\n"
48 " 'use strict';\n" 42 " 'use strict';\n"
49 " var objname;\n" 43 " var objname;\n"
50 " for (objname in list) {\n" 44 " for (objname in list) {\n"
51 " var globalobj = global[objname];\n" 45 " var globalobj = global[objname];\n"
52 " if (globalobj) {\n" 46 " if (globalobj) {\n"
53 " list[objname].forEach(function(name) {\n" 47 " list[objname].forEach(function(name) {\n"
54 " if (!globalobj[name]) {\n" 48 " if (!globalobj[name]) {\n"
55 " Object.defineProperty(globalobj, name, {\n" 49 " Object.defineProperty(globalobj, name, {\n"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 hReturnValue->Set(4, hMessage->GetSourceLine()); 114 hReturnValue->Set(4, hMessage->GetSourceLine());
121 v8::Maybe<int32_t> maybe_int = 115 v8::Maybe<int32_t> maybe_int =
122 hMessage->GetStartColumn(pIsolate->GetCurrentContext()); 116 hMessage->GetStartColumn(pIsolate->GetCurrentContext());
123 hReturnValue->Set(5, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0))); 117 hReturnValue->Set(5, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0)));
124 maybe_int = hMessage->GetEndColumn(pIsolate->GetCurrentContext()); 118 maybe_int = hMessage->GetEndColumn(pIsolate->GetCurrentContext());
125 hReturnValue->Set(6, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0))); 119 hReturnValue->Set(6, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0)));
126 } 120 }
127 return hReturnValue; 121 return hReturnValue;
128 } 122 }
129 123
130 FX_BOOL FXJSE_ReturnValue_GetMessage(FXJSE_HVALUE hRetValue,
131 CFX_ByteString& utf8Name,
132 CFX_ByteString& utf8Message) {
133 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hRetValue);
134 if (!lpValue) {
135 return FALSE;
136 }
137 v8::Isolate* pIsolate = lpValue->GetIsolate();
138 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate);
139 v8::Local<v8::Value> hValue =
140 v8::Local<v8::Value>::New(pIsolate, lpValue->DirectGetValue());
141 if (!hValue->IsObject()) {
142 return FALSE;
143 }
144 v8::String::Utf8Value hStringVal0(
145 hValue.As<v8::Object>()->Get(0)->ToString());
146 utf8Name = *hStringVal0;
147 v8::String::Utf8Value hStringVal1(
148 hValue.As<v8::Object>()->Get(1)->ToString());
149 utf8Message = *hStringVal1;
150 return TRUE;
151 }
152
153 FX_BOOL FXJSE_ReturnValue_GetLineInfo(FXJSE_HVALUE hRetValue,
154 int32_t& nLine,
155 int32_t& nCol) {
156 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hRetValue);
157 if (!lpValue) {
158 return FALSE;
159 }
160 v8::Isolate* pIsolate = lpValue->GetIsolate();
161 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate);
162 v8::Local<v8::Value> hValue =
163 v8::Local<v8::Value>::New(pIsolate, lpValue->DirectGetValue());
164 if (!hValue->IsObject()) {
165 return FALSE;
166 }
167 v8::MaybeLocal<v8::Int32> maybe_int =
168 hValue.As<v8::Object>()->Get(3)->ToInt32(pIsolate->GetCurrentContext());
169 nLine = maybe_int.FromMaybe(v8::Local<v8::Int32>())->Value();
170 maybe_int =
171 hValue.As<v8::Object>()->Get(5)->ToInt32(pIsolate->GetCurrentContext());
172 nCol = maybe_int.FromMaybe(v8::Local<v8::Int32>())->Value();
173 return TRUE;
174 }
175
176 CFXJSE_Context* CFXJSE_Context::Create(v8::Isolate* pIsolate, 124 CFXJSE_Context* CFXJSE_Context::Create(v8::Isolate* pIsolate,
177 const FXJSE_CLASS* lpGlobalClass, 125 const FXJSE_CLASS* lpGlobalClass,
178 void* lpGlobalObject) { 126 void* lpGlobalObject) {
179 CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); 127 CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate);
180 CFXJSE_Context* pContext = new CFXJSE_Context(pIsolate); 128 CFXJSE_Context* pContext = new CFXJSE_Context(pIsolate);
181 CFXJSE_Class* lpGlobalClassObj = NULL; 129 CFXJSE_Class* lpGlobalClassObj = NULL;
182 v8::Local<v8::ObjectTemplate> hObjectTemplate; 130 v8::Local<v8::ObjectTemplate> hObjectTemplate;
183 if (lpGlobalClass) { 131 if (lpGlobalClass) {
184 lpGlobalClassObj = CFXJSE_Class::Create(pContext, lpGlobalClass, TRUE); 132 lpGlobalClassObj = CFXJSE_Class::Create(pContext, lpGlobalClass, TRUE);
185 ASSERT(lpGlobalClassObj); 133 ASSERT(lpGlobalClassObj);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 return TRUE; 214 return TRUE;
267 } 215 }
268 } 216 }
269 if (lpRetValue) { 217 if (lpRetValue) {
270 lpRetValue->m_hValue.Reset(m_pIsolate, 218 lpRetValue->m_hValue.Reset(m_pIsolate,
271 FXJSE_CreateReturnValue(m_pIsolate, trycatch)); 219 FXJSE_CreateReturnValue(m_pIsolate, trycatch));
272 } 220 }
273 return FALSE; 221 return FALSE;
274 } 222 }
275 } 223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698