summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/color.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-24 11:23:25 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-24 17:17:44 +0000
commit1d8d9ac983fa9c7b6dfc3df736cfd3eae6908a60 (patch)
tree4508fee34d447c5753bdcc0568ad888873e838c2 /fpdfsdk/javascript/color.cpp
parente49749265c4e503c37a316e4ca6eeff430d13b87 (diff)
downloadpdfium-1d8d9ac983fa9c7b6dfc3df736cfd3eae6908a60.tar.xz
Remove CJS_Value constructors
This CL removes most of the CJS_Value constructors and leaves the v8::Local<v8::Value> constructor as the only non-default construtor. Change-Id: Ie98260d10eff645d0ca688b353e7d40ba1aac157 Reviewed-on: https://pdfium-review.googlesource.com/16611 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/color.cpp')
-rw-r--r--fpdfsdk/javascript/color.cpp39
1 files changed, 24 insertions, 15 deletions
diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp
index 37ab1cc4fe..e730c31588 100644
--- a/fpdfsdk/javascript/color.cpp
+++ b/fpdfsdk/javascript/color.cpp
@@ -44,24 +44,32 @@ CJS_Array color::ConvertPWLColorToArray(CJS_Runtime* pRuntime,
CJS_Array array;
switch (color.nColorType) {
case CFX_Color::kTransparent:
- array.SetElement(pRuntime, 0, CJS_Value(pRuntime, "T"));
+ array.SetElement(pRuntime, 0, CJS_Value(pRuntime->NewString(L"T")));
break;
case CFX_Color::kGray:
- array.SetElement(pRuntime, 0, CJS_Value(pRuntime, "G"));
- array.SetElement(pRuntime, 1, CJS_Value(pRuntime, color.fColor1));
+ array.SetElement(pRuntime, 0, CJS_Value(pRuntime->NewString(L"G")));
+ array.SetElement(pRuntime, 1,
+ CJS_Value(pRuntime->NewNumber(color.fColor1)));
break;
case CFX_Color::kRGB:
- array.SetElement(pRuntime, 0, CJS_Value(pRuntime, "RGB"));
- array.SetElement(pRuntime, 1, CJS_Value(pRuntime, color.fColor1));
- array.SetElement(pRuntime, 2, CJS_Value(pRuntime, color.fColor2));
- array.SetElement(pRuntime, 3, CJS_Value(pRuntime, color.fColor3));
+ array.SetElement(pRuntime, 0, CJS_Value(pRuntime->NewString(L"RGB")));
+ array.SetElement(pRuntime, 1,
+ CJS_Value(pRuntime->NewNumber(color.fColor1)));
+ array.SetElement(pRuntime, 2,
+ CJS_Value(pRuntime->NewNumber(color.fColor2)));
+ array.SetElement(pRuntime, 3,
+ CJS_Value(pRuntime->NewNumber(color.fColor3)));
break;
case CFX_Color::kCMYK:
- array.SetElement(pRuntime, 0, CJS_Value(pRuntime, "CMYK"));
- array.SetElement(pRuntime, 1, CJS_Value(pRuntime, color.fColor1));
- array.SetElement(pRuntime, 2, CJS_Value(pRuntime, color.fColor2));
- array.SetElement(pRuntime, 3, CJS_Value(pRuntime, color.fColor3));
- array.SetElement(pRuntime, 4, CJS_Value(pRuntime, color.fColor4));
+ array.SetElement(pRuntime, 0, CJS_Value(pRuntime->NewString(L"CMYK")));
+ array.SetElement(pRuntime, 1,
+ CJS_Value(pRuntime->NewNumber(color.fColor1)));
+ array.SetElement(pRuntime, 2,
+ CJS_Value(pRuntime->NewNumber(color.fColor2)));
+ array.SetElement(pRuntime, 3,
+ CJS_Value(pRuntime->NewNumber(color.fColor3)));
+ array.SetElement(pRuntime, 4,
+ CJS_Value(pRuntime->NewNumber(color.fColor4)));
break;
}
return array;
@@ -300,8 +308,9 @@ bool color::convert(CJS_Runtime* pRuntime,
CFX_Color color =
ConvertArrayToPWLColor(pRuntime, params[0].ToArray(pRuntime));
- vRet = CJS_Value(pRuntime, ConvertPWLColorToArray(
- pRuntime, color.ConvertColorType(nColorType)));
+ vRet = CJS_Value(
+ ConvertPWLColorToArray(pRuntime, color.ConvertColorType(nColorType))
+ .ToV8Array(pRuntime));
return true;
}
@@ -321,6 +330,6 @@ bool color::equal(CJS_Runtime* pRuntime,
ConvertArrayToPWLColor(pRuntime, params[1].ToArray(pRuntime));
color1 = color1.ConvertColorType(color2.nColorType);
- vRet = CJS_Value(pRuntime, color1 == color2);
+ vRet = CJS_Value(pRuntime->NewBoolean(color1 == color2));
return true;
}