From 1e6490da6fb813930d1073ac05ace8a21fa9ca28 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 10 Jan 2018 19:34:57 +0000 Subject: Rename GetCaption to GetCaptionIfExists This CL renames GetCaption to GetCaptionIfExists to make it clear the value returned can be a nullptr. The various callsites have been fixed which used the caption without validating. Change-Id: I9b600ac9ab5b9e04dfa6e8cee95ef3e9d629688d Reviewed-on: https://pdfium-review.googlesource.com/22670 Reviewed-by: Ryan Harrison Commit-Queue: dsinclair --- xfa/fxfa/cxfa_fffield.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'xfa/fxfa/cxfa_fffield.cpp') diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp index ffbaa43d62..fdc2b1c6ed 100644 --- a/xfa/fxfa/cxfa_fffield.cpp +++ b/xfa/fxfa/cxfa_fffield.cpp @@ -191,7 +191,7 @@ void CXFA_FFField::CapPlacement() { XFA_AttributeEnum iCapPlacement = XFA_AttributeEnum::Unknown; float fCapReserve = 0; - CXFA_Caption* caption = m_pNode->GetCaption(); + CXFA_Caption* caption = m_pNode->GetCaptionIfExists(); if (caption && !caption->IsHidden()) { iCapPlacement = caption->GetPlacementType(); if (iCapPlacement == XFA_AttributeEnum::Top && GetPrev()) { @@ -231,17 +231,18 @@ void CXFA_FFField::CapPlacement() { } m_rtUI = rtWidget; + CXFA_Margin* capMargin = caption ? caption->GetMargin() : nullptr; switch (iCapPlacement) { case XFA_AttributeEnum::Left: { m_rtCaption.width = fCapReserve; - CapLeftRightPlacement(caption->GetMargin(), rtWidget, iCapPlacement); + CapLeftRightPlacement(capMargin, rtWidget, iCapPlacement); m_rtUI.width -= fCapReserve; m_rtUI.left += fCapReserve; break; } case XFA_AttributeEnum::Top: { m_rtCaption.height = fCapReserve; - CapTopBottomPlacement(caption->GetMargin(), rtWidget, iCapPlacement); + CapTopBottomPlacement(capMargin, rtWidget, iCapPlacement); m_rtUI.top += fCapReserve; m_rtUI.height -= fCapReserve; break; @@ -249,14 +250,14 @@ void CXFA_FFField::CapPlacement() { case XFA_AttributeEnum::Right: { m_rtCaption.left = m_rtCaption.right() - fCapReserve; m_rtCaption.width = fCapReserve; - CapLeftRightPlacement(caption->GetMargin(), rtWidget, iCapPlacement); + CapLeftRightPlacement(capMargin, rtWidget, iCapPlacement); m_rtUI.width -= fCapReserve; break; } case XFA_AttributeEnum::Bottom: { m_rtCaption.top = m_rtCaption.bottom() - fCapReserve; m_rtCaption.height = fCapReserve; - CapTopBottomPlacement(caption->GetMargin(), rtWidget, iCapPlacement); + CapTopBottomPlacement(capMargin, rtWidget, iCapPlacement); m_rtUI.height -= fCapReserve; break; } @@ -601,7 +602,7 @@ void CXFA_FFField::RenderCaption(CXFA_Graphics* pGS, CFX_Matrix* pMatrix) { if (!pCapTextLayout) return; - CXFA_Caption* caption = m_pNode->GetCaption(); + CXFA_Caption* caption = m_pNode->GetCaptionIfExists(); if (!caption || !caption->IsVisible()) return; -- cgit v1.2.3