Reduce includes in cfgas_defaultfontmanager.h

Do IWYU elsewhere, and unindent CFGAS_DefaultFontManager::GetFont().

Change-Id: Idb06c4ae75ce2d72b231cc4c84f61e5ca8a80cc5
Reviewed-on: https://pdfium-review.googlesource.com/c/43314
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fgas/font/cfgas_defaultfontmanager.cpp b/xfa/fgas/font/cfgas_defaultfontmanager.cpp
index d8ffd54..fcaf6fd 100644
--- a/xfa/fgas/font/cfgas_defaultfontmanager.cpp
+++ b/xfa/fgas/font/cfgas_defaultfontmanager.cpp
@@ -6,6 +6,7 @@
 
 #include "xfa/fgas/font/cfgas_defaultfontmanager.h"
 
+#include "xfa/fgas/font/cfgas_gefont.h"
 #include "xfa/fgas/font/fgas_fontutils.h"
 
 CFGAS_DefaultFontManager::CFGAS_DefaultFontManager() {}
@@ -19,35 +20,37 @@
   WideString wsFontName(wsFontFamily);
   RetainPtr<CFGAS_GEFont> pFont =
       pFontMgr->LoadFont(wsFontName.c_str(), dwFontStyles, 0xFFFF);
-  if (!pFont) {
-    const FGAS_FontInfo* pCurFont =
-        FGAS_FontInfoByFontName(wsFontName.AsStringView());
-    if (pCurFont && pCurFont->pReplaceFont) {
-      uint32_t dwStyle = 0;
-      // TODO(dsinclair): Why doesn't this check the other flags?
-      if (FontStyleIsBold(dwFontStyles))
-        dwStyle |= FXFONT_BOLD;
-      if (FontStyleIsItalic(dwFontStyles))
-        dwStyle |= FXFONT_ITALIC;
+  if (pFont)
+    return pFont;
 
-      const wchar_t* pReplace = pCurFont->pReplaceFont;
-      int32_t iLength = wcslen(pReplace);
-      while (iLength > 0) {
-        const wchar_t* pNameText = pReplace;
-        while (*pNameText != L',' && iLength > 0) {
-          pNameText++;
-          iLength--;
-        }
-        WideString wsReplace = WideString(pReplace, pNameText - pReplace);
-        pFont = pFontMgr->LoadFont(wsReplace.c_str(), dwStyle, 0xFFFF);
-        if (pFont)
-          break;
+  const FGAS_FontInfo* pCurFont =
+      FGAS_FontInfoByFontName(wsFontName.AsStringView());
+  if (!pCurFont || !pCurFont->pReplaceFont)
+    return pFont;
 
-        iLength--;
-        pNameText++;
-        pReplace = pNameText;
-      }
+  uint32_t dwStyle = 0;
+  // TODO(dsinclair): Why doesn't this check the other flags?
+  if (FontStyleIsBold(dwFontStyles))
+    dwStyle |= FXFONT_BOLD;
+  if (FontStyleIsItalic(dwFontStyles))
+    dwStyle |= FXFONT_ITALIC;
+
+  const wchar_t* pReplace = pCurFont->pReplaceFont;
+  int32_t iLength = wcslen(pReplace);
+  while (iLength > 0) {
+    const wchar_t* pNameText = pReplace;
+    while (*pNameText != L',' && iLength > 0) {
+      pNameText++;
+      iLength--;
     }
+    WideString wsReplace = WideString(pReplace, pNameText - pReplace);
+    pFont = pFontMgr->LoadFont(wsReplace.c_str(), dwStyle, 0xFFFF);
+    if (pFont)
+      break;
+
+    iLength--;
+    pNameText++;
+    pReplace = pNameText;
   }
   return pFont;
 }
diff --git a/xfa/fgas/font/cfgas_defaultfontmanager.h b/xfa/fgas/font/cfgas_defaultfontmanager.h
index 623beb4..3d723d5 100644
--- a/xfa/fgas/font/cfgas_defaultfontmanager.h
+++ b/xfa/fgas/font/cfgas_defaultfontmanager.h
@@ -9,7 +9,9 @@
 
 #include "core/fxcrt/fx_string.h"
 #include "core/fxcrt/retain_ptr.h"
-#include "xfa/fgas/font/cfgas_gefont.h"
+
+class CFGAS_GEFont;
+class CFGAS_FontMgr;
 
 class CFGAS_DefaultFontManager {
  public:
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index 64ecf25..6f4a981 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -20,8 +20,10 @@
 #include "core/fxcrt/xml/cfx_xmldocument.h"
 #include "core/fxcrt/xml/cfx_xmlelement.h"
 #include "core/fxcrt/xml/cfx_xmlnode.h"
+#include "core/fxge/dib/cfx_dibitmap.h"
 #include "fxjs/xfa/cjx_object.h"
 #include "third_party/base/ptr_util.h"
+#include "xfa/fgas/font/cfgas_pdffontmgr.h"
 #include "xfa/fwl/cfwl_notedriver.h"
 #include "xfa/fxfa/cxfa_ffapp.h"
 #include "xfa/fxfa/cxfa_ffdocview.h"
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index 484e862..d8150a6 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -19,6 +19,7 @@
 #include "core/fxcrt/xml/cfx_xmlnode.h"
 #include "third_party/base/ptr_util.h"
 #include "xfa/fgas/font/cfgas_fontmgr.h"
+#include "xfa/fgas/font/cfgas_gefont.h"
 #include "xfa/fxfa/cxfa_ffapp.h"
 #include "xfa/fxfa/cxfa_ffdoc.h"
 #include "xfa/fxfa/cxfa_fontmgr.h"
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 3ada2aa..1f44b05 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -33,6 +33,7 @@
 #include "third_party/base/stl_util.h"
 #include "xfa/fde/cfde_textout.h"
 #include "xfa/fgas/font/cfgas_fontmgr.h"
+#include "xfa/fgas/font/cfgas_gefont.h"
 #include "xfa/fxfa/cxfa_eventparam.h"
 #include "xfa/fxfa/cxfa_ffapp.h"
 #include "xfa/fxfa/cxfa_ffdocview.h"