summaryrefslogtreecommitdiff
path: root/fxjs/cjs_color.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_color.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_color.cpp')
-rw-r--r--fxjs/cjs_color.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/fxjs/cjs_color.cpp b/fxjs/cjs_color.cpp
index 1568687365..3bfa1a78df 100644
--- a/fxjs/cjs_color.cpp
+++ b/fxjs/cjs_color.cpp
@@ -250,25 +250,26 @@ CJS_Return CJS_Color::set_light_gray(CJS_Runtime* pRuntime,
CJS_Return CJS_Color::GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* var) {
v8::Local<v8::Value> array = ConvertPWLColorToArray(pRuntime, *var);
if (array.IsEmpty())
- return CJS_Return(pRuntime->NewArray());
- return CJS_Return(array);
+ return CJS_Return::Success(pRuntime->NewArray());
+
+ return CJS_Return::Success(array);
}
CJS_Return CJS_Color::SetPropertyHelper(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp,
CFX_Color* var) {
if (vp.IsEmpty() || !vp->IsArray())
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
*var = ConvertArrayToPWLColor(pRuntime, pRuntime->ToArray(vp));
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Color::convert(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
int iSize = params.size();
if (iSize < 2 || params[0].IsEmpty() || !params[0]->IsArray())
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString sDestSpace = pRuntime->ToWideString(params[1]);
int nColorType = CFX_Color::kTransparent;
@@ -283,19 +284,19 @@ CJS_Return CJS_Color::convert(CJS_Runtime* pRuntime,
CFX_Color color =
ConvertArrayToPWLColor(pRuntime, pRuntime->ToArray(params[0]));
-
v8::Local<v8::Value> array =
ConvertPWLColorToArray(pRuntime, color.ConvertColorType(nColorType));
if (array.IsEmpty())
- return CJS_Return(pRuntime->NewArray());
- return CJS_Return(array);
+ return CJS_Return::Success(pRuntime->NewArray());
+
+ return CJS_Return::Success(array);
}
CJS_Return CJS_Color::equal(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2 || params[0].IsEmpty() || !params[0]->IsArray() ||
params[1].IsEmpty() || !params[1]->IsArray()) {
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
}
CFX_Color color1 =
@@ -304,5 +305,5 @@ CJS_Return CJS_Color::equal(CJS_Runtime* pRuntime,
ConvertArrayToPWLColor(pRuntime, pRuntime->ToArray(params[1]));
color1 = color1.ConvertColorType(color2.nColorType);
- return CJS_Return(pRuntime->NewBoolean(color1 == color2));
+ return CJS_Return::Success(pRuntime->NewBoolean(color1 == color2));
}