Chromium Code Reviews| Index: fpdfsdk/src/jsapi/fxjs_v8.cpp |
| diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp |
| index 0822531da60c71e900940b84afe03ea51375dc0d..198e26a616273928f0dc63e5df93802657bec240 100644 |
| --- a/fpdfsdk/src/jsapi/fxjs_v8.cpp |
| +++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp |
| @@ -30,7 +30,7 @@ static v8::Global<v8::ObjectTemplate>* g_DefaultGlobalObjectTemplate = nullptr; |
| class CFXJS_PerObjectData { |
| public: |
| - CFXJS_PerObjectData(int nObjDefID) |
| + explicit CFXJS_PerObjectData(int nObjDefID) |
| : m_ObjDefID(nObjDefID), m_pPrivate(nullptr) {} |
| int m_ObjDefID; |
|
Tom Sepez
2015/11/09 21:25:32
nit: just noticed this could be const?
Lei Zhang
2015/11/09 22:45:29
Done.
|
| @@ -39,15 +39,15 @@ class CFXJS_PerObjectData { |
| class CFXJS_ObjDefinition { |
| public: |
| - static int MaxID(v8::Isolate* pIsolate) { |
| - return static_cast<int>( |
| - FXJS_PerIsolateData::Get(pIsolate)->m_ObjectDefnArray.GetSize()); |
| + static size_t MaxID(v8::Isolate* pIsolate) { |
| + return FXJS_PerIsolateData::Get(pIsolate)->m_ObjectDefnArray.size(); |
| } |
| - static CFXJS_ObjDefinition* ForID(v8::Isolate* pIsolate, int id) { |
| + |
| + static CFXJS_ObjDefinition* ForID(v8::Isolate* pIsolate, size_t id) { |
|
Tom Sepez
2015/11/09 21:25:32
some places ID is an int, other places it's a size
Lei Zhang
2015/11/09 22:45:29
I went back to int, since we use -1 in some places
|
| // Note: GetAt() halts if out-of-range even in release builds. |
| - return static_cast<CFXJS_ObjDefinition*>( |
| - FXJS_PerIsolateData::Get(pIsolate)->m_ObjectDefnArray.GetAt(id)); |
| + return FXJS_PerIsolateData::Get(pIsolate)->m_ObjectDefnArray[id]; |
| } |
| + |
| CFXJS_ObjDefinition(v8::Isolate* isolate, |
| const wchar_t* sObjName, |
| FXJSOBJTYPE eObjType, |
| @@ -71,8 +71,8 @@ class CFXJS_ObjDefinition { |
| int AssignID() { |
| FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(m_pIsolate); |
| - pData->m_ObjectDefnArray.Add(this); |
| - return pData->m_ObjectDefnArray.GetSize() - 1; |
| + pData->m_ObjectDefnArray.push_back(this); |
| + return pData->m_ObjectDefnArray.size() - 1; |
| } |
| v8::Local<v8::ObjectTemplate> GetInstanceTemplate() { |
| @@ -100,8 +100,8 @@ class CFXJS_ObjDefinition { |
| static v8::Local<v8::ObjectTemplate> GetGlobalObjectTemplate( |
| v8::Isolate* pIsolate) { |
| - int maxID = CFXJS_ObjDefinition::MaxID(pIsolate); |
| - for (int i = 0; i < maxID; ++i) { |
| + size_t maxID = CFXJS_ObjDefinition::MaxID(pIsolate); |
| + for (size_t i = 0; i < maxID; ++i) { |
| CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(pIsolate, i); |
| if (pObjDef->m_ObjType == FXJSOBJTYPE_GLOBAL) |
| return pObjDef->GetInstanceTemplate(); |
| @@ -288,8 +288,8 @@ void FXJS_InitializeRuntime(v8::Isolate* pIsolate, |
| FXJS_PerIsolateData::SetUp(pIsolate); |
| v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pIRuntime); |
| - int maxID = CFXJS_ObjDefinition::MaxID(pIsolate); |
| - for (int i = 0; i < maxID; ++i) { |
| + size_t maxID = CFXJS_ObjDefinition::MaxID(pIsolate); |
| + for (size_t i = 0; i < maxID; ++i) { |
| CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(pIsolate, i); |
| CFX_ByteString bs = CFX_WideString(pObjDef->m_ObjName).UTF8Encode(); |
| v8::Local<v8::String> m_ObjName = |
| @@ -333,8 +333,8 @@ void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, |
| if (!pData) |
| return; |
| - int maxID = CFXJS_ObjDefinition::MaxID(pIsolate); |
| - for (int i = 0; i < maxID; ++i) { |
| + size_t maxID = CFXJS_ObjDefinition::MaxID(pIsolate); |
| + for (size_t i = 0; i < maxID; ++i) { |
| CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(pIsolate, i); |
| v8::Local<v8::Object> pObj; |
| if (pObjDef->m_ObjType == FXJSOBJTYPE_GLOBAL) { |
| @@ -553,8 +553,7 @@ v8::Local<v8::Array> FXJS_GetObjectElementNames(v8::Isolate* pIsolate, |
| void FXJS_PutObjectString(v8::Isolate* pIsolate, |
| v8::Local<v8::Object> pObj, |
| const wchar_t* PropertyName, |
| - const wchar_t* sValue) // VT_string |
| -{ |
| + const wchar_t* sValue) { |
| if (pObj.IsEmpty()) |
| return; |
| pObj->Set(pIsolate->GetCurrentContext(), |