John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 7 | #ifndef FPDFSDK_JAVASCRIPT_COLOR_H_ |
| 8 | #define FPDFSDK_JAVASCRIPT_COLOR_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
Dan Sinclair | 3ebd121 | 2016-03-09 09:59:23 -0500 | [diff] [blame] | 10 | #include <vector> |
| 11 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 12 | #include "fpdfsdk/javascript/JS_Define.h" |
dan sinclair | 89e904b | 2016-03-23 19:29:15 -0400 | [diff] [blame] | 13 | #include "fpdfsdk/pdfwindow/PWL_Wnd.h" |
Tom Sepez | 9a3f812 | 2015-04-07 15:35:48 -0700 | [diff] [blame] | 14 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 15 | class color : public CJS_EmbedObj { |
| 16 | public: |
Dan Sinclair | 85c8e7f | 2016-11-21 13:50:32 -0500 | [diff] [blame] | 17 | explicit color(CJS_Object* pJSObject); |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 18 | ~color() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 19 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 20 | bool black(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError); |
| 21 | bool blue(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError); |
| 22 | bool cyan(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError); |
| 23 | bool dkGray(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError); |
| 24 | bool gray(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError); |
| 25 | bool green(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError); |
| 26 | bool ltGray(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError); |
| 27 | bool magenta(CJS_Runtime* pRuntime, |
| 28 | CJS_PropValue& vp, |
| 29 | CFX_WideString& sError); |
| 30 | bool red(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError); |
| 31 | bool transparent(CJS_Runtime* pRuntime, |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 32 | CJS_PropValue& vp, |
| 33 | CFX_WideString& sError); |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 34 | bool white(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError); |
| 35 | bool yellow(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 36 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 37 | bool convert(CJS_Runtime* pRuntime, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 38 | const std::vector<CJS_Value>& params, |
| 39 | CJS_Value& vRet, |
| 40 | CFX_WideString& sError); |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 41 | bool equal(CJS_Runtime* pRuntime, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 42 | const std::vector<CJS_Value>& params, |
| 43 | CJS_Value& vRet, |
| 44 | CFX_WideString& sError); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 45 | |
tsepez | e5aff74 | 2016-08-08 09:49:42 -0700 | [diff] [blame] | 46 | static void ConvertPWLColorToArray(CJS_Runtime* pRuntime, |
| 47 | const CPWL_Color& color, |
| 48 | CJS_Array* array); |
| 49 | static void ConvertArrayToPWLColor(CJS_Runtime* pRuntime, |
| 50 | const CJS_Array& array, |
| 51 | CPWL_Color* color); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 52 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 53 | private: |
Tom Sepez | 37a35df | 2017-02-21 11:43:14 -0800 | [diff] [blame^] | 54 | bool PropertyHelper(CJS_Runtime* pRuntime, |
| 55 | CJS_PropValue& vp, |
| 56 | CPWL_Color* val); |
| 57 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 58 | CPWL_Color m_crTransparent; |
| 59 | CPWL_Color m_crBlack; |
| 60 | CPWL_Color m_crWhite; |
| 61 | CPWL_Color m_crRed; |
| 62 | CPWL_Color m_crGreen; |
| 63 | CPWL_Color m_crBlue; |
| 64 | CPWL_Color m_crCyan; |
| 65 | CPWL_Color m_crMagenta; |
| 66 | CPWL_Color m_crYellow; |
| 67 | CPWL_Color m_crDKGray; |
| 68 | CPWL_Color m_crGray; |
| 69 | CPWL_Color m_crLTGray; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 72 | class CJS_Color : public CJS_Object { |
| 73 | public: |
Dan Sinclair | 85c8e7f | 2016-11-21 13:50:32 -0500 | [diff] [blame] | 74 | explicit CJS_Color(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 75 | ~CJS_Color() override {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 76 | |
Tom Sepez | cd56a7d | 2015-10-06 11:45:28 -0700 | [diff] [blame] | 77 | DECLARE_JS_CLASS(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 78 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 79 | JS_STATIC_PROP(black, color); |
| 80 | JS_STATIC_PROP(blue, color); |
| 81 | JS_STATIC_PROP(cyan, color); |
| 82 | JS_STATIC_PROP(dkGray, color); |
| 83 | JS_STATIC_PROP(gray, color); |
| 84 | JS_STATIC_PROP(green, color); |
| 85 | JS_STATIC_PROP(ltGray, color); |
| 86 | JS_STATIC_PROP(magenta, color); |
| 87 | JS_STATIC_PROP(red, color); |
| 88 | JS_STATIC_PROP(transparent, color); |
| 89 | JS_STATIC_PROP(white, color); |
| 90 | JS_STATIC_PROP(yellow, color); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 91 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 92 | JS_STATIC_METHOD(convert, color); |
| 93 | JS_STATIC_METHOD(equal, color); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 94 | }; |
| 95 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 96 | #endif // FPDFSDK_JAVASCRIPT_COLOR_H_ |