• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef FPDFSDK_JAVASCRIPT_COLOR_H_
8 #define FPDFSDK_JAVASCRIPT_COLOR_H_
9 
10 #include <vector>
11 
12 #include "fpdfsdk/javascript/JS_Define.h"
13 #include "fpdfsdk/pdfwindow/PWL_Wnd.h"
14 
15 class color : public CJS_EmbedObj {
16  public:
17   explicit color(CJS_Object* pJSObject);
18   ~color() override;
19 
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,
32                    CJS_PropValue& vp,
33                    CFX_WideString& sError);
34   bool white(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
35   bool yellow(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
36 
37   bool convert(CJS_Runtime* pRuntime,
38                const std::vector<CJS_Value>& params,
39                CJS_Value& vRet,
40                CFX_WideString& sError);
41   bool equal(CJS_Runtime* pRuntime,
42              const std::vector<CJS_Value>& params,
43              CJS_Value& vRet,
44              CFX_WideString& sError);
45 
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);
52 
53  private:
54   bool PropertyHelper(CJS_Runtime* pRuntime,
55                       CJS_PropValue& vp,
56                       CPWL_Color* val);
57 
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;
70 };
71 
72 class CJS_Color : public CJS_Object {
73  public:
CJS_Color(v8::Local<v8::Object> pObject)74   explicit CJS_Color(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Color()75   ~CJS_Color() override {}
76 
77   DECLARE_JS_CLASS();
78 
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);
91 
92   JS_STATIC_METHOD(convert, color);
93   JS_STATIC_METHOD(equal, color);
94 };
95 
96 #endif  // FPDFSDK_JAVASCRIPT_COLOR_H_
97