Make CPDF_Font::GetFontBBox() return the bounding box.
Instead of using an out parameter. Fix nits in the only caller as well.
Change-Id: I04eb92705b2fbda001191c36da972eee499acbc7
Reviewed-on: https://pdfium-review.googlesource.com/39490
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h
index d79b13f..f246293 100644
--- a/core/fpdfapi/font/cpdf_font.h
+++ b/core/fpdfapi/font/cpdf_font.h
@@ -72,7 +72,7 @@
FXFT_Face GetFace() const { return m_Font.GetFace(); }
void AppendChar(ByteString* str, uint32_t charcode) const;
- void GetFontBBox(FX_RECT& rect) const { rect = m_FontBBox; }
+ const FX_RECT& GetFontBBox() const { return m_FontBBox; }
int GetTypeAscent() const { return m_Ascent; }
int GetTypeDescent() const { return m_Descent; }
uint32_t GetStringWidth(const ByteStringView& pString);
diff --git a/fpdfsdk/pwl/cpwl_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp
index 41f2517..5e28a4a 100644
--- a/fpdfsdk/pwl/cpwl_edit.cpp
+++ b/fpdfsdk/pwl/cpwl_edit.cpp
@@ -369,14 +369,13 @@
return m_pEdit->IsTextFull();
}
-float CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont,
+float CPWL_Edit::GetCharArrayAutoFontSize(const CPDF_Font* pFont,
const CFX_FloatRect& rcPlate,
int32_t nCharArray) {
if (!pFont || pFont->IsStandardFont())
return 0.0f;
- FX_RECT rcBBox;
- pFont->GetFontBBox(rcBBox);
+ const FX_RECT& rcBBox = pFont->GetFontBBox();
CFX_FloatRect rcCell = rcPlate;
float xdiv = rcCell.Width() / nCharArray * 1000.0f / rcBBox.Width();
diff --git a/fpdfsdk/pwl/cpwl_edit.h b/fpdfsdk/pwl/cpwl_edit.h
index 3f9cd43..ce1d682 100644
--- a/fpdfsdk/pwl/cpwl_edit.h
+++ b/fpdfsdk/pwl/cpwl_edit.h
@@ -84,7 +84,7 @@
bool IsTextFull() const;
- static float GetCharArrayAutoFontSize(CPDF_Font* pFont,
+ static float GetCharArrayAutoFontSize(const CPDF_Font* pFont,
const CFX_FloatRect& rcPlate,
int32_t nCharArray);
@@ -114,7 +114,6 @@
bool IsVScrollBarVisible() const;
void SetParamByFlag();
- float GetCharArrayAutoFontSize(int32_t nCharArray);
CFX_PointF GetWordRightBottomPoint(const CPVT_WordPlace& wpWord);
CPVT_WordRange CombineWordRange(const CPVT_WordRange& wr1,