From e76345ec2780ec13cc99b910ff78e0e3a1f87aec Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 20 Feb 2018 22:05:59 +0000 Subject: [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 Reviewed-by: Lei Zhang Reviewed-by: Ryan Harrison --- xfa/fxfa/fm2js/cxfa_fmexpression.cpp | 15 ++++----------- xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp | 3 ++- 2 files changed, 6 insertions(+), 12 deletions(-) (limited to 'xfa') 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"; -- cgit v1.2.3