summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/Document.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-02-27 16:37:36 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-02-28 01:11:23 +0000
commit313c42553b5355fc7e2625114d58da6f8dc71e51 (patch)
tree85c06d75b9eed2248179f40766cf8be5b0e958eb /fpdfsdk/javascript/Document.cpp
parenta99de0ec3cda8ff5b0d6383a059dd39c8626e504 (diff)
downloadpdfium-313c42553b5355fc7e2625114d58da6f8dc71e51.tar.xz
Remove unused IconElement::IconStream.
Follow up to https://pdfium-review.googlesource.com/c/2829/ Change-Id: Ic743a5931f743c3e0e3f24246dca768cec09be4f Reviewed-on: https://pdfium-review.googlesource.com/2843 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/Document.cpp')
-rw-r--r--fpdfsdk/javascript/Document.cpp44
1 files changed, 18 insertions, 26 deletions
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 6928a061a2..a45b8b9ea7 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -6,6 +6,7 @@
#include "fpdfsdk/javascript/Document.h"
+#include <algorithm>
#include <utility>
#include <vector>
@@ -1215,14 +1216,12 @@ bool Document::addIcon(CJS_Runtime* pRuntime,
return false;
}
- CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject(pRuntime)->GetEmbedObject();
- if (!pEmbedObj) {
+ if (!params[1].ToCJSObject(pRuntime)->GetEmbedObject()) {
sError = JSGetStringFromID(IDS_STRING_JSTYPEERROR);
return false;
}
- m_Icons.push_back(pdfium::MakeUnique<IconElement>(
- swIconName, static_cast<Icon*>(pEmbedObj)));
+ m_IconNames.push_back(swIconName);
return true;
}
@@ -1233,14 +1232,14 @@ bool Document::icons(CJS_Runtime* pRuntime,
sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
return false;
}
- if (m_Icons.empty()) {
+ if (m_IconNames.empty()) {
vp.GetJSValue()->SetNull(pRuntime);
return true;
}
CJS_Array Icons;
int i = 0;
- for (const auto& pIconElement : m_Icons) {
+ for (const auto& name : m_IconNames) {
v8::Local<v8::Object> pObj =
pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID);
if (pObj.IsEmpty())
@@ -1249,7 +1248,7 @@ bool Document::icons(CJS_Runtime* pRuntime,
CJS_Icon* pJS_Icon =
static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
- pIcon->SetIconName(pIconElement->IconName);
+ pIcon->SetIconName(name);
Icons.SetElement(pRuntime, i++, CJS_Value(pRuntime, pJS_Icon));
}
@@ -1266,28 +1265,21 @@ bool Document::getIcon(CJS_Runtime* pRuntime,
return false;
}
- if (m_Icons.empty())
- return false;
-
CFX_WideString swIconName = params[0].ToCFXWideString(pRuntime);
- for (const auto& pIconElement : m_Icons) {
- if (pIconElement->IconName != swIconName)
- continue;
-
- v8::Local<v8::Object> pObj =
- pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID);
- if (pObj.IsEmpty())
- return false;
+ auto it = std::find(m_IconNames.begin(), m_IconNames.end(), swIconName);
+ if (it == m_IconNames.end())
+ return false;
- CJS_Icon* pJS_Icon =
- static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
- Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
- pIcon->SetIconName(swIconName);
- vRet = CJS_Value(pRuntime, pJS_Icon);
- return true;
- }
+ v8::Local<v8::Object> pObj =
+ pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID);
+ if (pObj.IsEmpty())
+ return false;
- return false;
+ CJS_Icon* pJS_Icon = static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
+ Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
+ pIcon->SetIconName(*it);
+ vRet = CJS_Value(pRuntime, pJS_Icon);
+ return true;
}
bool Document::removeIcon(CJS_Runtime* pRuntime,