summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-16 11:35:42 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-16 16:23:11 +0000
commit8e7f932410732a4f05d2e69e9ff66277f54d1bd7 (patch)
tree963cf7fd3558da33edbc8b4e9ce52107d574037e /fpdfsdk/javascript
parenta74a6277a0913a674719da3134efd877a5e8d091 (diff)
downloadpdfium-8e7f932410732a4f05d2e69e9ff66277f54d1bd7.tar.xz
Convert CPVT_Color to CFX_Color
This CL converts the use of CPVT_Color to CFX_Color and removes the CPVT_Color class. Change-Id: I86a2d06524cd8f0fbce2335f0185426cc41dbe84 Reviewed-on: https://pdfium-review.googlesource.com/16030 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript')
-rw-r--r--fpdfsdk/javascript/Field.cpp41
-rw-r--r--fpdfsdk/javascript/color.cpp50
2 files changed, 46 insertions, 45 deletions
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index da0e60cc18..4e40e6fce5 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -1453,19 +1453,19 @@ bool Field::fillColor(CJS_Runtime* pRuntime,
pFormControl->GetBackgroundColor(iColorType);
CFX_Color color;
- if (iColorType == COLORTYPE_TRANSPARENT) {
- color = CFX_Color(COLORTYPE_TRANSPARENT);
- } else if (iColorType == COLORTYPE_GRAY) {
+ if (iColorType == CFX_Color::kTransparent) {
+ color = CFX_Color(CFX_Color::kTransparent);
+ } else if (iColorType == CFX_Color::kGray) {
+ color = CFX_Color(CFX_Color::kGray,
+ pFormControl->GetOriginalBackgroundColor(0));
+ } else if (iColorType == CFX_Color::kRGB) {
color =
- CFX_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBackgroundColor(0));
- } else if (iColorType == COLORTYPE_RGB) {
- color =
- CFX_Color(COLORTYPE_RGB, pFormControl->GetOriginalBackgroundColor(0),
+ CFX_Color(CFX_Color::kRGB, pFormControl->GetOriginalBackgroundColor(0),
pFormControl->GetOriginalBackgroundColor(1),
pFormControl->GetOriginalBackgroundColor(2));
- } else if (iColorType == COLORTYPE_CMYK) {
+ } else if (iColorType == CFX_Color::kCMYK) {
color =
- CFX_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBackgroundColor(0),
+ CFX_Color(CFX_Color::kCMYK, pFormControl->GetOriginalBackgroundColor(0),
pFormControl->GetOriginalBackgroundColor(1),
pFormControl->GetOriginalBackgroundColor(2),
pFormControl->GetOriginalBackgroundColor(3));
@@ -2227,16 +2227,17 @@ bool Field::strokeColor(CJS_Runtime* pRuntime,
pFormControl->GetBorderColor(iColorType);
CFX_Color color;
- if (iColorType == COLORTYPE_TRANSPARENT) {
- color = CFX_Color(COLORTYPE_TRANSPARENT);
- } else if (iColorType == COLORTYPE_GRAY) {
- color = CFX_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderColor(0));
- } else if (iColorType == COLORTYPE_RGB) {
- color = CFX_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderColor(0),
+ if (iColorType == CFX_Color::kTransparent) {
+ color = CFX_Color(CFX_Color::kTransparent);
+ } else if (iColorType == CFX_Color::kGray) {
+ color =
+ CFX_Color(CFX_Color::kGray, pFormControl->GetOriginalBorderColor(0));
+ } else if (iColorType == CFX_Color::kRGB) {
+ color = CFX_Color(CFX_Color::kRGB, pFormControl->GetOriginalBorderColor(0),
pFormControl->GetOriginalBorderColor(1),
pFormControl->GetOriginalBorderColor(2));
- } else if (iColorType == COLORTYPE_CMYK) {
- color = CFX_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderColor(0),
+ } else if (iColorType == CFX_Color::kCMYK) {
+ color = CFX_Color(CFX_Color::kCMYK, pFormControl->GetOriginalBorderColor(0),
pFormControl->GetOriginalBorderColor(1),
pFormControl->GetOriginalBorderColor(2),
pFormControl->GetOriginalBorderColor(3));
@@ -2375,10 +2376,10 @@ bool Field::textColor(CJS_Runtime* pRuntime,
std::tie(a, r, g, b) = ArgbDecode(color);
CFX_Color crRet =
- CFX_Color(COLORTYPE_RGB, r / 255.0f, g / 255.0f, b / 255.0f);
+ CFX_Color(CFX_Color::kRGB, r / 255.0f, g / 255.0f, b / 255.0f);
- if (iColorType == COLORTYPE_TRANSPARENT)
- crRet = CFX_Color(COLORTYPE_TRANSPARENT);
+ if (iColorType == CFX_Color::kTransparent)
+ crRet = CFX_Color(CFX_Color::kTransparent);
color::ConvertPWLColorToArray(pRuntime, crRet, &crArray);
vp << crArray;
diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp
index 574c81a3c0..db860d37df 100644
--- a/fpdfsdk/javascript/color.cpp
+++ b/fpdfsdk/javascript/color.cpp
@@ -39,18 +39,18 @@ JSMethodSpec CJS_Color::MethodSpecs[] = {{"convert", convert_static},
IMPLEMENT_JS_CLASS(CJS_Color, color)
color::color(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {
- m_crTransparent = CFX_Color(COLORTYPE_TRANSPARENT);
- m_crBlack = CFX_Color(COLORTYPE_GRAY, 0);
- m_crWhite = CFX_Color(COLORTYPE_GRAY, 1);
- m_crRed = CFX_Color(COLORTYPE_RGB, 1, 0, 0);
- m_crGreen = CFX_Color(COLORTYPE_RGB, 0, 1, 0);
- m_crBlue = CFX_Color(COLORTYPE_RGB, 0, 0, 1);
- m_crCyan = CFX_Color(COLORTYPE_CMYK, 1, 0, 0, 0);
- m_crMagenta = CFX_Color(COLORTYPE_CMYK, 0, 1, 0, 0);
- m_crYellow = CFX_Color(COLORTYPE_CMYK, 0, 0, 1, 0);
- m_crDKGray = CFX_Color(COLORTYPE_GRAY, 0.25);
- m_crGray = CFX_Color(COLORTYPE_GRAY, 0.5);
- m_crLTGray = CFX_Color(COLORTYPE_GRAY, 0.75);
+ m_crTransparent = CFX_Color(CFX_Color::kTransparent);
+ m_crBlack = CFX_Color(CFX_Color::kGray, 0);
+ m_crWhite = CFX_Color(CFX_Color::kGray, 1);
+ m_crRed = CFX_Color(CFX_Color::kRGB, 1, 0, 0);
+ m_crGreen = CFX_Color(CFX_Color::kRGB, 0, 1, 0);
+ m_crBlue = CFX_Color(CFX_Color::kRGB, 0, 0, 1);
+ m_crCyan = CFX_Color(CFX_Color::kCMYK, 1, 0, 0, 0);
+ m_crMagenta = CFX_Color(CFX_Color::kCMYK, 0, 1, 0, 0);
+ m_crYellow = CFX_Color(CFX_Color::kCMYK, 0, 0, 1, 0);
+ m_crDKGray = CFX_Color(CFX_Color::kGray, 0.25);
+ m_crGray = CFX_Color(CFX_Color::kGray, 0.5);
+ m_crLTGray = CFX_Color(CFX_Color::kGray, 0.75);
}
color::~color() {}
@@ -59,20 +59,20 @@ void color::ConvertPWLColorToArray(CJS_Runtime* pRuntime,
const CFX_Color& color,
CJS_Array* array) {
switch (color.nColorType) {
- case COLORTYPE_TRANSPARENT:
+ case CFX_Color::kTransparent:
array->SetElement(pRuntime, 0, CJS_Value(pRuntime, "T"));
break;
- case COLORTYPE_GRAY:
+ case CFX_Color::kGray:
array->SetElement(pRuntime, 0, CJS_Value(pRuntime, "G"));
array->SetElement(pRuntime, 1, CJS_Value(pRuntime, color.fColor1));
break;
- case COLORTYPE_RGB:
+ 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));
break;
- case COLORTYPE_CMYK:
+ 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));
@@ -119,14 +119,14 @@ void color::ConvertArrayToPWLColor(CJS_Runtime* pRuntime,
}
if (sSpace == "T") {
- *color = CFX_Color(COLORTYPE_TRANSPARENT);
+ *color = CFX_Color(CFX_Color::kTransparent);
} else if (sSpace == "G") {
- *color = CFX_Color(COLORTYPE_GRAY, (float)d1);
+ *color = CFX_Color(CFX_Color::kGray, (float)d1);
} else if (sSpace == "RGB") {
- *color = CFX_Color(COLORTYPE_RGB, (float)d1, (float)d2, (float)d3);
+ *color = CFX_Color(CFX_Color::kRGB, (float)d1, (float)d2, (float)d3);
} else if (sSpace == "CMYK") {
*color =
- CFX_Color(COLORTYPE_CMYK, (float)d1, (float)d2, (float)d3, (float)d4);
+ CFX_Color(CFX_Color::kCMYK, (float)d1, (float)d2, (float)d3, (float)d4);
}
}
@@ -226,16 +226,16 @@ bool color::convert(CJS_Runtime* pRuntime,
ConvertArrayToPWLColor(pRuntime, aSource, &crSource);
ByteString sDestSpace = params[1].ToCFXByteString(pRuntime);
- int nColorType = COLORTYPE_TRANSPARENT;
+ int nColorType = CFX_Color::kTransparent;
if (sDestSpace == "T") {
- nColorType = COLORTYPE_TRANSPARENT;
+ nColorType = CFX_Color::kTransparent;
} else if (sDestSpace == "G") {
- nColorType = COLORTYPE_GRAY;
+ nColorType = CFX_Color::kGray;
} else if (sDestSpace == "RGB") {
- nColorType = COLORTYPE_RGB;
+ nColorType = CFX_Color::kRGB;
} else if (sDestSpace == "CMYK") {
- nColorType = COLORTYPE_CMYK;
+ nColorType = CFX_Color::kCMYK;
}
CJS_Array aDest;