Use early returns in CXFA_FFNotify::OnCreateContentLayoutItem().
Commit 921d2441 made it possible to fail the ASSERT() at the end of this
method. Use early returns to bail out early so that ASSERT() holds.
BUG=pdfium:1237
Change-Id: I639ef1779a1bf6234907854ccf858652e222a26b
Reviewed-on: https://pdfium-review.googlesource.com/c/50713
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp
index 588f0d9..4a99ded 100644
--- a/xfa/fxfa/cxfa_ffnotify.cpp
+++ b/xfa/fxfa/cxfa_ffnotify.cpp
@@ -120,26 +120,29 @@
switch (pNode->GetFFWidgetType()) {
case XFA_FFWidgetType::kBarcode: {
CXFA_Node* child = pNode->GetUIChildNode();
- if (child->GetElementType() == XFA_Element::Barcode) {
- pWidget = pdfium::MakeUnique<CXFA_FFBarcode>(
- pNode, static_cast<CXFA_Barcode*>(child));
- }
+ if (child->GetElementType() != XFA_Element::Barcode)
+ return nullptr;
+
+ pWidget = pdfium::MakeUnique<CXFA_FFBarcode>(
+ pNode, static_cast<CXFA_Barcode*>(child));
break;
}
case XFA_FFWidgetType::kButton: {
CXFA_Node* child = pNode->GetUIChildNode();
- if (child->GetElementType() == XFA_Element::Button) {
- pWidget = pdfium::MakeUnique<CXFA_FFPushButton>(
- pNode, static_cast<CXFA_Button*>(child));
- }
+ if (child->GetElementType() != XFA_Element::Button)
+ return nullptr;
+
+ pWidget = pdfium::MakeUnique<CXFA_FFPushButton>(
+ pNode, static_cast<CXFA_Button*>(child));
break;
}
case XFA_FFWidgetType::kCheckButton: {
CXFA_Node* child = pNode->GetUIChildNode();
- if (child->GetElementType() == XFA_Element::CheckButton) {
- pWidget = pdfium::MakeUnique<CXFA_FFCheckButton>(
- pNode, static_cast<CXFA_CheckButton*>(child));
- }
+ if (child->GetElementType() != XFA_Element::CheckButton)
+ return nullptr;
+
+ pWidget = pdfium::MakeUnique<CXFA_FFCheckButton>(
+ pNode, static_cast<CXFA_CheckButton*>(child));
break;
}
case XFA_FFWidgetType::kChoiceList: {
@@ -160,10 +163,11 @@
break;
case XFA_FFWidgetType::kPasswordEdit: {
CXFA_Node* child = pNode->GetUIChildNode();
- if (child->GetElementType() == XFA_Element::PasswordEdit) {
- pWidget = pdfium::MakeUnique<CXFA_FFPasswordEdit>(
- pNode, static_cast<CXFA_PasswordEdit*>(child));
- }
+ if (child->GetElementType() != XFA_Element::PasswordEdit)
+ return nullptr;
+
+ pWidget = pdfium::MakeUnique<CXFA_FFPasswordEdit>(
+ pNode, static_cast<CXFA_PasswordEdit*>(child));
break;
}
case XFA_FFWidgetType::kSignature: