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

Unified Diff: Source/core/editing/Editor.cpp

Issue 21030005: Editor: Deffer event dispatch after selection change. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added event order test Created 7 years, 3 months 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: Source/core/editing/Editor.cpp
diff --git a/Source/core/editing/Editor.cpp b/Source/core/editing/Editor.cpp
index 16a9e01182b7f9b580ee9dc6b4fc5fc3e114215c..f138c08248c9dc0c8a1531407c232ae6a3160a8e 100644
--- a/Source/core/editing/Editor.cpp
+++ b/Source/core/editing/Editor.cpp
@@ -41,6 +41,7 @@
#include "core/dom/KeyboardEvent.h"
#include "core/dom/NodeList.h"
#include "core/dom/NodeTraversal.h"
+#include "core/dom/ScopedEventQueue.h"
#include "core/dom/Text.h"
#include "core/dom/TextEvent.h"
#include "core/editing/ApplyStyleCommand.h"
@@ -759,15 +760,16 @@ static void dispatchEditableContentChangedEvents(PassRefPtr<Element> startRoot,
void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd)
{
+ EventQueueScope scope;
m_frame->document()->updateLayout();
EditCommandComposition* composition = cmd->composition();
ASSERT(composition);
+ dispatchEditableContentChangedEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement());
VisibleSelection newSelection(cmd->endingSelection());
// Don't clear the typing style with this selection change. We do those things elsewhere if necessary.
changeSelectionAfterCommand(newSelection, 0);
- dispatchEditableContentChangedEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement());
if (!cmd->preservesTypingStyle())
m_frame->selection().clearTypingStyle();
@@ -787,11 +789,13 @@ void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd)
void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd)
{
+ EventQueueScope scope;
m_frame->document()->updateLayout();
+ dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement());
+
VisibleSelection newSelection(cmd->startingSelection());
changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle);
- dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement());
m_lastEditCommand = 0;
client().registerRedoStep(cmd);
@@ -800,11 +804,13 @@ void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd)
void Editor::reappliedEditing(PassRefPtr<EditCommandComposition> cmd)
{
+ EventQueueScope scope;
m_frame->document()->updateLayout();
+ dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement());
+
VisibleSelection newSelection(cmd->endingSelection());
changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle);
- dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement());
m_lastEditCommand = 0;
client().registerUndoStep(cmd);

Powered by Google App Engine
This is Rietveld 408576698