From 1a44cb4be8b60b706990cf8113abea6937aa1653 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 20 Jul 2017 12:01:21 -0400 Subject: Convert CFX_ListItem to use CFX_FloatRect The CFX_ListItem never calls the Height() method so doesn't need to use CLST_Rect. This CL removes unused methods from CLST_Rect and CPVT_FloatRect. Change-Id: I82d4f07ec104345e9275ccd838e3c8eed1de7a50 Reviewed-on: https://pdfium-review.googlesource.com/8431 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- core/fpdfdoc/cpvt_floatrect.h | 2 -- fpdfsdk/fxedit/fxet_list.cpp | 6 ++--- fpdfsdk/fxedit/fxet_list.h | 57 +++---------------------------------------- 3 files changed, 6 insertions(+), 59 deletions(-) diff --git a/core/fpdfdoc/cpvt_floatrect.h b/core/fpdfdoc/cpvt_floatrect.h index a8b32dc7e5..c5eb2202bb 100644 --- a/core/fpdfdoc/cpvt_floatrect.h +++ b/core/fpdfdoc/cpvt_floatrect.h @@ -30,8 +30,6 @@ class CPVT_FloatRect : public CFX_FloatRect { bottom = rect.bottom; } - void Default() { left = top = right = bottom = 0.0f; } - float Height() const { if (top > bottom) return top - bottom; diff --git a/fpdfsdk/fxedit/fxet_list.cpp b/fpdfsdk/fxedit/fxet_list.cpp index 0b1a2ac532..80f4fcc63e 100644 --- a/fpdfsdk/fxedit/fxet_list.cpp +++ b/fpdfsdk/fxedit/fxet_list.cpp @@ -38,11 +38,11 @@ CFX_Edit_Iterator* CFX_ListItem::GetIterator() const { return m_pEdit->GetIterator(); } -void CFX_ListItem::SetRect(const CLST_Rect& rect) { +void CFX_ListItem::SetRect(const CFX_FloatRect& rect) { m_rcListItem = rect; } -CLST_Rect CFX_ListItem::GetRect() const { +CFX_FloatRect CFX_ListItem::GetRect() const { return m_rcListItem; } @@ -559,7 +559,7 @@ int32_t CFX_ListCtrl::GetItemIndex(const CFX_PointF& point) const { for (const auto& pListItem : m_ListItems) { if (!pListItem) continue; - CLST_Rect rcListItem = pListItem->GetRect(); + CFX_FloatRect rcListItem = pListItem->GetRect(); if (IsFloatBigger(pt.y, rcListItem.top)) bFirst = false; if (IsFloatSmaller(pt.y, rcListItem.bottom)) diff --git a/fpdfsdk/fxedit/fxet_list.h b/fpdfsdk/fxedit/fxet_list.h index b4b0a56c1e..b34cc54830 100644 --- a/fpdfsdk/fxedit/fxet_list.h +++ b/fpdfsdk/fxedit/fxet_list.h @@ -42,62 +42,11 @@ class CLST_Rect : public CFX_FloatRect { ~CLST_Rect() {} - void Default() { left = top = right = bottom = 0.0f; } - - const CLST_Rect operator=(const CFX_FloatRect& rect) { - left = rect.left; - top = rect.top; - right = rect.right; - bottom = rect.bottom; - - return *this; - } - - bool operator==(const CLST_Rect& rect) const { - return memcmp(this, &rect, sizeof(CLST_Rect)) == 0; - } - - bool operator!=(const CLST_Rect& rect) const { return !(*this == rect); } - - float Width() const { return right - left; } - float Height() const { if (top > bottom) return top - bottom; return bottom - top; } - - CFX_PointF LeftTop() const { return CFX_PointF(left, top); } - - CFX_PointF RightBottom() const { return CFX_PointF(right, bottom); } - - const CLST_Rect operator+=(const CFX_PointF& point) { - left += point.x; - right += point.x; - top += point.y; - bottom += point.y; - - return *this; - } - - const CLST_Rect operator-=(const CFX_PointF& point) { - left -= point.x; - right -= point.x; - top -= point.y; - bottom -= point.y; - - return *this; - } - - CLST_Rect operator+(const CFX_PointF& point) const { - return CLST_Rect(left + point.x, top + point.y, right + point.x, - bottom + point.y); - } - - CLST_Rect operator-(const CFX_PointF& point) const { - return CLST_Rect(left - point.x, top - point.y, right - point.x, - bottom - point.y); - } }; class CFX_ListItem final { @@ -108,13 +57,13 @@ class CFX_ListItem final { void SetFontMap(IPVT_FontMap* pFontMap); CFX_Edit* GetEdit() const; - void SetRect(const CLST_Rect& rect); + void SetRect(const CFX_FloatRect& rect); void SetSelect(bool bSelected); void SetText(const CFX_WideString& text); void SetFontSize(float fFontSize); CFX_WideString GetText() const; - CLST_Rect GetRect() const; + CFX_FloatRect GetRect() const; bool IsSelected() const; float GetItemHeight() const; uint16_t GetFirstChar() const; @@ -124,7 +73,7 @@ class CFX_ListItem final { std::unique_ptr m_pEdit; bool m_bSelected; - CLST_Rect m_rcListItem; + CFX_FloatRect m_rcListItem; }; class CFX_ListContainer { -- cgit v1.2.3