diff options
author | tsepez <tsepez@chromium.org> | 2017-01-18 14:38:18 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2017-01-18 14:38:18 -0800 |
commit | e6cf01356e3336dc4f0717a391d9067693a418c1 (patch) | |
tree | a8d8c2cec202be753b3d558e320cf981c6983bb8 /fpdfsdk/javascript/Document.cpp | |
parent | 85c532b35b53836bebfdb8f8832905d5f313cf47 (diff) | |
download | pdfium-e6cf01356e3336dc4f0717a391d9067693a418c1.tar.xz |
Tidy FXJS_V8, backfill tests.chromium/2986
Move checks performed as part of JS_Value's object and array
handling back into FXJS, to ease removal of JS_Value in the future.
Remove some convenience routines in FXJS for objects, to shrink
API to be covered during testing.
Change some naming (number => double, string => widestring) to
make it clearer when there is a C++ type involved.
BUG=
Review-Url: https://codereview.chromium.org/2637503002
Diffstat (limited to 'fpdfsdk/javascript/Document.cpp')
-rw-r--r-- | fpdfsdk/javascript/Document.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp index 79d68ec3a7..4bf1afd5a3 100644 --- a/fpdfsdk/javascript/Document.cpp +++ b/fpdfsdk/javascript/Document.cpp @@ -801,15 +801,18 @@ bool Document::info(IJS_Context* cc, CJS_Runtime* pRuntime = pContext->GetJSRuntime(); v8::Local<v8::Object> pObj = pRuntime->NewFxDynamicObj(-1); - pRuntime->PutObjectString(pObj, L"Author", cwAuthor); - pRuntime->PutObjectString(pObj, L"Title", cwTitle); - pRuntime->PutObjectString(pObj, L"Subject", cwSubject); - pRuntime->PutObjectString(pObj, L"Keywords", cwKeywords); - pRuntime->PutObjectString(pObj, L"Creator", cwCreator); - pRuntime->PutObjectString(pObj, L"Producer", cwProducer); - pRuntime->PutObjectString(pObj, L"CreationDate", cwCreationDate); - pRuntime->PutObjectString(pObj, L"ModDate", cwModDate); - pRuntime->PutObjectString(pObj, L"Trapped", cwTrapped); + pRuntime->PutObjectProperty(pObj, L"Author", pRuntime->NewString(cwAuthor)); + pRuntime->PutObjectProperty(pObj, L"Title", pRuntime->NewString(cwTitle)); + pRuntime->PutObjectProperty(pObj, L"Subject", pRuntime->NewString(cwSubject)); + pRuntime->PutObjectProperty(pObj, L"Keywords", + pRuntime->NewString(cwKeywords)); + pRuntime->PutObjectProperty(pObj, L"Creator", pRuntime->NewString(cwCreator)); + pRuntime->PutObjectProperty(pObj, L"Producer", + pRuntime->NewString(cwProducer)); + pRuntime->PutObjectProperty(pObj, L"CreationDate", + pRuntime->NewString(cwCreationDate)); + pRuntime->PutObjectProperty(pObj, L"ModDate", pRuntime->NewString(cwModDate)); + pRuntime->PutObjectProperty(pObj, L"Trapped", pRuntime->NewString(cwTrapped)); // It's to be compatible to non-standard info dictionary. for (const auto& it : *pDictionary) { @@ -817,11 +820,14 @@ bool Document::info(IJS_Context* cc, CPDF_Object* pValueObj = it.second.get(); CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey.AsStringC()); if (pValueObj->IsString() || pValueObj->IsName()) { - pRuntime->PutObjectString(pObj, wsKey, pValueObj->GetUnicodeText()); + pRuntime->PutObjectProperty( + pObj, wsKey, pRuntime->NewString(pValueObj->GetUnicodeText())); } else if (pValueObj->IsNumber()) { - pRuntime->PutObjectNumber(pObj, wsKey, (float)pValueObj->GetNumber()); + pRuntime->PutObjectProperty(pObj, wsKey, + pRuntime->NewNumber(pValueObj->GetNumber())); } else if (pValueObj->IsBoolean()) { - pRuntime->PutObjectBoolean(pObj, wsKey, !!pValueObj->GetInteger()); + pRuntime->PutObjectProperty( + pObj, wsKey, pRuntime->NewBoolean(!!pValueObj->GetInteger())); } } vp << pObj; |