summaryrefslogtreecommitdiff
path: root/fxjs/cjs_annot.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-08-17 16:44:50 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-17 16:44:50 +0000
commit20736f7f5884cf1e2827543c92b6e47f8282aeaf (patch)
tree9a0f3cbd9262d1676f70ab02c3fa5b4e0acaa03a /fxjs/cjs_annot.cpp
parent21068062a038db72b5ee40512fe638acbdd17c3d (diff)
downloadpdfium-20736f7f5884cf1e2827543c92b6e47f8282aeaf.tar.xz
Introduce safer CJS_Return::Success() and Failure().
Avoid the possibility of ever re-introducing the issue noticed last week. Remove some redundant JSGetStringFromID() calls. Change-Id: I56687c2191bd72e378f747083f34080e50cbe490 Reviewed-on: https://pdfium-review.googlesource.com/40490 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/cjs_annot.cpp')
-rw-r--r--fxjs/cjs_annot.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/fxjs/cjs_annot.cpp b/fxjs/cjs_annot.cpp
index c4a4f7ab1d..4e93dc2516 100644
--- a/fxjs/cjs_annot.cpp
+++ b/fxjs/cjs_annot.cpp
@@ -39,10 +39,10 @@ CJS_Annot::~CJS_Annot() = default;
CJS_Return CJS_Annot::get_hidden(CJS_Runtime* pRuntime) {
if (!m_pAnnot)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_Annot* pPDFAnnot = m_pAnnot->AsBAAnnot()->GetPDFAnnot();
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict())));
}
@@ -53,7 +53,7 @@ CJS_Return CJS_Annot::set_hidden(CJS_Runtime* pRuntime,
CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get());
if (!pBAAnnot)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
uint32_t flags = pBAAnnot->GetFlags();
if (bHidden) {
@@ -68,14 +68,15 @@ CJS_Return CJS_Annot::set_hidden(CJS_Runtime* pRuntime,
flags |= ANNOTFLAG_PRINT;
}
pBAAnnot->SetFlags(flags);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Annot::get_name(CJS_Runtime* pRuntime) {
CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get());
if (!pBAAnnot)
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+
+ return CJS_Return::Success(
pRuntime->NewString(pBAAnnot->GetAnnotName().AsStringView()));
}
@@ -85,18 +86,18 @@ CJS_Return CJS_Annot::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get());
if (!pBAAnnot)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
pBAAnnot->SetAnnotName(annotName);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Annot::get_type(CJS_Runtime* pRuntime) {
CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get());
if (!pBAAnnot)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(
+ return CJS_Return::Success(pRuntime->NewString(
WideString::FromLocal(
CPDF_Annot::AnnotSubtypeToString(pBAAnnot->GetAnnotSubtype())
.AsStringView())
@@ -104,5 +105,5 @@ CJS_Return CJS_Annot::get_type(CJS_Runtime* pRuntime) {
}
CJS_Return CJS_Annot::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
}