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 --- fpdfsdk/pwl/cpwl_appstream.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'fpdfsdk/pwl') diff --git a/fpdfsdk/pwl/cpwl_appstream.cpp b/fpdfsdk/pwl/cpwl_appstream.cpp index 6e65831627..cbe6501a32 100644 --- a/fpdfsdk/pwl/cpwl_appstream.cpp +++ b/fpdfsdk/pwl/cpwl_appstream.cpp @@ -1180,8 +1180,9 @@ void CPWL_AppStream::SetAsPushButton() { CFX_Color crText(CFX_Color::kGray, 0); ByteString csNameTag; CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); - if (da.HasColor()) { - iColorType = da.GetColor(fc); + Optional color = da.GetColor(fc); + if (color) { + iColorType = *color; crText = CFX_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); } @@ -1358,8 +1359,9 @@ void CPWL_AppStream::SetAsCheckBox() { CFX_FloatRect rcWindow = widget_->GetRotatedRect(); CFX_FloatRect rcClient = rcWindow.GetDeflated(fBorderWidth, fBorderWidth); CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); - if (da.HasColor()) { - iColorType = da.GetColor(fc); + Optional color = da.GetColor(fc); + if (color) { + iColorType = *color; crText = CFX_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); } @@ -1474,8 +1476,9 @@ void CPWL_AppStream::SetAsRadioButton() { CFX_FloatRect rcWindow = widget_->GetRotatedRect(); CFX_FloatRect rcClient = rcWindow.GetDeflated(fBorderWidth, fBorderWidth); CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); - if (da.HasColor()) { - iColorType = da.GetColor(fc); + Optional color = da.GetColor(fc); + if (color) { + iColorType = *color; crText = CFX_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); } -- cgit v1.2.3