summaryrefslogtreecommitdiff
path: root/xfa/fde/cfde_texteditengine.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-04-26 20:07:20 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-26 20:07:20 +0000
commit051e837e08f52251de5932d90268d504060d12f1 (patch)
tree7bfadc142b885fb2651fb566841e10a8c3044706 /xfa/fde/cfde_texteditengine.cpp
parentea3a2529a7aa0199b385b7caa2e465c124eac8aa (diff)
downloadpdfium-051e837e08f52251de5932d90268d504060d12f1.tar.xz
Fix caret moving to next line upon click on line break in XFA edit.
Bug: chromium:836361 Change-Id: I40739a21a60610bd5ab0143629f87562ba834a0d Reviewed-on: https://pdfium-review.googlesource.com/31410 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fde/cfde_texteditengine.cpp')
-rw-r--r--xfa/fde/cfde_texteditengine.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/xfa/fde/cfde_texteditengine.cpp b/xfa/fde/cfde_texteditengine.cpp
index 989843c7f0..0157b353cf 100644
--- a/xfa/fde/cfde_texteditengine.cpp
+++ b/xfa/fde/cfde_texteditengine.cpp
@@ -941,13 +941,18 @@ size_t CFDE_TextEditEngine::GetIndexForPoint(const CFX_PointF& point) {
size_t pos = std::min(
static_cast<size_t>(start_it->nStart + start_it->nCount), text_length_);
- // The line is not the last one and it was broken right after a space, the
- // cursor should not be placed after the space, but before it. If the
- // cursor is moved after the space, it goes to the beginning of the next
- // line.
+ // If the line is not the last one and it was broken right after a breaking
+ // whitespace (space or line break), the cursor should not be placed after
+ // the whitespace, but before it. If the cursor is moved after the
+ // whitespace, it goes to the beginning of the next line.
bool is_last_line = (std::next(start_it) == text_piece_info_.end());
- if (!is_last_line && pos > 0 && GetChar(pos - 1) == L' ')
- --pos;
+ if (!is_last_line && pos > 0) {
+ wchar_t previous_char = GetChar(pos - 1);
+ if (previous_char == L' ' || previous_char == L'\n' ||
+ previous_char == L'\r') {
+ --pos;
+ }
+ }
return pos;
}