summaryrefslogtreecommitdiff
path: root/fpdfsdk/pdfwindow/cpwl_wnd.cpp
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2017-07-12 21:56:27 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-13 17:11:16 +0000
commitadf922f278d23e7f955b89f48cc64b5de7925977 (patch)
tree1cae79929399b712938d88480d90ebc2c7ea59ff /fpdfsdk/pdfwindow/cpwl_wnd.cpp
parenta860a3d596f3daeadfdca0cc2093bfca722fa3a3 (diff)
downloadpdfium-adf922f278d23e7f955b89f48cc64b5de7925977.tar.xz
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 <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/pdfwindow/cpwl_wnd.cpp')
-rw-r--r--fpdfsdk/pdfwindow/cpwl_wnd.cpp39
1 files changed, 31 insertions, 8 deletions
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<float>(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<float>(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<float>(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 {