From 20736f7f5884cf1e2827543c92b6e47f8282aeaf Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 17 Aug 2018 16:44:50 +0000 Subject: 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 Commit-Queue: Tom Sepez --- fxjs/cjs_color.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'fxjs/cjs_color.cpp') 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 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 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>& 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 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>& 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)); } -- cgit v1.2.3