summaryrefslogtreecommitdiff
path: root/xfa/fwl/cfwl_edit.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-02-06 21:36:45 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-06 21:36:45 +0000
commitbfeab62b37a701dc82f180e49d26c602f96f96f9 (patch)
tree114a99e1d3c0ea26f7dc15727dae0214125b4c89 /xfa/fwl/cfwl_edit.cpp
parentf3f1869409a59adbfde4b2b546f30c81051aad14 (diff)
downloadpdfium-bfeab62b37a701dc82f180e49d26c602f96f96f9.tar.xz
Fix caret not appearing in XFA Edits.
This makes the caret appear (again?), blink, and fixes its positioning to be a little spaced from the last character. Known issue: when the edit is empty, the caret is not necessarily aligned with where the text will be. Bug: chromium:592750 Change-Id: I950b0ea236db8855c6ed50f48ec1935d97e6ccf8 Reviewed-on: https://pdfium-review.googlesource.com/25451 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'xfa/fwl/cfwl_edit.cpp')
-rw-r--r--xfa/fwl/cfwl_edit.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index 960ec9967a..051c39f74e 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -79,7 +79,6 @@ CFWL_Edit::CFWL_Edit(const CFWL_App* app,
m_rtEngine.Reset();
m_rtStatic.Reset();
- InitCaret();
m_EdtEngine.SetDelegate(this);
}
@@ -1065,8 +1064,14 @@ bool CFWL_Edit::ValidateNumberChar(wchar_t cNum) {
}
void CFWL_Edit::InitCaret() {
- m_pCaret.reset();
- m_rtCaret = CFX_RectF();
+ if (m_pCaret)
+ return;
+
+ m_pCaret = pdfium::MakeUnique<CFWL_Caret>(
+ m_pOwnerApp.Get(), pdfium::MakeUnique<CFWL_WidgetProperties>(), this);
+ m_pCaret->SetParent(this);
+ m_pCaret->SetStates(m_pProperties->m_dwStates);
+ UpdateCursorRect();
}
void CFWL_Edit::UpdateCursorRect() {
@@ -1076,10 +1081,12 @@ void CFWL_Edit::UpdateCursorRect() {
m_EdtEngine.GetCharacterInfo(m_CursorPosition);
// TODO(dsinclair): This should handle bidi level ...
- if (m_rtCaret.width == 0 && m_rtCaret.left > 1.0f)
- m_rtCaret.left -= 1.0f;
-
m_rtCaret.width = 1.0f;
+
+ // TODO(hnakashima): Handle correctly edits with empty text instead of using
+ // these defaults.
+ if (m_rtCaret.height == 0)
+ m_rtCaret.height = 8.0f;
}
void CFWL_Edit::SetCursorPosition(size_t position) {