Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp

Issue 2581073003: [Editing] Introduce |EditCommandComposition::willUn/Reapply()| in prepare for 'beforeinput' (2/3) (Closed)
Patch Set: xiaocheng's review: Add TODO for implementation Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
index 8e9f33a1e1d1e1348aee20a445f9137a3502cd4a..ee81dce271d7319aab59e5652f6a218db8f031a0 100644
--- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
@@ -105,11 +105,14 @@ bool EditCommandComposition::belongsTo(const LocalFrame& frame) const {
return m_document->frame() == &frame;
}
-void EditCommandComposition::unapply() {
+void EditCommandComposition::unapply(EditCommandSource source) {
DCHECK(m_document);
LocalFrame* frame = m_document->frame();
DCHECK(frame);
+ if (!willUnapply(source))
+ return;
+
// Changes to the document may have been made since the last editing operation
// that require a layout, as in <rdar://problem/5658603>. Low level
// operations, like RemoveNodeCommand, don't require a layout because the high
@@ -126,11 +129,14 @@ void EditCommandComposition::unapply() {
frame->editor().unappliedEditing(this);
}
-void EditCommandComposition::reapply() {
+void EditCommandComposition::reapply(EditCommandSource source) {
DCHECK(m_document);
LocalFrame* frame = m_document->frame();
DCHECK(frame);
+ if (!willReapply(source))
+ return;
+
// Changes to the document may have been made since the last editing operation
// that require a layout, as in <rdar://problem/5658603>. Low level
// operations, like RemoveNodeCommand, don't require a layout because the high
@@ -146,6 +152,16 @@ void EditCommandComposition::reapply() {
frame->editor().reappliedEditing(this);
}
+bool EditCommandComposition::willUnapply(EditCommandSource) {
+ // TODO(chongz): Fire 'beforeinput' for 'historyUndo'.
+ return true;
+}
+
+bool EditCommandComposition::willReapply(EditCommandSource) {
+ // TODO(chongz): Fire 'beforeinput' for 'historyRedo'.
+ return true;
+}
+
InputEvent::InputType EditCommandComposition::inputType() const {
return m_inputType;
}

Powered by Google App Engine
This is Rietveld 408576698