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

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

Issue 2720063002: Make Editor::changeSelectionAfterCommand take SelectionInDOMTree (Closed)
Patch Set: Rebased Created 3 years, 10 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/Editor.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/Editor.cpp
diff --git a/third_party/WebKit/Source/core/editing/Editor.cpp b/third_party/WebKit/Source/core/editing/Editor.cpp
index 06c5d14c9e91215e653b65b61d04f7dcc6c8cdae..4de5568a138a5f770356612757342d7cd394927f 100644
--- a/third_party/WebKit/Source/core/editing/Editor.cpp
+++ b/third_party/WebKit/Source/core/editing/Editor.cpp
@@ -866,6 +866,15 @@ static void dispatchEditableContentChangedEvents(Element* startRoot,
Event::create(EventTypeNames::webkitEditableContentChanged));
}
+static VisibleSelection correctedVisibleSelection(
yosin_UTC9 2017/03/01 01:20:39 It seems you need to rebase. Patch[1] did this cha
Xiaocheng 2017/03/01 01:41:23 No need to rebase. This patch removes this functi
yosin_UTC9 2017/03/01 01:44:01 Oops. I see.
+ const VisibleSelection& passedSelection) {
+ if (!passedSelection.base().isConnected() ||
+ !passedSelection.extent().isConnected())
+ return VisibleSelection();
+ DCHECK(!passedSelection.base().document()->needsLayoutTreeUpdate());
+ return createVisibleSelection(passedSelection.asSelection());
+}
+
void Editor::appliedEditing(CompositeEditCommand* cmd) {
DCHECK(!cmd->isCommandGroupWrapper());
EventQueueScope scope;
@@ -890,11 +899,12 @@ void Editor::appliedEditing(CompositeEditCommand* cmd) {
// selection canonicalization so that selection update does not need layout.
frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
- VisibleSelection newSelection(cmd->endingSelection());
+ const VisibleSelection& newSelection =
+ correctedVisibleSelection(cmd->endingSelection());
// Don't clear the typing style with this selection change. We do those things
// elsewhere if necessary.
- changeSelectionAfterCommand(newSelection, 0);
+ changeSelectionAfterCommand(newSelection.asSelection(), 0);
if (!cmd->preservesTypingStyle())
clearTypingStyle();
@@ -919,15 +929,6 @@ void Editor::appliedEditing(CompositeEditCommand* cmd) {
respondToChangedContents(newSelection.start());
}
-static VisibleSelection correctedVisibleSelection(
- const VisibleSelection& passedSelection) {
- if (!passedSelection.base().isConnected() ||
- !passedSelection.extent().isConnected())
- return VisibleSelection();
- DCHECK(!passedSelection.base().document()->needsLayoutTreeUpdate());
- return createVisibleSelection(passedSelection.asSelection());
-}
-
void Editor::unappliedEditing(UndoStep* cmd) {
EventQueueScope scope;
@@ -947,11 +948,9 @@ void Editor::unappliedEditing(UndoStep* cmd) {
const VisibleSelection& newSelection =
correctedVisibleSelection(cmd->startingSelection());
DCHECK(newSelection.isValidFor(*frame().document())) << newSelection;
- if (!newSelection.isNone()) {
- changeSelectionAfterCommand(
- newSelection,
- FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle);
- }
+ changeSelectionAfterCommand(
+ newSelection.asSelection(),
+ FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle);
m_lastEditCommand = nullptr;
m_undoStack->registerRedoStep(cmd);
@@ -976,11 +975,9 @@ void Editor::reappliedEditing(UndoStep* cmd) {
const VisibleSelection& newSelection =
correctedVisibleSelection(cmd->endingSelection());
DCHECK(newSelection.isValidFor(*frame().document())) << newSelection;
- if (!newSelection.isNone()) {
- changeSelectionAfterCommand(
- newSelection,
- FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle);
- }
+ changeSelectionAfterCommand(
+ newSelection.asSelection(),
+ FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle);
m_lastEditCommand = nullptr;
m_undoStack->registerUndoStep(cmd);
@@ -1412,17 +1409,15 @@ void Editor::addToKillRing(const EphemeralRange& range) {
}
void Editor::changeSelectionAfterCommand(
- const VisibleSelection& newSelection,
+ const SelectionInDOMTree& newSelection,
FrameSelection::SetSelectionOptions options) {
- // If the new selection is orphaned, then don't update the selection.
- if (newSelection.start().isOrphan() || newSelection.end().isOrphan())
+ if (newSelection.isNone())
return;
// See <rdar://problem/5729315> Some shouldChangeSelectedDOMRange contain
// Ranges for selections that are no longer valid
bool selectionDidNotChangeDOMPosition =
- newSelection ==
- frame().selection().computeVisibleSelectionInDOMTreeDeprecated();
+ newSelection == frame().selection().selectionInDOMTree();
frame().selection().setSelection(newSelection, options);
// Some editing operations change the selection visually without affecting its
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698