summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-02-20 22:05:59 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-20 22:05:59 +0000
commite76345ec2780ec13cc99b910ff78e0e3a1f87aec (patch)
tree485ed41f615a54491944f02a3ecfc55f2894bbfd /xfa/fxfa/fm2js
parentceab166b7dafc2bb514755e4a017bf178d0c8e8b (diff)
downloadpdfium-e76345ec2780ec13cc99b910ff78e0e3a1f87aec.tar.xz
[formcalc] Treat elseif and else the same during output
This CL combines the elseif and else output code for formcalc. This causes an extra set of {}'s to be output in the else case but should be syntactically the same. Change-Id: Ie30a51efadae2034d117f4bf280b9f7abc950a23 Reviewed-on: https://pdfium-review.googlesource.com/27431 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmexpression.cpp15
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp3
2 files changed, 6 insertions, 12 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
index 638922cfd5..481b76c868 100644
--- a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
@@ -263,17 +263,10 @@ bool CXFA_FMIfExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
}
if (m_pElseExpression) {
- if (m_pElseExpression->GetExpType() == XFA_FM_EXPTYPE_IF) {
- js << L"else\n{\n";
- if (!m_pElseExpression->ToJavaScript(js, type))
- return false;
-
- js << L"}\n";
- } else {
- js << L"else\n";
- if (!m_pElseExpression->ToJavaScript(js, type))
- return false;
- }
+ js << L"else\n{\n";
+ if (!m_pElseExpression->ToJavaScript(js, type))
+ return false;
+ js << L"}\n";
}
return !CXFA_IsTooBig(js);
}
diff --git a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
index cff98531bd..458213a4a0 100644
--- a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
@@ -90,7 +90,7 @@ TEST(CXFA_FMParserTest, Parse) {
L"pfm_rt.dot_acc(border, \"border\", \"fill\", 0, 0), \"\", "
L"\"color\", 0, 0), \"\", \"value\", 0, 0), \"255,64,64\");\n"
L"}\n"
- L"}\nelse\n{\n"
+ L"}\nelse\n{\n{\n"
L"if (pfm_rt.is_obj(pfm_rt.dot_acc(pfm_rt.dot_acc(pfm_rt.dot_acc("
L"border, \"border\", \"fill\", 0, 0), \"\", \"color\", 0, 0), \"\", "
L"\"value\", 0, 0)))\n{\n"
@@ -99,6 +99,7 @@ TEST(CXFA_FMParserTest, Parse) {
L"\"color\", 0, 0), \"\", \"value\", 0, 0), \"20,170,13\");\n"
L"}\n"
L"}\n"
+ L"}\n"
L"pfm_ret = this;\n"
L"return pfm_rt.get_val(pfm_ret);\n"
L"}\n).call(this);\n";