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

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

Issue 1096813008: Kill overloaded cast operators in CJS_Value. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: More Tabify. Created 5 years, 8 months 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
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 "../../include/javascript/JavaScript.h" 7 #include "../../include/javascript/JavaScript.h"
8 #include "../../include/javascript/IJavaScript.h" 8 #include "../../include/javascript/IJavaScript.h"
9 #include "../../include/javascript/JS_Define.h" 9 #include "../../include/javascript/JS_Define.h"
10 #include "../../include/javascript/JS_Object.h" 10 #include "../../include/javascript/JS_Object.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 break; 97 break;
98 } 98 }
99 } 99 }
100 100
101 void color::ConvertArrayToPWLColor(CJS_Array& array, CPWL_Color& color) 101 void color::ConvertArrayToPWLColor(CJS_Array& array, CPWL_Color& color)
102 { 102 {
103 int nArrayLen = array.GetLength(); 103 int nArrayLen = array.GetLength();
104 if (nArrayLen < 1) return; 104 if (nArrayLen < 1) return;
105 105
106 CJS_Value value(array.GetIsolate()); 106 CJS_Value value(array.GetIsolate());
107 CFX_ByteString sSpace;
108 array.GetElement(0, value); 107 array.GetElement(0, value);
109 » sSpace = value; 108 » CFX_ByteString sSpace = value.ToCFXByteString();
110 109
111 double d1 = 0; 110 double d1 = 0;
112 double d2 = 0; 111 double d2 = 0;
113 double d3 = 0; 112 double d3 = 0;
114 double d4 = 0; 113 double d4 = 0;
115 114
116 if (nArrayLen > 1) 115 if (nArrayLen > 1)
117 { 116 {
118 array.GetElement(1, value); 117 array.GetElement(1, value);
119 » » d1 = value; 118 » » d1 = value.ToDouble();
120 } 119 }
121 120
122 if (nArrayLen > 2) 121 if (nArrayLen > 2)
123 { 122 {
124 array.GetElement(2, value); 123 array.GetElement(2, value);
125 » » d2 = value; 124 » » d2 = value.ToDouble();
126 } 125 }
127 126
128 if (nArrayLen > 3) 127 if (nArrayLen > 3)
129 { 128 {
130 array.GetElement(3, value); 129 array.GetElement(3, value);
131 » » d3 = value; 130 » » d3 = value.ToDouble();
132 } 131 }
133 132
134 if (nArrayLen > 4) 133 if (nArrayLen > 4)
135 { 134 {
136 array.GetElement(4, value); 135 array.GetElement(4, value);
137 » » d4 = value; 136 » » d4 = value.ToDouble();
138 } 137 }
139 138
140 if (sSpace == "T") 139 if (sSpace == "T")
141 { 140 {
142 color = CPWL_Color(COLORTYPE_TRANSPARENT); 141 color = CPWL_Color(COLORTYPE_TRANSPARENT);
143 } 142 }
144 else if (sSpace == "G") 143 else if (sSpace == "G")
145 { 144 {
146 color = CPWL_Color(COLORTYPE_GRAY, (FX_FLOAT)d1); 145 color = CPWL_Color(COLORTYPE_GRAY, (FX_FLOAT)d1);
147 } 146 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 { 191 {
193 v8::Isolate* isolate = GetIsolate(cc); 192 v8::Isolate* isolate = GetIsolate(cc);
194 int iSize = params.size(); 193 int iSize = params.size();
195 if (iSize < 2) return FALSE; 194 if (iSize < 2) return FALSE;
196 CJS_Array aSource(isolate); 195 CJS_Array aSource(isolate);
197 if (!params[0].ConvertToArray(aSource)) return FALSE; 196 if (!params[0].ConvertToArray(aSource)) return FALSE;
198 197
199 CPWL_Color crSource; 198 CPWL_Color crSource;
200 ConvertArrayToPWLColor(aSource, crSource); 199 ConvertArrayToPWLColor(aSource, crSource);
201 200
202 » CFX_ByteString sDestSpace = params[1]; 201 » CFX_ByteString sDestSpace = params[1].ToCFXByteString();
202 » int nColorType = COLORTYPE_TRANSPARENT;
203 203
204 int nColorType = COLORTYPE_TRANSPARENT;
205
206 if (sDestSpace == "T") 204 if (sDestSpace == "T")
207 { 205 {
208 nColorType = COLORTYPE_TRANSPARENT; 206 nColorType = COLORTYPE_TRANSPARENT;
209 } 207 }
210 else if (sDestSpace == "G") 208 else if (sDestSpace == "G")
211 { 209 {
212 nColorType = COLORTYPE_GRAY; 210 nColorType = COLORTYPE_GRAY;
213 } 211 }
214 else if (sDestSpace == "RGB") 212 else if (sDestSpace == "RGB")
215 { 213 {
(...skipping 28 matching lines...) Expand all
244 242
245 ConvertArrayToPWLColor(array1, color1); 243 ConvertArrayToPWLColor(array1, color1);
246 ConvertArrayToPWLColor(array2, color2); 244 ConvertArrayToPWLColor(array2, color2);
247 245
248 color1.ConvertColorType(color2.nColorType); 246 color1.ConvertColorType(color2.nColorType);
249 247
250 vRet = color1 == color2; 248 vRet = color1 == color2;
251 return TRUE; 249 return TRUE;
252 } 250 }
253 251
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698