From e4fde52cc2c827e637c96e8e1f76ba4644cf718a Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 23 Apr 2015 11:23:10 -0700 Subject: Kill overloaded cast operators in CJS_Value. The red-flag here is the explicit invocation of things like params[1].operator CFX_WideString() rather than static_cast(params[1]) to invoke the conversion. Turns out the above won't compile due to ambiguity given the number of implicit constructors for widestrings. CJS_Value has both constructors and assignment operators for the primitive types, which means that conversions can take place unexpectedly in both directions, a second red flag. We don't want the compiler invoking these at will since it may hide bugs. In fact, when they are removed, three such places were discovered. Also rename ToJSValue to ToV8Value to match the other ToV8xxxxx functions added. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1096813008 --- fpdfsdk/src/javascript/color.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'fpdfsdk/src/javascript/color.cpp') diff --git a/fpdfsdk/src/javascript/color.cpp b/fpdfsdk/src/javascript/color.cpp index a338624bd9..ddf6ed4361 100644 --- a/fpdfsdk/src/javascript/color.cpp +++ b/fpdfsdk/src/javascript/color.cpp @@ -104,9 +104,8 @@ void color::ConvertArrayToPWLColor(CJS_Array& array, CPWL_Color& color) if (nArrayLen < 1) return; CJS_Value value(array.GetIsolate()); - CFX_ByteString sSpace; array.GetElement(0, value); - sSpace = value; + CFX_ByteString sSpace = value.ToCFXByteString(); double d1 = 0; double d2 = 0; @@ -116,25 +115,25 @@ void color::ConvertArrayToPWLColor(CJS_Array& array, CPWL_Color& color) if (nArrayLen > 1) { array.GetElement(1, value); - d1 = value; + d1 = value.ToDouble(); } if (nArrayLen > 2) { array.GetElement(2, value); - d2 = value; + d2 = value.ToDouble(); } if (nArrayLen > 3) { array.GetElement(3, value); - d3 = value; + d3 = value.ToDouble(); } if (nArrayLen > 4) { array.GetElement(4, value); - d4 = value; + d4 = value.ToDouble(); } if (sSpace == "T") @@ -199,10 +198,9 @@ FX_BOOL color::convert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu CPWL_Color crSource; ConvertArrayToPWLColor(aSource, crSource); - CFX_ByteString sDestSpace = params[1]; - + CFX_ByteString sDestSpace = params[1].ToCFXByteString(); int nColorType = COLORTYPE_TRANSPARENT; - + if (sDestSpace == "T") { nColorType = COLORTYPE_TRANSPARENT; -- cgit v1.2.3