Replace CPDF_PathObject::set_matrix() with SetPathMatrix().

SetPathMatrix() will consistently call CalcBoundingBox internally. Then
convert set_matrix() callers.

Change-Id: I73daa6a22ba18bdf8b51f072bcd30e41eac2fe3a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/82615
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_pathobject.cpp b/core/fpdfapi/page/cpdf_pathobject.cpp
index 50c9c6e..7082734 100644
--- a/core/fpdfapi/page/cpdf_pathobject.cpp
+++ b/core/fpdfapi/page/cpdf_pathobject.cpp
@@ -52,3 +52,8 @@
     rect.Inflate(0.5f, 0.5f);
   SetRect(rect);
 }
+
+void CPDF_PathObject::SetPathMatrix(const CFX_Matrix& matrix) {
+  m_Matrix = matrix;
+  CalcBoundingBox();
+}
diff --git a/core/fpdfapi/page/cpdf_pathobject.h b/core/fpdfapi/page/cpdf_pathobject.h
index d337cdb..7ff326c 100644
--- a/core/fpdfapi/page/cpdf_pathobject.h
+++ b/core/fpdfapi/page/cpdf_pathobject.h
@@ -60,7 +60,7 @@
   const CPDF_Path& path() const { return m_Path; }
 
   const CFX_Matrix& matrix() const { return m_Matrix; }
-  void set_matrix(const CFX_Matrix& matrix) { m_Matrix = matrix; }
+  void SetPathMatrix(const CFX_Matrix& matrix);
 
  private:
   bool m_bStroke = false;
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 0e84cee..6e1e3b2 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -1493,9 +1493,8 @@
     pPathObj->set_stroke(bStroke);
     pPathObj->set_filltype(fill_type);
     pPathObj->path() = path;
-    pPathObj->set_matrix(matrix);
     SetGraphicStates(pPathObj.get(), true, false, true);
-    pPathObj->CalcBoundingBox();
+    pPathObj->SetPathMatrix(matrix);
     m_pObjectHolder->AppendPageObject(std::move(pPathObj));
   }
   if (path_clip_type != CFX_FillRenderOptions::FillType::kNoFill) {
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index afecf66..eb1700e 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1128,8 +1128,7 @@
     path.set_filltype(fill ? CFX_FillRenderOptions::FillType::kWinding
                            : CFX_FillRenderOptions::FillType::kNoFill);
     path.path().Append(*pPath, &matrix);
-    path.set_matrix(mtTextMatrix);
-    path.CalcBoundingBox();
+    path.SetPathMatrix(mtTextMatrix);
     ProcessPath(&path, mtObj2Device);
   }
 }
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index b060a1a..a74ac9f 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -655,7 +655,7 @@
       pPageObj->AsText()->SetTextMatrix(cmatrix);
       break;
     case CPDF_PageObject::PATH:
-      pPageObj->AsPath()->set_matrix(cmatrix);
+      pPageObj->AsPath()->SetPathMatrix(cmatrix);
       break;
     case CPDF_PageObject::IMAGE:
       pPageObj->AsImage()->SetImageMatrix(cmatrix);