Replace CFX_FloatRect::InitRect() with a constructor.

Because that's what InitRect() really is. Update the 2 callers, and fix
nits in surrounding code.

Change-Id: Ib9e03c90fcff21ffea40802b711cea958bcb091a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/80935
Reviewed-by: Hui Yingst <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index b96b179..38aec36 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -75,19 +75,23 @@
     return CFX_FloatRect();
 
   CFX_FloatRect rect;
-  bool bStarted = false;
+  bool update_rect = false;
   bool bGouraud = type == kFreeFormGouraudTriangleMeshShading ||
                   type == kLatticeFormGouraudTriangleMeshShading;
 
-  int point_count = kSingleCoordinatePair;
+  int point_count;
   if (type == kTensorProductPatchMeshShading)
     point_count = kTensorCoordinatePairs;
   else if (type == kCoonsPatchMeshShading)
     point_count = kCoonsCoordinatePairs;
+  else
+    point_count = kSingleCoordinatePair;
 
-  int color_count = kSingleColorPerPatch;
+  int color_count;
   if (type == kCoonsPatchMeshShading || type == kTensorProductPatchMeshShading)
     color_count = kQuadColorsPerPatch;
+  else
+    color_count = kSingleColorPerPatch;
 
   while (!stream.BitStream()->IsEOF()) {
     uint32_t flag = 0;
@@ -102,15 +106,16 @@
       color_count -= 2;
     }
 
-    for (int i = 0; i < point_count; i++) {
+    for (int i = 0; i < point_count; ++i) {
       if (!stream.CanReadCoords())
         break;
+
       CFX_PointF origin = stream.ReadCoords();
-      if (bStarted) {
+      if (update_rect) {
         rect.UpdateRect(origin);
       } else {
-        rect.InitRect(origin);
-        bStarted = true;
+        rect = CFX_FloatRect(origin);
+        update_rect = true;
       }
     }
     FX_SAFE_UINT32 nBits = stream.Components();
diff --git a/core/fxcrt/fx_coordinates.cpp b/core/fxcrt/fx_coordinates.cpp
index ac49903..dfaa89a 100644
--- a/core/fxcrt/fx_coordinates.cpp
+++ b/core/fxcrt/fx_coordinates.cpp
@@ -91,6 +91,9 @@
 CFX_FloatRect::CFX_FloatRect(const FX_RECT& rect)
     : left(rect.left), bottom(rect.top), right(rect.right), top(rect.bottom) {}
 
+CFX_FloatRect::CFX_FloatRect(const CFX_PointF& point)
+    : left(point.x), bottom(point.y), right(point.x), top(point.y) {}
+
 // static
 CFX_FloatRect CFX_FloatRect::GetBBox(const CFX_PointF* pPoints, int nPoints) {
   if (nPoints == 0)
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index fb2c0be..e458380 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -227,6 +227,7 @@
       : CFX_FloatRect(pArray[0], pArray[1], pArray[2], pArray[3]) {}
 
   explicit CFX_FloatRect(const FX_RECT& rect);
+  explicit CFX_FloatRect(const CFX_PointF& point);
 
   static CFX_FloatRect GetBBox(const CFX_PointF* pPoints, int nPoints);
 
@@ -255,12 +256,6 @@
 
   CFX_FloatRect GetCenterSquare() const;
 
-  void InitRect(const CFX_PointF& point) {
-    left = point.x;
-    right = point.x;
-    bottom = point.y;
-    top = point.y;
-  }
   void UpdateRect(const CFX_PointF& point);
 
   float Width() const { return right - left; }
diff --git a/core/fxge/cfx_pathdata.cpp b/core/fxge/cfx_pathdata.cpp
index 7012254..fa083c2 100644
--- a/core/fxge/cfx_pathdata.cpp
+++ b/core/fxge/cfx_pathdata.cpp
@@ -327,9 +327,8 @@
   if (m_Points.empty())
     return CFX_FloatRect();
 
-  CFX_FloatRect rect;
-  rect.InitRect(m_Points[0].m_Point);
-  for (size_t i = 1; i < m_Points.size(); i++)
+  CFX_FloatRect rect(m_Points[0].m_Point);
+  for (size_t i = 1; i < m_Points.size(); ++i)
     rect.UpdateRect(m_Points[i].m_Point);
   return rect;
 }