diff options
author | tsepez <tsepez@chromium.org> | 2016-08-09 07:30:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-09 07:30:38 -0700 |
commit | f3c883239be0e016d0577f0d9d52185387f64856 (patch) | |
tree | dffbabaaa85f77dbcd78dba8863fb96d41584f94 /fpdfsdk/javascript/util.cpp | |
parent | fb362089d952950212ccf159f86a46923f223172 (diff) | |
download | pdfium-f3c883239be0e016d0577f0d9d52185387f64856.tar.xz |
Remove back-pointer to CJS_Runtime from CJS_Date
Review-Url: https://codereview.chromium.org/2224113003
Diffstat (limited to 'fpdfsdk/javascript/util.cpp')
-rw-r--r-- | fpdfsdk/javascript/util.cpp | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp index 4f2d834208..82c85a0268 100644 --- a/fpdfsdk/javascript/util.cpp +++ b/fpdfsdk/javascript/util.cpp @@ -186,13 +186,13 @@ FX_BOOL util::printd(IJS_Context* cc, CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); CJS_Value p1 = params[0]; CJS_Value p2 = params[1]; - CJS_Date jsDate(pRuntime); + CJS_Date jsDate; if (!p2.ConvertToDate(jsDate)) { sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPRINT1); return FALSE; } - if (!jsDate.IsValidDate()) { + if (!jsDate.IsValidDate(pRuntime->GetIsolate())) { sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPRINT2); return FALSE; } @@ -201,22 +201,31 @@ FX_BOOL util::printd(IJS_Context* cc, CFX_WideString swResult; switch (p1.ToInt()) { case 0: - swResult.Format(L"D:%04d%02d%02d%02d%02d%02d", jsDate.GetYear(), - jsDate.GetMonth() + 1, jsDate.GetDay(), - jsDate.GetHours(), jsDate.GetMinutes(), - jsDate.GetSeconds()); + swResult.Format(L"D:%04d%02d%02d%02d%02d%02d", + jsDate.GetYear(pRuntime->GetIsolate()), + jsDate.GetMonth(pRuntime->GetIsolate()) + 1, + jsDate.GetDay(pRuntime->GetIsolate()), + jsDate.GetHours(pRuntime->GetIsolate()), + jsDate.GetMinutes(pRuntime->GetIsolate()), + jsDate.GetSeconds(pRuntime->GetIsolate())); break; case 1: - swResult.Format(L"%04d.%02d.%02d %02d:%02d:%02d", jsDate.GetYear(), - jsDate.GetMonth() + 1, jsDate.GetDay(), - jsDate.GetHours(), jsDate.GetMinutes(), - jsDate.GetSeconds()); + swResult.Format(L"%04d.%02d.%02d %02d:%02d:%02d", + jsDate.GetYear(pRuntime->GetIsolate()), + jsDate.GetMonth(pRuntime->GetIsolate()) + 1, + jsDate.GetDay(pRuntime->GetIsolate()), + jsDate.GetHours(pRuntime->GetIsolate()), + jsDate.GetMinutes(pRuntime->GetIsolate()), + jsDate.GetSeconds(pRuntime->GetIsolate())); break; case 2: - swResult.Format(L"%04d/%02d/%02d %02d:%02d:%02d", jsDate.GetYear(), - jsDate.GetMonth() + 1, jsDate.GetDay(), - jsDate.GetHours(), jsDate.GetMinutes(), - jsDate.GetSeconds()); + swResult.Format(L"%04d/%02d/%02d %02d:%02d:%02d", + jsDate.GetYear(pRuntime->GetIsolate()), + jsDate.GetMonth(pRuntime->GetIsolate()) + 1, + jsDate.GetDay(pRuntime->GetIsolate()), + jsDate.GetHours(pRuntime->GetIsolate()), + jsDate.GetMinutes(pRuntime->GetIsolate()), + jsDate.GetSeconds(pRuntime->GetIsolate())); break; default: sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSVALUEERROR); @@ -250,12 +259,12 @@ FX_BOOL util::printd(IJS_Context* cc, } } - int iYear = jsDate.GetYear(); - int iMonth = jsDate.GetMonth(); - int iDay = jsDate.GetDay(); - int iHour = jsDate.GetHours(); - int iMin = jsDate.GetMinutes(); - int iSec = jsDate.GetSeconds(); + int iYear = jsDate.GetYear(pRuntime->GetIsolate()); + int iMonth = jsDate.GetMonth(pRuntime->GetIsolate()); + int iDay = jsDate.GetDay(pRuntime->GetIsolate()); + int iHour = jsDate.GetHours(pRuntime->GetIsolate()); + int iMin = jsDate.GetMinutes(pRuntime->GetIsolate()); + int iSec = jsDate.GetSeconds(pRuntime->GetIsolate()); TbConvertAdditional cTableAd[] = { {L"m", iMonth + 1}, {L"d", iDay}, @@ -434,7 +443,9 @@ FX_BOOL util::scand(IJS_Context* cc, } if (!JS_PortIsNan(dDate)) { - vRet = CJS_Date(CJS_Runtime::FromContext(cc), dDate); + CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + vRet = CJS_Value(pRuntime, CJS_Date(pRuntime->GetIsolate(), dDate) + .ToV8Date(pRuntime->GetIsolate())); } else { vRet.SetNull(); } |