diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-02-21 11:43:14 -0800 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-02-21 20:28:47 +0000 |
commit | 37a35df8c878d6e21a62ce0dfd2d480997d9e86c (patch) | |
tree | 1d8102d3346ec0a599628f5825df47730379f4af /fpdfsdk | |
parent | b97f8d578f6a11962f36d522bd1dbf33064e7461 (diff) | |
download | pdfium-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')
-rw-r--r-- | fpdfsdk/javascript/color.cpp | 110 | ||||
-rw-r--r-- | fpdfsdk/javascript/color.h | 4 |
2 files changed, 89 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, diff --git a/fpdfsdk/javascript/color.h b/fpdfsdk/javascript/color.h index f966ca76d1..8d6187a178 100644 --- a/fpdfsdk/javascript/color.h +++ b/fpdfsdk/javascript/color.h @@ -51,6 +51,10 @@ class color : public CJS_EmbedObj { CPWL_Color* color); private: + bool PropertyHelper(CJS_Runtime* pRuntime, + CJS_PropValue& vp, + CPWL_Color* val); + CPWL_Color m_crTransparent; CPWL_Color m_crBlack; CPWL_Color m_crWhite; |