Rename CXFA_LayoutPageMgr functions that operate on children only.

As opposed to operating on the item argument itself, several
functions only manipulate the children, so put the word |Children|
in the name of the methods.

- Simplify the recursion by removing null checks that are already
  accommodated by the next level of the function itself.

Change-Id: I321586629930cd5ce4ef5b6c95901a4352501eef
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/54230
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fxfa/layout/cxfa_layoutpagemgr.cpp b/xfa/fxfa/layout/cxfa_layoutpagemgr.cpp
index b191b9c..86bd0a9 100644
--- a/xfa/fxfa/layout/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/layout/cxfa_layoutpagemgr.cpp
@@ -243,16 +243,14 @@
   return nullptr;
 }
 
-void SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem,
-                          CXFA_FFNotify* pNotify,
-                          CXFA_LayoutProcessor* pDocLayout) {
+void SyncRemoveLayoutItemChildren(CXFA_LayoutItem* pParentLayoutItem,
+                                  CXFA_FFNotify* pNotify,
+                                  CXFA_LayoutProcessor* pDocLayout) {
   CXFA_LayoutItem* pNextLayoutItem;
   CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->GetFirstChild();
   while (pCurLayoutItem) {
     pNextLayoutItem = pCurLayoutItem->GetNextSibling();
-    if (pCurLayoutItem->GetFirstChild())
-      SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout);
-
+    SyncRemoveLayoutItemChildren(pCurLayoutItem, pNotify, pDocLayout);
     pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem);
     pCurLayoutItem->RemoveSelfIfParented();
     delete pCurLayoutItem;
@@ -1600,7 +1598,8 @@
   m_pPageSetMap.clear();
 }
 
-void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) {
+void CXFA_LayoutPageMgr::SaveLayoutItemChildren(
+    CXFA_LayoutItem* pParentLayoutItem) {
   CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->GetFirstChild();
   while (pCurLayoutItem) {
     CXFA_LayoutItem* pNextLayoutItem = pCurLayoutItem->GetNextSibling();
@@ -1610,16 +1609,13 @@
             m_pTemplatePageSetRoot->GetDocument()->GetNotify();
         CXFA_LayoutProcessor* pDocLayout =
             m_pTemplatePageSetRoot->GetDocument()->GetLayoutProcessor();
-        if (pCurLayoutItem->GetFirstChild())
-          SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout);
-
+        SyncRemoveLayoutItemChildren(pCurLayoutItem, pNotify, pDocLayout);
         pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem);
         pCurLayoutItem->RemoveSelfIfParented();
         delete pCurLayoutItem;
         pCurLayoutItem = pNextLayoutItem;
         continue;
       }
-
       if (pCurLayoutItem->GetFormNode()->IsLayoutGeneratedNode()) {
         CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode>
             sIterator(pCurLayoutItem->GetFormNode());
@@ -1629,10 +1625,7 @@
         }
       }
     }
-
-    if (pCurLayoutItem->GetFirstChild())
-      SaveLayoutItem(pCurLayoutItem);
-
+    SaveLayoutItemChildren(pCurLayoutItem);
     pCurLayoutItem->RemoveSelfIfParented();
     if (!pCurLayoutItem->IsContentLayoutItem() &&
         pCurLayoutItem->GetFormNode()->GetElementType() !=
@@ -1963,7 +1956,7 @@
   CXFA_ViewLayoutItem* pNextLayout = nullptr;
   for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) {
     pNextLayout = ToViewLayoutItem(pRootLayoutItem->GetNextSibling());
-    SaveLayoutItem(pRootLayoutItem);
+    SaveLayoutItemChildren(pRootLayoutItem);
     pRootLayoutItem->RemoveSelfIfParented();
     delete pRootLayoutItem;
   }
diff --git a/xfa/fxfa/layout/cxfa_layoutpagemgr.h b/xfa/fxfa/layout/cxfa_layoutpagemgr.h
index 2ebcaf9..335e22d 100644
--- a/xfa/fxfa/layout/cxfa_layoutpagemgr.h
+++ b/xfa/fxfa/layout/cxfa_layoutpagemgr.h
@@ -146,7 +146,7 @@
   void MergePageSetContents();
   void LayoutPageSetContents();
   void PrepareLayout();
-  void SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem);
+  void SaveLayoutItemChildren(CXFA_LayoutItem* pParentLayoutItem);
   void ProcessSimplexOrDuplexPageSets(CXFA_ViewLayoutItem* pPageSetLayoutItem,
                                       bool bIsSimplex);