diff options
author | tsepez <tsepez@chromium.org> | 2016-08-11 19:50:57 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-11 19:50:57 -0700 |
commit | d0b6ed1a0842386e474c5fcd6bdbb260bb631bd1 (patch) | |
tree | 6d7282f78ac953fc965e17815bcbef7995dd59ec /fxjs/fxjs_v8.cpp | |
parent | 229d05df5bc5deb3890b26b614113c25d9b6935e (diff) | |
download | pdfium-d0b6ed1a0842386e474c5fcd6bdbb260bb631bd1.tar.xz |
Make FXJS_GetObjectElement return std::vector<CFX_WideString>.chromium/2829chromium/2828
Analogous to getting the length of JS array, this result
should be a C++-side object only.
Also rename to FXJS_GetObjectProperty to match JS nomenclature.
Review-Url: https://codereview.chromium.org/2242593002
Diffstat (limited to 'fxjs/fxjs_v8.cpp')
-rw-r--r-- | fxjs/fxjs_v8.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/fxjs/fxjs_v8.cpp b/fxjs/fxjs_v8.cpp index d161af6281..92207fdd47 100644 --- a/fxjs/fxjs_v8.cpp +++ b/fxjs/fxjs_v8.cpp @@ -596,7 +596,7 @@ v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate, .ToLocalChecked(); } -v8::Local<v8::Value> FXJS_GetObjectElement( +v8::Local<v8::Value> FXJS_GetObjectProperty( v8::Isolate* pIsolate, v8::Local<v8::Object> pObj, const CFX_WideString& wsPropertyName) { @@ -610,14 +610,23 @@ v8::Local<v8::Value> FXJS_GetObjectElement( return val; } -v8::Local<v8::Array> FXJS_GetObjectElementNames(v8::Isolate* pIsolate, - v8::Local<v8::Object> pObj) { +std::vector<CFX_WideString> FXJS_GetObjectPropertyNames( + v8::Isolate* pIsolate, + v8::Local<v8::Object> pObj) { if (pObj.IsEmpty()) - return v8::Local<v8::Array>(); + return std::vector<CFX_WideString>(); + v8::Local<v8::Array> val; if (!pObj->GetPropertyNames(pIsolate->GetCurrentContext()).ToLocal(&val)) - return v8::Local<v8::Array>(); - return val; + return std::vector<CFX_WideString>(); + + std::vector<CFX_WideString> result; + for (uint32_t i = 0; i < val->Length(); ++i) { + result.push_back(FXJS_ToString( + pIsolate, val->Get(pIsolate->GetCurrentContext(), i).ToLocalChecked())); + } + + return result; } void FXJS_PutObjectString(v8::Isolate* pIsolate, |