summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/Document.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-02-16 17:01:00 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-02-21 15:18:27 +0000
commitb1670b5cca9a59dfb612ef9eb891a70dd716bf9c (patch)
treee624b1ca93721894ff29a14bb52443bf4f952cf6 /fpdfsdk/javascript/Document.cpp
parent026f3d306d339585612d63a9f6ac5ed8839a3179 (diff)
downloadpdfium-b1670b5cca9a59dfb612ef9eb891a70dd716bf9c.tar.xz
Pass CJS_Runtime to JS callbacks.
This is much more convenient, since only a fraction of them need an IJS_EventContext, which can be obtained from the CJS_Runtime. Make GetCurrentEventContext() specific to CJS_Runtime, and return the concrete type. This saves a lot of casting. Change-Id: If79a3bcbf44de513f3caace153099234cc313d47 Reviewed-on: https://pdfium-review.googlesource.com/2793 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/Document.cpp')
-rw-r--r--fpdfsdk/javascript/Document.cpp196
1 files changed, 86 insertions, 110 deletions
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 38600ed766..133e1b3fd9 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -163,7 +163,7 @@ Document::~Document() {
}
// the total number of fileds in document.
-bool Document::numFields(IJS_EventContext* cc,
+bool Document::numFields(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (vp.IsSetting()) {
@@ -180,7 +180,7 @@ bool Document::numFields(IJS_EventContext* cc,
return true;
}
-bool Document::dirty(IJS_EventContext* cc,
+bool Document::dirty(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (!m_pFormFillEnv) {
@@ -201,16 +201,16 @@ bool Document::dirty(IJS_EventContext* cc,
return true;
}
-bool Document::ADBE(IJS_EventContext* cc,
+bool Document::ADBE(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (vp.IsGetting())
- vp.GetJSValue()->SetNull(CJS_Runtime::FromEventContext(cc));
+ vp.GetJSValue()->SetNull(pRuntime);
return true;
}
-bool Document::pageNum(IJS_EventContext* cc,
+bool Document::pageNum(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (!m_pFormFillEnv) {
@@ -235,7 +235,7 @@ bool Document::pageNum(IJS_EventContext* cc,
return true;
}
-bool Document::addAnnot(IJS_EventContext* cc,
+bool Document::addAnnot(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -243,7 +243,7 @@ bool Document::addAnnot(IJS_EventContext* cc,
return true;
}
-bool Document::addField(IJS_EventContext* cc,
+bool Document::addField(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -251,7 +251,7 @@ bool Document::addField(IJS_EventContext* cc,
return true;
}
-bool Document::exportAsText(IJS_EventContext* cc,
+bool Document::exportAsText(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -259,7 +259,7 @@ bool Document::exportAsText(IJS_EventContext* cc,
return true;
}
-bool Document::exportAsFDF(IJS_EventContext* cc,
+bool Document::exportAsFDF(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -267,7 +267,7 @@ bool Document::exportAsFDF(IJS_EventContext* cc,
return true;
}
-bool Document::exportAsXFDF(IJS_EventContext* cc,
+bool Document::exportAsXFDF(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -280,7 +280,7 @@ bool Document::exportAsXFDF(IJS_EventContext* cc,
// note: the paremter cName, this is clue how to treat if the cName is not a
// valiable filed name in this document
-bool Document::getField(IJS_EventContext* cc,
+bool Document::getField(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -292,7 +292,6 @@ bool Document::getField(IJS_EventContext* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
CFX_WideString wideName = params[0].ToCFXWideString(pRuntime);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
@@ -313,7 +312,7 @@ bool Document::getField(IJS_EventContext* cc,
}
// Gets the name of the nth field in the document
-bool Document::getNthFieldName(IJS_EventContext* cc,
+bool Document::getNthFieldName(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -325,7 +324,6 @@ bool Document::getNthFieldName(IJS_EventContext* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
int nIndex = params[0].ToInt(pRuntime);
if (nIndex < 0) {
sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
@@ -341,7 +339,7 @@ bool Document::getNthFieldName(IJS_EventContext* cc,
return true;
}
-bool Document::importAnFDF(IJS_EventContext* cc,
+bool Document::importAnFDF(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -349,7 +347,7 @@ bool Document::importAnFDF(IJS_EventContext* cc,
return true;
}
-bool Document::importAnXFDF(IJS_EventContext* cc,
+bool Document::importAnXFDF(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -357,7 +355,7 @@ bool Document::importAnXFDF(IJS_EventContext* cc,
return true;
}
-bool Document::importTextData(IJS_EventContext* cc,
+bool Document::importTextData(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -368,7 +366,7 @@ bool Document::importTextData(IJS_EventContext* cc,
// exports the form data and mails the resulting fdf file as an attachment to
// all recipients.
// comment: need reader supports
-bool Document::mailForm(IJS_EventContext* cc,
+bool Document::mailForm(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -380,7 +378,6 @@ bool Document::mailForm(IJS_EventContext* cc,
sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
int iLength = params.size();
bool bUI = iLength > 0 ? params[0].ToBool(pRuntime) : true;
CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString(pRuntime) : L"";
@@ -403,7 +400,7 @@ bool Document::mailForm(IJS_EventContext* cc,
return true;
}
-bool Document::print(IJS_EventContext* cc,
+bool Document::print(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -411,7 +408,6 @@ bool Document::print(IJS_EventContext* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
bool bUI = true;
int nStart = 0;
int nEnd = 0;
@@ -472,7 +468,7 @@ bool Document::print(IJS_EventContext* cc,
// comment:
// note: if the filed name is not rational, adobe is dumb for it.
-bool Document::removeField(IJS_EventContext* cc,
+bool Document::removeField(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -489,7 +485,6 @@ bool Document::removeField(IJS_EventContext* cc,
sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
CFX_WideString sFieldName = params[0].ToCFXWideString(pRuntime);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
std::vector<CPDFSDK_Annot::ObservedPtr> widgets;
@@ -532,7 +527,7 @@ bool Document::removeField(IJS_EventContext* cc,
// comment:
// note: if the fields names r not rational, aodbe is dumb for it.
-bool Document::resetForm(IJS_EventContext* cc,
+bool Document::resetForm(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -557,9 +552,6 @@ bool Document::resetForm(IJS_EventContext* cc,
return true;
}
- CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
-
switch (params[0].GetType()) {
default:
aName.Attach(params[0].ToV8Array(pRuntime));
@@ -586,7 +578,7 @@ bool Document::resetForm(IJS_EventContext* cc,
return true;
}
-bool Document::saveAs(IJS_EventContext* cc,
+bool Document::saveAs(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -594,14 +586,14 @@ bool Document::saveAs(IJS_EventContext* cc,
return true;
}
-bool Document::syncAnnotScan(IJS_EventContext* cc,
+bool Document::syncAnnotScan(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
return true;
}
-bool Document::submitForm(IJS_EventContext* cc,
+bool Document::submitForm(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -614,7 +606,7 @@ bool Document::submitForm(IJS_EventContext* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
+
CJS_Array aFields;
CFX_WideString strURL;
bool bFDF = true;
@@ -683,18 +675,16 @@ void Document::SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
m_pFormFillEnv.Reset(pFormFillEnv);
}
-bool Document::bookmarkRoot(IJS_EventContext* cc,
+bool Document::bookmarkRoot(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
return true;
}
-bool Document::mailDoc(IJS_EventContext* cc,
+bool Document::mailDoc(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
-
// TODO(tsepez): Check maximum number of allowed params.
bool bUI = true;
CFX_WideString cTo = L"";
@@ -746,13 +736,13 @@ bool Document::mailDoc(IJS_EventContext* cc,
return true;
}
-bool Document::author(IJS_EventContext* cc,
+bool Document::author(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
- return getPropertyInternal(cc, vp, "Author", sError);
+ return getPropertyInternal(pRuntime, vp, "Author", sError);
}
-bool Document::info(IJS_EventContext* cc,
+bool Document::info(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (vp.IsSetting()) {
@@ -778,7 +768,6 @@ bool Document::info(IJS_EventContext* cc,
CFX_WideString cwModDate = pDictionary->GetUnicodeTextFor("ModDate");
CFX_WideString cwTrapped = pDictionary->GetUnicodeTextFor("Trapped");
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
v8::Local<v8::Object> pObj = pRuntime->NewFxDynamicObj(-1);
pRuntime->PutObjectProperty(pObj, L"Author", pRuntime->NewString(cwAuthor));
pRuntime->PutObjectProperty(pObj, L"Title", pRuntime->NewString(cwTitle));
@@ -813,7 +802,7 @@ bool Document::info(IJS_EventContext* cc,
return true;
}
-bool Document::getPropertyInternal(IJS_EventContext* cc,
+bool Document::getPropertyInternal(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
const CFX_ByteString& propName,
CFX_WideString& sError) {
@@ -841,19 +830,19 @@ bool Document::getPropertyInternal(IJS_EventContext* cc,
return true;
}
-bool Document::creationDate(IJS_EventContext* cc,
+bool Document::creationDate(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
- return getPropertyInternal(cc, vp, "CreationDate", sError);
+ return getPropertyInternal(pRuntime, vp, "CreationDate", sError);
}
-bool Document::creator(IJS_EventContext* cc,
+bool Document::creator(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
- return getPropertyInternal(cc, vp, "Creator", sError);
+ return getPropertyInternal(pRuntime, vp, "Creator", sError);
}
-bool Document::delay(IJS_EventContext* cc,
+bool Document::delay(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (!m_pFormFillEnv) {
@@ -881,41 +870,41 @@ bool Document::delay(IJS_EventContext* cc,
return true;
}
-bool Document::keywords(IJS_EventContext* cc,
+bool Document::keywords(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
- return getPropertyInternal(cc, vp, "Keywords", sError);
+ return getPropertyInternal(pRuntime, vp, "Keywords", sError);
}
-bool Document::modDate(IJS_EventContext* cc,
+bool Document::modDate(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
- return getPropertyInternal(cc, vp, "ModDate", sError);
+ return getPropertyInternal(pRuntime, vp, "ModDate", sError);
}
-bool Document::producer(IJS_EventContext* cc,
+bool Document::producer(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
- return getPropertyInternal(cc, vp, "Producer", sError);
+ return getPropertyInternal(pRuntime, vp, "Producer", sError);
}
-bool Document::subject(IJS_EventContext* cc,
+bool Document::subject(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
- return getPropertyInternal(cc, vp, "Subject", sError);
+ return getPropertyInternal(pRuntime, vp, "Subject", sError);
}
-bool Document::title(IJS_EventContext* cc,
+bool Document::title(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (!m_pFormFillEnv || !m_pFormFillEnv->GetUnderlyingDocument()) {
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
}
- return getPropertyInternal(cc, vp, "Title", sError);
+ return getPropertyInternal(pRuntime, vp, "Title", sError);
}
-bool Document::numPages(IJS_EventContext* cc,
+bool Document::numPages(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (vp.IsSetting()) {
@@ -930,7 +919,7 @@ bool Document::numPages(IJS_EventContext* cc,
return true;
}
-bool Document::external(IJS_EventContext* cc,
+bool Document::external(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
// In Chrome case, should always return true.
@@ -940,7 +929,7 @@ bool Document::external(IJS_EventContext* cc,
return true;
}
-bool Document::filesize(IJS_EventContext* cc,
+bool Document::filesize(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (vp.IsSetting()) {
@@ -951,19 +940,19 @@ bool Document::filesize(IJS_EventContext* cc,
return true;
}
-bool Document::mouseX(IJS_EventContext* cc,
+bool Document::mouseX(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
return true;
}
-bool Document::mouseY(IJS_EventContext* cc,
+bool Document::mouseY(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
return true;
}
-bool Document::URL(IJS_EventContext* cc,
+bool Document::URL(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (vp.IsSetting()) {
@@ -978,7 +967,7 @@ bool Document::URL(IJS_EventContext* cc,
return true;
}
-bool Document::baseURL(IJS_EventContext* cc,
+bool Document::baseURL(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (vp.IsGetting()) {
@@ -989,7 +978,7 @@ bool Document::baseURL(IJS_EventContext* cc,
return true;
}
-bool Document::calculate(IJS_EventContext* cc,
+bool Document::calculate(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (!m_pFormFillEnv) {
@@ -1007,7 +996,7 @@ bool Document::calculate(IJS_EventContext* cc,
return true;
}
-bool Document::documentFileName(IJS_EventContext* cc,
+bool Document::documentFileName(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (vp.IsSetting()) {
@@ -1032,7 +1021,7 @@ bool Document::documentFileName(IJS_EventContext* cc,
return true;
}
-bool Document::path(IJS_EventContext* cc,
+bool Document::path(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (vp.IsSetting()) {
@@ -1047,40 +1036,40 @@ bool Document::path(IJS_EventContext* cc,
return true;
}
-bool Document::pageWindowRect(IJS_EventContext* cc,
+bool Document::pageWindowRect(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
return true;
}
-bool Document::layout(IJS_EventContext* cc,
+bool Document::layout(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
return true;
}
-bool Document::addLink(IJS_EventContext* cc,
+bool Document::addLink(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
return true;
}
-bool Document::closeDoc(IJS_EventContext* cc,
+bool Document::closeDoc(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
return true;
}
-bool Document::getPageBox(IJS_EventContext* cc,
+bool Document::getPageBox(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
return true;
}
-bool Document::getAnnot(IJS_EventContext* cc,
+bool Document::getAnnot(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1092,7 +1081,6 @@ bool Document::getAnnot(IJS_EventContext* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
int nPageNo = params[0].ToInt(pRuntime);
CFX_WideString swAnnotName = params[1].ToCFXWideString(pRuntime);
CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(nPageNo);
@@ -1131,7 +1119,7 @@ bool Document::getAnnot(IJS_EventContext* cc,
return true;
}
-bool Document::getAnnots(IJS_EventContext* cc,
+bool Document::getAnnots(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1139,8 +1127,6 @@ bool Document::getAnnots(IJS_EventContext* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
-
// TODO(tonikitoo): Add support supported parameters as per
// the PDF spec.
@@ -1180,29 +1166,29 @@ bool Document::getAnnots(IJS_EventContext* cc,
return true;
}
-bool Document::getAnnot3D(IJS_EventContext* cc,
+bool Document::getAnnot3D(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
- vRet.SetNull(CJS_Runtime::FromEventContext(cc));
+ vRet.SetNull(pRuntime);
return true;
}
-bool Document::getAnnots3D(IJS_EventContext* cc,
+bool Document::getAnnots3D(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
return true;
}
-bool Document::getOCGs(IJS_EventContext* cc,
+bool Document::getOCGs(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
return true;
}
-bool Document::getLinks(IJS_EventContext* cc,
+bool Document::getLinks(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1214,7 +1200,7 @@ bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) {
rect.right >= LinkRect.right && rect.bottom >= LinkRect.bottom);
}
-bool Document::addIcon(IJS_EventContext* cc,
+bool Document::addIcon(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1223,7 +1209,6 @@ bool Document::addIcon(IJS_EventContext* cc,
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
CFX_WideString swIconName = params[0].ToCFXWideString(pRuntime);
if (params[1].GetType() != CJS_Value::VT_object) {
sError = JSGetStringFromID(IDS_STRING_JSTYPEERROR);
@@ -1247,22 +1232,19 @@ bool Document::addIcon(IJS_EventContext* cc,
return true;
}
-bool Document::icons(IJS_EventContext* cc,
+bool Document::icons(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (vp.IsSetting()) {
sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
return false;
}
-
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
if (m_Icons.empty()) {
vp.GetJSValue()->SetNull(pRuntime);
return true;
}
CJS_Array Icons;
-
int i = 0;
for (const auto& pIconElement : m_Icons) {
v8::Local<v8::Object> pObj =
@@ -1288,7 +1270,7 @@ bool Document::icons(IJS_EventContext* cc,
return true;
}
-bool Document::getIcon(IJS_EventContext* cc,
+bool Document::getIcon(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1300,9 +1282,7 @@ bool Document::getIcon(IJS_EventContext* cc,
if (m_Icons.empty())
return false;
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
CFX_WideString swIconName = params[0].ToCFXWideString(pRuntime);
-
for (const auto& pIconElement : m_Icons) {
if (pIconElement->IconName != swIconName)
continue;
@@ -1331,7 +1311,7 @@ bool Document::getIcon(IJS_EventContext* cc,
return false;
}
-bool Document::removeIcon(IJS_EventContext* cc,
+bool Document::removeIcon(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1339,7 +1319,7 @@ bool Document::removeIcon(IJS_EventContext* cc,
return true;
}
-bool Document::createDataObject(IJS_EventContext* cc,
+bool Document::createDataObject(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1347,13 +1327,13 @@ bool Document::createDataObject(IJS_EventContext* cc,
return true;
}
-bool Document::media(IJS_EventContext* cc,
+bool Document::media(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
return true;
}
-bool Document::calculateNow(IJS_EventContext* cc,
+bool Document::calculateNow(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1371,13 +1351,13 @@ bool Document::calculateNow(IJS_EventContext* cc,
return true;
}
-bool Document::Collab(IJS_EventContext* cc,
+bool Document::Collab(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
return true;
}
-bool Document::getPageNthWord(IJS_EventContext* cc,
+bool Document::getPageNthWord(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1389,7 +1369,6 @@ bool Document::getPageNthWord(IJS_EventContext* cc,
sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
// TODO(tsepez): check maximum allowable params.
@@ -1436,7 +1415,7 @@ bool Document::getPageNthWord(IJS_EventContext* cc,
return true;
}
-bool Document::getPageNthWordQuads(IJS_EventContext* cc,
+bool Document::getPageNthWordQuads(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1451,7 +1430,7 @@ bool Document::getPageNthWordQuads(IJS_EventContext* cc,
return false;
}
-bool Document::getPageNumWords(IJS_EventContext* cc,
+bool Document::getPageNumWords(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1463,7 +1442,6 @@ bool Document::getPageNumWords(IJS_EventContext* cc,
sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
int nPageNo = params.size() > 0 ? params[0].ToInt(pRuntime) : 0;
CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) {
@@ -1488,11 +1466,10 @@ bool Document::getPageNumWords(IJS_EventContext* cc,
return true;
}
-bool Document::getPrintParams(IJS_EventContext* cc,
+bool Document::getPrintParams(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
v8::Local<v8::Object> pRetObj =
pRuntime->NewFxDynamicObj(CJS_PrintParamsObj::g_nObjDefnID);
@@ -1574,7 +1551,7 @@ CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj,
return swRet;
}
-bool Document::zoom(IJS_EventContext* cc,
+bool Document::zoom(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
return true;
@@ -1590,13 +1567,13 @@ bool Document::zoom(IJS_EventContext* cc,
(refW, ReflowWidth)
*/
-bool Document::zoomType(IJS_EventContext* cc,
+bool Document::zoomType(CJS_Runtime* pRuntime,
CJS_PropValue& vp,
CFX_WideString& sError) {
return true;
}
-bool Document::deletePages(IJS_EventContext* cc,
+bool Document::deletePages(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1604,7 +1581,7 @@ bool Document::deletePages(IJS_EventContext* cc,
return true;
}
-bool Document::extractPages(IJS_EventContext* cc,
+bool Document::extractPages(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1612,7 +1589,7 @@ bool Document::extractPages(IJS_EventContext* cc,
return true;
}
-bool Document::insertPages(IJS_EventContext* cc,
+bool Document::insertPages(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1620,7 +1597,7 @@ bool Document::insertPages(IJS_EventContext* cc,
return true;
}
-bool Document::replacePages(IJS_EventContext* cc,
+bool Document::replacePages(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1628,7 +1605,7 @@ bool Document::replacePages(IJS_EventContext* cc,
return true;
}
-bool Document::getURL(IJS_EventContext* cc,
+bool Document::getURL(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1636,7 +1613,7 @@ bool Document::getURL(IJS_EventContext* cc,
return true;
}
-bool Document::gotoNamedDest(IJS_EventContext* cc,
+bool Document::gotoNamedDest(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -1648,7 +1625,6 @@ bool Document::gotoNamedDest(IJS_EventContext* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
CFX_WideString wideName = params[0].ToCFXWideString(pRuntime);
CFX_ByteString utf8Name = wideName.UTF8Encode();
CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();