From 7a8d3d6f8cf6989b43de24995171ab309a1c94fa Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 10 Oct 2018 17:28:53 +0000 Subject: Simplify some object rect calculations. Change-Id: I46ae4fb4e0f8d51130f5e5beae286dae5466b629 Reviewed-on: https://pdfium-review.googlesource.com/c/43574 Reviewed-by: Tom Sepez Commit-Queue: Lei Zhang --- core/fpdfapi/page/cpdf_pathobject.cpp | 8 ++------ core/fpdfapi/page/cpdf_textobject.cpp | 5 +---- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'core/fpdfapi') diff --git a/core/fpdfapi/page/cpdf_pathobject.cpp b/core/fpdfapi/page/cpdf_pathobject.cpp index 84cf45d7e0..4fb8f10a6b 100644 --- a/core/fpdfapi/page/cpdf_pathobject.cpp +++ b/core/fpdfapi/page/cpdf_pathobject.cpp @@ -47,11 +47,7 @@ void CPDF_PathObject::CalcBoundingBox() { } rect = m_Matrix.TransformRect(rect); - if (width == 0 && m_bStroke) { - rect.left += -0.5f; - rect.right += 0.5f; - rect.bottom += -0.5f; - rect.top += 0.5f; - } + if (width == 0 && m_bStroke) + rect.Inflate(0.5f, 0.5f); SetRect(rect); } diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp index b158376293..2b866baa25 100644 --- a/core/fpdfapi/page/cpdf_textobject.cpp +++ b/core/fpdfapi/page/cpdf_textobject.cpp @@ -293,10 +293,7 @@ void CPDF_TextObject::SetPosition(float x, float y) { float dy = y - m_Pos.y; m_Pos.x = x; m_Pos.y = y; - m_Rect.left += dx; - m_Rect.right += dx; - m_Rect.top += dy; - m_Rect.bottom += dy; + m_Rect.Translate(dx, dy); } void CPDF_TextObject::RecalcPositionData() { -- cgit v1.2.3