From 6af5369477ec05554ef9e73ae6762860095f09e9 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 29 May 2018 19:42:39 +0000 Subject: [xfa] Propagate the xfa change data for text to JS and back. This CL adds the necessary plumbing to propagate the change information for a text widget from FWL out to JS and handle the returned value as necessary. Bug: pdfium:1066 Change-Id: I78fd81761b90294f1836e9f09dba12ed238963cc Reviewed-on: https://pdfium-review.googlesource.com/33070 Reviewed-by: Ryan Harrison Commit-Queue: dsinclair --- xfa/fwl/cfwl_edit.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'xfa/fwl/cfwl_edit.cpp') diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index 7bdb818192..7c4f0e1607 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -19,7 +19,7 @@ #include "xfa/fwl/cfwl_app.h" #include "xfa/fwl/cfwl_caret.h" #include "xfa/fwl/cfwl_event.h" -#include "xfa/fwl/cfwl_eventtextchanged.h" +#include "xfa/fwl/cfwl_eventtextwillchange.h" #include "xfa/fwl/cfwl_eventvalidate.h" #include "xfa/fwl/cfwl_messagekey.h" #include "xfa/fwl/cfwl_messagemouse.h" @@ -171,9 +171,10 @@ void CFWL_Edit::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { m_pProperties->m_pThemeProvider = pThemeProvider; } -void CFWL_Edit::SetText(const WideString& wsText) { +void CFWL_Edit::SetText(const WideString& wsText, + CFDE_TextEditEngine::RecordOperation op) { m_EdtEngine.Clear(); - m_EdtEngine.Insert(0, wsText); + m_EdtEngine.Insert(0, wsText, op); } int32_t CFWL_Edit::GetTextLength() const { @@ -297,14 +298,26 @@ void CFWL_Edit::OnCaretChanged() { } } -void CFWL_Edit::OnTextChanged(const WideString& prevText) { - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask) - UpdateVAlignment(); +void CFWL_Edit::OnTextWillChange(CFDE_TextEditEngine::TextChange* change) { + CFWL_EventTextWillChange event(this); + event.previous_text = change->previous_text; + event.change_text = change->text; + event.selection_start = change->selection_start; + event.selection_end = change->selection_end; + event.cancelled = false; - CFWL_EventTextChanged event(this); - event.wsPrevText = prevText; DispatchEvent(&event); + change->text = event.change_text; + change->selection_start = event.selection_start; + change->selection_end = event.selection_end; + change->cancelled = event.cancelled; +} + +void CFWL_Edit::OnTextChanged() { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask) + UpdateVAlignment(); + LayoutScrollBar(); RepaintRect(GetClientRect()); } -- cgit v1.2.3