summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/color.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/javascript/color.cpp')
-rw-r--r--fpdfsdk/javascript/color.cpp165
1 files changed, 58 insertions, 107 deletions
diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp
index 97d10b978d..621fe6b752 100644
--- a/fpdfsdk/javascript/color.cpp
+++ b/fpdfsdk/javascript/color.cpp
@@ -122,172 +122,129 @@ color::color(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {
color::~color() {}
-bool color::get_transparent(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crTransparent);
+CJS_Return color::get_transparent(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crTransparent);
}
-bool color::set_transparent(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_transparent(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crTransparent);
}
-bool color::get_black(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crBlack);
+CJS_Return color::get_black(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crBlack);
}
-bool color::set_black(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_black(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crBlack);
}
-bool color::get_white(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crWhite);
+CJS_Return color::get_white(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crWhite);
}
-bool color::set_white(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_white(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crWhite);
}
-bool color::get_red(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crRed);
+CJS_Return color::get_red(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crRed);
}
-bool color::set_red(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_red(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crRed);
}
-bool color::get_green(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crGreen);
+CJS_Return color::get_green(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crGreen);
}
-bool color::set_green(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_green(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crGreen);
}
-bool color::get_blue(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crBlue);
+CJS_Return color::get_blue(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crBlue);
}
-bool color::set_blue(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_blue(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crBlue);
}
-bool color::get_cyan(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crCyan);
+CJS_Return color::get_cyan(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crCyan);
}
-bool color::set_cyan(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_cyan(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crCyan);
}
-bool color::get_magenta(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crMagenta);
+CJS_Return color::get_magenta(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crMagenta);
}
-bool color::set_magenta(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_magenta(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crMagenta);
}
-bool color::get_yellow(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crYellow);
+CJS_Return color::get_yellow(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crYellow);
}
-bool color::set_yellow(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_yellow(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crYellow);
}
-bool color::get_dark_gray(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crDKGray);
+CJS_Return color::get_dark_gray(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crDKGray);
}
-bool color::set_dark_gray(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_dark_gray(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crDKGray);
}
-bool color::get_gray(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crGray);
+CJS_Return color::get_gray(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crGray);
}
-bool color::set_gray(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crGray);
}
-bool color::get_light_gray(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crLTGray);
+CJS_Return color::get_light_gray(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crLTGray);
}
-bool color::set_light_gray(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_light_gray(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crLTGray);
}
-bool color::GetPropertyHelper(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- CFX_Color* var) {
+CJS_Return color::GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* var) {
CJS_Array array = ConvertPWLColorToArray(pRuntime, *var);
if (array.ToV8Value().IsEmpty())
- vp->Set(pRuntime->NewArray());
- else
- vp->Set(array.ToV8Value());
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(array.ToV8Value());
}
-bool color::SetPropertyHelper(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- CFX_Color* var) {
+CJS_Return color::SetPropertyHelper(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp,
+ CFX_Color* var) {
if (vp.IsEmpty() || !vp->IsArray())
- return false;
+ return CJS_Return(false);
*var = ConvertArrayToPWLColor(pRuntime, CJS_Array(pRuntime->ToArray(vp)));
- return true;
+ return CJS_Return(true);
}
-bool color::convert(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return color::convert(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
int iSize = params.size();
if (iSize < 2)
- return false;
+ return CJS_Return(false);
if (params[0].IsEmpty() || !params[0]->IsArray())
- return false;
+ return CJS_Return(false);
WideString sDestSpace = pRuntime->ToWideString(params[1]);
int nColorType = CFX_Color::kTransparent;
@@ -306,22 +263,17 @@ bool color::convert(CJS_Runtime* pRuntime,
CJS_Array array =
ConvertPWLColorToArray(pRuntime, color.ConvertColorType(nColorType));
if (array.ToV8Value().IsEmpty())
- vRet = CJS_Value(pRuntime->NewArray());
- else
- vRet = CJS_Value(array.ToV8Value());
-
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(array.ToV8Value());
}
-bool color::equal(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return color::equal(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
- return false;
+ return CJS_Return(false);
if (params[0].IsEmpty() || !params[0]->IsArray() || params[1].IsEmpty() ||
!params[1]->IsArray()) {
- return false;
+ return CJS_Return(false);
}
CFX_Color color1 =
@@ -330,6 +282,5 @@ bool color::equal(CJS_Runtime* pRuntime,
ConvertArrayToPWLColor(pRuntime, CJS_Array(pRuntime->ToArray(params[1])));
color1 = color1.ConvertColorType(color2.nColorType);
- vRet = CJS_Value(pRuntime->NewBoolean(color1 == color2));
- return true;
+ return CJS_Return(pRuntime->NewBoolean(color1 == color2));
}