summaryrefslogtreecommitdiff
path: root/xfa/fxfa/cxfa_widgetacc.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-10 19:34:57 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-10 19:34:57 +0000
commit1e6490da6fb813930d1073ac05ace8a21fa9ca28 (patch)
treed1849bda5efcb3b3cd7c4a39580d36228b4ab696 /xfa/fxfa/cxfa_widgetacc.cpp
parenta74e75d69594e469906e2a95b5f2394c88acbe7a (diff)
downloadpdfium-1e6490da6fb813930d1073ac05ace8a21fa9ca28.tar.xz
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 <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/cxfa_widgetacc.cpp')
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 0c55bd6ce6..222de47e89 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -122,7 +122,7 @@ class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData {
bool LoadCaption(CXFA_FFDoc* doc, CXFA_WidgetAcc* pAcc) {
if (m_pCapTextLayout)
return true;
- CXFA_Caption* caption = pAcc->GetNode()->GetCaption();
+ CXFA_Caption* caption = pAcc->GetNode()->GetCaptionIfExists();
if (!caption || caption->IsHidden())
return false;
@@ -484,7 +484,7 @@ void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFDocView* docView,
}
void CXFA_WidgetAcc::CalcCaptionSize(CXFA_FFDoc* doc, CFX_SizeF& szCap) {
- CXFA_Caption* caption = m_pNode->GetCaption();
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
if (!caption || !caption->IsVisible())
return;
@@ -550,7 +550,10 @@ bool CXFA_WidgetAcc::CalculateFieldAutoSize(CXFA_FFDoc* doc, CFX_SizeF& size) {
size.width += rtUIMargin.left + rtUIMargin.width;
size.height += rtUIMargin.top + rtUIMargin.height;
if (szCap.width > 0 && szCap.height > 0) {
- switch (m_pNode->GetCaption()->GetPlacementType()) {
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
+ XFA_AttributeEnum placement =
+ caption ? caption->GetPlacementType() : XFA_AttributeEnum::Left;
+ switch (placement) {
case XFA_AttributeEnum::Left:
case XFA_AttributeEnum::Right:
case XFA_AttributeEnum::Inline: {
@@ -651,7 +654,9 @@ bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CXFA_FFDoc* doc,
bool bCapExit = szCap.width > 0.01 && szCap.height > 0.01;
XFA_AttributeEnum iCapPlacement = XFA_AttributeEnum::Unknown;
if (bCapExit) {
- iCapPlacement = m_pNode->GetCaption()->GetPlacementType();
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
+ iCapPlacement =
+ caption ? caption->GetPlacementType() : XFA_AttributeEnum::Left;
switch (iCapPlacement) {
case XFA_AttributeEnum::Left:
case XFA_AttributeEnum::Right:
@@ -985,7 +990,7 @@ bool CXFA_WidgetAcc::FindSplitPos(CXFA_FFDocView* docView,
XFA_AttributeEnum iCapPlacement = XFA_AttributeEnum::Unknown;
float fCapReserve = 0;
if (iBlockIndex == 0) {
- CXFA_Caption* caption = m_pNode->GetCaption();
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
if (caption && !caption->IsHidden()) {
iCapPlacement = caption->GetPlacementType();
fCapReserve = caption->GetReserve();