From d3b0f7cc78e6a143e00e5eb653b3e7c918054426 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Wed, 2 May 2018 15:31:32 +0000 Subject: Remove int out params from reference to pointer in CXFA_Node. Return a CFX_Size instead. Change-Id: I3bef1093fbc887237aa69dc942f878af27b4e8e9 Reviewed-on: https://pdfium-review.googlesource.com/31911 Commit-Queue: Henrique Nakashima Reviewed-by: Ryan Harrison Reviewed-by: Lei Zhang --- xfa/fxfa/cxfa_ffimage.cpp | 7 ++----- xfa/fxfa/cxfa_ffimageedit.cpp | 8 +++----- xfa/fxfa/parser/cxfa_node.cpp | 29 +++++++++-------------------- xfa/fxfa/parser/cxfa_node.h | 7 +++---- 4 files changed, 17 insertions(+), 34 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/cxfa_ffimage.cpp b/xfa/fxfa/cxfa_ffimage.cpp index a80b19a337..15916de456 100644 --- a/xfa/fxfa/cxfa_ffimage.cpp +++ b/xfa/fxfa/cxfa_ffimage.cpp @@ -65,14 +65,11 @@ void CXFA_FFImage::RenderWidget(CXFA_Graphics* pGS, iVertAlign = para->GetVerticalAlign(); } - int32_t iImageXDpi = 0; - int32_t iImageYDpi = 0; - m_pNode->GetImageDpi(iImageXDpi, iImageYDpi); - auto* value = m_pNode->GetFormValueIfExists(); CXFA_Image* image = value ? value->GetImageIfExists() : nullptr; if (image) { + CFX_Size dpi = m_pNode->GetImageDpi(); XFA_DrawImage(pGS, rtImage, mtRotate, pDIBitmap, image->GetAspect(), - iImageXDpi, iImageYDpi, iHorzAlign, iVertAlign); + dpi.width, dpi.height, iHorzAlign, iVertAlign); } } diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp index 40afdb1c4c..f07bc1e267 100644 --- a/xfa/fxfa/cxfa_ffimageedit.cpp +++ b/xfa/fxfa/cxfa_ffimageedit.cpp @@ -89,11 +89,9 @@ void CXFA_FFImageEdit::RenderWidget(CXFA_Graphics* pGS, iAspect = image->GetAspect(); } - int32_t iImageXDpi = 0; - int32_t iImageYDpi = 0; - m_pNode->GetImageEditDpi(iImageXDpi, iImageYDpi); - XFA_DrawImage(pGS, rtImage, mtRotate, pDIBitmap, iAspect, iImageXDpi, - iImageYDpi, iHorzAlign, iVertAlign); + CFX_Size dpi = m_pNode->GetImageEditDpi(); + XFA_DrawImage(pGS, rtImage, mtRotate, pDIBitmap, iAspect, dpi.width, + dpi.height, iHorzAlign, iVertAlign); } bool CXFA_FFImageEdit::AcceptsFocusOnButtonDown(uint32_t dwFlags, diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index c83c118e73..c3fbf62eb7 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -2907,10 +2907,9 @@ bool CXFA_Node::CalculatePushButtonAutoSize(CXFA_FFDoc* doc, CFX_SizeF* pSize) { CFX_SizeF CXFA_Node::CalculateImageSize(float img_width, float img_height, - float dpi_x, - float dpi_y) { - CFX_RectF rtImage(0, 0, XFA_UnitPx2Pt(img_width, dpi_x), - XFA_UnitPx2Pt(img_height, dpi_y)); + const CFX_Size& dpi) { + CFX_RectF rtImage(0, 0, XFA_UnitPx2Pt(img_width, dpi.width), + XFA_UnitPx2Pt(img_height, dpi.height)); CFX_RectF rtFit; Optional width = TryWidth(); @@ -2941,12 +2940,8 @@ bool CXFA_Node::CalculateImageAutoSize(CXFA_FFDoc* doc, CFX_SizeF* pSize) { if (!pBitmap) return CalculateWidgetAutoSize(pSize); - int32_t iImageXDpi = 0; - int32_t iImageYDpi = 0; - GetImageDpi(iImageXDpi, iImageYDpi); - *pSize = CalculateImageSize(pBitmap->GetWidth(), pBitmap->GetHeight(), - iImageXDpi, iImageYDpi); + GetImageDpi()); return CalculateWidgetAutoSize(pSize); } @@ -2959,12 +2954,8 @@ bool CXFA_Node::CalculateImageEditAutoSize(CXFA_FFDoc* doc, CFX_SizeF* pSize) { if (!pBitmap) return CalculateFieldAutoSize(doc, pSize); - int32_t iImageXDpi = 0; - int32_t iImageYDpi = 0; - GetImageEditDpi(iImageXDpi, iImageYDpi); - *pSize = CalculateImageSize(pBitmap->GetWidth(), pBitmap->GetHeight(), - iImageXDpi, iImageYDpi); + GetImageEditDpi()); return CalculateFieldAutoSize(doc, pSize); } @@ -2980,18 +2971,16 @@ bool CXFA_Node::LoadImageEditImage(CXFA_FFDoc* doc) { ->LoadImageData(doc, this); } -void CXFA_Node::GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { +CFX_Size CXFA_Node::GetImageDpi() const { CXFA_ImageLayoutData* pData = static_cast(m_pLayoutData.get()); - iImageXDpi = pData->m_iImageXDpi; - iImageYDpi = pData->m_iImageYDpi; + return CFX_Size(pData->m_iImageXDpi, pData->m_iImageYDpi); } -void CXFA_Node::GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { +CFX_Size CXFA_Node::GetImageEditDpi() const { CXFA_ImageEditData* pData = static_cast(m_pLayoutData.get()); - iImageXDpi = pData->m_iImageXDpi; - iImageYDpi = pData->m_iImageYDpi; + return CFX_Size(pData->m_iImageXDpi, pData->m_iImageYDpi); } float CXFA_Node::CalculateWidgetAutoWidth(float fWidthCalc) { diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index 32e5cfd861..b12a26ef3b 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -312,8 +312,8 @@ class CXFA_Node : public CXFA_Object { bool LoadImageImage(CXFA_FFDoc* doc); bool LoadImageEditImage(CXFA_FFDoc* doc); - void GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi); - void GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi); + CFX_Size GetImageDpi() const; + CFX_Size GetImageEditDpi() const; RetainPtr GetImageImage(); RetainPtr GetImageEditImage(); @@ -452,8 +452,7 @@ class CXFA_Node : public CXFA_Object { bool CalculatePushButtonAutoSize(CXFA_FFDoc* doc, CFX_SizeF* pSize); CFX_SizeF CalculateImageSize(float img_width, float img_height, - float dpi_x, - float dpi_y); + const CFX_Size& dpi); bool CalculateImageEditAutoSize(CXFA_FFDoc* doc, CFX_SizeF* pSize); bool CalculateImageAutoSize(CXFA_FFDoc* doc, CFX_SizeF* pSize); float CalculateWidgetAutoHeight(float fHeightCalc); -- cgit v1.2.3