From 878b27de2fa8e5bdc3b910c98846f4b43185d4aa Mon Sep 17 00:00:00 2001 From: Jane Liu Date: Tue, 22 Aug 2017 10:50:06 -0400 Subject: Converted CFX_Matrix::TransformRect() to take in consts Currently, all three of CFX_Matrix::TransformRect() take in rect values and modify them in place. This CL converts them to take in constant values and return the transformed values instead, and fixes all the call sites. Bug=pdfium:874 Change-Id: I9c274df3b14e9d88c100ba0530068e06e8fec32b Reviewed-on: https://pdfium-review.googlesource.com/11550 Reviewed-by: dsinclair Commit-Queue: Jane Liu --- xfa/fde/cfde_textout.cpp | 4 +--- xfa/fwl/cfwl_edit.cpp | 9 ++++----- xfa/fwl/cfwl_listbox.cpp | 3 +-- xfa/fwl/cfwl_spinbutton.cpp | 3 --- xfa/fwl/cfwl_widgetmgr.cpp | 6 +++--- xfa/fxfa/cxfa_fffield.cpp | 6 ++---- xfa/fxfa/cxfa_ffpushbutton.cpp | 2 +- xfa/fxfa/cxfa_fftext.cpp | 3 +-- xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp | 4 ++-- xfa/fxgraphics/cxfa_graphics.cpp | 4 ++-- 10 files changed, 17 insertions(+), 27 deletions(-) (limited to 'xfa') diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp index 2e4753a902..76ffcf9517 100644 --- a/xfa/fde/cfde_textout.cpp +++ b/xfa/fde/cfde_textout.cpp @@ -299,9 +299,7 @@ void CFDE_TextOut::DrawLogicText(CFX_RenderDevice* device, if (!device || m_ttoLines.empty()) return; - CFX_RectF rtClip; - m_Matrix.TransformRect(rtClip); - + CFX_RectF rtClip = m_Matrix.TransformRect(CFX_RectF()); device->SaveState(); if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) device->SetClip_Rect(rtClip); diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index fc8b0fa888..127c258d04 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -228,7 +228,7 @@ void CFWL_Edit::DrawSpellCheck(CXFA_Graphics* pGraphics, CFX_RectF rtClip = m_rtEngine; CFX_Matrix mt(1, 0, 0, 1, fOffSetX, fOffSetY); if (pMatrix) { - pMatrix->TransformRect(rtClip); + rtClip = pMatrix->TransformRect(rtClip); mt.Concat(*pMatrix); } pGraphics->SetClipRect(rtClip); @@ -511,7 +511,7 @@ void CFWL_Edit::DrawContent(CXFA_Graphics* pGraphics, float fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; CFX_Matrix mt(1, 0, 0, 1, fOffSetX, fOffSetY); if (pMatrix) { - pMatrix->TransformRect(rtClip); + rtClip = pMatrix->TransformRect(rtClip); mt.Concat(*pMatrix); } @@ -609,7 +609,7 @@ void CFWL_Edit::RenderText(CFX_RenderDevice* pRenderDev, rtDocClip.width = static_cast(pRenderDev->GetWidth()); rtDocClip.height = static_cast(pRenderDev->GetHeight()); } - mt.GetInverse().TransformRect(rtDocClip); + rtDocClip = mt.GetInverse().TransformRect(rtDocClip); std::vector char_pos; @@ -1130,8 +1130,7 @@ void CFWL_Edit::ShowCaret(CFX_RectF* pRect) { if (!pDocEnvironment) return; - CFX_RectF rt(*pRect); - pXFAWidget->GetRotateMatrix().TransformRect(rt); + CFX_RectF rt = pXFAWidget->GetRotateMatrix().TransformRect(*pRect); pDocEnvironment->DisplayCaret(pXFAWidget, true, &rt); } diff --git a/xfa/fwl/cfwl_listbox.cpp b/xfa/fwl/cfwl_listbox.cpp index ce1c0133f9..210ec1f06e 100644 --- a/xfa/fwl/cfwl_listbox.cpp +++ b/xfa/fwl/cfwl_listbox.cpp @@ -107,9 +107,8 @@ void CFWL_ListBox::DrawWidget(CXFA_Graphics* pGraphics, rtClip.height -= m_fScorllBarWidth; if (IsShowScrollBar(true)) rtClip.width -= m_fScorllBarWidth; - matrix.TransformRect(rtClip); - pGraphics->SetClipRect(rtClip); + pGraphics->SetClipRect(matrix.TransformRect(rtClip)); if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) DrawBkground(pGraphics, pTheme, &matrix); diff --git a/xfa/fwl/cfwl_spinbutton.cpp b/xfa/fwl/cfwl_spinbutton.cpp index 3119c7517a..f4ca339089 100644 --- a/xfa/fwl/cfwl_spinbutton.cpp +++ b/xfa/fwl/cfwl_spinbutton.cpp @@ -83,9 +83,6 @@ void CFWL_SpinButton::DrawWidget(CXFA_Graphics* pGraphics, if (!pGraphics) return; - CFX_RectF rtClip(m_rtClient); - matrix.TransformRect(rtClip); - IFWL_ThemeProvider* pTheme = GetAvailableTheme(); if (HasBorder()) DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix); diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp index f5beb411e6..d3f2dd4655 100644 --- a/xfa/fwl/cfwl_widgetmgr.cpp +++ b/xfa/fwl/cfwl_widgetmgr.cpp @@ -514,8 +514,8 @@ bool CFWL_WidgetMgr::IsNeedRepaint(CFWL_Widget* pWidget, return true; } - CFX_RectF rtWidget(0, 0, pWidget->GetWidgetRect().Size()); - pMatrix->TransformRect(rtWidget); + CFX_RectF rtWidget = + pMatrix->TransformRect(CFX_RectF(0, 0, pWidget->GetWidgetRect().Size())); if (!rtWidget.IntersectWith(rtDirty)) return false; @@ -593,7 +593,7 @@ bool CFWL_WidgetMgr::IsNeedRepaint(CFWL_Widget* pWidget, if (repaintPoint > 0) return true; - pMatrix->TransformRect(rtChilds); + rtChilds = pMatrix->TransformRect(rtChilds); if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) return false; return true; diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp index 31003417a8..bfc9e4edbc 100644 --- a/xfa/fxfa/cxfa_fffield.cpp +++ b/xfa/fxfa/cxfa_fffield.cpp @@ -52,9 +52,7 @@ CFX_RectF CXFA_FFField::GetBBox(uint32_t dwStatus, bool bDrawFocus) { return CFX_RectF(); } - CFX_RectF rtBox = m_rtUI; - GetRotateMatrix().TransformRect(rtBox); - return rtBox; + return GetRotateMatrix().TransformRect(m_rtUI); } void CXFA_FFField::RenderWidget(CXFA_Graphics* pGS, @@ -619,7 +617,7 @@ void CXFA_FFField::RenderCaption(CXFA_Graphics* pGS, CFX_Matrix* pMatrix) { CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); CFX_Matrix mt(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); if (pMatrix) { - pMatrix->TransformRect(rtClip); + rtClip = pMatrix->TransformRect(rtClip); mt.Concat(*pMatrix); } pCapTextLayout->DrawString(pRenderDevice, mt, rtClip); diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp index d201e42c86..63079cfaa0 100644 --- a/xfa/fxfa/cxfa_ffpushbutton.cpp +++ b/xfa/fxfa/cxfa_ffpushbutton.cpp @@ -176,7 +176,7 @@ void CXFA_FFPushButton::RenderHighlightCaption(CXFA_Graphics* pGS, rtClip.Intersect(GetRectWithoutRotate()); CFX_Matrix mt(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); if (pMatrix) { - pMatrix->TransformRect(rtClip); + rtClip = pMatrix->TransformRect(rtClip); mt.Concat(*pMatrix); } diff --git a/xfa/fxfa/cxfa_fftext.cpp b/xfa/fxfa/cxfa_fftext.cpp index 6246ec5731..274f3bfb61 100644 --- a/xfa/fxfa/cxfa_fftext.cpp +++ b/xfa/fxfa/cxfa_fftext.cpp @@ -61,8 +61,7 @@ void CXFA_FFText::RenderWidget(CXFA_Graphics* pGS, } CFX_Matrix mt(1, 0, 0, 1, rtText.left, rtText.top); - CFX_RectF rtClip = rtText; - mtRotate.TransformRect(rtClip); + CFX_RectF rtClip = mtRotate.TransformRect(rtText); mt.Concat(mtRotate); pTextLayout->DrawString(pRenderDevice, mt, rtClip, GetIndex()); } diff --git a/xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp b/xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp index 4dacd0300b..6fdd553712 100644 --- a/xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp +++ b/xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp @@ -30,8 +30,8 @@ bool CXFA_FWLAdapterWidgetMgr::GetPopupPos(CFWL_Widget* pWidget, const CFX_RectF& rtAnchor, CFX_RectF& rtPopup) { CXFA_FFWidget* pFFWidget = pWidget->GetLayoutItem(); - CFX_RectF rtRotateAnchor(rtAnchor); - pFFWidget->GetRotateMatrix().TransformRect(rtRotateAnchor); + CFX_RectF rtRotateAnchor = + pFFWidget->GetRotateMatrix().TransformRect(rtAnchor); pFFWidget->GetDoc()->GetDocEnvironment()->GetPopupPos( pFFWidget, fMinHeight, fMaxHeight, rtRotateAnchor, rtPopup); return true; diff --git a/xfa/fxgraphics/cxfa_graphics.cpp b/xfa/fxgraphics/cxfa_graphics.cpp index 7cad380802..a94e99e200 100644 --- a/xfa/fxgraphics/cxfa_graphics.cpp +++ b/xfa/fxgraphics/cxfa_graphics.cpp @@ -346,8 +346,8 @@ void CXFA_Graphics::FillPathWithPattern(const CXFA_Path* path, auto mask = pdfium::MakeRetain(); mask->Create(data.width, data.height, FXDIB_1bppMask); memcpy(mask->GetBuffer(), data.maskBits, mask->GetPitch() * data.height); - CFX_FloatRect rectf = path->GetPathData()->GetBoundingBox(); - matrix.TransformRect(rectf); + CFX_FloatRect rectf = + matrix.TransformRect(path->GetPathData()->GetBoundingBox()); FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); -- cgit v1.2.3