From adf922f278d23e7f955b89f48cc64b5de7925977 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Wed, 12 Jul 2017 21:56:27 -0400 Subject: Remove CPWL_Utils::{In,De}flateRect This CL removes the custom InflateRect and Deflate rect code in CPWL_Utils in favour of calling the CFX_FloatRect version. This required inlining some extra code at each callsite to check the rect size and normalize. Change-Id: I7f60e5de03fc1db0c1d8e51eaa1d0e0700ebf157 Reviewed-on: https://pdfium-review.googlesource.com/7710 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- fpdfsdk/pdfwindow/cpwl_wnd.cpp | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'fpdfsdk/pdfwindow/cpwl_wnd.cpp') diff --git a/fpdfsdk/pdfwindow/cpwl_wnd.cpp b/fpdfsdk/pdfwindow/cpwl_wnd.cpp index 6e2e75c5a1..552c901f06 100644 --- a/fpdfsdk/pdfwindow/cpwl_wnd.cpp +++ b/fpdfsdk/pdfwindow/cpwl_wnd.cpp @@ -155,7 +155,11 @@ void CPWL_Wnd::Create(const PWL_CREATEPARAM& cp) { m_sPrivateParam.rcRectWnd.Normalize(); m_rcWindow = m_sPrivateParam.rcRectWnd; - m_rcClip = CPWL_Utils::InflateRect(m_rcWindow, 1.0f); + m_rcClip = m_rcWindow; + if (!m_rcClip.IsEmpty()) { + m_rcClip.Inflate(1.0f, 1.0f); + m_rcClip.Normalize(); + } CreateMsgControl(); if (m_sPrivateParam.pParentWnd) @@ -288,8 +292,13 @@ void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice, return; if (HasFlag(PWS_BACKGROUND)) { - CFX_FloatRect rcClient = CPWL_Utils::DeflateRect( - rectWnd, (float)(GetBorderWidth() + GetInnerBorderWidth())); + CFX_FloatRect rcClient = rectWnd; + if (!rcClient.IsEmpty()) { + float width = + static_cast(GetBorderWidth() + GetInnerBorderWidth()); + rcClient.Deflate(width, width); + rcClient.Normalize(); + } CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient, GetBackgroundColor(), GetTransparency()); } @@ -459,8 +468,13 @@ CFX_FloatRect CPWL_Wnd::GetWindowRect() const { CFX_FloatRect CPWL_Wnd::GetClientRect() const { CFX_FloatRect rcWindow = GetWindowRect(); - CFX_FloatRect rcClient = CPWL_Utils::DeflateRect( - rcWindow, (float)(GetBorderWidth() + GetInnerBorderWidth())); + CFX_FloatRect rcClient = rcWindow; + if (!rcClient.IsEmpty()) { + float width = static_cast(GetBorderWidth() + GetInnerBorderWidth()); + rcClient.Deflate(width, width); + rcClient.Normalize(); + } + if (CPWL_ScrollBar* pVSB = GetVScrollBar()) rcClient.right -= pVSB->GetScrollBarWidth(); @@ -633,8 +647,12 @@ void CPWL_Wnd::RePosChildWnd() { if (!pVSB) return; - CFX_FloatRect rcContent = CPWL_Utils::DeflateRect( - GetWindowRect(), (float)(GetBorderWidth() + GetInnerBorderWidth())); + CFX_FloatRect rcContent = GetWindowRect(); + if (!rcContent.IsEmpty()) { + float width = static_cast(GetBorderWidth() + GetInnerBorderWidth()); + rcContent.Deflate(width, width); + rcContent.Normalize(); + } CFX_FloatRect rcVScroll = CFX_FloatRect(rcContent.right - PWL_SCROLLBAR_WIDTH, rcContent.bottom, rcContent.right - 1.0f, rcContent.top); @@ -687,7 +705,12 @@ bool CPWL_Wnd::IsFocused() const { } CFX_FloatRect CPWL_Wnd::GetFocusRect() const { - return CPWL_Utils::InflateRect(GetWindowRect(), 1); + CFX_FloatRect rect = GetWindowRect(); + if (!rect.IsEmpty()) { + rect.Inflate(1.0f, 1.0f); + rect.Normalize(); + } + return rect; } float CPWL_Wnd::GetFontSize() const { -- cgit v1.2.3