Rename xfa_doclayout and xfa_document_layout_imp files.

This Cl moves the xfa_doclayout and xfa_document_layout_imp files to have
names based off of their classes.

Review-Url: https://codereview.chromium.org/2170473002
diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp
index bbed31b..e361be8 100644
--- a/xfa/fxfa/app/xfa_ffdocview.cpp
+++ b/xfa/fxfa/app/xfa_ffdocview.cpp
@@ -30,8 +30,8 @@
 #include "xfa/fxfa/include/xfa_ffwidget.h"
 #include "xfa/fxfa/include/xfa_ffwidgethandler.h"
 #include "xfa/fxfa/parser/cxfa_binditems.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
-#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
 #include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
 
 extern const XFA_ATTRIBUTEENUM gs_EventActivity[] = {
diff --git a/xfa/fxfa/app/xfa_ffpageview.cpp b/xfa/fxfa/app/xfa_ffpageview.cpp
index c1417c7..347174c 100644
--- a/xfa/fxfa/app/xfa_ffpageview.cpp
+++ b/xfa/fxfa/app/xfa_ffpageview.cpp
@@ -121,15 +121,13 @@
 }
 
 void CXFA_FFPageView::GetPageViewRect(CFX_RectF& rtPage) const {
-  CFX_SizeF sz;
-  GetPageSize(sz);
-  rtPage.Set(0, 0, sz);
+  rtPage.Set(0, 0, GetPageSize());
 }
+
 void CXFA_FFPageView::GetDisplayMatrix(CFX_Matrix& mt,
                                        const CFX_Rect& rtDisp,
                                        int32_t iRotate) const {
-  CFX_SizeF sz;
-  GetPageSize(sz);
+  CFX_SizeF sz = GetPageSize();
   CFX_RectF fdePage;
   fdePage.Set(0, 0, sz.x, sz.y);
   GetPageMatrix(mt, fdePage, rtDisp, iRotate, 0);
diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
index 57bd7bf..075f2aa 100644
--- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
@@ -24,8 +24,8 @@
 #include "xfa/fxfa/include/xfa_ffpageview.h"
 #include "xfa/fxfa/include/xfa_ffwidget.h"
 #include "xfa/fxfa/include/xfa_fontmgr.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
-#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
 #include "xfa/fxfa/parser/xfa_localevalue.h"
 #include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
 
diff --git a/xfa/fxfa/app/xfa_ffwidgethandler.cpp b/xfa/fxfa/app/xfa_ffwidgethandler.cpp
index 5b2577b..7d3da44 100644
--- a/xfa/fxfa/app/xfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgethandler.cpp
@@ -14,8 +14,8 @@
 #include "xfa/fxfa/include/xfa_ffdoc.h"
 #include "xfa/fxfa/include/xfa_ffdocview.h"
 #include "xfa/fxfa/include/xfa_ffwidget.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
 #include "xfa/fxfa/parser/cxfa_measurement.h"
-#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
 
 CXFA_FFWidgetHandler::CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView)
     : m_pDocView(pDocView) {}
diff --git a/xfa/fxfa/include/xfa_ffpageview.h b/xfa/fxfa/include/xfa_ffpageview.h
index 2c703b0..6b22dfe 100644
--- a/xfa/fxfa/include/xfa_ffpageview.h
+++ b/xfa/fxfa/include/xfa_ffpageview.h
@@ -7,7 +7,9 @@
 #ifndef XFA_FXFA_INCLUDE_XFA_FFPAGEVIEW_H_
 #define XFA_FXFA_INCLUDE_XFA_FFPAGEVIEW_H_
 
-#include "xfa/fxfa/parser/xfa_doclayout.h"
+#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
+#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
+#include "xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h"
 
 class CXFA_FFWidget;
 class CXFA_FFDocView;
diff --git a/xfa/fxfa/include/xfa_ffwidget.h b/xfa/fxfa/include/xfa_ffwidget.h
index 23a9a82..bde247f 100644
--- a/xfa/fxfa/include/xfa_ffwidget.h
+++ b/xfa/fxfa/include/xfa_ffwidget.h
@@ -12,7 +12,7 @@
 #include "core/fxcodec/include/fx_codec_def.h"
 #include "core/fxge/include/fx_ge.h"
 #include "xfa/fxfa/include/fxfa.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
+#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
 
 class CXFA_FFPageView;
 class CXFA_FFDocView;
diff --git a/xfa/fxfa/parser/cscript_datawindow.cpp b/xfa/fxfa/parser/cscript_datawindow.cpp
index 43f2244..9378b20 100644
--- a/xfa/fxfa/parser/cscript_datawindow.cpp
+++ b/xfa/fxfa/parser/cscript_datawindow.cpp
@@ -7,7 +7,6 @@
 #include "xfa/fxfa/parser/cscript_datawindow.h"
 
 #include "fxjs/include/cfxjse_arguments.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp
index 6b08cdc..16b2586 100644
--- a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp
@@ -11,7 +11,6 @@
 #include "xfa/fxfa/include/cxfa_eventparam.h"
 #include "xfa/fxfa/include/xfa_ffwidgethandler.h"
 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp
index eb4fcd9..a648735 100644
--- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp
@@ -8,10 +8,9 @@
 
 #include "fxjs/include/cfxjse_arguments.h"
 #include "xfa/fxfa/app/xfa_ffnotify.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
-#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
 #include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
index fe504c4..227a207 100644
--- a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
@@ -11,11 +11,13 @@
 #include "fxjs/include/cfxjse_arguments.h"
 #include "third_party/base/stl_util.h"
 #include "xfa/fxfa/app/xfa_ffnotify.h"
+#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
+#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
+#include "xfa/fxfa/parser/cxfa_layoutitem.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
 #include "xfa/fxfa/parser/cxfa_measurement.h"
 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
-#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
 #include "xfa/fxfa/parser/xfa_layout_appadapter.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.h b/xfa/fxfa/parser/cscript_layoutpseudomodel.h
index f812c3d..793e43c 100644
--- a/xfa/fxfa/parser/cscript_layoutpseudomodel.h
+++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.h
@@ -8,7 +8,6 @@
 #define XFA_FXFA_PARSER_CSCRIPT_LAYOUTPSEUDOMODEL_H_
 
 #include "fxjs/include/cfxjse_arguments.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_object.h"
 
 enum XFA_LAYOUTMODEL_HWXY {
@@ -18,6 +17,8 @@
   XFA_LAYOUTMODEL_Y
 };
 
+class CXFA_LayoutProcessor;
+
 class CScript_LayoutPseudoModel : public CXFA_Object {
  public:
   explicit CScript_LayoutPseudoModel(CXFA_Document* pDocument);
diff --git a/xfa/fxfa/parser/cscript_logpseudomodel.cpp b/xfa/fxfa/parser/cscript_logpseudomodel.cpp
index fbb13af..247a81d 100644
--- a/xfa/fxfa/parser/cscript_logpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_logpseudomodel.cpp
@@ -7,7 +7,6 @@
 #include "xfa/fxfa/parser/cscript_logpseudomodel.h"
 
 #include "fxjs/include/cfxjse_arguments.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp
index 2a23110..0e7cf65 100644
--- a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp
@@ -9,7 +9,6 @@
 #include "fxjs/include/cfxjse_arguments.h"
 #include "xfa/fxfa/app/xfa_ffnotify.h"
 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp b/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp
new file mode 100644
index 0000000..0db7fb2
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp
@@ -0,0 +1,44 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
+
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
+#include "xfa/fxfa/parser/cxfa_measurement.h"
+#include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h"
+
+CXFA_ContainerLayoutItem::CXFA_ContainerLayoutItem(CXFA_Node* pNode)
+    : CXFA_LayoutItem(pNode, FALSE), m_pOldSubform(nullptr) {}
+
+CXFA_LayoutProcessor* CXFA_ContainerLayoutItem::GetLayout() const {
+  return m_pFormNode->GetDocument()->GetLayoutProcessor();
+}
+
+int32_t CXFA_ContainerLayoutItem::GetPageIndex() const {
+  return m_pFormNode->GetDocument()
+      ->GetLayoutProcessor()
+      ->GetLayoutPageMgr()
+      ->GetPageIndex(this);
+}
+
+CFX_SizeF CXFA_ContainerLayoutItem::GetPageSize() const {
+  CFX_SizeF size;
+  CXFA_Node* pMedium = m_pFormNode->GetFirstChildByClass(XFA_Element::Medium);
+  if (!pMedium)
+    return size;
+
+  size = CFX_SizeF(pMedium->GetMeasure(XFA_ATTRIBUTE_Short).ToUnit(XFA_UNIT_Pt),
+                   pMedium->GetMeasure(XFA_ATTRIBUTE_Long).ToUnit(XFA_UNIT_Pt));
+  if (pMedium->GetEnum(XFA_ATTRIBUTE_Orientation) ==
+      XFA_ATTRIBUTEENUM_Landscape) {
+    size = CFX_SizeF(size.y, size.x);
+  }
+  return size;
+}
+
+CXFA_Node* CXFA_ContainerLayoutItem::GetMasterPage() const {
+  return m_pFormNode;
+}
diff --git a/xfa/fxfa/parser/cxfa_containerlayoutitem.h b/xfa/fxfa/parser/cxfa_containerlayoutitem.h
new file mode 100644
index 0000000..87fa360
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_containerlayoutitem.h
@@ -0,0 +1,28 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_CONTAINERLAYOUTITEM_H_
+#define XFA_FXFA_PARSER_CXFA_CONTAINERLAYOUTITEM_H_
+
+#include "xfa/fxfa/parser/cxfa_layoutitem.h"
+
+class CXFA_ContainerLayoutItem : public CXFA_LayoutItem {
+ public:
+  CXFA_ContainerLayoutItem(CXFA_Node* pNode);
+
+  CXFA_LayoutProcessor* GetLayout() const;
+  int32_t GetPageIndex() const;
+  CFX_SizeF GetPageSize() const;
+  CXFA_Node* GetMasterPage() const;
+
+  CXFA_Node* m_pOldSubform;
+};
+
+inline CXFA_ContainerLayoutItem* ToContainerLayoutItem(CXFA_LayoutItem* pItem) {
+  return pItem ? pItem->AsContainerLayoutItem() : nullptr;
+}
+
+#endif  // XFA_FXFA_PARSER_CXFA_CONTAINERLAYOUTITEM_H_
diff --git a/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp b/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp
new file mode 100644
index 0000000..7e9311f
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp
@@ -0,0 +1,18 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
+
+CXFA_ContentLayoutItem::CXFA_ContentLayoutItem(CXFA_Node* pNode)
+    : CXFA_LayoutItem(pNode, TRUE),
+      m_pPrev(nullptr),
+      m_pNext(nullptr),
+      m_dwStatus(0) {}
+
+CXFA_ContentLayoutItem::~CXFA_ContentLayoutItem() {
+  if (m_pFormNode->GetUserData(XFA_LAYOUTITEMKEY) == this)
+    m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, nullptr);
+}
diff --git a/xfa/fxfa/parser/cxfa_contentlayoutitem.h b/xfa/fxfa/parser/cxfa_contentlayoutitem.h
new file mode 100644
index 0000000..f826f52
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_contentlayoutitem.h
@@ -0,0 +1,28 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_CONTENTLAYOUTITEM_H_
+#define XFA_FXFA_PARSER_CXFA_CONTENTLAYOUTITEM_H_
+
+#include "xfa/fxfa/parser/cxfa_layoutitem.h"
+
+class CXFA_ContentLayoutItem : public CXFA_LayoutItem {
+ public:
+  CXFA_ContentLayoutItem(CXFA_Node* pNode);
+  ~CXFA_ContentLayoutItem() override;
+
+  CXFA_ContentLayoutItem* m_pPrev;
+  CXFA_ContentLayoutItem* m_pNext;
+  CFX_PointF m_sPos;
+  CFX_SizeF m_sSize;
+  uint32_t m_dwStatus;
+};
+
+inline CXFA_ContentLayoutItem* ToContentLayoutItem(CXFA_LayoutItem* pItem) {
+  return pItem ? pItem->AsContentLayoutItem() : nullptr;
+}
+
+#endif  // XFA_FXFA_PARSER_CXFA_CONTENTLAYOUTITEM_H_
diff --git a/xfa/fxfa/parser/cxfa_layoutitem.cpp b/xfa/fxfa/parser/cxfa_layoutitem.cpp
new file mode 100644
index 0000000..a9ba349
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_layoutitem.cpp
@@ -0,0 +1,28 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_layoutitem.h"
+
+#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
+#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
+
+CXFA_LayoutItem::CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem)
+    : m_pFormNode(pNode),
+      m_pParent(nullptr),
+      m_pNextSibling(nullptr),
+      m_pFirstChild(nullptr),
+      m_bIsContentLayoutItem(bIsContentLayoutItem) {}
+
+CXFA_LayoutItem::~CXFA_LayoutItem() {}
+
+CXFA_ContainerLayoutItem* CXFA_LayoutItem::AsContainerLayoutItem() {
+  return IsContainerLayoutItem() ? static_cast<CXFA_ContainerLayoutItem*>(this)
+                                 : nullptr;
+}
+CXFA_ContentLayoutItem* CXFA_LayoutItem::AsContentLayoutItem() {
+  return IsContentLayoutItem() ? static_cast<CXFA_ContentLayoutItem*>(this)
+                               : nullptr;
+}
diff --git a/xfa/fxfa/parser/cxfa_layoutitem.h b/xfa/fxfa/parser/cxfa_layoutitem.h
new file mode 100644
index 0000000..785272b
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_layoutitem.h
@@ -0,0 +1,54 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_LAYOUTITEM_H_
+#define XFA_FXFA_PARSER_CXFA_LAYOUTITEM_H_
+
+#include "xfa/fxfa/parser/xfa_document.h"
+
+class CXFA_ContainerLayoutItem;
+class CXFA_ContentLayoutItem;
+class CXFA_LayoutProcessor;
+
+class CXFA_LayoutItem {
+ public:
+  virtual ~CXFA_LayoutItem();
+
+  FX_BOOL IsContainerLayoutItem() const { return !m_bIsContentLayoutItem; }
+  FX_BOOL IsContentLayoutItem() const { return m_bIsContentLayoutItem; }
+  CXFA_ContainerLayoutItem* AsContainerLayoutItem();
+  CXFA_ContentLayoutItem* AsContentLayoutItem();
+
+  CXFA_ContainerLayoutItem* GetPage() const;
+  CXFA_Node* GetFormNode() const;
+  void GetRect(CFX_RectF& rtLayout, FX_BOOL bRelative = FALSE) const;
+  int32_t GetIndex() const;
+  int32_t GetCount() const;
+  CXFA_LayoutItem* GetParent() const;
+  const CXFA_LayoutItem* GetFirst() const;
+  CXFA_LayoutItem* GetFirst();
+  const CXFA_LayoutItem* GetLast() const;
+  CXFA_LayoutItem* GetLast();
+  CXFA_LayoutItem* GetPrev() const;
+  CXFA_LayoutItem* GetNext() const;
+
+  void AddChild(CXFA_LayoutItem* pChildItem);
+  void AddHeadChild(CXFA_LayoutItem* pChildItem);
+  void RemoveChild(CXFA_LayoutItem* pChildItem);
+  void InsertChild(CXFA_LayoutItem* pBeforeItem, CXFA_LayoutItem* pChildItem);
+
+  CXFA_Node* m_pFormNode;
+  CXFA_LayoutItem* m_pParent;
+  CXFA_LayoutItem* m_pNextSibling;
+  CXFA_LayoutItem* m_pFirstChild;
+
+ protected:
+  CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem);
+
+  FX_BOOL m_bIsContentLayoutItem;
+};
+
+#endif  // XFA_FXFA_PARSER_CXFA_LAYOUTITEM_H_
diff --git a/xfa/fxfa/parser/xfa_document_layout_imp.cpp b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
similarity index 68%
rename from xfa/fxfa/parser/xfa_document_layout_imp.cpp
rename to xfa/fxfa/parser/cxfa_layoutprocessor.cpp
index ec407a2..7ebe528 100644
--- a/xfa/fxfa/parser/xfa_document_layout_imp.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
@@ -1,13 +1,12 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2016 PDFium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
 
 #include "xfa/fxfa/parser/cxfa_measurement.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h"
 #include "xfa/fxfa/parser/xfa_layout_appadapter.h"
@@ -24,18 +23,22 @@
   }
   return m_pLayoutProcessor;
 }
+
 CXFA_LayoutProcessor* CXFA_Document::GetDocLayout() {
   return GetLayoutProcessor();
 }
+
 CXFA_LayoutProcessor::CXFA_LayoutProcessor(CXFA_Document* pDocument)
     : m_pDocument(pDocument),
       m_pRootItemLayoutProcessor(nullptr),
       m_pLayoutPageMgr(nullptr),
       m_nProgressCounter(0),
       m_bNeeLayout(TRUE) {}
+
 CXFA_LayoutProcessor::~CXFA_LayoutProcessor() {
   ClearLayoutData();
 }
+
 CXFA_Document* CXFA_LayoutProcessor::GetDocument() const {
   return m_pDocument;
 }
@@ -49,32 +52,29 @@
   m_nProgressCounter = 0;
   CXFA_Node* pFormPacketNode =
       ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form));
-  if (!pFormPacketNode) {
+  if (!pFormPacketNode)
     return -1;
-  }
+
   CXFA_Node* pFormRoot =
       pFormPacketNode->GetFirstChildByClass(XFA_Element::Subform);
-  if (!pFormRoot) {
+  if (!pFormRoot)
     return -1;
-  }
-  if (!m_pLayoutPageMgr) {
+  if (!m_pLayoutPageMgr)
     m_pLayoutPageMgr = new CXFA_LayoutPageMgr(this);
-  }
-  if (!m_pLayoutPageMgr->InitLayoutPage(pFormRoot)) {
+  if (!m_pLayoutPageMgr->InitLayoutPage(pFormRoot))
     return -1;
-  }
-  if (!m_pLayoutPageMgr->PrepareFirstPage(pFormRoot)) {
+  if (!m_pLayoutPageMgr->PrepareFirstPage(pFormRoot))
     return -1;
-  }
   m_pRootItemLayoutProcessor =
       new CXFA_ItemLayoutProcessor(pFormRoot, m_pLayoutPageMgr);
   m_nProgressCounter = 1;
   return 0;
 }
+
 int32_t CXFA_LayoutProcessor::DoLayout(IFX_Pause* pPause) {
-  if (m_nProgressCounter < 1) {
+  if (m_nProgressCounter < 1)
     return -1;
-  }
+
   XFA_ItemLayoutProcessorResult eStatus;
   CXFA_Node* pFormNode = m_pRootItemLayoutProcessor->GetFormNode();
   FX_FLOAT fPosX = pFormNode->GetMeasure(XFA_ATTRIBUTE_X).ToUnit(XFA_UNIT_Pt);
@@ -83,17 +83,18 @@
     FX_FLOAT fAvailHeight = m_pLayoutPageMgr->GetAvailHeight();
     eStatus =
         m_pRootItemLayoutProcessor->DoLayout(TRUE, fAvailHeight, fAvailHeight);
-    if (eStatus != XFA_ItemLayoutProcessorResult_Done) {
+    if (eStatus != XFA_ItemLayoutProcessorResult_Done)
       m_nProgressCounter++;
-    }
+
     CXFA_ContentLayoutItem* pLayoutItem =
         m_pRootItemLayoutProcessor->ExtractLayoutItem();
-    if (pLayoutItem) {
+    if (pLayoutItem)
       pLayoutItem->m_sPos = CFX_PointF(fPosX, fPosY);
-    }
+
     m_pLayoutPageMgr->SubmitContentItem(pLayoutItem, eStatus);
   } while (eStatus != XFA_ItemLayoutProcessorResult_Done &&
            (!pPause || !pPause->NeedToPauseNow()));
+
   if (eStatus == XFA_ItemLayoutProcessorResult_Done) {
     m_pLayoutPageMgr->FinishPaginatedPageSets();
     m_pLayoutPageMgr->SyncLayoutData();
@@ -105,18 +106,19 @@
                     : m_nProgressCounter - 1) /
          m_nProgressCounter;
 }
+
 FX_BOOL CXFA_LayoutProcessor::IncrementLayout() {
   if (m_bNeeLayout) {
     StartLayout(TRUE);
     return DoLayout(nullptr) == 100;
   }
+
   for (int32_t i = 0, c = m_rgChangedContainers.GetSize(); i < c; i++) {
     CXFA_Node* pNode = m_rgChangedContainers[i];
     CXFA_Node* pParentNode =
         pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
-    if (!pParentNode) {
+    if (!pParentNode)
       return FALSE;
-    }
     if (!CXFA_ItemLayoutProcessor::IncrementRelayoutNode(this, pNode,
                                                          pParentNode)) {
       return FALSE;
@@ -125,21 +127,25 @@
   m_rgChangedContainers.RemoveAll();
   return TRUE;
 }
+
 int32_t CXFA_LayoutProcessor::CountPages() const {
   return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetPageCount() : 0;
 }
+
 CXFA_ContainerLayoutItem* CXFA_LayoutProcessor::GetPage(int32_t index) const {
   return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetPage(index) : nullptr;
 }
+
 CXFA_LayoutItem* CXFA_LayoutProcessor::GetLayoutItem(CXFA_Node* pFormItem) {
   return static_cast<CXFA_LayoutItem*>(
       pFormItem->GetUserData(XFA_LAYOUTITEMKEY));
 }
+
 void CXFA_LayoutProcessor::AddChangedContainer(CXFA_Node* pContainer) {
-  if (m_rgChangedContainers.Find(pContainer) < 0) {
+  if (m_rgChangedContainers.Find(pContainer) < 0)
     m_rgChangedContainers.Add(pContainer);
-  }
 }
+
 CXFA_ContainerLayoutItem* CXFA_LayoutProcessor::GetRootLayoutItem() const {
   return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetRootLayoutItem() : nullptr;
 }
@@ -155,49 +161,3 @@
 FX_BOOL CXFA_LayoutProcessor::IsNeedLayout() {
   return m_bNeeLayout || m_rgChangedContainers.GetSize() > 0;
 }
-CXFA_LayoutItem::CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem)
-    : m_pFormNode(pNode),
-      m_pParent(nullptr),
-      m_pNextSibling(nullptr),
-      m_pFirstChild(nullptr),
-      m_bIsContentLayoutItem(bIsContentLayoutItem) {}
-CXFA_LayoutItem::~CXFA_LayoutItem() {}
-CXFA_ContainerLayoutItem::CXFA_ContainerLayoutItem(CXFA_Node* pNode)
-    : CXFA_LayoutItem(pNode, FALSE), m_pOldSubform(nullptr) {}
-CXFA_LayoutProcessor* CXFA_ContainerLayoutItem::GetLayout() const {
-  return m_pFormNode->GetDocument()->GetLayoutProcessor();
-}
-int32_t CXFA_ContainerLayoutItem::GetPageIndex() const {
-  return m_pFormNode->GetDocument()
-      ->GetLayoutProcessor()
-      ->GetLayoutPageMgr()
-      ->GetPageIndex(this);
-}
-
-void CXFA_ContainerLayoutItem::GetPageSize(CFX_SizeF& size) const {
-  size.clear();
-  CXFA_Node* pMedium = m_pFormNode->GetFirstChildByClass(XFA_Element::Medium);
-  if (!pMedium)
-    return;
-
-  size = CFX_SizeF(pMedium->GetMeasure(XFA_ATTRIBUTE_Short).ToUnit(XFA_UNIT_Pt),
-                   pMedium->GetMeasure(XFA_ATTRIBUTE_Long).ToUnit(XFA_UNIT_Pt));
-  if (pMedium->GetEnum(XFA_ATTRIBUTE_Orientation) ==
-      XFA_ATTRIBUTEENUM_Landscape) {
-    size = CFX_SizeF(size.y, size.x);
-  }
-}
-
-CXFA_Node* CXFA_ContainerLayoutItem::GetMasterPage() const {
-  return m_pFormNode;
-}
-CXFA_ContentLayoutItem::CXFA_ContentLayoutItem(CXFA_Node* pNode)
-    : CXFA_LayoutItem(pNode, TRUE),
-      m_pPrev(nullptr),
-      m_pNext(nullptr),
-      m_dwStatus(0) {}
-CXFA_ContentLayoutItem::~CXFA_ContentLayoutItem() {
-  if (m_pFormNode->GetUserData(XFA_LAYOUTITEMKEY) == this) {
-    m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, nullptr);
-  }
-}
diff --git a/xfa/fxfa/parser/xfa_document_layout_imp.h b/xfa/fxfa/parser/cxfa_layoutprocessor.h
similarity index 78%
rename from xfa/fxfa/parser/xfa_document_layout_imp.h
rename to xfa/fxfa/parser/cxfa_layoutprocessor.h
index 87f7ca0..1e66402 100644
--- a/xfa/fxfa/parser/xfa_document_layout_imp.h
+++ b/xfa/fxfa/parser/cxfa_layoutprocessor.h
@@ -1,17 +1,22 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2016 PDFium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef XFA_FXFA_PARSER_XFA_DOCUMENT_LAYOUT_IMP_H_
-#define XFA_FXFA_PARSER_XFA_DOCUMENT_LAYOUT_IMP_H_
+#ifndef XFA_FXFA_PARSER_CXFA_LAYOUTPROCESSOR_H_
+#define XFA_FXFA_PARSER_CXFA_LAYOUTPROCESSOR_H_
 
-#include "xfa/fxfa/parser/xfa_doclayout.h"
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fxfa/parser/xfa_object.h"
 
-class CXFA_ItemLayoutProcessor;
-class CXFA_LayoutPageMgr;
 class CXFA_ContainerLayoutItem;
+class CXFA_Document;
+class CXFA_ItemLayoutProcessor;
+class CXFA_LayoutItem;
+class CXFA_LayoutPageMgr;
+class CXFA_Node;
+class IFX_Pause;
 
 class CXFA_LayoutProcessor {
  public:
@@ -34,7 +39,7 @@
   }
   CXFA_LayoutPageMgr* GetLayoutPageMgr() { return m_pLayoutPageMgr; }
 
- protected:
+ private:
   void ClearLayoutData();
 
   FX_BOOL IsNeedLayout();
@@ -47,4 +52,4 @@
   FX_BOOL m_bNeeLayout;
 };
 
-#endif  // XFA_FXFA_PARSER_XFA_DOCUMENT_LAYOUT_IMP_H_
+#endif  // XFA_FXFA_PARSER_CXFA_LAYOUTPROCESSOR_H_
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 44b7e2f..800ada4 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -17,13 +17,13 @@
 #include "xfa/fgas/crt/fgas_system.h"
 #include "xfa/fxfa/app/xfa_ffnotify.h"
 #include "xfa/fxfa/include/cxfa_eventparam.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
 #include "xfa/fxfa/parser/cxfa_measurement.h"
 #include "xfa/fxfa/parser/cxfa_occur.h"
 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
 #include "xfa/fxfa/parser/cxfa_simple_parser.h"
 #include "xfa/fxfa/parser/xfa_basic_data.h"
 #include "xfa/fxfa/parser/xfa_document.h"
-#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
 
 namespace {
 
diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/xfa/fxfa/parser/cxfa_nodehelper.cpp
index 038a5a5..f5b4c04 100644
--- a/xfa/fxfa/parser/cxfa_nodehelper.cpp
+++ b/xfa/fxfa/parser/cxfa_nodehelper.cpp
@@ -8,7 +8,6 @@
 
 #include "core/fxcrt/include/fx_ext.h"
 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp
index b6894c4..578c2dc 100644
--- a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp
@@ -9,7 +9,6 @@
 #include "core/fxcrt/include/fx_ext.h"
 #include "xfa/fxfa/parser/cxfa_nodehelper.h"
 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.cpp b/xfa/fxfa/parser/cxfa_scriptcontext.cpp
index f59700a..24c3e50 100644
--- a/xfa/fxfa/parser/cxfa_scriptcontext.cpp
+++ b/xfa/fxfa/parser/cxfa_scriptcontext.cpp
@@ -15,7 +15,6 @@
 #include "xfa/fxfa/parser/cxfa_nodehelper.h"
 #include "xfa/fxfa/parser/cxfa_resolveprocessor.h"
 #include "xfa/fxfa/parser/xfa_basic_data.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h b/xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h
new file mode 100644
index 0000000..7b39826
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h
@@ -0,0 +1,25 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_TRAVERSESTRATEGY_LAYOUTITEM_H_
+#define XFA_FXFA_PARSER_CXFA_TRAVERSESTRATEGY_LAYOUTITEM_H_
+
+#include "xfa/fxfa/parser/cxfa_layoutitem.h"
+
+class CXFA_TraverseStrategy_LayoutItem {
+ public:
+  static CXFA_LayoutItem* GetFirstChild(CXFA_LayoutItem* pLayoutItem) {
+    return pLayoutItem->m_pFirstChild;
+  }
+  static CXFA_LayoutItem* GetNextSibling(CXFA_LayoutItem* pLayoutItem) {
+    return pLayoutItem->m_pNextSibling;
+  }
+  static CXFA_LayoutItem* GetParent(CXFA_LayoutItem* pLayoutItem) {
+    return pLayoutItem->m_pParent;
+  }
+};
+
+#endif  // XFA_FXFA_PARSER_CXFA_TRAVERSESTRATEGY_LAYOUTITEM_H_
diff --git a/xfa/fxfa/parser/xfa_doclayout.h b/xfa/fxfa/parser/xfa_doclayout.h
deleted file mode 100644
index cc0cf82..0000000
--- a/xfa/fxfa/parser/xfa_doclayout.h
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXFA_PARSER_XFA_DOCLAYOUT_H_
-#define XFA_FXFA_PARSER_XFA_DOCLAYOUT_H_
-
-#include "xfa/fxfa/parser/xfa_document.h"
-
-class CXFA_ContainerLayoutItem;
-class CXFA_ContentLayoutItem;
-class CXFA_LayoutProcessor;
-
-class CXFA_LayoutItem {
- public:
-  virtual ~CXFA_LayoutItem();
-
-  FX_BOOL IsContainerLayoutItem() const { return !m_bIsContentLayoutItem; }
-  FX_BOOL IsContentLayoutItem() const { return m_bIsContentLayoutItem; }
-  inline CXFA_ContainerLayoutItem* AsContainerLayoutItem();
-  inline CXFA_ContentLayoutItem* AsContentLayoutItem();
-
-  CXFA_ContainerLayoutItem* GetPage() const;
-  CXFA_Node* GetFormNode() const;
-  void GetRect(CFX_RectF& rtLayout, FX_BOOL bRelative = FALSE) const;
-  int32_t GetIndex() const;
-  int32_t GetCount() const;
-  CXFA_LayoutItem* GetParent() const;
-  const CXFA_LayoutItem* GetFirst() const;
-  CXFA_LayoutItem* GetFirst();
-  const CXFA_LayoutItem* GetLast() const;
-  CXFA_LayoutItem* GetLast();
-  CXFA_LayoutItem* GetPrev() const;
-  CXFA_LayoutItem* GetNext() const;
-
-  void AddChild(CXFA_LayoutItem* pChildItem);
-  void AddHeadChild(CXFA_LayoutItem* pChildItem);
-  void RemoveChild(CXFA_LayoutItem* pChildItem);
-  void InsertChild(CXFA_LayoutItem* pBeforeItem, CXFA_LayoutItem* pChildItem);
-
-  CXFA_Node* m_pFormNode;
-  CXFA_LayoutItem* m_pParent;
-  CXFA_LayoutItem* m_pNextSibling;
-  CXFA_LayoutItem* m_pFirstChild;
-
- protected:
-  CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem);
-
-  FX_BOOL m_bIsContentLayoutItem;
-};
-
-class CXFA_ContainerLayoutItem : public CXFA_LayoutItem {
- public:
-  CXFA_ContainerLayoutItem(CXFA_Node* pNode);
-
-  CXFA_LayoutProcessor* GetLayout() const;
-  int32_t GetPageIndex() const;
-  void GetPageSize(CFX_SizeF& size) const;
-  CXFA_Node* GetMasterPage() const;
-
-  CXFA_Node* m_pOldSubform;
-};
-
-class CXFA_ContentLayoutItem : public CXFA_LayoutItem {
- public:
-  CXFA_ContentLayoutItem(CXFA_Node* pNode);
-  ~CXFA_ContentLayoutItem() override;
-
-  CXFA_ContentLayoutItem* m_pPrev;
-  CXFA_ContentLayoutItem* m_pNext;
-  CFX_PointF m_sPos;
-  CFX_SizeF m_sSize;
-  uint32_t m_dwStatus;
-};
-
-CXFA_ContainerLayoutItem* CXFA_LayoutItem::AsContainerLayoutItem() {
-  return IsContainerLayoutItem() ? static_cast<CXFA_ContainerLayoutItem*>(this)
-                                 : nullptr;
-}
-CXFA_ContentLayoutItem* CXFA_LayoutItem::AsContentLayoutItem() {
-  return IsContentLayoutItem() ? static_cast<CXFA_ContentLayoutItem*>(this)
-                               : nullptr;
-}
-inline CXFA_ContainerLayoutItem* ToContainerLayoutItem(CXFA_LayoutItem* pItem) {
-  return pItem ? pItem->AsContainerLayoutItem() : nullptr;
-}
-inline CXFA_ContentLayoutItem* ToContentLayoutItem(CXFA_LayoutItem* pItem) {
-  return pItem ? pItem->AsContentLayoutItem() : nullptr;
-}
-
-class CXFA_TraverseStrategy_LayoutItem {
- public:
-  static inline CXFA_LayoutItem* GetFirstChild(CXFA_LayoutItem* pLayoutItem) {
-    return pLayoutItem->m_pFirstChild;
-  }
-  static inline CXFA_LayoutItem* GetNextSibling(CXFA_LayoutItem* pLayoutItem) {
-    return pLayoutItem->m_pNextSibling;
-  }
-  static inline CXFA_LayoutItem* GetParent(CXFA_LayoutItem* pLayoutItem) {
-    return pLayoutItem->m_pParent;
-  }
-};
-
-#endif  // XFA_FXFA_PARSER_XFA_DOCLAYOUT_H_
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index d1f9b8e..19b0698 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -8,11 +8,10 @@
 
 #include "core/fxcrt/include/fx_ext.h"
 #include "xfa/fde/xml/fde_xml_imp.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
 #include "xfa/fxfa/parser/cxfa_occur.h"
 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
-#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
 #include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
diff --git a/xfa/fxfa/parser/xfa_document_imp.cpp b/xfa/fxfa/parser/xfa_document_imp.cpp
index 46a6edc..633e2e2 100644
--- a/xfa/fxfa/parser/xfa_document_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_imp.cpp
@@ -13,10 +13,9 @@
 #include "xfa/fxfa/parser/cscript_logpseudomodel.h"
 #include "xfa/fxfa/parser/cscript_signaturepseudomodel.h"
 #include "xfa/fxfa/parser/cxfa_document_parser.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
-#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
 #include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
diff --git a/xfa/fxfa/parser/xfa_document_serialize.cpp b/xfa/fxfa/parser/xfa_document_serialize.cpp
index e6cd3e8..a524c73 100644
--- a/xfa/fxfa/parser/xfa_document_serialize.cpp
+++ b/xfa/fxfa/parser/xfa_document_serialize.cpp
@@ -9,7 +9,6 @@
 #include "xfa/fde/xml/fde_xml_imp.h"
 #include "xfa/fgas/crt/fgas_codepage.h"
 #include "xfa/fxfa/parser/cxfa_simple_parser.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/xfa_layout_appadapter.cpp b/xfa/fxfa/parser/xfa_layout_appadapter.cpp
index ad6c560..3dc9b5f 100644
--- a/xfa/fxfa/parser/xfa_layout_appadapter.cpp
+++ b/xfa/fxfa/parser/xfa_layout_appadapter.cpp
@@ -7,9 +7,7 @@
 #include "xfa/fxfa/parser/xfa_layout_appadapter.h"
 
 #include "xfa/fxfa/app/xfa_ffnotify.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
-#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
 #include "xfa/fxfa/parser/xfa_layout_itemlayout.h"
 #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
diff --git a/xfa/fxfa/parser/xfa_layout_appadapter.h b/xfa/fxfa/parser/xfa_layout_appadapter.h
index 498c023..7de62e6 100644
--- a/xfa/fxfa/parser/xfa_layout_appadapter.h
+++ b/xfa/fxfa/parser/xfa_layout_appadapter.h
@@ -7,7 +7,9 @@
 #ifndef XFA_FXFA_PARSER_XFA_LAYOUT_APPADAPTER_H_
 #define XFA_FXFA_PARSER_XFA_LAYOUT_APPADAPTER_H_
 
-#include "xfa/fxfa/parser/xfa_doclayout.h"
+#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
+#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
+#include "xfa/fxfa/parser/cxfa_layoutitem.h"
 
 class CXFA_TraverseStrategy_PageAreaContainerLayoutItem {
  public:
diff --git a/xfa/fxfa/parser/xfa_layout_itemlayout.cpp b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp
index c120893..99432d8 100644
--- a/xfa/fxfa/parser/xfa_layout_itemlayout.cpp
+++ b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp
@@ -12,9 +12,7 @@
 #include "xfa/fxfa/app/xfa_ffnotify.h"
 #include "xfa/fxfa/parser/cxfa_measurement.h"
 #include "xfa/fxfa/parser/cxfa_occur.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
-#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
 #include "xfa/fxfa/parser/xfa_layout_appadapter.h"
 #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
diff --git a/xfa/fxfa/parser/xfa_layout_itemlayout.h b/xfa/fxfa/parser/xfa_layout_itemlayout.h
index f326715..a1344ba 100644
--- a/xfa/fxfa/parser/xfa_layout_itemlayout.h
+++ b/xfa/fxfa/parser/xfa_layout_itemlayout.h
@@ -13,8 +13,7 @@
 #include <map>
 
 #include "core/fxcrt/include/fx_basic.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
-#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
+#include "xfa/fxfa/include/fxfa_basic.h"
 
 #define XFA_LAYOUT_INVALIDNODE ((CXFA_Node*)(intptr_t)-1)
 #define XFA_LAYOUT_FLOAT_PERCISION (0.0005f)
@@ -24,6 +23,7 @@
 class CXFA_ContentLayoutItem;
 class CXFA_ItemLayoutProcessor;
 class CXFA_LayoutPageMgr;
+class CXFA_LayoutProcessor;
 class CXFA_Node;
 
 enum XFA_ItemLayoutProcessorResult {
diff --git a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp
index 8794864..779e783 100644
--- a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp
+++ b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp
@@ -7,12 +7,12 @@
 #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h"
 
 #include "xfa/fxfa/app/xfa_ffnotify.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
 #include "xfa/fxfa/parser/cxfa_measurement.h"
 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
+#include "xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h"
-#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
 #include "xfa/fxfa/parser/xfa_layout_appadapter.h"
 #include "xfa/fxfa/parser/xfa_layout_itemlayout.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
diff --git a/xfa/fxfa/parser/xfa_layout_pagemgr_new.h b/xfa/fxfa/parser/xfa_layout_pagemgr_new.h
index 5ffa40e..f4cc175 100644
--- a/xfa/fxfa/parser/xfa_layout_pagemgr_new.h
+++ b/xfa/fxfa/parser/xfa_layout_pagemgr_new.h
@@ -7,9 +7,10 @@
 #ifndef XFA_FXFA_PARSER_XFA_LAYOUT_PAGEMGR_NEW_H_
 #define XFA_FXFA_PARSER_XFA_LAYOUT_PAGEMGR_NEW_H_
 
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_layout_itemlayout.h"
 
+class CXFA_LayoutItem;
+
 class CXFA_ContainerRecord {
  public:
   CXFA_ContainerRecord(CXFA_ContainerLayoutItem* pPageSet = nullptr,
diff --git a/xfa/fxfa/parser/xfa_locale.cpp b/xfa/fxfa/parser/xfa_locale.cpp
index 48492a9..48e0f1e 100644
--- a/xfa/fxfa/parser/xfa_locale.cpp
+++ b/xfa/fxfa/parser/xfa_locale.cpp
@@ -7,7 +7,6 @@
 #include "xfa/fxfa/parser/xfa_locale.h"
 
 #include "core/fxcrt/include/fx_xml.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/xfa_localemgr.cpp b/xfa/fxfa/parser/xfa_localemgr.cpp
index f19b132..4b80f3e 100644
--- a/xfa/fxfa/parser/xfa_localemgr.cpp
+++ b/xfa/fxfa/parser/xfa_localemgr.cpp
@@ -9,7 +9,6 @@
 #include "core/fxcodec/include/fx_codec.h"
 #include "core/fxcrt/include/fx_xml.h"
 #include "core/fxge/include/fx_ge.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_locale.h"
 #include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/xfa_localevalue.cpp b/xfa/fxfa/parser/xfa_localevalue.cpp
index f5d95ad..0ec38d5 100644
--- a/xfa/fxfa/parser/xfa_localevalue.cpp
+++ b/xfa/fxfa/parser/xfa_localevalue.cpp
@@ -8,7 +8,6 @@
 
 #include "core/fxcrt/include/fx_ext.h"
 #include "xfa/fgas/localization/fgas_localeimp.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/xfa_utils_imp.cpp b/xfa/fxfa/parser/xfa_utils_imp.cpp
index 50438b7..064ef6c 100644
--- a/xfa/fxfa/parser/xfa_utils_imp.cpp
+++ b/xfa/fxfa/parser/xfa_utils_imp.cpp
@@ -10,7 +10,6 @@
 #include "xfa/fde/xml/fde_xml_imp.h"
 #include "xfa/fxfa/parser/cxfa_measurement.h"
 #include "xfa/fxfa/parser/xfa_basic_data.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
 #include "xfa/fxfa/parser/xfa_document.h"
 #include "xfa/fxfa/parser/xfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_localevalue.h"