summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-11 14:34:56 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-11 14:34:56 +0000
commit19835921655cd6f2086c7a741696906fc340abac (patch)
tree7b71d4d2ae2985a9418160e41e47eeea4eff370e
parent241752f3c188ed992a26618361e55b1d7f2be7cc (diff)
downloadpdfium-19835921655cd6f2086c7a741696906fc340abac.tar.xz
Rename GetFormValue to GetFormValueIfExists
This CL makes it clear that GetFormValue can return nullptr and fixes up a few callsites as needed. Change-Id: Id2e85b0956a678b5b338b9e2a4d32731fe6c4729 Reviewed-on: https://pdfium-review.googlesource.com/22690 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--fxjs/xfa/cjx_field.cpp3
-rw-r--r--xfa/fxfa/cxfa_ffarc.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffdatetimeedit.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffimage.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffimageedit.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffline.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffrectangle.cpp2
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp9
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_node.h2
10 files changed, 15 insertions, 13 deletions
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp
index 0007bad592..299c6ef3a4 100644
--- a/fxjs/xfa/cjx_field.cpp
+++ b/fxjs/xfa/cjx_field.cpp
@@ -272,7 +272,8 @@ void CJX_Field::defaultValue(CFXJSE_Value* pValue,
}
CXFA_Node* pUIChild = pWidgetAcc->GetUIChild();
- CXFA_Node* pNode = xfaNode->GetFormValue()->GetFirstChild();
+ CXFA_Node* formValue = xfaNode->GetFormValueIfExists();
+ CXFA_Node* pNode = formValue ? formValue->GetFirstChild() : nullptr;
if (pNode && pNode->GetElementType() == XFA_Element::Decimal) {
if (pUIChild->GetElementType() == XFA_Element::NumericEdit &&
(pNode->JSObject()->GetInteger(XFA_Attribute::FracDigits) == -1)) {
diff --git a/xfa/fxfa/cxfa_ffarc.cpp b/xfa/fxfa/cxfa_ffarc.cpp
index 0b1647b915..a738221b05 100644
--- a/xfa/fxfa/cxfa_ffarc.cpp
+++ b/xfa/fxfa/cxfa_ffarc.cpp
@@ -19,7 +19,7 @@ void CXFA_FFArc::RenderWidget(CXFA_Graphics* pGS,
if (!IsMatchVisibleStatus(dwStatus))
return;
- CXFA_Value* value = m_pNode->GetFormValue();
+ CXFA_Value* value = m_pNode->GetFormValueIfExists();
if (!value)
return;
diff --git a/xfa/fxfa/cxfa_ffdatetimeedit.cpp b/xfa/fxfa/cxfa_ffdatetimeedit.cpp
index 018830024b..d6bd096e54 100644
--- a/xfa/fxfa/cxfa_ffdatetimeedit.cpp
+++ b/xfa/fxfa/cxfa_ffdatetimeedit.cpp
@@ -53,7 +53,7 @@ bool CXFA_FFDateTimeEdit::LoadWidget() {
m_pNode->GetWidgetAcc()->GetValue(XFA_VALUEPICTURE_Display);
pWidget->SetEditText(wsText);
- CXFA_Value* value = m_pNode->GetFormValue();
+ CXFA_Value* value = m_pNode->GetFormValueIfExists();
if (value) {
switch (value->GetChildValueClassID()) {
case XFA_Element::Date: {
diff --git a/xfa/fxfa/cxfa_ffimage.cpp b/xfa/fxfa/cxfa_ffimage.cpp
index 4fb5f159ed..3a5a63a1e4 100644
--- a/xfa/fxfa/cxfa_ffimage.cpp
+++ b/xfa/fxfa/cxfa_ffimage.cpp
@@ -70,7 +70,7 @@ void CXFA_FFImage::RenderWidget(CXFA_Graphics* pGS,
int32_t iImageXDpi = 0;
int32_t iImageYDpi = 0;
m_pNode->GetWidgetAcc()->GetImageDpi(iImageXDpi, iImageYDpi);
- auto* value = m_pNode->GetFormValue();
+ auto* value = m_pNode->GetFormValueIfExists();
CXFA_Image* image = value ? value->GetImage() : nullptr;
XFA_DrawImage(pGS, rtImage, mtRotate, pDIBitmap, image->GetAspect(),
iImageXDpi, iImageYDpi, iHorzAlign, iVertAlign);
diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp
index 15d798c30c..15a8dc3fd4 100644
--- a/xfa/fxfa/cxfa_ffimageedit.cpp
+++ b/xfa/fxfa/cxfa_ffimageedit.cpp
@@ -82,7 +82,7 @@ void CXFA_FFImageEdit::RenderWidget(CXFA_Graphics* pGS,
}
XFA_AttributeEnum iAspect = XFA_AttributeEnum::Fit;
- CXFA_Value* value = m_pNode->GetFormValue();
+ CXFA_Value* value = m_pNode->GetFormValueIfExists();
if (value) {
CXFA_Image* image = value->GetImage();
if (image)
diff --git a/xfa/fxfa/cxfa_ffline.cpp b/xfa/fxfa/cxfa_ffline.cpp
index 45ff95380d..ee8ca1841a 100644
--- a/xfa/fxfa/cxfa_ffline.cpp
+++ b/xfa/fxfa/cxfa_ffline.cpp
@@ -87,7 +87,7 @@ void CXFA_FFLine::RenderWidget(CXFA_Graphics* pGS,
if (!IsMatchVisibleStatus(dwStatus))
return;
- CXFA_Value* value = m_pNode->GetFormValue();
+ CXFA_Value* value = m_pNode->GetFormValueIfExists();
if (!value)
return;
diff --git a/xfa/fxfa/cxfa_ffrectangle.cpp b/xfa/fxfa/cxfa_ffrectangle.cpp
index 93c4ea2afb..b3dd6f45c6 100644
--- a/xfa/fxfa/cxfa_ffrectangle.cpp
+++ b/xfa/fxfa/cxfa_ffrectangle.cpp
@@ -19,7 +19,7 @@ void CXFA_FFRectangle::RenderWidget(CXFA_Graphics* pGS,
if (!IsMatchVisibleStatus(dwStatus))
return;
- CXFA_Value* value = m_pNode->GetFormValue();
+ CXFA_Value* value = m_pNode->GetFormValueIfExists();
if (!value)
return;
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 5c2c168343..d7fa3ccde9 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -95,7 +95,7 @@ class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData {
if (m_pDIBitmap)
return true;
- CXFA_Value* value = pAcc->GetNode()->GetFormValue();
+ CXFA_Value* value = pAcc->GetNode()->GetFormValueIfExists();
if (!value)
return false;
@@ -152,7 +152,7 @@ class CXFA_ImageEditData : public CXFA_FieldLayoutData {
if (m_pDIBitmap)
return true;
- CXFA_Value* value = pAcc->GetNode()->GetFormValue();
+ CXFA_Value* value = pAcc->GetNode()->GetFormValueIfExists();
if (!value)
return false;
@@ -439,7 +439,7 @@ void CXFA_WidgetAcc::ResetData() {
void CXFA_WidgetAcc::SetImageEdit(const WideString& wsContentType,
const WideString& wsHref,
const WideString& wsData) {
- CXFA_Value* formValue = m_pNode->GetFormValue();
+ CXFA_Value* formValue = m_pNode->GetFormValueIfExists();
CXFA_Image* image = formValue ? formValue->GetImage() : nullptr;
if (image) {
image->SetContentType(WideString(wsContentType));
@@ -451,7 +451,8 @@ void CXFA_WidgetAcc::SetImageEdit(const WideString& wsContentType,
CXFA_Node* pBind = m_pNode->GetBindData();
if (!pBind) {
- image->SetTransferEncoding(XFA_AttributeEnum::Base64);
+ if (image)
+ image->SetTransferEncoding(XFA_AttributeEnum::Base64);
return;
}
pBind->JSObject()->SetCData(XFA_Attribute::ContentType, wsContentType, false,
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index ed2093cb7a..9c28668c16 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1600,7 +1600,7 @@ CXFA_Value* CXFA_Node::GetDefaultValueIfExists() {
: nullptr;
}
-CXFA_Value* CXFA_Node::GetFormValue() const {
+CXFA_Value* CXFA_Node::GetFormValueIfExists() const {
return JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value);
}
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index 7aea742a96..8a0a3610a6 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -253,7 +253,7 @@ class CXFA_Node : public CXFA_Object {
CXFA_Validate* GetOrCreateValidateIfPossible();
CXFA_Value* GetDefaultValueIfExists();
- CXFA_Value* GetFormValue() const;
+ CXFA_Value* GetFormValueIfExists() const;
WideString GetRawValue();
int32_t GetRotate();