summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-08-08 13:03:16 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-08 13:03:16 -0700
commite1e7bd037538c6b31537fc0e3e01c508dab68132 (patch)
tree96ef5d14b8c889ab3a59a259f6ef585cef0e57eb /fpdfsdk
parente3ff76b11ac6fcd0d0196ef83946d2321ab8e9bf (diff)
downloadpdfium-e1e7bd037538c6b31537fc0e3e01c508dab68132.tar.xz
Remove MsgBox()/Alert() from CJS_EmbedObj.
They're only related to the |app| object, not all embed's. Alert() itself unused. Review-Url: https://codereview.chromium.org/2224073002
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/javascript/JS_Object.cpp24
-rw-r--r--fpdfsdk/javascript/JS_Object.h11
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp33
-rw-r--r--fpdfsdk/javascript/app.cpp12
4 files changed, 32 insertions, 48 deletions
diff --git a/fpdfsdk/javascript/JS_Object.cpp b/fpdfsdk/javascript/JS_Object.cpp
index e72d0f3872..d97029765d 100644
--- a/fpdfsdk/javascript/JS_Object.cpp
+++ b/fpdfsdk/javascript/JS_Object.cpp
@@ -16,24 +16,6 @@ CJS_EmbedObj::~CJS_EmbedObj() {
m_pJSObject = nullptr;
}
-int CJS_EmbedObj::MsgBox(CPDFDoc_Environment* pApp,
- const FX_WCHAR* swMsg,
- const FX_WCHAR* swTitle,
- FX_UINT nType,
- FX_UINT nIcon) {
- if (!pApp)
- return 0;
-
- if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument())
- pDoc->KillFocusAnnot();
-
- return pApp->JS_appAlert(swMsg, swTitle, nType, nIcon);
-}
-
-void CJS_EmbedObj::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg) {
- CJS_Object::Alert(pContext, swMsg);
-}
-
void FreeObject(const v8::WeakCallbackInfo<CJS_Object>& data) {
CJS_Object* pJSObj = data.GetParameter();
pJSObj->ExitInstance();
@@ -66,9 +48,3 @@ void CJS_Object::Dispose() {
void CJS_Object::InitInstance(IJS_Runtime* pIRuntime) {}
void CJS_Object::ExitInstance() {}
-
-void CJS_Object::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg) {
- CPDFDoc_Environment* pApp = pContext->GetReaderApp();
- if (pApp)
- pApp->JS_appAlert(swMsg, nullptr, 0, 3);
-}
diff --git a/fpdfsdk/javascript/JS_Object.h b/fpdfsdk/javascript/JS_Object.h
index 3f0db0ea71..5875861fff 100644
--- a/fpdfsdk/javascript/JS_Object.h
+++ b/fpdfsdk/javascript/JS_Object.h
@@ -25,13 +25,6 @@ class CJS_EmbedObj {
CJS_Object* GetJSObject() const { return m_pJSObject; }
- int MsgBox(CPDFDoc_Environment* pApp,
- const FX_WCHAR* swMsg,
- const FX_WCHAR* swTitle,
- FX_UINT nType,
- FX_UINT nIcon);
- void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg);
-
protected:
CJS_Object* m_pJSObject;
};
@@ -53,9 +46,7 @@ class CJS_Object {
void SetEmbedObject(CJS_EmbedObj* pObj) { m_pEmbedObj.reset(pObj); }
CJS_EmbedObj* GetEmbedObject() const { return m_pEmbedObj.get(); }
- static void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg);
-
- v8::Isolate* GetIsolate() { return m_pIsolate; }
+ v8::Isolate* GetIsolate() const { return m_pIsolate; }
protected:
std::unique_ptr<CJS_EmbedObj> m_pEmbedObj;
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index 6af59bd278..aa0efb1fa6 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -77,6 +77,12 @@ CFX_WideString StrTrim(const CFX_WideString& pStr) {
return result;
}
+void AlertIfPossible(CJS_Context* pContext, const FX_WCHAR* swMsg) {
+ CPDFDoc_Environment* pApp = pContext->GetReaderApp();
+ if (pApp)
+ pApp->JS_appAlert(swMsg, nullptr, 0, 3);
+}
+
} // namespace
bool CJS_PublicMethods::IsNumber(const CFX_WideString& str) {
@@ -913,7 +919,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(
if (!IsNumber(swTemp.c_str())) {
pEvent->Rc() = FALSE;
sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE);
- Alert(pContext, sError.c_str());
+ AlertIfPossible(pContext, sError.c_str());
}
return TRUE; // it happens after the last keystroke and before validating,
}
@@ -1122,7 +1128,7 @@ FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IJS_Context* cc,
CFX_WideString swMsg;
swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(),
sFormat.c_str());
- Alert(pContext, swMsg.c_str());
+ AlertIfPossible(pContext, swMsg.c_str());
return FALSE;
}
@@ -1214,7 +1220,7 @@ FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(
CFX_WideString swMsg;
swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(),
sFormat.c_str());
- Alert(pContext, swMsg.c_str());
+ AlertIfPossible(pContext, swMsg.c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
@@ -1432,7 +1438,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(
if (iIndexMask != wstrMask.GetLength() ||
(iIndexMask != valEvent.GetLength() && wstrMask.GetLength() != 0)) {
- Alert(
+ AlertIfPossible(
pContext,
JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE).c_str());
pEvent->Rc() = FALSE;
@@ -1449,23 +1455,26 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(
FX_STRSIZE combined_len = valEvent.GetLength() + wChange.GetLength() +
pEvent->SelStart() - pEvent->SelEnd();
if (combined_len > wstrMask.GetLength()) {
- Alert(pContext,
- JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
+ AlertIfPossible(
+ pContext,
+ JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
if (iIndexMask >= wstrMask.GetLength() && !wChange.IsEmpty()) {
- Alert(pContext,
- JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
+ AlertIfPossible(
+ pContext,
+ JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
for (FX_STRSIZE i = 0; i < wChange.GetLength(); ++i) {
if (iIndexMask >= wstrMask.GetLength()) {
- Alert(pContext,
- JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
+ AlertIfPossible(
+ pContext,
+ JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
@@ -1584,7 +1593,7 @@ FX_BOOL CJS_PublicMethods::AFParseDateEx(IJS_Context* cc,
CFX_WideString swMsg;
swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(),
sFormat.c_str());
- Alert((CJS_Context*)cc, swMsg.c_str());
+ AlertIfPossible((CJS_Context*)cc, swMsg.c_str());
return FALSE;
}
@@ -1768,7 +1777,7 @@ FX_BOOL CJS_PublicMethods::AFRange_Validate(
}
if (!swMsg.IsEmpty()) {
- Alert(pContext, swMsg.c_str());
+ AlertIfPossible(pContext, swMsg.c_str());
pEvent->Rc() = FALSE;
}
return TRUE;
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index 755652d219..50afd9a6c4 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -403,6 +403,12 @@ FX_BOOL app::alert(IJS_Context* cc,
return FALSE;
}
+ CPDFDoc_Environment* pApp = pRuntime->GetReaderApp();
+ if (!pApp) {
+ vRet = 0;
+ return TRUE;
+ }
+
CFX_WideString swMsg;
if (newParams[0].GetType() == CJS_Value::VT_object) {
CJS_Array carray;
@@ -438,8 +444,10 @@ FX_BOOL app::alert(IJS_Context* cc,
swTitle = JSGetStringFromID(pContext, IDS_STRING_JSALERT);
pRuntime->BeginBlock();
- vRet = MsgBox(pRuntime->GetReaderApp(), swMsg.c_str(), swTitle.c_str(), iType,
- iIcon);
+ if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument())
+ pDoc->KillFocusAnnot();
+
+ vRet = pApp->JS_appAlert(swMsg.c_str(), swTitle.c_str(), iType, iIcon);
pRuntime->EndBlock();
return TRUE;
}