Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Side by Side Diff: fpdfsdk/javascript/color.cpp

Issue 2453683011: Remove FX_BOOL from fpdfsdk. (Closed)
Patch Set: Regenerate patch after rebase. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/javascript/color.h ('k') | fpdfsdk/javascript/console.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/javascript/color.h" 7 #include "fpdfsdk/javascript/color.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } else if (sSpace == "RGB") { 127 } else if (sSpace == "RGB") {
128 *color = 128 *color =
129 CPWL_Color(COLORTYPE_RGB, (FX_FLOAT)d1, (FX_FLOAT)d2, (FX_FLOAT)d3); 129 CPWL_Color(COLORTYPE_RGB, (FX_FLOAT)d1, (FX_FLOAT)d2, (FX_FLOAT)d3);
130 } else if (sSpace == "CMYK") { 130 } else if (sSpace == "CMYK") {
131 *color = CPWL_Color(COLORTYPE_CMYK, (FX_FLOAT)d1, (FX_FLOAT)d2, 131 *color = CPWL_Color(COLORTYPE_CMYK, (FX_FLOAT)d1, (FX_FLOAT)d2,
132 (FX_FLOAT)d3, (FX_FLOAT)d4); 132 (FX_FLOAT)d3, (FX_FLOAT)d4);
133 } 133 }
134 } 134 }
135 135
136 #define JS_IMPLEMENT_COLORPROP(prop, var) \ 136 #define JS_IMPLEMENT_COLORPROP(prop, var) \
137 FX_BOOL color::prop(IJS_Context* cc, CJS_PropValue& vp, \ 137 bool color::prop(IJS_Context* cc, CJS_PropValue& vp, \
138 CFX_WideString& sError) { \ 138 CFX_WideString& sError) { \
139 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); \ 139 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); \
140 CJS_Array array; \ 140 CJS_Array array; \
141 if (vp.IsGetting()) { \ 141 if (vp.IsGetting()) { \
142 ConvertPWLColorToArray(pRuntime, var, &array); \ 142 ConvertPWLColorToArray(pRuntime, var, &array); \
143 vp << array; \ 143 vp << array; \
144 } else { \ 144 } else { \
145 if (!vp.GetJSValue()->ConvertToArray(pRuntime, array)) \ 145 if (!vp.GetJSValue()->ConvertToArray(pRuntime, array)) \
146 return FALSE; \ 146 return false; \
147 ConvertArrayToPWLColor(pRuntime, array, &var); \ 147 ConvertArrayToPWLColor(pRuntime, array, &var); \
148 } \ 148 } \
149 return TRUE; \ 149 return true; \
150 } 150 }
151 151
152 JS_IMPLEMENT_COLORPROP(transparent, m_crTransparent) 152 JS_IMPLEMENT_COLORPROP(transparent, m_crTransparent)
153 JS_IMPLEMENT_COLORPROP(black, m_crBlack) 153 JS_IMPLEMENT_COLORPROP(black, m_crBlack)
154 JS_IMPLEMENT_COLORPROP(white, m_crWhite) 154 JS_IMPLEMENT_COLORPROP(white, m_crWhite)
155 JS_IMPLEMENT_COLORPROP(red, m_crRed) 155 JS_IMPLEMENT_COLORPROP(red, m_crRed)
156 JS_IMPLEMENT_COLORPROP(green, m_crGreen) 156 JS_IMPLEMENT_COLORPROP(green, m_crGreen)
157 JS_IMPLEMENT_COLORPROP(blue, m_crBlue) 157 JS_IMPLEMENT_COLORPROP(blue, m_crBlue)
158 JS_IMPLEMENT_COLORPROP(cyan, m_crCyan) 158 JS_IMPLEMENT_COLORPROP(cyan, m_crCyan)
159 JS_IMPLEMENT_COLORPROP(magenta, m_crMagenta) 159 JS_IMPLEMENT_COLORPROP(magenta, m_crMagenta)
160 JS_IMPLEMENT_COLORPROP(yellow, m_crYellow) 160 JS_IMPLEMENT_COLORPROP(yellow, m_crYellow)
161 JS_IMPLEMENT_COLORPROP(dkGray, m_crDKGray) 161 JS_IMPLEMENT_COLORPROP(dkGray, m_crDKGray)
162 JS_IMPLEMENT_COLORPROP(gray, m_crGray) 162 JS_IMPLEMENT_COLORPROP(gray, m_crGray)
163 JS_IMPLEMENT_COLORPROP(ltGray, m_crLTGray) 163 JS_IMPLEMENT_COLORPROP(ltGray, m_crLTGray)
164 164
165 FX_BOOL color::convert(IJS_Context* cc, 165 bool color::convert(IJS_Context* cc,
166 const std::vector<CJS_Value>& params, 166 const std::vector<CJS_Value>& params,
167 CJS_Value& vRet, 167 CJS_Value& vRet,
168 CFX_WideString& sError) { 168 CFX_WideString& sError) {
169 int iSize = params.size(); 169 int iSize = params.size();
170 if (iSize < 2) 170 if (iSize < 2)
171 return FALSE; 171 return false;
172 172
173 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 173 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
174 CJS_Array aSource; 174 CJS_Array aSource;
175 if (!params[0].ConvertToArray(pRuntime, aSource)) 175 if (!params[0].ConvertToArray(pRuntime, aSource))
176 return FALSE; 176 return false;
177 177
178 CPWL_Color crSource; 178 CPWL_Color crSource;
179 ConvertArrayToPWLColor(pRuntime, aSource, &crSource); 179 ConvertArrayToPWLColor(pRuntime, aSource, &crSource);
180 180
181 CFX_ByteString sDestSpace = params[1].ToCFXByteString(pRuntime); 181 CFX_ByteString sDestSpace = params[1].ToCFXByteString(pRuntime);
182 int nColorType = COLORTYPE_TRANSPARENT; 182 int nColorType = COLORTYPE_TRANSPARENT;
183 183
184 if (sDestSpace == "T") { 184 if (sDestSpace == "T") {
185 nColorType = COLORTYPE_TRANSPARENT; 185 nColorType = COLORTYPE_TRANSPARENT;
186 } else if (sDestSpace == "G") { 186 } else if (sDestSpace == "G") {
187 nColorType = COLORTYPE_GRAY; 187 nColorType = COLORTYPE_GRAY;
188 } else if (sDestSpace == "RGB") { 188 } else if (sDestSpace == "RGB") {
189 nColorType = COLORTYPE_RGB; 189 nColorType = COLORTYPE_RGB;
190 } else if (sDestSpace == "CMYK") { 190 } else if (sDestSpace == "CMYK") {
191 nColorType = COLORTYPE_CMYK; 191 nColorType = COLORTYPE_CMYK;
192 } 192 }
193 193
194 CJS_Array aDest; 194 CJS_Array aDest;
195 CPWL_Color crDest = crSource; 195 CPWL_Color crDest = crSource;
196 crDest.ConvertColorType(nColorType); 196 crDest.ConvertColorType(nColorType);
197 ConvertPWLColorToArray(pRuntime, crDest, &aDest); 197 ConvertPWLColorToArray(pRuntime, crDest, &aDest);
198 vRet = CJS_Value(pRuntime, aDest); 198 vRet = CJS_Value(pRuntime, aDest);
199 199
200 return TRUE; 200 return true;
201 } 201 }
202 202
203 FX_BOOL color::equal(IJS_Context* cc, 203 bool color::equal(IJS_Context* cc,
204 const std::vector<CJS_Value>& params, 204 const std::vector<CJS_Value>& params,
205 CJS_Value& vRet, 205 CJS_Value& vRet,
206 CFX_WideString& sError) { 206 CFX_WideString& sError) {
207 if (params.size() < 2) 207 if (params.size() < 2)
208 return FALSE; 208 return false;
209 209
210 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 210 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
211 CJS_Array array1; 211 CJS_Array array1;
212 CJS_Array array2; 212 CJS_Array array2;
213 if (!params[0].ConvertToArray(pRuntime, array1)) 213 if (!params[0].ConvertToArray(pRuntime, array1))
214 return FALSE; 214 return false;
215 if (!params[1].ConvertToArray(pRuntime, array2)) 215 if (!params[1].ConvertToArray(pRuntime, array2))
216 return FALSE; 216 return false;
217 217
218 CPWL_Color color1; 218 CPWL_Color color1;
219 CPWL_Color color2; 219 CPWL_Color color2;
220 ConvertArrayToPWLColor(pRuntime, array1, &color1); 220 ConvertArrayToPWLColor(pRuntime, array1, &color1);
221 ConvertArrayToPWLColor(pRuntime, array2, &color2); 221 ConvertArrayToPWLColor(pRuntime, array2, &color2);
222 color1.ConvertColorType(color2.nColorType); 222 color1.ConvertColorType(color2.nColorType);
223 vRet = CJS_Value(pRuntime, color1 == color2); 223 vRet = CJS_Value(pRuntime, color1 == color2);
224 return TRUE; 224 return true;
225 } 225 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/color.h ('k') | fpdfsdk/javascript/console.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698