Add CPDF_Path::AppendFloatRect().

Make it simpler for callers that already have a CFX_FloatRect to pass
in. Instead of making them pass in the 4 components of the rectangle.
This better aligns with the APIs offered by CFX_PathData, which
CPDF_Path uses. At the same time, rename the CFX_FloatRect version of
CFX_PathData::AppendRect() to avoid overloading.

Change-Id: I0bdd53a34ef8ecaa17a8442299a2a2fcbaa54b17
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/60850
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index 0caafef..5b3efe1 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -69,8 +69,7 @@
   if (pBBox) {
     form_bbox = pBBox->GetRect();
     ClipPath.Emplace();
-    ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.right,
-                        form_bbox.top);
+    ClipPath.AppendFloatRect(form_bbox);
     ClipPath.Transform(form_matrix);
     if (pParentMatrix)
       ClipPath.Transform(*pParentMatrix);
diff --git a/core/fpdfapi/page/cpdf_path.cpp b/core/fpdfapi/page/cpdf_path.cpp
index d96b3e3..a07bb6a 100644
--- a/core/fpdfapi/page/cpdf_path.cpp
+++ b/core/fpdfapi/page/cpdf_path.cpp
@@ -45,6 +45,10 @@
   m_Ref.GetPrivateCopy()->Append(pData, pMatrix);
 }
 
+void CPDF_Path::AppendFloatRect(const CFX_FloatRect& rect) {
+  m_Ref.GetPrivateCopy()->AppendFloatRect(rect);
+}
+
 void CPDF_Path::AppendRect(float left, float bottom, float right, float top) {
   m_Ref.GetPrivateCopy()->AppendRect(left, bottom, right, top);
 }
diff --git a/core/fpdfapi/page/cpdf_path.h b/core/fpdfapi/page/cpdf_path.h
index 62ff675..48f5634 100644
--- a/core/fpdfapi/page/cpdf_path.h
+++ b/core/fpdfapi/page/cpdf_path.h
@@ -33,7 +33,7 @@
   void Transform(const CFX_Matrix& matrix);
 
   void Append(const CFX_PathData* pData, const CFX_Matrix* pMatrix);
-  // TODO(thestig): Switch to CFX_FloatRect.
+  void AppendFloatRect(const CFX_FloatRect& rect);
   void AppendRect(float left, float bottom, float right, float top);
   void AppendPoint(const CFX_PointF& point, FXPT_TYPE type, bool close);
 
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index d412b52..89b815b 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1955,8 +1955,7 @@
     path.m_ClipPath.AppendTexts(&pCopy);
     path.m_ColorState = textobj->m_ColorState;
     path.m_GeneralState = textobj->m_GeneralState;
-    path.path().AppendRect(textobj->GetRect().left, textobj->GetRect().bottom,
-                           textobj->GetRect().right, textobj->GetRect().top);
+    path.path().AppendFloatRect(textobj->GetRect());
     path.SetRect(textobj->GetRect());
 
     AutoRestorer<UnownedPtr<const CPDF_PageObject>> restorer2(&m_pCurObj);
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index 6d542ee..9142a90 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -510,7 +510,7 @@
   CFX_FloatRect rect = GetRect();
   rect.Deflate(width / 2, width / 2);
   CFX_PathData path;
-  path.AppendRect(rect);
+  path.AppendFloatRect(rect);
 
   int fill_type = 0;
   if (pOptions && pOptions->GetOptions().bNoPathSmooth)
diff --git a/core/fxge/cfx_pathdata.cpp b/core/fxge/cfx_pathdata.cpp
index 078a180..55ce854 100644
--- a/core/fxge/cfx_pathdata.cpp
+++ b/core/fxge/cfx_pathdata.cpp
@@ -231,7 +231,7 @@
   AppendPoint(pt2, FXPT_TYPE::LineTo, false);
 }
 
-void CFX_PathData::AppendRect(const CFX_FloatRect& rect) {
+void CFX_PathData::AppendFloatRect(const CFX_FloatRect& rect) {
   return AppendRect(rect.left, rect.bottom, rect.right, rect.top);
 }
 
diff --git a/core/fxge/cfx_pathdata.h b/core/fxge/cfx_pathdata.h
index 8a18d82..3fd57e2 100644
--- a/core/fxge/cfx_pathdata.h
+++ b/core/fxge/cfx_pathdata.h
@@ -62,7 +62,7 @@
   bool IsRect(const CFX_Matrix* pMatrix, CFX_FloatRect* rect) const;
 
   void Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix);
-  void AppendRect(const CFX_FloatRect& rect);
+  void AppendFloatRect(const CFX_FloatRect& rect);
   void AppendRect(float left, float bottom, float right, float top);
   void AppendLine(const CFX_PointF& pt1, const CFX_PointF& pt2);
   void AppendPoint(const CFX_PointF& point, FXPT_TYPE type, bool closeFigure);
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index c2c0ec0..fdfdd6a 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -1087,7 +1087,7 @@
                                     const CFX_FloatRect& rect,
                                     const FX_COLORREF& color) {
   CFX_PathData path;
-  path.AppendRect(rect);
+  path.AppendFloatRect(rect);
   DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_WINDING);
 }
 
@@ -1111,7 +1111,7 @@
   gsd.m_LineWidth = fWidth;
 
   CFX_PathData path;
-  path.AppendRect(rect);
+  path.AppendFloatRect(rect);
   DrawPath(&path, &mtUser2Device, &gsd, 0, color, FXFILL_ALTERNATE);
 }
 
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index 24289fc..6feb146 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -662,7 +662,7 @@
     gsd.m_LineWidth = 0.0f;
 
     CFX_PathData pathData;
-    pathData.AppendRect(GetRect());
+    pathData.AppendFloatRect(GetRect());
     pDevice->DrawPath(&pathData, &mtUser2Device, &gsd, 0, 0xFFAAAAAA,
                       FXFILL_ALTERNATE);
   } else {