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

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

Issue 2645453002: Move EditCommand::starting/endingSelection() to CompositeEditCommand (2/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 | « no previous file | third_party/WebKit/Source/core/editing/commands/EditCommand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 285830eacb088698b646a4302f72c5de898f230f..dc6c3c3787a3f4ee481c8ce7e800ef2a9126e854 100644
--- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
@@ -1933,6 +1933,53 @@ Node* CompositeEditCommand::splitTreeToNode(Node* start,
return node;
}
+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->parent() || command->parent()->isFirstCommand(command))
+ break;
+ }
+}
+
+// TODO(yosin): We will make |SelectionInDOMTree| version of
+// |setEndingSelection()| as primary function instead of wrapper, once
+// |EditCommand| holds other than |VisibleSelection|.
+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.
+ document().updateStyleAndLayoutIgnorePendingStylesheets();
+ setEndingVisibleSelection(createVisibleSelection(selection));
+}
+
+// TODO(yosin): We will make |SelectionInDOMTree| version of
+// |setEndingSelection()| as primary function instead of wrapper.
+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);
+ }
+ command->m_endingSelection = selection;
+ }
+}
+
+void CompositeEditCommand::setParent(CompositeEditCommand* parent) {
+ EditCommand::setParent(parent);
+ if (parent) {
yosin_UTC9 2017/01/18 12:17:02 nit: let's use early return pattern to avoid inden
Xiaocheng 2017/01/18 22:21:07 Done.
+ m_startingSelection = parent->m_endingSelection;
+ m_endingSelection = parent->m_endingSelection;
+ }
+}
+
DEFINE_TRACE(CompositeEditCommand) {
visitor->trace(m_commands);
visitor->trace(m_startingSelection);
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/commands/EditCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698