summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-06 00:32:16 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-06 00:32:16 +0000
commitd9826495fe0e279c6e2d587a656c7452cc2dc71f (patch)
tree0256f8903da70445c5f8e21b62c01d2d70385201
parenta0032a2a2c53794bbf0ccb412a5c70ce66f052fb (diff)
downloadpdfium-d9826495fe0e279c6e2d587a656c7452cc2dc71f.tar.xz
Encapsulate CPDF_PageObject's rect member.
At the same time, change it from 4 floats to a CFX_FloatRect. Change-Id: I00ded941723d6a264b7a17c73fd337e66b449308 Reviewed-on: https://pdfium-review.googlesource.com/c/43570 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r--core/fpdfapi/page/cpdf_contentparser.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_formobject.cpp7
-rw-r--r--core/fpdfapi/page/cpdf_imageobject.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_pageobject.cpp13
-rw-r--r--core/fpdfapi/page/cpdf_pageobject.h17
-rw-r--r--core/fpdfapi/page/cpdf_pageobjectholder.cpp9
-rw-r--r--core/fpdfapi/page/cpdf_path.h1
-rw-r--r--core/fpdfapi/page/cpdf_pathobject.cpp5
-rw-r--r--core/fpdfapi/page/cpdf_shadingobject.cpp12
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp5
-rw-r--r--core/fpdfapi/page/cpdf_textobject.cpp20
-rw-r--r--core/fpdfapi/render/cpdf_progressiverenderer.cpp8
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp17
-rw-r--r--core/fpdftext/cpdf_textpage.cpp32
-rw-r--r--core/fxcrt/fx_coordinates.h4
-rw-r--r--fpdfsdk/fpdf_editimg.cpp4
-rw-r--r--fpdfsdk/fpdf_editpage.cpp2
-rw-r--r--fpdfsdk/fpdf_flatten.cpp6
18 files changed, 73 insertions, 97 deletions
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index 2cbac8f447..3427fe5230 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -234,9 +234,7 @@ CPDF_ContentParser::Stage CPDF_ContentParser::CheckClip() {
CFX_PointF point0 = ClipPath.GetPoint(0);
CFX_PointF point2 = ClipPath.GetPoint(2);
CFX_FloatRect old_rect(point0.x, point0.y, point2.x, point2.y);
- CFX_FloatRect obj_rect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right,
- pObj->m_Top);
- if (old_rect.Contains(obj_rect))
+ if (old_rect.Contains(pObj->GetRect()))
pObj->m_ClipPath.SetNull();
}
return Stage::kComplete;
diff --git a/core/fpdfapi/page/cpdf_formobject.cpp b/core/fpdfapi/page/cpdf_formobject.cpp
index 22ac0d3823..a7c2643b66 100644
--- a/core/fpdfapi/page/cpdf_formobject.cpp
+++ b/core/fpdfapi/page/cpdf_formobject.cpp
@@ -41,10 +41,5 @@ CPDF_PageObject::Type CPDF_FormObject::GetType() const {
}
void CPDF_FormObject::CalcBoundingBox() {
- CFX_FloatRect form_rect =
- m_FormMatrix.TransformRect(m_pForm->CalcBoundingBox());
- m_Left = form_rect.left;
- m_Bottom = form_rect.bottom;
- m_Right = form_rect.right;
- m_Top = form_rect.top;
+ SetRect(m_FormMatrix.TransformRect(m_pForm->CalcBoundingBox()));
}
diff --git a/core/fpdfapi/page/cpdf_imageobject.cpp b/core/fpdfapi/page/cpdf_imageobject.cpp
index 516a6e8cad..2b3d7b0de3 100644
--- a/core/fpdfapi/page/cpdf_imageobject.cpp
+++ b/core/fpdfapi/page/cpdf_imageobject.cpp
@@ -44,8 +44,8 @@ const CPDF_ImageObject* CPDF_ImageObject::AsImage() const {
}
void CPDF_ImageObject::CalcBoundingBox() {
- std::tie(m_Left, m_Right, m_Top, m_Bottom) =
- m_Matrix.TransformRect(0.f, 1.f, 1.f, 0.f);
+ static constexpr CFX_FloatRect kRect(0.0f, 0.0f, 1.0f, 1.0f);
+ SetRect(m_Matrix.TransformRect(kRect));
}
void CPDF_ImageObject::SetImage(const RetainPtr<CPDF_Image>& pImage) {
diff --git a/core/fpdfapi/page/cpdf_pageobject.cpp b/core/fpdfapi/page/cpdf_pageobject.cpp
index 0c3a850936..c61a7c333d 100644
--- a/core/fpdfapi/page/cpdf_pageobject.cpp
+++ b/core/fpdfapi/page/cpdf_pageobject.cpp
@@ -9,11 +9,11 @@
constexpr int32_t CPDF_PageObject::kNoContentStream;
CPDF_PageObject::CPDF_PageObject(int32_t content_stream)
- : m_bDirty(false), m_ContentStream(content_stream) {}
+ : m_ContentStream(content_stream) {}
CPDF_PageObject::CPDF_PageObject() : CPDF_PageObject(kNoContentStream) {}
-CPDF_PageObject::~CPDF_PageObject() {}
+CPDF_PageObject::~CPDF_PageObject() = default;
bool CPDF_PageObject::IsText() const {
return false;
@@ -77,21 +77,18 @@ const CPDF_FormObject* CPDF_PageObject::AsForm() const {
void CPDF_PageObject::CopyData(const CPDF_PageObject* pSrc) {
CopyStates(*pSrc);
- m_Left = pSrc->m_Left;
- m_Right = pSrc->m_Right;
- m_Top = pSrc->m_Top;
- m_Bottom = pSrc->m_Bottom;
+ m_Rect = pSrc->m_Rect;
m_bDirty = true;
}
-void CPDF_PageObject::TransformClipPath(CFX_Matrix& matrix) {
+void CPDF_PageObject::TransformClipPath(const CFX_Matrix& matrix) {
if (!m_ClipPath.HasRef())
return;
m_ClipPath.Transform(matrix);
SetDirty(true);
}
-void CPDF_PageObject::TransformGeneralState(CFX_Matrix& matrix) {
+void CPDF_PageObject::TransformGeneralState(const CFX_Matrix& matrix) {
if (!m_GeneralState.HasRef())
return;
m_GeneralState.GetMutableMatrix()->Concat(matrix);
diff --git a/core/fpdfapi/page/cpdf_pageobject.h b/core/fpdfapi/page/cpdf_pageobject.h
index 1dfe20b6f9..013ef0d03b 100644
--- a/core/fpdfapi/page/cpdf_pageobject.h
+++ b/core/fpdfapi/page/cpdf_pageobject.h
@@ -54,12 +54,11 @@ class CPDF_PageObject : public CPDF_GraphicStates {
void SetDirty(bool value) { m_bDirty = value; }
bool IsDirty() const { return m_bDirty; }
- void TransformClipPath(CFX_Matrix& matrix);
- void TransformGeneralState(CFX_Matrix& matrix);
+ void TransformClipPath(const CFX_Matrix& matrix);
+ void TransformGeneralState(const CFX_Matrix& matrix);
- CFX_FloatRect GetRect() const {
- return CFX_FloatRect(m_Left, m_Bottom, m_Right, m_Top);
- }
+ void SetRect(const CFX_FloatRect& rect) { m_Rect = rect; }
+ const CFX_FloatRect& GetRect() const { return m_Rect; }
FX_RECT GetBBox() const;
FX_RECT GetTransformedBBox(const CFX_Matrix& matrix) const;
@@ -75,20 +74,18 @@ class CPDF_PageObject : public CPDF_GraphicStates {
m_ContentStream = new_content_stream;
}
- float m_Left;
- float m_Right;
- float m_Top;
- float m_Bottom;
CPDF_ContentMark m_ContentMark;
protected:
void CopyData(const CPDF_PageObject* pSrcObject);
+ CFX_FloatRect m_Rect;
+
private:
CPDF_PageObject(const CPDF_PageObject& src) = delete;
void operator=(const CPDF_PageObject& src) = delete;
- bool m_bDirty;
+ bool m_bDirty = false;
int32_t m_ContentStream;
};
diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.cpp b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
index 67f68c7c42..c6f310f77b 100644
--- a/core/fpdfapi/page/cpdf_pageobjectholder.cpp
+++ b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
@@ -85,10 +85,11 @@ CFX_FloatRect CPDF_PageObjectHolder::CalcBoundingBox() const {
float bottom = 1000000.0f;
float top = -1000000.0f;
for (const auto& pObj : m_PageObjectList) {
- left = std::min(left, pObj->m_Left);
- right = std::max(right, pObj->m_Right);
- bottom = std::min(bottom, pObj->m_Bottom);
- top = std::max(top, pObj->m_Top);
+ const auto& rect = pObj->GetRect();
+ left = std::min(left, rect.left);
+ right = std::max(right, rect.right);
+ bottom = std::min(bottom, rect.bottom);
+ top = std::max(top, rect.top);
}
return CFX_FloatRect(left, bottom, right, top);
}
diff --git a/core/fpdfapi/page/cpdf_path.h b/core/fpdfapi/page/cpdf_path.h
index 613d715b03..4a984a540c 100644
--- a/core/fpdfapi/page/cpdf_path.h
+++ b/core/fpdfapi/page/cpdf_path.h
@@ -36,6 +36,7 @@ class CPDF_Path {
void Append(const CPDF_Path& other, const CFX_Matrix* pMatrix);
void Append(const CFX_PathData* pData, const CFX_Matrix* pMatrix);
+ // TODO(thestig): Switch to CFX_FloatRect.
void AppendRect(float left, float bottom, float right, float top);
void AppendPoint(const CFX_PointF& point, FXPT_TYPE type, bool close);
diff --git a/core/fpdfapi/page/cpdf_pathobject.cpp b/core/fpdfapi/page/cpdf_pathobject.cpp
index 0882dc17f0..84cf45d7e0 100644
--- a/core/fpdfapi/page/cpdf_pathobject.cpp
+++ b/core/fpdfapi/page/cpdf_pathobject.cpp
@@ -53,8 +53,5 @@ void CPDF_PathObject::CalcBoundingBox() {
rect.bottom += -0.5f;
rect.top += 0.5f;
}
- m_Left = rect.left;
- m_Right = rect.right;
- m_Top = rect.top;
- m_Bottom = rect.bottom;
+ SetRect(rect);
}
diff --git a/core/fpdfapi/page/cpdf_shadingobject.cpp b/core/fpdfapi/page/cpdf_shadingobject.cpp
index 725e2e4591..bdaceaa7e8 100644
--- a/core/fpdfapi/page/cpdf_shadingobject.cpp
+++ b/core/fpdfapi/page/cpdf_shadingobject.cpp
@@ -27,10 +27,10 @@ void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) {
m_Matrix.Concat(matrix);
if (m_ClipPath.HasRef()) {
CalcBoundingBox();
- } else {
- std::tie(m_Left, m_Right, m_Top, m_Bottom) =
- matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom);
+ return;
}
+
+ SetRect(matrix.TransformRect(GetRect()));
}
bool CPDF_ShadingObject::IsShading() const {
@@ -48,9 +48,5 @@ const CPDF_ShadingObject* CPDF_ShadingObject::AsShading() const {
void CPDF_ShadingObject::CalcBoundingBox() {
if (!m_ClipPath.HasRef())
return;
- CFX_FloatRect rect = m_ClipPath.GetClipBox();
- m_Left = rect.left;
- m_Bottom = rect.bottom;
- m_Right = rect.right;
- m_Top = rect.top;
+ SetRect(m_ClipPath.GetClipBox());
}
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 0760e150f3..b381705123 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -1106,10 +1106,7 @@ void CPDF_StreamContentParser::Handle_ShadeFill() {
pObj->m_ClipPath.HasRef() ? pObj->m_ClipPath.GetClipBox() : m_BBox;
if (pShading->IsMeshShading())
bbox.Intersect(GetShadingBBox(pShading, pObj->matrix()));
- pObj->m_Left = bbox.left;
- pObj->m_Right = bbox.right;
- pObj->m_Top = bbox.top;
- pObj->m_Bottom = bbox.bottom;
+ pObj->SetRect(bbox);
m_pObjectHolder->AppendPageObject(std::move(pObj));
}
diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp
index 84428fee81..b158376293 100644
--- a/core/fpdfapi/page/cpdf_textobject.cpp
+++ b/core/fpdfapi/page/cpdf_textobject.cpp
@@ -273,17 +273,17 @@ CFX_PointF CPDF_TextObject::CalcPositionData(float horz_scale) {
min_y = min_y * fontsize / 1000;
max_y = max_y * fontsize / 1000;
}
- std::tie(m_Left, m_Right, m_Top, m_Bottom) =
- GetTextMatrix().TransformRect(min_x, max_x, max_y, min_y);
+ SetRect(
+ GetTextMatrix().TransformRect(CFX_FloatRect(min_x, min_y, max_x, max_y)));
if (!TextRenderingModeIsStrokeMode(m_TextState.GetTextMode()))
return ret;
float half_width = m_GraphState.GetLineWidth() / 2;
- m_Left -= half_width;
- m_Right += half_width;
- m_Top += half_width;
- m_Bottom -= half_width;
+ m_Rect.left -= half_width;
+ m_Rect.right += half_width;
+ m_Rect.top += half_width;
+ m_Rect.bottom -= half_width;
return ret;
}
@@ -293,10 +293,10 @@ void CPDF_TextObject::SetPosition(float x, float y) {
float dy = y - m_Pos.y;
m_Pos.x = x;
m_Pos.y = y;
- m_Left += dx;
- m_Right += dx;
- m_Top += dy;
- m_Bottom += dy;
+ m_Rect.left += dx;
+ m_Rect.right += dx;
+ m_Rect.top += dy;
+ m_Rect.bottom += dy;
}
void CPDF_TextObject::RecalcPositionData() {
diff --git a/core/fpdfapi/render/cpdf_progressiverenderer.cpp b/core/fpdfapi/render/cpdf_progressiverenderer.cpp
index 1a38740a42..74b26137d1 100644
--- a/core/fpdfapi/render/cpdf_progressiverenderer.cpp
+++ b/core/fpdfapi/render/cpdf_progressiverenderer.cpp
@@ -78,10 +78,10 @@ void CPDF_ProgressiveRenderer::Continue(PauseIndicatorIface* pPause) {
bool is_mask = false;
while (iter != iterEnd) {
CPDF_PageObject* pCurObj = iter->get();
- if (pCurObj && pCurObj->m_Left <= m_ClipRect.right &&
- pCurObj->m_Right >= m_ClipRect.left &&
- pCurObj->m_Bottom <= m_ClipRect.top &&
- pCurObj->m_Top >= m_ClipRect.bottom) {
+ if (pCurObj && pCurObj->GetRect().left <= m_ClipRect.right &&
+ pCurObj->GetRect().right >= m_ClipRect.left &&
+ pCurObj->GetRect().bottom <= m_ClipRect.top &&
+ pCurObj->GetRect().top >= m_ClipRect.bottom) {
if (m_pOptions->HasFlag(RENDER_BREAKFORMASKS) && pCurObj->IsImage() &&
pCurObj->AsImage()->GetImage()->IsMask()) {
if (m_pDevice->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) {
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 19fea76d70..f77b6c654f 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1040,10 +1040,10 @@ void CPDF_RenderStatus::RenderObjectList(
if (!pCurObj)
continue;
- if (pCurObj->m_Left > clip_rect.right ||
- pCurObj->m_Right < clip_rect.left ||
- pCurObj->m_Bottom > clip_rect.top ||
- pCurObj->m_Top < clip_rect.bottom) {
+ if (pCurObj->GetRect().left > clip_rect.right ||
+ pCurObj->GetRect().right < clip_rect.left ||
+ pCurObj->GetRect().bottom > clip_rect.top ||
+ pCurObj->GetRect().top < clip_rect.bottom) {
continue;
}
RenderSingleObject(pCurObj.get(), mtObj2Device);
@@ -1972,12 +1972,9 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj,
path.m_ClipPath.AppendTexts(&pCopy);
path.m_ColorState = textobj->m_ColorState;
path.m_GeneralState = textobj->m_GeneralState;
- path.m_Path.AppendRect(textobj->m_Left, textobj->m_Bottom, textobj->m_Right,
- textobj->m_Top);
- path.m_Left = textobj->m_Left;
- path.m_Bottom = textobj->m_Bottom;
- path.m_Right = textobj->m_Right;
- path.m_Top = textobj->m_Top;
+ path.m_Path.AppendRect(textobj->GetRect().left, textobj->GetRect().bottom,
+ textobj->GetRect().right, textobj->GetRect().top);
+ path.SetRect(textobj->GetRect());
AutoRestorer<UnownedPtr<const CPDF_PageObject>> restorer2(&m_pCurObj);
RenderSingleObject(&path, mtObj2Device);
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 411ba398ae..77eae4de75 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -551,11 +551,13 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::FindTextlineFlowOrientation()
if (!pPageObj->IsText())
continue;
- int32_t minH = std::max(static_cast<int32_t>(pPageObj->m_Left), 0);
+ int32_t minH = std::max(static_cast<int32_t>(pPageObj->GetRect().left), 0);
int32_t maxH =
- std::min(static_cast<int32_t>(pPageObj->m_Right), nPageWidth);
- int32_t minV = std::max(static_cast<int32_t>(pPageObj->m_Bottom), 0);
- int32_t maxV = std::min(static_cast<int32_t>(pPageObj->m_Top), nPageHeight);
+ std::min(static_cast<int32_t>(pPageObj->GetRect().right), nPageWidth);
+ int32_t minV =
+ std::max(static_cast<int32_t>(pPageObj->GetRect().bottom), 0);
+ int32_t maxV =
+ std::min(static_cast<int32_t>(pPageObj->GetRect().top), nPageHeight);
if (minH >= maxH || minV >= maxV)
continue;
@@ -570,7 +572,7 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::FindTextlineFlowOrientation()
nEndV = std::max(nEndV, maxV);
if (fLineHeight <= 0.0f)
- fLineHeight = pPageObj->m_Top - pPageObj->m_Bottom;
+ fLineHeight = pPageObj->GetRect().Height();
}
const int32_t nDoubleLineHeight = 2 * fLineHeight;
if ((nEndV - nStartV) < nDoubleLineHeight)
@@ -751,7 +753,7 @@ void CPDF_TextPage::ProcessTextObject(
const CFX_Matrix& formMatrix,
const CPDF_PageObjectList* pObjList,
CPDF_PageObjectList::const_iterator ObjPos) {
- if (fabs(pTextObj->m_Right - pTextObj->m_Left) < kSizeEpsilon)
+ if (fabs(pTextObj->GetRect().Width()) < kSizeEpsilon)
return;
size_t count = m_LineObj.size();
@@ -943,7 +945,7 @@ void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend,
void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
CPDF_TextObject* pTextObj = Obj.m_pTextObj.Get();
- if (fabs(pTextObj->m_Right - pTextObj->m_Left) < kSizeEpsilon)
+ if (fabs(pTextObj->GetRect().Width()) < kSizeEpsilon)
return;
CFX_Matrix formMatrix = Obj.m_formMatrix;
CPDF_Font* pFont = pTextObj->GetFont();
@@ -1244,8 +1246,8 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject(
CPDF_TextObjectItem item;
pObj->GetItemInfo(0, &item);
- CFX_FloatRect this_rect = pObj->GetRect();
- CFX_FloatRect prev_rect = m_pPreTextObj->GetRect();
+ const CFX_FloatRect& this_rect = pObj->GetRect();
+ const CFX_FloatRect& prev_rect = m_pPreTextObj->GetRect();
WideString wstrItem = pObj->GetFont()->UnicodeFromCharCode(item.m_CharCode);
if (wstrItem.IsEmpty())
@@ -1299,14 +1301,16 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject(
m_DisplayMatrix.a > 0.9 && m_DisplayMatrix.b < 0.1 &&
m_DisplayMatrix.c < 0.1 && m_DisplayMatrix.d < -0.9 && m.b < 0.1 &&
m.c < 0.1) {
- CFX_FloatRect re(0, m_pPreTextObj->m_Bottom, 1000,
- m_pPreTextObj->m_Top);
+ CFX_FloatRect re(0, m_pPreTextObj->GetRect().bottom, 1000,
+ m_pPreTextObj->GetRect().top);
if (re.Contains(pObj->GetPos())) {
bNewline = false;
} else {
- if (CFX_FloatRect(0, pObj->m_Bottom, 1000, pObj->m_Top)
- .Contains(m_pPreTextObj->GetPos()))
+ if (CFX_FloatRect(0, pObj->GetRect().bottom, 1000,
+ pObj->GetRect().top)
+ .Contains(m_pPreTextObj->GetPos())) {
bNewline = false;
+ }
}
}
}
@@ -1356,7 +1360,7 @@ bool CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1,
return false;
CFX_FloatRect rcPreObj = pTextObj2->GetRect();
- CFX_FloatRect rcCurObj = pTextObj1->GetRect();
+ const CFX_FloatRect& rcCurObj = pTextObj1->GetRect();
if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty()) {
float dbXdif = fabs(rcPreObj.left - rcCurObj.left);
size_t nCount = m_CharList.size();
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index 05e60c47b5..9e41efc417 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -225,8 +225,8 @@ struct FX_RECT {
// LTRB rectangles (y-axis runs upwards).
class CFX_FloatRect {
public:
- CFX_FloatRect() : CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f) {}
- CFX_FloatRect(float l, float b, float r, float t)
+ constexpr CFX_FloatRect() : CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f) {}
+ constexpr CFX_FloatRect(float l, float b, float r, float t)
: left(l), bottom(b), right(r), top(t) {}
explicit CFX_FloatRect(const float* pArray)
diff --git a/fpdfsdk/fpdf_editimg.cpp b/fpdfsdk/fpdf_editimg.cpp
index a062990afe..04d7af0f41 100644
--- a/fpdfsdk/fpdf_editimg.cpp
+++ b/fpdfsdk/fpdf_editimg.cpp
@@ -298,8 +298,8 @@ FPDFImageObj_GetImageMetadata(FPDF_PAGEOBJECT image_object,
metadata->width = nPixelWidth;
metadata->height = nPixelHeight;
- const float nWidth = pObj->m_Right - pObj->m_Left;
- const float nHeight = pObj->m_Top - pObj->m_Bottom;
+ const float nWidth = pObj->GetRect().Width();
+ const float nHeight = pObj->GetRect().Height();
constexpr int nPointsPerInch = 72;
if (nWidth != 0 && nHeight != 0) {
metadata->horizontal_dpi = nPixelWidth / nWidth * nPointsPerInch;
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index d9a9bef26a..193dd76091 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -729,7 +729,7 @@ FPDFPageObj_GetBounds(FPDF_PAGEOBJECT pageObject,
return false;
CPDF_PageObject* pPageObj = CPDFPageObjectFromFPDFPageObject(pageObject);
- CFX_FloatRect bbox = pPageObj->GetRect();
+ const CFX_FloatRect& bbox = pPageObj->GetRect();
*left = bbox.left;
*bottom = bbox.bottom;
*right = bbox.right;
diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp
index a27d79f09e..6f9adf136d 100644
--- a/fpdfsdk/fpdf_flatten.cpp
+++ b/fpdfsdk/fpdf_flatten.cpp
@@ -52,11 +52,7 @@ void GetContentsRect(CPDF_Document* pDoc,
pPDFPage->ParseContent();
for (const auto& pPageObject : *pPDFPage->GetPageObjectList()) {
- CFX_FloatRect rc;
- rc.left = pPageObject->m_Left;
- rc.right = pPageObject->m_Right;
- rc.bottom = pPageObject->m_Bottom;
- rc.top = pPageObject->m_Top;
+ const CFX_FloatRect& rc = pPageObject->GetRect();
if (IsValidRect(rc, pDict->GetRectFor(pdfium::page_object::kMediaBox)))
pRectArray->push_back(rc);
}