From 28bb2f2ffe751cf4142329e27238da52ae9f848b Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 3 Apr 2018 19:52:27 +0000 Subject: Remove DefaultAppearance HasColor and return an optional instead This CL converts CPDF_DefaultAppearance to return Optional items instead of having a HasColor. This saves the double parse of the appearance stream. Change-Id: Ib3c136da6e2adfb559e495de1d299cce0b4ad25f Reviewed-on: https://pdfium-review.googlesource.com/29630 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- fxjs/cjs_field.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'fxjs') diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp index acc0fe3188..3ae40a97a8 100644 --- a/fxjs/cjs_field.cpp +++ b/fxjs/cjs_field.cpp @@ -1885,22 +1885,22 @@ CJS_Return CJS_Field::get_text_color(CJS_Runtime* pRuntime) { if (!pFormControl) return CJS_Return(false); - int iColorType; + Optional iColorType; FX_ARGB color; CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance(); std::tie(iColorType, color) = FieldAppearance.GetColor(); - int32_t a; - int32_t r; - int32_t g; - int32_t b; - std::tie(a, r, g, b) = ArgbDecode(color); - - CFX_Color crRet = - CFX_Color(CFX_Color::kRGB, r / 255.0f, g / 255.0f, b / 255.0f); - - if (iColorType == CFX_Color::kTransparent) + CFX_Color crRet; + if (!iColorType || *iColorType == CFX_Color::kTransparent) { crRet = CFX_Color(CFX_Color::kTransparent); + } else { + int32_t a; + int32_t r; + int32_t g; + int32_t b; + std::tie(a, r, g, b) = ArgbDecode(color); + crRet = CFX_Color(CFX_Color::kRGB, r / 255.0f, g / 255.0f, b / 255.0f); + } v8::Local array = CJS_Color::ConvertPWLColorToArray(pRuntime, crRet); -- cgit v1.2.3