summaryrefslogtreecommitdiff
path: root/xfa/fwl
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fwl')
-rw-r--r--xfa/fwl/cfwl_caret.cpp12
-rw-r--r--xfa/fwl/cfwl_edit.cpp19
-rw-r--r--xfa/fwl/cfwl_timer.cpp8
-rw-r--r--xfa/fwl/cfwl_timer.h4
-rw-r--r--xfa/fwl/ifwl_adaptertimermgr.h1
5 files changed, 31 insertions, 13 deletions
diff --git a/xfa/fwl/cfwl_caret.cpp b/xfa/fwl/cfwl_caret.cpp
index cd85041d92..03c8ffde68 100644
--- a/xfa/fwl/cfwl_caret.cpp
+++ b/xfa/fwl/cfwl_caret.cpp
@@ -58,17 +58,21 @@ void CFWL_Caret::DrawWidget(CXFA_Graphics* pGraphics,
}
void CFWL_Caret::ShowCaret() {
- if (m_pTimerInfo)
- m_pTimerInfo->StopTimer();
+ if (m_pTimerInfo) {
+ CFWL_TimerInfo* pOldTimerInfo = m_pTimerInfo.Release();
+ pOldTimerInfo->StopTimer();
+ }
+
m_pTimerInfo = m_pTimer->StartTimer(kFrequency, true);
RemoveStates(FWL_WGTSTATE_Invisible);
}
void CFWL_Caret::HideCaret() {
if (m_pTimerInfo) {
- m_pTimerInfo->StopTimer();
- m_pTimerInfo = nullptr;
+ CFWL_TimerInfo* pOldTimerInfo = m_pTimerInfo.Release();
+ pOldTimerInfo->StopTimer();
}
+
SetStates(FWL_WGTSTATE_Invisible);
}
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) {
diff --git a/xfa/fwl/cfwl_timer.cpp b/xfa/fwl/cfwl_timer.cpp
index 2734e49d78..597f928ba0 100644
--- a/xfa/fwl/cfwl_timer.cpp
+++ b/xfa/fwl/cfwl_timer.cpp
@@ -25,11 +25,13 @@ CFWL_TimerInfo* CFWL_Timer::StartTimer(uint32_t dwElapse, bool bImmediately) {
if (!pAdapterNative)
return nullptr;
- IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr();
- if (!pAdapterTimerMgr)
+ if (!m_pTimeMgrAdapter)
+ m_pTimeMgrAdapter.reset(pAdapterNative->GetTimerMgr());
+
+ if (!m_pTimeMgrAdapter)
return nullptr;
CFWL_TimerInfo* pTimerInfo = nullptr;
- pAdapterTimerMgr->Start(this, dwElapse, bImmediately, &pTimerInfo);
+ m_pTimeMgrAdapter->Start(this, dwElapse, bImmediately, &pTimerInfo);
return pTimerInfo;
}
diff --git a/xfa/fwl/cfwl_timer.h b/xfa/fwl/cfwl_timer.h
index da1b4437e2..355ea69d67 100644
--- a/xfa/fwl/cfwl_timer.h
+++ b/xfa/fwl/cfwl_timer.h
@@ -7,11 +7,14 @@
#ifndef XFA_FWL_CFWL_TIMER_H_
#define XFA_FWL_CFWL_TIMER_H_
+#include <memory>
+
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/unowned_ptr.h"
class CFWL_TimerInfo;
class CFWL_Widget;
+class IFWL_AdapterTimerMgr;
class CFWL_Timer {
public:
@@ -23,6 +26,7 @@ class CFWL_Timer {
protected:
UnownedPtr<CFWL_Widget> m_pWidget;
+ std::unique_ptr<IFWL_AdapterTimerMgr> m_pTimeMgrAdapter;
};
#endif // XFA_FWL_CFWL_TIMER_H_
diff --git a/xfa/fwl/ifwl_adaptertimermgr.h b/xfa/fwl/ifwl_adaptertimermgr.h
index 1f655892ea..23627d9191 100644
--- a/xfa/fwl/ifwl_adaptertimermgr.h
+++ b/xfa/fwl/ifwl_adaptertimermgr.h
@@ -11,6 +11,7 @@
class IFWL_AdapterTimerMgr {
public:
+ virtual ~IFWL_AdapterTimerMgr() {}
virtual void Start(CFWL_Timer* pTimer,
uint32_t dwElapse,
bool bImmediately,