diff options
author | Lei Zhang <thestig@chromium.org> | 2017-06-29 21:33:34 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-06-30 04:45:24 +0000 |
commit | a173900b19e158130df049dd1c31b7494baefffd (patch) | |
tree | 68a10871f738b3dca78a9341138ca5e7680d973b /xfa/fwl/cfwl_edit.cpp | |
parent | 91e39d2218c1b4e67321f845daf0fdb8d171982b (diff) | |
download | pdfium-a173900b19e158130df049dd1c31b7494baefffd.tar.xz |
Fix nits in a bunch of random XFA files.
- Simplify if (cond) return true; return false; pattern.
- Use size_t in CXFA_FFDocView::RunCalculateRecursive().
Change-Id: I1c426556bc927a118cb062999812ab06bbfcfec7
Reviewed-on: https://pdfium-review.googlesource.com/7130
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fwl/cfwl_edit.cpp')
-rw-r--r-- | xfa/fwl/cfwl_edit.cpp | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index eff76ffabf..b0d22c17c4 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -1140,34 +1140,24 @@ bool CFWL_Edit::ValidateNumberChar(wchar_t cNum) { return true; CFX_WideString wsText = m_EdtEngine.GetText(0, -1); - if (wsText.IsEmpty()) { - if (cNum == L'0') - return false; - return true; - } + if (wsText.IsEmpty()) + return cNum != L'0'; - int32_t caretPos = m_EdtEngine.GetCaretPos(); - if (CountSelRanges() == 0) { - if (cNum == L'0' && caretPos == 0) - return false; + if (CountSelRanges() != 0) + return wsText.GetInteger() <= m_iMax; - int32_t nLen = wsText.GetLength(); - CFX_WideString l = wsText.Mid(0, caretPos); - CFX_WideString r = wsText.Mid(caretPos, nLen - caretPos); - CFX_WideString wsNew = l + cNum + r; - if (wsNew.GetInteger() <= m_iMax) - return true; + int32_t caretPos = m_EdtEngine.GetCaretPos(); + if (cNum == L'0' && caretPos == 0) return false; - } - if (wsText.GetInteger() <= m_iMax) - return true; - return false; + int32_t nLen = wsText.GetLength(); + CFX_WideString l = wsText.Mid(0, caretPos); + CFX_WideString r = wsText.Mid(caretPos, nLen - caretPos); + CFX_WideString wsNew = l + cNum + r; + return wsNew.GetInteger() <= m_iMax; } void CFWL_Edit::InitCaret() { - if (!m_pCaret) - return; m_pCaret.reset(); } @@ -1233,9 +1223,7 @@ void CFWL_Edit::OnProcessMessage(CFWL_Message* pMessage) { } void CFWL_Edit::OnProcessEvent(CFWL_Event* pEvent) { - if (!pEvent) - return; - if (pEvent->GetType() != CFWL_Event::Type::Scroll) + if (!pEvent || pEvent->GetType() != CFWL_Event::Type::Scroll) return; CFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; @@ -1261,10 +1249,8 @@ void CFWL_Edit::DoButtonDown(CFWL_MessageMouse* pMsg) { return; bool bBefore = true; - int32_t nIndex = pPage->GetCharIndex(DeviceToEngine(pMsg->m_pos), bBefore); - if (nIndex < 0) - nIndex = 0; - + int32_t nIndex = + std::max(0, pPage->GetCharIndex(DeviceToEngine(pMsg->m_pos), bBefore)); m_EdtEngine.SetCaretPos(nIndex, bBefore); } |