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

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

Issue 2110543008: Move UndoStack from Page to Editor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use |const Member| and add notes to UndoStack class 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 74818e022a20ffb40cba3ae648826a4ca11c544f..02486c9d11fba8e53845c0e47b49e271114e3e74 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);
}
@@ -814,8 +805,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);
}
@@ -826,6 +816,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).
@@ -1060,28 +1051,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)
@@ -1434,6 +1419,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