summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpvt_generateap.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-04-03 19:10:51 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-03 19:10:51 +0000
commit4c22dd5690cdec725389055bb7c07c300a4b6fe4 (patch)
tree2b4ead266695d206172fbf11c63274286c496496 /core/fpdfdoc/cpvt_generateap.cpp
parent232b918d1f0faec230652f4097b834257a7dbb27 (diff)
downloadpdfium-4c22dd5690cdec725389055bb7c07c300a4b6fe4.tar.xz
Use Optional to determine if appearance stream as fontchromium/3388
This CL changes the CPDF_DefaultAppearance code to remove the HasFont method and change GetFont to return an Optional. This forces all the call sites to verify a font was returned correctly and removes the need for the duplicate appearance stream parsing. Bug: chromium:827430 Change-Id: If09e0a7d3f7dd63ad77b97a5a388127e4a02da61 Reviewed-on: https://pdfium-review.googlesource.com/29610 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpvt_generateap.cpp')
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index a6a64aaf8d..ef55545f9e 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -923,13 +923,13 @@ void CPVT_GenerateAP::GenerateFormAP(Type type,
return;
CPDF_DefaultAppearance appearance(DA);
- if (!appearance.HasFont())
- return;
- ASSERT(appearance.HasFont());
float fFontSize = 0;
- ByteString sFontName =
- PDF_NameDecode(appearance.GetFont(&fFontSize).AsStringView());
+ Optional<ByteString> font = appearance.GetFont(&fFontSize);
+ if (!font)
+ return;
+
+ ByteString sFontName = PDF_NameDecode(font->AsStringView());
if (sFontName.IsEmpty())
return;