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

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

Issue 2124723002: Reland of "Move UndoStack from Page to Editor" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hide UndoStack::clear in Editor::clear Created 4 years, 5 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: third_party/WebKit/Source/core/editing/Editor.cpp
diff --git a/third_party/WebKit/Source/core/editing/Editor.cpp b/third_party/WebKit/Source/core/editing/Editor.cpp
index 07e3fc167a377e360d0d2e73b9571f722364a9ae..caf368c34c9d588ac014c05f9b54c5fa75ba66ad 100644
--- a/third_party/WebKit/Source/core/editing/Editor.cpp
+++ b/third_party/WebKit/Source/core/editing/Editor.cpp
@@ -206,13 +206,6 @@ EditorClient& Editor::client() const
return emptyEditorClient();
}
-UndoStack* Editor::undoStack() const
-{
- if (Page* page = frame().page())
- return &page->undoStack();
- return 0;
-}
-
bool Editor::handleTextEvent(TextEvent* event)
{
// Default event handling for Drag and Drop will be handled by DragController
@@ -776,8 +769,7 @@ void Editor::appliedEditing(CompositeEditCommand* cmd)
// Only register a new undo command if the command passed in is
// different from the last command
m_lastEditCommand = cmd;
- if (UndoStack* undoStack = this->undoStack())
- undoStack->registerUndoStep(m_lastEditCommand->ensureComposition());
+ m_undoStack->registerUndoStep(m_lastEditCommand->ensureComposition());
}
respondToChangedContents(newSelection);
@@ -797,8 +789,7 @@ void Editor::unappliedEditing(EditCommandComposition* cmd)
changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle);
m_lastEditCommand = nullptr;
- if (UndoStack* undoStack = this->undoStack())
- undoStack->registerRedoStep(cmd);
+ m_undoStack->registerRedoStep(cmd);
respondToChangedContents(newSelection);
}
@@ -820,8 +811,7 @@ void Editor::reappliedEditing(EditCommandComposition* cmd)
changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle);
m_lastEditCommand = nullptr;
- if (UndoStack* undoStack = this->undoStack())
- undoStack->registerUndoStep(cmd);
+ m_undoStack->registerUndoStep(cmd);
respondToChangedContents(newSelection);
}
@@ -832,6 +822,7 @@ Editor* Editor::create(LocalFrame& frame)
Editor::Editor(LocalFrame& frame)
: m_frame(&frame)
+ , m_undoStack(UndoStack::create())
, m_preventRevealSelection(0)
, m_shouldStartNewKillRingSequence(false)
// This is off by default, since most editors want this behavior (this matches IE but not FF).
@@ -852,6 +843,7 @@ void Editor::clear()
frame().inputMethodController().clear();
m_shouldStyleWithCSS = false;
m_defaultParagraphSeparator = EditorParagraphSeparatorIsDiv;
+ m_undoStack->clear();
}
bool Editor::insertText(const String& text, KeyboardEvent* triggeringEvent)
@@ -1066,28 +1058,22 @@ void Editor::copyImage(const HitTestResult& result)
bool Editor::canUndo()
{
- if (UndoStack* undoStack = this->undoStack())
- return undoStack->canUndo();
- return false;
+ return m_undoStack->canUndo();
}
void Editor::undo()
{
- if (UndoStack* undoStack = this->undoStack())
- undoStack->undo();
+ m_undoStack->undo();
}
bool Editor::canRedo()
{
- if (UndoStack* undoStack = this->undoStack())
- return undoStack->canRedo();
- return false;
+ return m_undoStack->canRedo();
}
void Editor::redo()
{
- if (UndoStack* undoStack = this->undoStack())
- undoStack->redo();
+ m_undoStack->redo();
}
void Editor::setBaseWritingDirection(WritingDirection direction)
@@ -1440,6 +1426,7 @@ DEFINE_TRACE(Editor)
{
visitor->trace(m_frame);
visitor->trace(m_lastEditCommand);
+ visitor->trace(m_undoStack);
visitor->trace(m_mark);
}
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.h ('k') | third_party/WebKit/Source/core/editing/commands/UndoStack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698