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

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

Issue 2641803002: Move EditCommand::starting/endingSelection() to CompositeEditCommand (1/2) (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/EditCommand.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/commands/EditCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/EditCommand.cpp b/third_party/WebKit/Source/core/editing/commands/EditCommand.cpp
index 1f630a5c8f2f8ba5684c591ce7699cdc4337ddf0..a8e51ac6720f6b80e1631ebe254d1332dde8038e 100644
--- a/third_party/WebKit/Source/core/editing/commands/EditCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/EditCommand.cpp
@@ -38,8 +38,6 @@ EditCommand::EditCommand(Document& document)
: m_document(&document), m_parent(nullptr) {
DCHECK(m_document);
DCHECK(m_document->frame());
- setStartingSelection(m_document->frame()->selection().selection());
- setEndingVisibleSelection(m_startingSelection);
}
EditCommand::~EditCommand() {}
@@ -52,28 +50,26 @@ String EditCommand::textDataForInputEvent() const {
return nullAtom;
}
-static inline UndoStep* undoStepIfPossible(EditCommand* command) {
- if (!command->isCompositeEditCommand())
- return 0;
- return toCompositeEditCommand(command)->undoStep();
-}
-
-void EditCommand::setStartingSelection(const VisibleSelection& selection) {
- for (EditCommand* command = this;; command = command->m_parent) {
- if (UndoStep* undoStep = undoStepIfPossible(command)) {
+// TODO(xiaochengh): Move it to CompositeEditCommand.cpp
+void CompositeEditCommand::setStartingSelection(
+ const VisibleSelection& selection) {
+ for (CompositeEditCommand* command = this;; command = command->parent()) {
+ if (UndoStep* undoStep = command->undoStep()) {
DCHECK(command->isTopLevelCommand());
undoStep->setStartingSelection(selection);
}
command->m_startingSelection = selection;
- if (!command->m_parent || command->m_parent->isFirstCommand(command))
+ if (!command->parent() || command->parent()->isFirstCommand(command))
break;
}
}
+// TODO(xiaochengh): Move it to CompositeEditCommand.cpp
// TODO(yosin): We will make |SelectionInDOMTree| version of
// |setEndingSelection()| as primary function instead of wrapper, once
// |EditCommand| holds other than |VisibleSelection|.
-void EditCommand::setEndingSelection(const SelectionInDOMTree& selection) {
+void CompositeEditCommand::setEndingSelection(
+ const SelectionInDOMTree& selection) {
// TODO(editing-dev): The use of
// updateStyleAndLayoutIgnorePendingStylesheets
// needs to be audited. See http://crbug.com/590369 for more details.
@@ -81,11 +77,14 @@ void EditCommand::setEndingSelection(const SelectionInDOMTree& selection) {
setEndingVisibleSelection(createVisibleSelection(selection));
}
+// TODO(xiaochengh): Move it to CompositeEditCommand.cpp
// TODO(yosin): We will make |SelectionInDOMTree| version of
// |setEndingSelection()| as primary function instead of wrapper.
-void EditCommand::setEndingVisibleSelection(const VisibleSelection& selection) {
- for (EditCommand* command = this; command; command = command->m_parent) {
- if (UndoStep* undoStep = undoStepIfPossible(command)) {
+void CompositeEditCommand::setEndingVisibleSelection(
+ const VisibleSelection& selection) {
+ for (CompositeEditCommand* command = this; command;
+ command = command->parent()) {
+ if (UndoStep* undoStep = command->undoStep()) {
DCHECK(command->isTopLevelCommand());
undoStep->setEndingSelection(selection);
}
@@ -113,6 +112,11 @@ void EditCommand::setParent(CompositeEditCommand* parent) {
DCHECK(!parent || !isCompositeEditCommand() ||
!toCompositeEditCommand(this)->undoStep());
m_parent = parent;
+}
+
+// TODO(xiaochengh): Move it to CompositeEditCommand.cpp
+void CompositeEditCommand::setParent(CompositeEditCommand* parent) {
+ EditCommand::setParent(parent);
if (parent) {
m_startingSelection = parent->m_endingSelection;
m_endingSelection = parent->m_endingSelection;
@@ -126,8 +130,6 @@ void SimpleEditCommand::doReapply() {
DEFINE_TRACE(EditCommand) {
visitor->trace(m_document);
- visitor->trace(m_startingSelection);
- visitor->trace(m_endingSelection);
visitor->trace(m_parent);
}
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/EditCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698