summaryrefslogtreecommitdiff
path: root/xfa/fxfa/cxfa_ffwidgethandler.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-10 20:47:55 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-10 20:47:55 +0000
commit3ffde1bc73156098e78e5e303b3f5198a1d073b8 (patch)
treec3a13bfda69bfb9bc4a85855d588d64d27faaa57 /xfa/fxfa/cxfa_ffwidgethandler.cpp
parent326c38c4f2749e61fa2dec1d0f326e4099d6a24c (diff)
downloadpdfium-3ffde1bc73156098e78e5e303b3f5198a1d073b8.tar.xz
Rename GetTemplateNode to GetTemplateNodeIfExists
This CL makes it explicit that GetTemplateNodeIfExists can return nullptr. Various call sites are updated as needed. Change-Id: If6edd5962b59e7e4ce3dbe9bbdc957783cf76abe Reviewed-on: https://pdfium-review.googlesource.com/22678 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/cxfa_ffwidgethandler.cpp')
-rw-r--r--xfa/fxfa/cxfa_ffwidgethandler.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp
index 857a3c6687..87a013cee2 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp
@@ -254,7 +254,11 @@ CXFA_FFWidget* CXFA_FFWidgetHandler::CreateWidget(CXFA_FFWidget* hParent,
if (!pNewFormItem)
return nullptr;
- pNewFormItem->GetTemplateNode()->SetFlag(XFA_NodeFlag_Initialized, true);
+ CXFA_Node* templateNode = pNewFormItem->GetTemplateNodeIfExists();
+ if (!templateNode)
+ return nullptr;
+
+ templateNode->SetFlag(XFA_NodeFlag_Initialized, true);
pNewFormItem->SetFlag(XFA_NodeFlag_Initialized, true);
m_pDocView->RunLayout();
CXFA_LayoutItem* pLayout =
@@ -485,7 +489,13 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateSubform(CXFA_Node* pParent,
CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_Element eElement,
CXFA_Node* pParent,
CXFA_Node* pBefore) const {
- CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : nullptr;
+ if (!pParent)
+ return nullptr;
+
+ CXFA_Node* pTemplateParent = pParent->GetTemplateNodeIfExists();
+ if (!pTemplateParent)
+ return nullptr;
+
CXFA_Node* pNewFormItem = pTemplateParent->CloneTemplateToForm(false);
if (pParent)
pParent->InsertChild(pNewFormItem, pBefore);
@@ -495,10 +505,13 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_Element eElement,
CXFA_Node* CXFA_FFWidgetHandler::CreateCopyNode(XFA_Element eElement,
CXFA_Node* pParent,
CXFA_Node* pBefore) const {
- CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : nullptr;
+ if (!pParent)
+ return nullptr;
+
+ CXFA_Node* pTemplateParent = pParent->GetTemplateNodeIfExists();
CXFA_Node* pNewNode =
CreateTemplateNode(eElement, pTemplateParent,
- pBefore ? pBefore->GetTemplateNode() : nullptr)
+ pBefore ? pBefore->GetTemplateNodeIfExists() : nullptr)
->Clone(false);
if (pParent)
pParent->InsertChild(pNewNode, pBefore);