summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/color.h
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2017-10-19 14:29:33 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-19 19:50:07 +0000
commitcbe23dbdff3f6e41843fd99cbf615000b52727ed (patch)
treef2f9e6e5f4dc8818ef15a8f72fdfdab71a848097 /fpdfsdk/javascript/color.h
parentc136b3146257d0f12d1347a9f1a4784372e19a56 (diff)
downloadpdfium-cbe23dbdff3f6e41843fd99cbf615000b52727ed.tar.xz
Refactoring JS Callbacks.
This CL updates the fpdfsdk/javascript callbacks to have explicit get/set methods instead of one method which worked differently depending on the mode. This allows better ownership of the passed in params, (get takes a * and set takes a const&). The Value object was changed to have To* and Set methods to make the code clearer compared to the operator<< and operator>> overloading. Bug: Change-Id: Id6ff20a4e3252adfd0a78b643e50b9f095085018 Reviewed-on: https://pdfium-review.googlesource.com/16330 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/color.h')
-rw-r--r--fpdfsdk/javascript/color.h112
1 files changed, 85 insertions, 27 deletions
diff --git a/fpdfsdk/javascript/color.h b/fpdfsdk/javascript/color.h
index 5e1e871064..d4ca43a878 100644
--- a/fpdfsdk/javascript/color.h
+++ b/fpdfsdk/javascript/color.h
@@ -17,20 +17,73 @@ class color : public CJS_EmbedObj {
explicit color(CJS_Object* pJSObject);
~color() override;
- bool black(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError);
- bool blue(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError);
- bool cyan(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError);
- bool dkGray(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError);
- bool gray(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError);
- bool green(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError);
- bool ltGray(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError);
- bool magenta(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError);
- bool red(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError);
- bool transparent(CJS_Runtime* pRuntime,
- CJS_PropValue& vp,
- WideString& sError);
- bool white(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError);
- bool yellow(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError);
+ bool get_black(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError);
+ bool set_black(CJS_Runtime* pRuntime,
+ const CJS_PropValue& vp,
+ WideString* sError);
+
+ bool get_blue(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError);
+ bool set_blue(CJS_Runtime* pRuntime,
+ const CJS_PropValue& vp,
+ WideString* sError);
+
+ bool get_cyan(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError);
+ bool set_cyan(CJS_Runtime* pRuntime,
+ const CJS_PropValue& vp,
+ WideString* sError);
+
+ bool get_dark_gray(CJS_Runtime* pRuntime,
+ CJS_PropValue* vp,
+ WideString* sError);
+ bool set_dark_gray(CJS_Runtime* pRuntime,
+ const CJS_PropValue& vp,
+ WideString* sError);
+
+ bool get_gray(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError);
+ bool set_gray(CJS_Runtime* pRuntime,
+ const CJS_PropValue& vp,
+ WideString* sError);
+
+ bool get_green(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError);
+ bool set_green(CJS_Runtime* pRuntime,
+ const CJS_PropValue& vp,
+ WideString* sError);
+
+ bool get_light_gray(CJS_Runtime* pRuntime,
+ CJS_PropValue* vp,
+ WideString* sError);
+ bool set_light_gray(CJS_Runtime* pRuntime,
+ const CJS_PropValue& vp,
+ WideString* sError);
+
+ bool get_magenta(CJS_Runtime* pRuntime,
+ CJS_PropValue* vp,
+ WideString* sError);
+ bool set_magenta(CJS_Runtime* pRuntime,
+ const CJS_PropValue& vp,
+ WideString* sError);
+
+ bool get_red(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError);
+ bool set_red(CJS_Runtime* pRuntime,
+ const CJS_PropValue& vp,
+ WideString* sError);
+
+ bool get_transparent(CJS_Runtime* pRuntime,
+ CJS_PropValue* vp,
+ WideString* sError);
+ bool set_transparent(CJS_Runtime* pRuntime,
+ const CJS_PropValue& vp,
+ WideString* sError);
+
+ bool get_white(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError);
+ bool set_white(CJS_Runtime* pRuntime,
+ const CJS_PropValue& vp,
+ WideString* sError);
+
+ bool get_yellow(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError);
+ bool set_yellow(CJS_Runtime* pRuntime,
+ const CJS_PropValue& vp,
+ WideString* sError);
bool convert(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
@@ -49,7 +102,12 @@ class color : public CJS_EmbedObj {
CFX_Color* color);
private:
- bool PropertyHelper(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_Color* val);
+ bool GetPropertyHelper(CJS_Runtime* pRuntime,
+ CJS_PropValue* vp,
+ CFX_Color* val);
+ bool SetPropertyHelper(CJS_Runtime* pRuntime,
+ const CJS_PropValue& vp,
+ CFX_Color* val);
CFX_Color m_crTransparent;
CFX_Color m_crBlack;
@@ -72,18 +130,18 @@ class CJS_Color : public CJS_Object {
DECLARE_JS_CLASS();
- JS_STATIC_PROP(black, color);
- JS_STATIC_PROP(blue, color);
- JS_STATIC_PROP(cyan, color);
- JS_STATIC_PROP(dkGray, color);
- JS_STATIC_PROP(gray, color);
- JS_STATIC_PROP(green, color);
- JS_STATIC_PROP(ltGray, color);
- JS_STATIC_PROP(magenta, color);
- JS_STATIC_PROP(red, color);
- JS_STATIC_PROP(transparent, color);
- JS_STATIC_PROP(white, color);
- JS_STATIC_PROP(yellow, color);
+ JS_STATIC_PROP(black, black, color);
+ JS_STATIC_PROP(blue, blue, color);
+ JS_STATIC_PROP(cyan, cyan, color);
+ JS_STATIC_PROP(dkGray, dark_gray, color);
+ JS_STATIC_PROP(gray, gray, color);
+ JS_STATIC_PROP(green, green, color);
+ JS_STATIC_PROP(ltGray, light_gray, color);
+ JS_STATIC_PROP(magenta, magenta, color);
+ JS_STATIC_PROP(red, red, color);
+ JS_STATIC_PROP(transparent, transparent, color);
+ JS_STATIC_PROP(white, white, color);
+ JS_STATIC_PROP(yellow, yellow, color);
JS_STATIC_METHOD(convert, color);
JS_STATIC_METHOD(equal, color);