summaryrefslogtreecommitdiff
path: root/xfa/fwl/cfwl_edit.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-05-29 19:42:39 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-29 19:42:39 +0000
commit6af5369477ec05554ef9e73ae6762860095f09e9 (patch)
tree0a9d28f4e3f89ca5b141954913169fdff63bf59c /xfa/fwl/cfwl_edit.cpp
parent162a31a6af1538acf7ac9835111626161287d742 (diff)
downloadpdfium-6af5369477ec05554ef9e73ae6762860095f09e9.tar.xz
[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 <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fwl/cfwl_edit.cpp')
-rw-r--r--xfa/fwl/cfwl_edit.cpp29
1 files changed, 21 insertions, 8 deletions
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());
}