Move two files from top-level fpdfsdk/ directory.

These were inconsistently named with regards to the rest of the
files in the directory, and as it turns out, there are better
places for these to live.

CPDF_AnnotContext is a straight move to core/fpdfapi/page.
CPDFSDK_XFAWidget is renamed to CPDFXFA_Widget and moves
to fpdfsdk/fpdfxfa with the other xfa-only files.

The build rules get slightly simpler as a result.

Change-Id: Ie8120b6c037c254ded0ad2c231c680e9435d30f7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/59610
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/page/BUILD.gn b/core/fpdfapi/page/BUILD.gn
index e853773..1ed9094 100644
--- a/core/fpdfapi/page/BUILD.gn
+++ b/core/fpdfapi/page/BUILD.gn
@@ -10,6 +10,8 @@
   sources = [
     "cpdf_allstates.cpp",
     "cpdf_allstates.h",
+    "cpdf_annotcontext.cpp",
+    "cpdf_annotcontext.h",
     "cpdf_clippath.cpp",
     "cpdf_clippath.h",
     "cpdf_color.cpp",
diff --git a/fpdfsdk/cpdf_annotcontext.cpp b/core/fpdfapi/page/cpdf_annotcontext.cpp
similarity index 95%
rename from fpdfsdk/cpdf_annotcontext.cpp
rename to core/fpdfapi/page/cpdf_annotcontext.cpp
index f363ef2..1078e46 100644
--- a/fpdfsdk/cpdf_annotcontext.cpp
+++ b/core/fpdfapi/page/cpdf_annotcontext.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "fpdfsdk/cpdf_annotcontext.h"
+#include "core/fpdfapi/page/cpdf_annotcontext.h"
 
 #include "core/fpdfapi/page/cpdf_form.h"
 #include "core/fpdfapi/page/cpdf_page.h"
diff --git a/fpdfsdk/cpdf_annotcontext.h b/core/fpdfapi/page/cpdf_annotcontext.h
similarity index 87%
rename from fpdfsdk/cpdf_annotcontext.h
rename to core/fpdfapi/page/cpdf_annotcontext.h
index 0561357..ee9f3fc 100644
--- a/fpdfsdk/cpdf_annotcontext.h
+++ b/core/fpdfapi/page/cpdf_annotcontext.h
@@ -4,8 +4,8 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef FPDFSDK_CPDF_ANNOTCONTEXT_H_
-#define FPDFSDK_CPDF_ANNOTCONTEXT_H_
+#ifndef CORE_FPDFAPI_PAGE_CPDF_ANNOTCONTEXT_H_
+#define CORE_FPDFAPI_PAGE_CPDF_ANNOTCONTEXT_H_
 
 #include <memory>
 
@@ -38,4 +38,4 @@
   UnownedPtr<CPDF_Page> const m_pPage;
 };
 
-#endif  // FPDFSDK_CPDF_ANNOTCONTEXT_H_
+#endif  // CORE_FPDFAPI_PAGE_CPDF_ANNOTCONTEXT_H_
diff --git a/fpdfsdk/BUILD.gn b/fpdfsdk/BUILD.gn
index f5c4aa5..d2a36c4 100644
--- a/fpdfsdk/BUILD.gn
+++ b/fpdfsdk/BUILD.gn
@@ -8,8 +8,6 @@
 
 jumbo_source_set("fpdfsdk") {
   sources = [
-    "cpdf_annotcontext.cpp",
-    "cpdf_annotcontext.h",
     "cpdfsdk_actionhandler.cpp",
     "cpdfsdk_actionhandler.h",
     "cpdfsdk_annot.cpp",
@@ -97,11 +95,6 @@
   visibility = [ "../*" ]
 
   if (pdf_enable_xfa) {
-    sources += [
-      "cpdfsdk_xfawidget.cpp",
-      "cpdfsdk_xfawidget.h",
-    ]
-
     deps += [
       "../fxbarcode",
       "../xfa/fxfa",
diff --git a/fpdfsdk/cpdfsdk_interactiveform.cpp b/fpdfsdk/cpdfsdk_interactiveform.cpp
index 0686205..ae43435 100644
--- a/fpdfsdk/cpdfsdk_interactiveform.cpp
+++ b/fpdfsdk/cpdfsdk_interactiveform.cpp
@@ -39,7 +39,7 @@
 #include "third_party/base/ptr_util.h"
 
 #ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/cpdfsdk_xfawidget.h"
+#include "fpdfsdk/fpdfxfa/cpdfxfa_widget.h"
 #include "xfa/fxfa/cxfa_ffwidget.h"
 #endif  // PDF_ENABLE_XFA
 
@@ -225,7 +225,7 @@
 
 #ifdef PDF_ENABLE_XFA
 void CPDFSDK_InteractiveForm::AddXFAMap(CXFA_FFWidget* hWidget,
-                                        CPDFSDK_XFAWidget* pWidget) {
+                                        CPDFXFA_Widget* pWidget) {
   ASSERT(hWidget);
   m_XFAMap[hWidget] = pWidget;
 }
@@ -235,8 +235,7 @@
     m_XFAMap.erase(hWidget);
 }
 
-CPDFSDK_XFAWidget* CPDFSDK_InteractiveForm::GetXFAWidget(
-    CXFA_FFWidget* hWidget) {
+CPDFXFA_Widget* CPDFSDK_InteractiveForm::GetXFAWidget(CXFA_FFWidget* hWidget) {
   ASSERT(hWidget);
   auto it = m_XFAMap.find(hWidget);
   return it != m_XFAMap.end() ? it->second : nullptr;
diff --git a/fpdfsdk/cpdfsdk_interactiveform.h b/fpdfsdk/cpdfsdk_interactiveform.h
index 4e6deb8..17a350d 100644
--- a/fpdfsdk/cpdfsdk_interactiveform.h
+++ b/fpdfsdk/cpdfsdk_interactiveform.h
@@ -26,7 +26,7 @@
 class CPDFSDK_FormFillEnvironment;
 
 #ifdef PDF_ENABLE_XFA
-class CPDFSDK_XFAWidget;
+class CPDFXFA_Widget;
 class CXFA_FFWidget;
 #endif  // PDF_ENABLE_XFA
 
@@ -55,9 +55,9 @@
   bool IsCalculateEnabled() const;
 
 #ifdef PDF_ENABLE_XFA
-  void AddXFAMap(CXFA_FFWidget* hWidget, CPDFSDK_XFAWidget* pWidget);
+  void AddXFAMap(CXFA_FFWidget* hWidget, CPDFXFA_Widget* pWidget);
   void RemoveXFAMap(CXFA_FFWidget* hWidget);
-  CPDFSDK_XFAWidget* GetXFAWidget(CXFA_FFWidget* hWidget);
+  CPDFXFA_Widget* GetXFAWidget(CXFA_FFWidget* hWidget);
   void XfaEnableCalculate(bool bEnabled);
   bool IsXfaCalculateEnabled() const;
   bool IsXfaValidationsEnabled();
@@ -116,7 +116,7 @@
   std::unique_ptr<CPDF_InteractiveForm> const m_pInteractiveForm;
   std::map<CPDF_FormControl*, CPDFSDK_Widget*> m_Map;
 #ifdef PDF_ENABLE_XFA
-  std::map<CXFA_FFWidget*, CPDFSDK_XFAWidget*> m_XFAMap;
+  std::map<CXFA_FFWidget*, CPDFXFA_Widget*> m_XFAMap;
   bool m_bXfaCalculate = true;
   bool m_bXfaValidationsEnabled = true;
 #endif  // PDF_ENABLE_XFA
diff --git a/fpdfsdk/cpdfsdk_xfawidget.cpp b/fpdfsdk/cpdfsdk_xfawidget.cpp
deleted file mode 100644
index f529a72..0000000
--- a/fpdfsdk/cpdfsdk_xfawidget.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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 "fpdfsdk/cpdfsdk_xfawidget.h"
-
-#include "fpdfsdk/ipdfsdk_annothandler.h"
-#include "xfa/fxfa/cxfa_ffwidget.h"
-
-CPDFSDK_XFAWidget::CPDFSDK_XFAWidget(CXFA_FFWidget* pAnnot,
-                                     CPDFSDK_PageView* pPageView,
-                                     CPDFSDK_InteractiveForm* pInteractiveForm)
-    : CPDFSDK_Annot(pPageView),
-      m_pInteractiveForm(pInteractiveForm),
-      m_pXFAWidget(pAnnot) {}
-
-CPDFSDK_XFAWidget::~CPDFSDK_XFAWidget() = default;
-
-bool CPDFSDK_XFAWidget::IsXFAField() const {
-  return true;
-}
-
-CXFA_FFWidget* CPDFSDK_XFAWidget::GetXFAWidget() const {
-  return m_pXFAWidget.Get();
-}
-
-CPDF_Annot::Subtype CPDFSDK_XFAWidget::GetAnnotSubtype() const {
-  return CPDF_Annot::Subtype::XFAWIDGET;
-}
-
-CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const {
-  return GetXFAWidget()->GetLayoutItem()->GetRect(false).ToFloatRect();
-}
diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp
index 7053459..211c102 100644
--- a/fpdfsdk/fpdf_annot.cpp
+++ b/fpdfsdk/fpdf_annot.cpp
@@ -9,6 +9,7 @@
 
 #include "constants/annotation_common.h"
 #include "core/fpdfapi/edit/cpdf_pagecontentgenerator.h"
+#include "core/fpdfapi/page/cpdf_annotcontext.h"
 #include "core/fpdfapi/page/cpdf_form.h"
 #include "core/fpdfapi/page/cpdf_page.h"
 #include "core/fpdfapi/page/cpdf_pageobject.h"
@@ -25,7 +26,6 @@
 #include "core/fpdfdoc/cpdf_interactiveform.h"
 #include "core/fpdfdoc/cpvt_generateap.h"
 #include "core/fxge/cfx_color.h"
-#include "fpdfsdk/cpdf_annotcontext.h"
 #include "fpdfsdk/cpdfsdk_helpers.h"
 #include "fpdfsdk/cpdfsdk_interactiveform.h"
 #include "third_party/base/ptr_util.h"
diff --git a/fpdfsdk/fpdfxfa/BUILD.gn b/fpdfsdk/fpdfxfa/BUILD.gn
index ef26c60..b3f821e 100644
--- a/fpdfsdk/fpdfxfa/BUILD.gn
+++ b/fpdfsdk/fpdfxfa/BUILD.gn
@@ -16,6 +16,8 @@
     "cpdfxfa_docenvironment.h",
     "cpdfxfa_page.cpp",
     "cpdfxfa_page.h",
+    "cpdfxfa_widget.cpp",
+    "cpdfxfa_widget.h",
     "cpdfxfa_widgethandler.cpp",
     "cpdfxfa_widgethandler.h",
   ]
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp
new file mode 100644
index 0000000..3505a3e
--- /dev/null
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp
@@ -0,0 +1,35 @@
+// 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 "fpdfsdk/fpdfxfa/cpdfxfa_widget.h"
+
+#include "fpdfsdk/ipdfsdk_annothandler.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
+
+CPDFXFA_Widget::CPDFXFA_Widget(CXFA_FFWidget* pAnnot,
+                               CPDFSDK_PageView* pPageView,
+                               CPDFSDK_InteractiveForm* pInteractiveForm)
+    : CPDFSDK_Annot(pPageView),
+      m_pInteractiveForm(pInteractiveForm),
+      m_pXFAWidget(pAnnot) {}
+
+CPDFXFA_Widget::~CPDFXFA_Widget() = default;
+
+bool CPDFXFA_Widget::IsXFAField() const {
+  return true;
+}
+
+CXFA_FFWidget* CPDFXFA_Widget::GetXFAWidget() const {
+  return m_pXFAWidget.Get();
+}
+
+CPDF_Annot::Subtype CPDFXFA_Widget::GetAnnotSubtype() const {
+  return CPDF_Annot::Subtype::XFAWIDGET;
+}
+
+CFX_FloatRect CPDFXFA_Widget::GetRect() const {
+  return GetXFAWidget()->GetLayoutItem()->GetRect(false).ToFloatRect();
+}
diff --git a/fpdfsdk/cpdfsdk_xfawidget.h b/fpdfsdk/fpdfxfa/cpdfxfa_widget.h
similarity index 67%
rename from fpdfsdk/cpdfsdk_xfawidget.h
rename to fpdfsdk/fpdfxfa/cpdfxfa_widget.h
index 3ee5cde..ba3b23d 100644
--- a/fpdfsdk/cpdfsdk_xfawidget.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widget.h
@@ -4,8 +4,8 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef FPDFSDK_CPDFSDK_XFAWIDGET_H_
-#define FPDFSDK_CPDFSDK_XFAWIDGET_H_
+#ifndef FPDFSDK_FPDFXFA_CPDFXFA_WIDGET_H_
+#define FPDFSDK_FPDFXFA_CPDFXFA_WIDGET_H_
 
 #include "core/fxcrt/fx_coordinates.h"
 #include "core/fxcrt/fx_string.h"
@@ -17,12 +17,12 @@
 class CPDFSDK_PageView;
 class CXFA_FFWidget;
 
-class CPDFSDK_XFAWidget final : public CPDFSDK_Annot {
+class CPDFXFA_Widget final : public CPDFSDK_Annot {
  public:
-  CPDFSDK_XFAWidget(CXFA_FFWidget* pAnnot,
-                    CPDFSDK_PageView* pPageView,
-                    CPDFSDK_InteractiveForm* pInteractiveForm);
-  ~CPDFSDK_XFAWidget() override;
+  CPDFXFA_Widget(CXFA_FFWidget* pAnnot,
+                 CPDFSDK_PageView* pPageView,
+                 CPDFSDK_InteractiveForm* pInteractiveForm);
+  ~CPDFXFA_Widget() override;
 
   // CPDFSDK_Annot:
   bool IsXFAField() const override;
@@ -39,9 +39,10 @@
   ObservedPtr<CXFA_FFWidget> const m_pXFAWidget;
 };
 
-inline CPDFSDK_XFAWidget* ToXFAWidget(CPDFSDK_Annot* pAnnot) {
+inline CPDFXFA_Widget* ToXFAWidget(CPDFSDK_Annot* pAnnot) {
   return pAnnot && pAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET
-      ? static_cast<CPDFSDK_XFAWidget*>(pAnnot) : nullptr;
+             ? static_cast<CPDFXFA_Widget*>(pAnnot)
+             : nullptr;
 }
 
-#endif  // FPDFSDK_CPDFSDK_XFAWIDGET_H_
+#endif  // FPDFSDK_FPDFXFA_CPDFXFA_WIDGET_H_
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
index 4ad437e..4e6fa00 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
@@ -10,8 +10,8 @@
 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
 #include "fpdfsdk/cpdfsdk_interactiveform.h"
 #include "fpdfsdk/cpdfsdk_pageview.h"
-#include "fpdfsdk/cpdfsdk_xfawidget.h"
 #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
+#include "fpdfsdk/fpdfxfa/cpdfxfa_widget.h"
 #include "public/fpdf_fwlevent.h"
 #include "xfa/fwl/cfwl_app.h"
 #include "xfa/fwl/fwl_widgetdef.h"
@@ -218,7 +218,7 @@
 CPDFSDK_Annot* CPDFXFA_WidgetHandler::NewAnnotForXFA(CXFA_FFWidget* pAnnot,
                                                      CPDFSDK_PageView* pPage) {
   CPDFSDK_InteractiveForm* pForm = m_pFormFillEnv->GetInteractiveForm();
-  CPDFSDK_XFAWidget* pWidget = new CPDFSDK_XFAWidget(pAnnot, pPage, pForm);
+  CPDFXFA_Widget* pWidget = new CPDFXFA_Widget(pAnnot, pPage, pForm);
   pForm->AddXFAMap(pAnnot, pWidget);
   return pWidget;
 }
@@ -247,7 +247,7 @@
 
 void CPDFXFA_WidgetHandler::ReleaseAnnot(
     std::unique_ptr<CPDFSDK_Annot> pAnnot) {
-  CPDFSDK_XFAWidget* pWidget = ToXFAWidget(pAnnot.get());
+  CPDFXFA_Widget* pWidget = ToXFAWidget(pAnnot.get());
   pWidget->GetInteractiveForm()->RemoveXFAMap(pWidget->GetXFAWidget());
 }