Remove CXFA_RenderContext

Its only used in one place, and doesn't require any special state,
so just inline it as a simple loop.

Change-Id: I1ed8537de0a0a3b7168ea4cff4510f08b29814f2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/71914
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
index 021af5a..a1111a3 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
@@ -18,7 +18,6 @@
 #include "xfa/fxfa/cxfa_ffpageview.h"
 #include "xfa/fxfa/cxfa_ffwidget.h"
 #include "xfa/fxfa/cxfa_ffwidgethandler.h"
-#include "xfa/fxfa/cxfa_rendercontext.h"
 #include "xfa/fxgraphics/cxfa_graphics.h"
 
 namespace {
@@ -266,8 +265,21 @@
   gs.SetClipRect(rectClip);
 
   CXFA_FFPageView* xfaView = GetXFAPageView();
-  CXFA_RenderContext renderContext(xfaView, rectClip, mtUser2Device);
-  renderContext.DoRender(&gs);
+  std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator =
+      xfaView->CreateFormWidgetIterator(XFA_WidgetStatus_Visible |
+                                        XFA_WidgetStatus_Viewable);
+
+  while (1) {
+    CXFA_FFWidget* pWidget = pWidgetIterator->MoveToNext();
+    if (!pWidget)
+      break;
+
+    CFX_RectF rtWidgetBox = pWidget->GetBBox(CXFA_FFWidget::kDoNotDrawFocus);
+    ++rtWidgetBox.width;
+    ++rtWidgetBox.height;
+    if (rtWidgetBox.IntersectWith(rectClip))
+      pWidget->RenderWidget(&gs, mtUser2Device, CXFA_FFWidget::kHighlight);
+  }
 
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
   if (!pXFAWidget)
diff --git a/xfa/fxfa/BUILD.gn b/xfa/fxfa/BUILD.gn
index 66bce13..1f03242 100644
--- a/xfa/fxfa/BUILD.gn
+++ b/xfa/fxfa/BUILD.gn
@@ -77,8 +77,6 @@
     "cxfa_pieceline.h",
     "cxfa_readynodeiterator.cpp",
     "cxfa_readynodeiterator.h",
-    "cxfa_rendercontext.cpp",
-    "cxfa_rendercontext.h",
     "cxfa_textlayout.cpp",
     "cxfa_textlayout.h",
     "cxfa_textparsecontext.cpp",
diff --git a/xfa/fxfa/cxfa_rendercontext.cpp b/xfa/fxfa/cxfa_rendercontext.cpp
deleted file mode 100644
index 94eae6d..0000000
--- a/xfa/fxfa/cxfa_rendercontext.cpp
+++ /dev/null
@@ -1,33 +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
-
-#include "xfa/fxfa/cxfa_rendercontext.h"
-
-#include "xfa/fxfa/cxfa_ffpageview.h"
-#include "xfa/fxfa/cxfa_ffwidget.h"
-
-CXFA_RenderContext::CXFA_RenderContext(CXFA_FFPageView* pPageView,
-                                       const CFX_RectF& clipRect,
-                                       const CFX_Matrix& matrix)
-    : m_pWidgetIterator(pPageView->CreateFormWidgetIterator(
-          XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)),
-      m_pWidget(m_pWidgetIterator->MoveToNext()),
-      m_matrix(matrix),
-      m_ClipRect(clipRect) {}
-
-CXFA_RenderContext::~CXFA_RenderContext() = default;
-
-void CXFA_RenderContext::DoRender(CXFA_Graphics* gs) {
-  while (m_pWidget) {
-    CFX_RectF rtWidgetBox = m_pWidget->GetBBox(CXFA_FFWidget::kDoNotDrawFocus);
-    ++rtWidgetBox.width;
-    ++rtWidgetBox.height;
-    if (rtWidgetBox.IntersectWith(m_ClipRect))
-      m_pWidget->RenderWidget(gs, m_matrix, CXFA_FFWidget::kHighlight);
-
-    m_pWidget = m_pWidgetIterator->MoveToNext();
-  }
-}
diff --git a/xfa/fxfa/cxfa_rendercontext.h b/xfa/fxfa/cxfa_rendercontext.h
deleted file mode 100644
index bcf1618..0000000
--- a/xfa/fxfa/cxfa_rendercontext.h
+++ /dev/null
@@ -1,36 +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_CXFA_RENDERCONTEXT_H_
-#define XFA_FXFA_CXFA_RENDERCONTEXT_H_
-
-#include <memory>
-
-#include "core/fxcrt/fx_coordinates.h"
-#include "core/fxcrt/unowned_ptr.h"
-
-class CXFA_Graphics;
-class CXFA_FFPageView;
-class CXFA_FFWidget;
-class IXFA_WidgetIterator;
-
-class CXFA_RenderContext {
- public:
-  CXFA_RenderContext(CXFA_FFPageView* pPageView,
-                     const CFX_RectF& clipRect,
-                     const CFX_Matrix& matrix);
-  ~CXFA_RenderContext();
-
-  void DoRender(CXFA_Graphics* gs);
-
- private:
-  std::unique_ptr<IXFA_WidgetIterator> const m_pWidgetIterator;
-  UnownedPtr<CXFA_FFWidget> m_pWidget;
-  const CFX_Matrix m_matrix;
-  const CFX_RectF m_ClipRect;
-};
-
-#endif  // XFA_FXFA_CXFA_RENDERCONTEXT_H_