summaryrefslogtreecommitdiff
path: root/xfa/fgas/font/cfgas_fontmgr.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-03 17:53:09 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-03 17:53:09 +0000
commitf9e0498bb1ce2a52628065bc13389b4fc2768f42 (patch)
treeca32a8eec12a42538fa5a5e1f86268c67a394ebc /xfa/fgas/font/cfgas_fontmgr.cpp
parenta1c846c4cf3f8c08edfffa1cc6b60860c011000b (diff)
downloadpdfium-f9e0498bb1ce2a52628065bc13389b4fc2768f42.tar.xz
Simplify CFX_FontSourceEnum_File's file iterator.
Break the methods down to their basic functionality, and built up from there. Change-Id: I691abaf08375425b59f2382cf95577c3917aca9d Reviewed-on: https://pdfium-review.googlesource.com/42972 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'xfa/fgas/font/cfgas_fontmgr.cpp')
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.cpp30
1 files changed, 12 insertions, 18 deletions
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index b2150f99b8..c8aed88547 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -634,20 +634,18 @@ ByteString CFX_FontSourceEnum_File::GetNextFile() {
return bsName;
}
-bool CFX_FontSourceEnum_File::HasStartPosition() {
+void CFX_FontSourceEnum_File::GetNext() {
m_wsNext = GetNextFile().UTF8Decode();
- return !m_wsNext.IsEmpty();
}
-std::pair<bool, RetainPtr<IFX_SeekableStream>>
-CFX_FontSourceEnum_File::GetNext() {
- if (m_wsNext.IsEmpty())
- return {false, nullptr};
+bool CFX_FontSourceEnum_File::HasNext() const {
+ return !m_wsNext.IsEmpty();
+}
- auto stream = IFX_SeekableStream::CreateFromFilename(m_wsNext.c_str(),
- FX_FILEMODE_ReadOnly);
- m_wsNext = GetNextFile().UTF8Decode();
- return {true, stream};
+RetainPtr<IFX_SeekableStream> CFX_FontSourceEnum_File::GetStream() const {
+ ASSERT(HasNext());
+ return IFX_SeekableStream::CreateFromFilename(m_wsNext.c_str(),
+ FX_FILEMODE_ReadOnly);
}
CFGAS_FontMgr::CFGAS_FontMgr()
@@ -684,16 +682,12 @@ bool CFGAS_FontMgr::EnumFontsFromFontMapper() {
bool CFGAS_FontMgr::EnumFontsFromFiles() {
CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary();
- if (!m_pFontSource->HasStartPosition())
- return !m_InstalledFonts.empty();
-
- bool has_next;
- RetainPtr<IFX_SeekableStream> stream;
- std::tie(has_next, stream) = m_pFontSource->GetNext();
- while (has_next) {
+ m_pFontSource->GetNext();
+ while (m_pFontSource->HasNext()) {
+ RetainPtr<IFX_SeekableStream> stream = m_pFontSource->GetStream();
if (stream)
RegisterFaces(stream, nullptr);
- std::tie(has_next, stream) = m_pFontSource->GetNext();
+ m_pFontSource->GetNext();
}
return !m_InstalledFonts.empty();
}