Remove non-const ref parameters in CPDF_IconFit.

Also make methods const.

Change-Id: I40a21d63fea30bbf37898cb57e1acc5ba8b3345f
Reviewed-on: https://pdfium-review.googlesource.com/c/43792
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfdoc/cpdf_iconfit.cpp b/core/fpdfdoc/cpdf_iconfit.cpp
index bef9eb4..8b8fa4e 100644
--- a/core/fpdfdoc/cpdf_iconfit.cpp
+++ b/core/fpdfdoc/cpdf_iconfit.cpp
@@ -10,13 +10,19 @@
 #include "core/fpdfapi/parser/cpdf_dictionary.h"
 #include "core/fxcrt/fx_string.h"
 
+namespace {
+
+constexpr float kDefaultPosition = 0.5f;
+
+}  // namespace
+
 CPDF_IconFit::CPDF_IconFit(const CPDF_Dictionary* pDict) : m_pDict(pDict) {}
 
 CPDF_IconFit::CPDF_IconFit(const CPDF_IconFit& that) = default;
 
-CPDF_IconFit::~CPDF_IconFit() {}
+CPDF_IconFit::~CPDF_IconFit() = default;
 
-CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() {
+CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() const {
   if (!m_pDict)
     return Always;
 
@@ -30,25 +36,28 @@
   return Always;
 }
 
-bool CPDF_IconFit::IsProportionalScale() {
-  return m_pDict ? m_pDict->GetStringFor("S", "P") != "A" : true;
+bool CPDF_IconFit::IsProportionalScale() const {
+  return !m_pDict || m_pDict->GetStringFor("S", "P") != "A";
 }
 
-void CPDF_IconFit::GetIconPosition(float& fLeft, float& fBottom) {
-  fLeft = fBottom = 0.5;
+CFX_PointF CPDF_IconFit::GetIconBottomLeftPosition() const {
+  float fLeft = kDefaultPosition;
+  float fBottom = kDefaultPosition;
   if (!m_pDict)
-    return;
+    return {fLeft, fBottom};
 
   const CPDF_Array* pA = m_pDict->GetArrayFor("A");
-  if (pA) {
-    uint32_t dwCount = pA->GetCount();
-    if (dwCount > 0)
-      fLeft = pA->GetNumberAt(0);
-    if (dwCount > 1)
-      fBottom = pA->GetNumberAt(1);
-  }
+  if (!pA)
+    return {fLeft, fBottom};
+
+  size_t dwCount = pA->GetCount();
+  if (dwCount > 0)
+    fLeft = pA->GetNumberAt(0);
+  if (dwCount > 1)
+    fBottom = pA->GetNumberAt(1);
+  return {fLeft, fBottom};
 }
 
-bool CPDF_IconFit::GetFittingBounds() {
+bool CPDF_IconFit::GetFittingBounds() const {
   return m_pDict && m_pDict->GetBooleanFor("FB", false);
 }
diff --git a/core/fpdfdoc/cpdf_iconfit.h b/core/fpdfdoc/cpdf_iconfit.h
index e6aafb6..7c27d6f 100644
--- a/core/fpdfdoc/cpdf_iconfit.h
+++ b/core/fpdfdoc/cpdf_iconfit.h
@@ -7,6 +7,7 @@
 #ifndef CORE_FPDFDOC_CPDF_ICONFIT_H_
 #define CORE_FPDFDOC_CPDF_ICONFIT_H_
 
+#include "core/fxcrt/fx_coordinates.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/unowned_ptr.h"
 
@@ -20,10 +21,10 @@
   CPDF_IconFit(const CPDF_IconFit& that);
   ~CPDF_IconFit();
 
-  ScaleMethod GetScaleMethod();
-  bool IsProportionalScale();
-  void GetIconPosition(float& fLeft, float& fBottom);
-  bool GetFittingBounds();
+  ScaleMethod GetScaleMethod() const;
+  bool IsProportionalScale() const;
+  CFX_PointF GetIconBottomLeftPosition() const;
+  bool GetFittingBounds() const;
   const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
 
  private:
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index 2777fd8..9c47e70 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -758,11 +758,8 @@
     return CJS_Result::Failure(JSMessage::kBadObjectError);
 
   CPDF_IconFit IconFit = pFormControl->GetIconFit();
-
-  float fLeft;
-  float fBottom;
-  IconFit.GetIconPosition(fLeft, fBottom);
-  return CJS_Result::Success(pRuntime->NewNumber(static_cast<int32_t>(fLeft)));
+  CFX_PointF pos = IconFit.GetIconBottomLeftPosition();
+  return CJS_Result::Success(pRuntime->NewNumber(static_cast<int32_t>(pos.x)));
 }
 
 CJS_Result CJS_Field::set_button_align_x(CJS_Runtime* pRuntime,
@@ -788,13 +785,8 @@
     return CJS_Result::Failure(JSMessage::kBadObjectError);
 
   CPDF_IconFit IconFit = pFormControl->GetIconFit();
-
-  float fLeft;
-  float fBottom;
-  IconFit.GetIconPosition(fLeft, fBottom);
-
-  return CJS_Result::Success(
-      pRuntime->NewNumber(static_cast<int32_t>(fBottom)));
+  CFX_PointF pos = IconFit.GetIconBottomLeftPosition();
+  return CJS_Result::Success(pRuntime->NewNumber(static_cast<int32_t>(pos.y)));
 }
 
 CJS_Result CJS_Field::set_button_align_y(CJS_Runtime* pRuntime,