diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-02-16 11:49:55 -0800 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-02-16 20:23:48 +0000 |
commit | d6ae2afa821c87e84790d5c04bbc172a7b12f08f (patch) | |
tree | 10beb72deaffca61ccc54a3fb49ea0d9636579bb /fpdfsdk/javascript/PublicMethods.cpp | |
parent | 49f7deb494064351c72ef4d31577e04f634e63f3 (diff) | |
download | pdfium-d6ae2afa821c87e84790d5c04bbc172a7b12f08f.tar.xz |
Rename IJS_Context to IJS_EventContext.
Prevents confusion with v8::Context, which is wrapped by a
different IJS_ class.
Change-Id: Iff75809e65015c0f810294de1f0d8ecf963150a3
Reviewed-on: https://pdfium-review.googlesource.com/2751
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/PublicMethods.cpp')
-rw-r--r-- | fpdfsdk/javascript/PublicMethods.cpp | 121 |
1 files changed, 60 insertions, 61 deletions
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp index c0ea84c0ae..32484d4813 100644 --- a/fpdfsdk/javascript/PublicMethods.cpp +++ b/fpdfsdk/javascript/PublicMethods.cpp @@ -22,7 +22,7 @@ #include "fpdfsdk/javascript/JS_EventHandler.h" #include "fpdfsdk/javascript/JS_Object.h" #include "fpdfsdk/javascript/JS_Value.h" -#include "fpdfsdk/javascript/cjs_context.h" +#include "fpdfsdk/javascript/cjs_event_context.h" #include "fpdfsdk/javascript/cjs_runtime.h" #include "fpdfsdk/javascript/color.h" #include "fpdfsdk/javascript/resource.h" @@ -82,7 +82,7 @@ CFX_WideString StrTrim(const CFX_WideString& pStr) { return result; } -void AlertIfPossible(CJS_Context* pContext, const FX_WCHAR* swMsg) { +void AlertIfPossible(CJS_EventContext* pContext, const FX_WCHAR* swMsg) { CPDFSDK_FormFillEnvironment* pFormFillEnv = pContext->GetFormFillEnv(); if (pFormFillEnv) pFormFillEnv->JS_appAlert(swMsg, nullptr, 0, 3); @@ -750,7 +750,7 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, // function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, // bCurrencyPrepend) -bool CJS_PublicMethods::AFNumber_Format(IJS_Context* cc, +bool CJS_PublicMethods::AFNumber_Format(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -760,7 +760,7 @@ bool CJS_PublicMethods::AFNumber_Format(IJS_Context* cc, return false; } - CJS_Context* pContext = static_cast<CJS_Context*>(cc); + CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc); CJS_Runtime* pRuntime = pContext->GetJSRuntime(); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (!pEvent->m_pValue) @@ -898,11 +898,11 @@ bool CJS_PublicMethods::AFNumber_Format(IJS_Context* cc, // function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, // bCurrencyPrepend) -bool CJS_PublicMethods::AFNumber_Keystroke(IJS_Context* cc, +bool CJS_PublicMethods::AFNumber_Keystroke(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { - CJS_Context* pContext = static_cast<CJS_Context*>(cc); + CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (params.size() < 2) @@ -945,7 +945,7 @@ bool CJS_PublicMethods::AFNumber_Keystroke(IJS_Context* cc, } } - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); int iSepStyle = params[1].ToInt(pRuntime); if (iSepStyle < 0 || iSepStyle > 3) iSepStyle = 0; @@ -999,13 +999,13 @@ bool CJS_PublicMethods::AFNumber_Keystroke(IJS_Context* cc, } // function AFPercent_Format(nDec, sepStyle) -bool CJS_PublicMethods::AFPercent_Format(IJS_Context* cc, +bool CJS_PublicMethods::AFPercent_Format(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { #if _FX_OS_ != _FX_ANDROID_ - CJS_Context* pContext = static_cast<CJS_Context*>(cc); - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (params.size() != 2) { @@ -1092,7 +1092,7 @@ bool CJS_PublicMethods::AFPercent_Format(IJS_Context* cc, } // AFPercent_Keystroke(nDec, sepStyle) bool CJS_PublicMethods::AFPercent_Keystroke( - IJS_Context* cc, + IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1100,12 +1100,12 @@ bool CJS_PublicMethods::AFPercent_Keystroke( } // function AFDate_FormatEx(cFormat) -bool CJS_PublicMethods::AFDate_FormatEx(IJS_Context* cc, +bool CJS_PublicMethods::AFDate_FormatEx(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { - CJS_Context* pContext = static_cast<CJS_Context*>(cc); - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (params.size() != 1) { @@ -1200,12 +1200,12 @@ double CJS_PublicMethods::MakeInterDate(const CFX_WideString& strValue) { } // AFDate_KeystrokeEx(cFormat) -bool CJS_PublicMethods::AFDate_KeystrokeEx(IJS_Context* cc, +bool CJS_PublicMethods::AFDate_KeystrokeEx(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { - CJS_Context* pContext = (CJS_Context*)cc; - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_EventContext* pContext = (CJS_EventContext*)cc; + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (params.size() != 1) { @@ -1235,7 +1235,7 @@ bool CJS_PublicMethods::AFDate_KeystrokeEx(IJS_Context* cc, return true; } -bool CJS_PublicMethods::AFDate_Format(IJS_Context* cc, +bool CJS_PublicMethods::AFDate_Format(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1244,7 +1244,7 @@ bool CJS_PublicMethods::AFDate_Format(IJS_Context* cc, return false; } - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); int iIndex = params[0].ToInt(pRuntime); const FX_WCHAR* cFormats[] = {L"m/d", L"m/d/yy", @@ -1266,12 +1266,12 @@ bool CJS_PublicMethods::AFDate_Format(IJS_Context* cc, std::vector<CJS_Value> newParams; newParams.push_back( - CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex])); + CJS_Value(CJS_Runtime::FromEventContext(cc), cFormats[iIndex])); return AFDate_FormatEx(cc, newParams, vRet, sError); } // AFDate_KeystrokeEx(cFormat) -bool CJS_PublicMethods::AFDate_Keystroke(IJS_Context* cc, +bool CJS_PublicMethods::AFDate_Keystroke(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1280,7 +1280,7 @@ bool CJS_PublicMethods::AFDate_Keystroke(IJS_Context* cc, return false; } - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); int iIndex = params[0].ToInt(pRuntime); const FX_WCHAR* cFormats[] = {L"m/d", L"m/d/yy", @@ -1302,12 +1302,12 @@ bool CJS_PublicMethods::AFDate_Keystroke(IJS_Context* cc, std::vector<CJS_Value> newParams; newParams.push_back( - CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex])); + CJS_Value(CJS_Runtime::FromEventContext(cc), cFormats[iIndex])); return AFDate_KeystrokeEx(cc, newParams, vRet, sError); } // function AFTime_Format(ptf) -bool CJS_PublicMethods::AFTime_Format(IJS_Context* cc, +bool CJS_PublicMethods::AFTime_Format(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1316,7 +1316,7 @@ bool CJS_PublicMethods::AFTime_Format(IJS_Context* cc, return false; } - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); int iIndex = params[0].ToInt(pRuntime); const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt"}; @@ -1326,11 +1326,11 @@ bool CJS_PublicMethods::AFTime_Format(IJS_Context* cc, std::vector<CJS_Value> newParams; newParams.push_back( - CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex])); + CJS_Value(CJS_Runtime::FromEventContext(cc), cFormats[iIndex])); return AFDate_FormatEx(cc, newParams, vRet, sError); } -bool CJS_PublicMethods::AFTime_Keystroke(IJS_Context* cc, +bool CJS_PublicMethods::AFTime_Keystroke(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1339,7 +1339,7 @@ bool CJS_PublicMethods::AFTime_Keystroke(IJS_Context* cc, return false; } - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); int iIndex = params[0].ToInt(pRuntime); const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt"}; @@ -1349,18 +1349,18 @@ bool CJS_PublicMethods::AFTime_Keystroke(IJS_Context* cc, std::vector<CJS_Value> newParams; newParams.push_back( - CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex])); + CJS_Value(CJS_Runtime::FromEventContext(cc), cFormats[iIndex])); return AFDate_KeystrokeEx(cc, newParams, vRet, sError); } -bool CJS_PublicMethods::AFTime_FormatEx(IJS_Context* cc, +bool CJS_PublicMethods::AFTime_FormatEx(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { return AFDate_FormatEx(cc, params, vRet, sError); } -bool CJS_PublicMethods::AFTime_KeystrokeEx(IJS_Context* cc, +bool CJS_PublicMethods::AFTime_KeystrokeEx(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1368,7 +1368,7 @@ bool CJS_PublicMethods::AFTime_KeystrokeEx(IJS_Context* cc, } // function AFSpecial_Format(psf) -bool CJS_PublicMethods::AFSpecial_Format(IJS_Context* cc, +bool CJS_PublicMethods::AFSpecial_Format(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1377,12 +1377,12 @@ bool CJS_PublicMethods::AFSpecial_Format(IJS_Context* cc, return false; } - CJS_Context* pContext = static_cast<CJS_Context*>(cc); + CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (!pEvent->m_pValue) return false; - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); CFX_WideString wsSource = pEvent->Value(); CFX_WideString wsFormat; switch (params[0].ToInt(pRuntime)) { @@ -1409,12 +1409,12 @@ bool CJS_PublicMethods::AFSpecial_Format(IJS_Context* cc, // function AFSpecial_KeystrokeEx(mask) bool CJS_PublicMethods::AFSpecial_KeystrokeEx( - IJS_Context* cc, + IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { - CJS_Context* pContext = (CJS_Context*)cc; - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_EventContext* pContext = (CJS_EventContext*)cc; + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (params.size() < 1) { @@ -1494,7 +1494,7 @@ bool CJS_PublicMethods::AFSpecial_KeystrokeEx( // function AFSpecial_Keystroke(psf) bool CJS_PublicMethods::AFSpecial_Keystroke( - IJS_Context* cc, + IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1503,13 +1503,13 @@ bool CJS_PublicMethods::AFSpecial_Keystroke( return false; } - CJS_Context* pContext = static_cast<CJS_Context*>(cc); + CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (!pEvent->m_pValue) return false; const char* cFormat = ""; - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); switch (params[0].ToInt(pRuntime)) { case 0: cFormat = "99999"; @@ -1529,11 +1529,11 @@ bool CJS_PublicMethods::AFSpecial_Keystroke( } std::vector<CJS_Value> params2; - params2.push_back(CJS_Value(CJS_Runtime::FromContext(cc), cFormat)); + params2.push_back(CJS_Value(CJS_Runtime::FromEventContext(cc), cFormat)); return AFSpecial_KeystrokeEx(cc, params2, vRet, sError); } -bool CJS_PublicMethods::AFMergeChange(IJS_Context* cc, +bool CJS_PublicMethods::AFMergeChange(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1542,8 +1542,8 @@ bool CJS_PublicMethods::AFMergeChange(IJS_Context* cc, return false; } - CJS_Context* pContext = static_cast<CJS_Context*>(cc); - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); CJS_EventHandler* pEventHandler = pContext->GetEventHandler(); CFX_WideString swValue; @@ -1574,7 +1574,7 @@ bool CJS_PublicMethods::AFMergeChange(IJS_Context* cc, return true; } -bool CJS_PublicMethods::AFParseDateEx(IJS_Context* cc, +bool CJS_PublicMethods::AFParseDateEx(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1583,17 +1583,16 @@ bool CJS_PublicMethods::AFParseDateEx(IJS_Context* cc, return false; } - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc); + CJS_Runtime* pRuntime = pContext->GetJSRuntime(); CFX_WideString sValue = params[0].ToCFXWideString(pRuntime); CFX_WideString sFormat = params[1].ToCFXWideString(pRuntime); - double dDate = MakeRegularDate(sValue, sFormat, nullptr); - if (JS_PortIsNan(dDate)) { CFX_WideString swMsg; swMsg.Format(JSGetStringFromID(IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str()); - AlertIfPossible((CJS_Context*)cc, swMsg.c_str()); + AlertIfPossible(pContext, swMsg.c_str()); return false; } @@ -1601,7 +1600,7 @@ bool CJS_PublicMethods::AFParseDateEx(IJS_Context* cc, return true; } -bool CJS_PublicMethods::AFSimple(IJS_Context* cc, +bool CJS_PublicMethods::AFSimple(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1610,7 +1609,7 @@ bool CJS_PublicMethods::AFSimple(IJS_Context* cc, return false; } - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); vRet = CJS_Value(pRuntime, static_cast<double>(AF_Simple( params[0].ToCFXWideString(pRuntime).c_str(), params[1].ToDouble(pRuntime), @@ -1619,7 +1618,7 @@ bool CJS_PublicMethods::AFSimple(IJS_Context* cc, return true; } -bool CJS_PublicMethods::AFMakeNumber(IJS_Context* cc, +bool CJS_PublicMethods::AFMakeNumber(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1628,7 +1627,7 @@ bool CJS_PublicMethods::AFMakeNumber(IJS_Context* cc, return false; } - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); CFX_WideString ws = params[0].ToCFXWideString(pRuntime); ws.Replace(L",", L"."); vRet = CJS_Value(pRuntime, ws.c_str()); @@ -1638,7 +1637,7 @@ bool CJS_PublicMethods::AFMakeNumber(IJS_Context* cc, return true; } -bool CJS_PublicMethods::AFSimple_Calculate(IJS_Context* cc, +bool CJS_PublicMethods::AFSimple_Calculate(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1653,8 +1652,8 @@ bool CJS_PublicMethods::AFSimple_Calculate(IJS_Context* cc, return false; } - CJS_Context* pContext = static_cast<CJS_Context*>(cc); - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); CPDFSDK_InterForm* pReaderInterForm = pContext->GetFormFillEnv()->GetInterForm(); CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); @@ -1737,7 +1736,7 @@ bool CJS_PublicMethods::AFSimple_Calculate(IJS_Context* cc, /* This function validates the current event to ensure that its value is ** within the specified range. */ -bool CJS_PublicMethods::AFRange_Validate(IJS_Context* cc, +bool CJS_PublicMethods::AFRange_Validate(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1745,8 +1744,8 @@ bool CJS_PublicMethods::AFRange_Validate(IJS_Context* cc, sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR); return false; } - CJS_Context* pContext = static_cast<CJS_Context*>(cc); - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (!pEvent->m_pValue) return false; @@ -1784,7 +1783,7 @@ bool CJS_PublicMethods::AFRange_Validate(IJS_Context* cc, return true; } -bool CJS_PublicMethods::AFExtractNums(IJS_Context* cc, +bool CJS_PublicMethods::AFExtractNums(IJS_EventContext* cc, const std::vector<CJS_Value>& params, CJS_Value& vRet, CFX_WideString& sError) { @@ -1793,7 +1792,7 @@ bool CJS_PublicMethods::AFExtractNums(IJS_Context* cc, return false; } - CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); + CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); CFX_WideString str = params[0].ToCFXWideString(pRuntime); CFX_WideString sPart; CJS_Array nums; |