summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-04-26 18:28:07 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-26 18:28:07 +0000
commitf9666864254bf84ef878630bbdaaaabbecab8ba5 (patch)
tree83b0578cd45b62308f90132d533373ecfd886693
parent15bc974936fd14598214a37aafd62f29c3b42a61 (diff)
downloadpdfium-f9666864254bf84ef878630bbdaaaabbecab8ba5.tar.xz
Enter key inserts a line break correctly in XFA edits.
Bug: chromium:836361 Change-Id: I6d86ccec813f934ed2d0ab124501527d39ce535f Reviewed-on: https://pdfium-review.googlesource.com/31390 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--xfa/fde/cfde_texteditengine_unittest.cpp14
-rw-r--r--xfa/fgas/layout/cfx_txtbreak.cpp1
2 files changed, 14 insertions, 1 deletions
diff --git a/xfa/fde/cfde_texteditengine_unittest.cpp b/xfa/fde/cfde_texteditengine_unittest.cpp
index bd74868438..ab8e64078b 100644
--- a/xfa/fde/cfde_texteditengine_unittest.cpp
+++ b/xfa/fde/cfde_texteditengine_unittest.cpp
@@ -420,7 +420,7 @@ TEST_F(CFDE_TextEditEngineTest, GetIndexForPoint) {
EXPECT_EQ(1U, engine()->GetIndexForPoint({10.0f, 5.0f}));
}
-TEST_F(CFDE_TextEditEngineTest, GetIndexForPointMultiline) {
+TEST_F(CFDE_TextEditEngineTest, GetIndexForPointLineWrap) {
engine()->SetFontSize(10.0f);
engine()->Insert(0,
L"A text long enough to span multiple lines and test "
@@ -441,6 +441,18 @@ TEST_F(CFDE_TextEditEngineTest, GetIndexForPointSpaceAtEnd) {
EXPECT_EQ(12U, engine()->GetIndexForPoint({999999.0f, 0.0f}));
}
+TEST_F(CFDE_TextEditEngineTest, GetIndexForPointLineBreaks) {
+ engine()->SetFontSize(10.0f);
+ engine()->Insert(0, L"Hello\nWorld");
+ EXPECT_EQ(0U, engine()->GetIndexForPoint({0.0f, 0.0f}));
+
+ // TODO(hnakashima): Should be 5U, caret is moving to next line.
+ EXPECT_EQ(6U, engine()->GetIndexForPoint({999999.0f, 0.0f}));
+
+ EXPECT_EQ(6U, engine()->GetIndexForPoint({0.0f, 10.0f}));
+ EXPECT_EQ(11U, engine()->GetIndexForPoint({999999.0f, 9999999.0f}));
+}
+
TEST_F(CFDE_TextEditEngineTest, BoundsForWordAt) {
size_t start_idx;
size_t count;
diff --git a/xfa/fgas/layout/cfx_txtbreak.cpp b/xfa/fgas/layout/cfx_txtbreak.cpp
index ccbc6a817a..3a2929d226 100644
--- a/xfa/fgas/layout/cfx_txtbreak.cpp
+++ b/xfa/fgas/layout/cfx_txtbreak.cpp
@@ -227,6 +227,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar(wchar_t wch) {
// don't get matched as control characters so we go into AppendChar_other
// and never detect the new paragraph ...
dwRet2 = CFX_BreakType::Paragraph;
+ EndBreak(dwRet2);
} else {
switch (chartype) {
case FX_CHARTYPE_Tab: