diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-08-30 12:16:16 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-30 16:26:12 +0000 |
commit | 68eefa6a6f6bbab73000a29e2cac3e104be1cc81 (patch) | |
tree | b48dbf0932022bc551ae06e2400262c203856942 /xfa/fwl/cfwl_edit.h | |
parent | aa3a9cd82df9dff1ef136797259e606a39c18b75 (diff) | |
download | pdfium-68eefa6a6f6bbab73000a29e2cac3e104be1cc81.tar.xz |
Rebuild CFDE_TextEditEngine.
This CL rebuilds the text edit engine in a simpler fashion. Instead of
depending on multiple pages, paragraphs and buffer fields there is a
single text edit engine which contains a gap buffer.
This makes the code easier to understand and follow.
Change-Id: I10fe85603fa9ed15a647eaac2d931f113cd0c7b0
Reviewed-on: https://pdfium-review.googlesource.com/11990
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fwl/cfwl_edit.h')
-rw-r--r-- | xfa/fwl/cfwl_edit.h | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/xfa/fwl/cfwl_edit.h b/xfa/fwl/cfwl_edit.h index 4a30904b0a..310cb81578 100644 --- a/xfa/fwl/cfwl_edit.h +++ b/xfa/fwl/cfwl_edit.h @@ -7,12 +7,11 @@ #ifndef XFA_FWL_CFWL_EDIT_H_ #define XFA_FWL_CFWL_EDIT_H_ -#include <deque> #include <memory> +#include <utility> #include <vector> -#include "xfa/fde/cfde_txtedtengine.h" -#include "xfa/fde/ifde_txtedtdorecord.h" +#include "xfa/fde/cfde_texteditengine.h" #include "xfa/fwl/cfwl_event.h" #include "xfa/fwl/cfwl_scrollbar.h" #include "xfa/fwl/cfwl_widget.h" @@ -39,15 +38,13 @@ #define FWL_STYLEEXT_EDT_HAlignModeMask (3L << 22) #define FWL_STYLEEXT_EDT_ShowScrollbarFocus (1L << 25) #define FWL_STYLEEXT_EDT_OuterScrollbar (1L << 26) -#define FWL_STYLEEXT_EDT_LastLineHeight (1L << 27) -class IFDE_TxtEdtDoRecord; class CFWL_Edit; class CFWL_MessageMouse; class CFWL_WidgetProperties; class CFWL_Caret; -class CFWL_Edit : public CFWL_Widget { +class CFWL_Edit : public CFWL_Widget, public CFDE_TextEditEngine::Delegate { public: CFWL_Edit(const CFWL_App* app, std::unique_ptr<CFWL_WidgetProperties> properties, @@ -74,10 +71,12 @@ class CFWL_Edit : public CFWL_Widget { CFX_WideString GetText() const; void ClearText(); - void AddSelRange(int32_t nStart); - int32_t CountSelRanges() const; - int32_t GetSelRange(int32_t nIndex, int32_t* nStart) const; - void ClearSelections(); + void SelectAll(); + void ClearSelection(); + bool HasSelection() const; + // Returns <start, end> indices of the selection. + std::pair<size_t, size_t> GetSelection() const; + int32_t GetLimit() const; void SetLimit(int32_t nLimit); void SetAliasChar(wchar_t wAlias); @@ -91,23 +90,23 @@ class CFWL_Edit : public CFWL_Widget { void SetOuter(CFWL_Widget* pOuter); - void OnCaretChanged(); - void OnTextChanged(const CFX_WideString& prevText); - void OnSelChanged(); - void OnAddDoRecord(std::unique_ptr<IFDE_TxtEdtDoRecord> pRecord); - bool OnValidate(const CFX_WideString& wsText); - void SetScrollOffset(float fScrollOffset); + // CFDE_TextEditEngine::Delegate + void NotifyTextFull() override; + void OnCaretChanged() override; + void OnTextChanged(const CFX_WideString& prevText) override; + void OnSelChanged() override; + bool OnValidate(const CFX_WideString& wsText) override; + void SetScrollOffset(float fScrollOffset) override; protected: void ShowCaret(CFX_RectF* pRect); void HideCaret(CFX_RectF* pRect); const CFX_RectF& GetRTClient() const { return m_rtClient; } - CFDE_TxtEdtEngine* GetTxtEdtEngine() { return &m_EdtEngine; } + CFDE_TextEditEngine* GetTxtEdtEngine() { return &m_EdtEngine; } private: void RenderText(CFX_RenderDevice* pRenderDev, const CFX_RectF& clipRect, - const CFDE_TxtEdtPage& pPage, const CFX_Matrix& mt); void DrawTextBk(CXFA_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, @@ -133,22 +132,21 @@ class CFWL_Edit : public CFWL_Widget { void InitEngine(); void InitCaret(); bool ValidateNumberChar(wchar_t cNum); - void ClearRecord(); bool IsShowScrollBar(bool bVert); bool IsContentHeightOverflow(); - int32_t AddDoRecord(std::unique_ptr<IFDE_TxtEdtDoRecord> pRecord); - void ProcessInsertError(FDE_EditResult iError); void AddSpellCheckObj(CXFA_Path& PathData, int32_t nStart, int32_t nCount, float fOffSetX, float fOffSetY); + void SetCursorPosition(size_t position); + void UpdateCursorRect(); void DoButtonDown(CFWL_MessageMouse* pMsg); void OnFocusChanged(CFWL_Message* pMsg, bool bSet); void OnLButtonDown(CFWL_MessageMouse* pMsg); void OnLButtonUp(CFWL_MessageMouse* pMsg); - void OnButtonDblClk(CFWL_MessageMouse* pMsg); + void OnButtonDoubleClick(CFWL_MessageMouse* pMsg); void OnMouseMove(CFWL_MessageMouse* pMsg); void OnKeyDown(CFWL_MessageKey* pMsg); void OnChar(CFWL_MessageKey* pMsg); @@ -159,12 +157,13 @@ class CFWL_Edit : public CFWL_Widget { CFX_RectF m_rtClient; CFX_RectF m_rtEngine; CFX_RectF m_rtStatic; + CFX_RectF m_rtCaret; float m_fVAlignOffset; float m_fScrollOffsetX; float m_fScrollOffsetY; - CFDE_TxtEdtEngine m_EdtEngine; + CFDE_TextEditEngine m_EdtEngine; bool m_bLButtonDown; - int32_t m_nSelStart; + size_t m_CursorPosition; int32_t m_nLimit; float m_fFontSize; bool m_bSetRange; @@ -174,9 +173,6 @@ class CFWL_Edit : public CFWL_Widget { std::unique_ptr<CFWL_Caret> m_pCaret; CFX_WideString m_wsCache; CFX_WideString m_wsFont; - std::deque<std::unique_ptr<IFDE_TxtEdtDoRecord>> m_DoRecords; - int32_t m_iCurRecord; - int32_t m_iMaxRecord; }; #endif // XFA_FWL_CFWL_EDIT_H_ |