summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/color.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-02-21 11:43:14 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-02-21 20:28:47 +0000
commit37a35df8c878d6e21a62ce0dfd2d480997d9e86c (patch)
tree1d8102d3346ec0a599628f5825df47730379f4af /fpdfsdk/javascript/color.cpp
parentb97f8d578f6a11962f36d522bd1dbf33064e7461 (diff)
downloadpdfium-37a35df8c878d6e21a62ce0dfd2d480997d9e86c.tar.xz
Replace JS_IMPLEMENT_COLORPROP with helper function.
Change-Id: Ifd2aa2de9a7a57bc2aa4aa49e5400467621a7851 Reviewed-on: https://pdfium-review.googlesource.com/2794 Commit-Queue: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/color.cpp')
-rw-r--r--fpdfsdk/javascript/color.cpp110
1 files changed, 85 insertions, 25 deletions
diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp
index 4d8701b9f2..66ff90c406 100644
--- a/fpdfsdk/javascript/color.cpp
+++ b/fpdfsdk/javascript/color.cpp
@@ -131,33 +131,93 @@ void color::ConvertArrayToPWLColor(CJS_Runtime* pRuntime,
}
}
-#define JS_IMPLEMENT_COLORPROP(prop, var) \
- bool color::prop(CJS_Runtime* pRuntime, CJS_PropValue& vp, \
- CFX_WideString& sError) { \
- CJS_Array array; \
- if (vp.IsGetting()) { \
- ConvertPWLColorToArray(pRuntime, var, &array); \
- vp << array; \
- } else { \
- if (!vp.GetJSValue()->ConvertToArray(pRuntime, array)) \
- return false; \
- ConvertArrayToPWLColor(pRuntime, array, &var); \
- } \
- return true; \
+bool color::transparent(CJS_Runtime* pRuntime,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ return PropertyHelper(pRuntime, vp, &m_crTransparent);
+}
+
+bool color::black(CJS_Runtime* pRuntime,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ return PropertyHelper(pRuntime, vp, &m_crBlack);
+}
+
+bool color::white(CJS_Runtime* pRuntime,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ return PropertyHelper(pRuntime, vp, &m_crWhite);
+}
+
+bool color::red(CJS_Runtime* pRuntime,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ return PropertyHelper(pRuntime, vp, &m_crRed);
+}
+
+bool color::green(CJS_Runtime* pRuntime,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ return PropertyHelper(pRuntime, vp, &m_crGreen);
+}
+
+bool color::blue(CJS_Runtime* pRuntime,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ return PropertyHelper(pRuntime, vp, &m_crBlue);
+}
+
+bool color::cyan(CJS_Runtime* pRuntime,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ return PropertyHelper(pRuntime, vp, &m_crCyan);
+}
+
+bool color::magenta(CJS_Runtime* pRuntime,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ return PropertyHelper(pRuntime, vp, &m_crMagenta);
+}
+
+bool color::yellow(CJS_Runtime* pRuntime,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ return PropertyHelper(pRuntime, vp, &m_crYellow);
+}
+
+bool color::dkGray(CJS_Runtime* pRuntime,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ return PropertyHelper(pRuntime, vp, &m_crDKGray);
+}
+
+bool color::gray(CJS_Runtime* pRuntime,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ return PropertyHelper(pRuntime, vp, &m_crGray);
+}
+
+bool color::ltGray(CJS_Runtime* pRuntime,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ return PropertyHelper(pRuntime, vp, &m_crLTGray);
+}
+
+bool color::PropertyHelper(CJS_Runtime* pRuntime,
+ CJS_PropValue& vp,
+ CPWL_Color* var) {
+ CJS_Array array;
+ if (vp.IsGetting()) {
+ ConvertPWLColorToArray(pRuntime, *var, &array);
+ vp << array;
+ return true;
}
+ if (!vp.GetJSValue()->ConvertToArray(pRuntime, array))
+ return false;
-JS_IMPLEMENT_COLORPROP(transparent, m_crTransparent)
-JS_IMPLEMENT_COLORPROP(black, m_crBlack)
-JS_IMPLEMENT_COLORPROP(white, m_crWhite)
-JS_IMPLEMENT_COLORPROP(red, m_crRed)
-JS_IMPLEMENT_COLORPROP(green, m_crGreen)
-JS_IMPLEMENT_COLORPROP(blue, m_crBlue)
-JS_IMPLEMENT_COLORPROP(cyan, m_crCyan)
-JS_IMPLEMENT_COLORPROP(magenta, m_crMagenta)
-JS_IMPLEMENT_COLORPROP(yellow, m_crYellow)
-JS_IMPLEMENT_COLORPROP(dkGray, m_crDKGray)
-JS_IMPLEMENT_COLORPROP(gray, m_crGray)
-JS_IMPLEMENT_COLORPROP(ltGray, m_crLTGray)
+ ConvertArrayToPWLColor(pRuntime, array, var);
+ return true;
+}
bool color::convert(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,