summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-10 17:50:31 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-10 17:50:31 +0000
commit65b8db9a76b4b303d97836037b24b19e797fcd86 (patch)
treec9084c53facf81a072f75919c5e7dcd5725cf15f /core
parent7a8d3d6f8cf6989b43de24995171ab309a1c94fa (diff)
downloadpdfium-65b8db9a76b4b303d97836037b24b19e797fcd86.tar.xz
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>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfdoc/cpdf_iconfit.cpp39
-rw-r--r--core/fpdfdoc/cpdf_iconfit.h9
2 files changed, 29 insertions, 19 deletions
diff --git a/core/fpdfdoc/cpdf_iconfit.cpp b/core/fpdfdoc/cpdf_iconfit.cpp
index bef9eb4ebf..8b8fa4ed5b 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 @@ CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() {
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 e6aafb62e1..7c27d6f145 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 @@ class CPDF_IconFit {
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: