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

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

Issue 2431153002: Introduce FrameSelection::moveCaretSelection() as replacement of moveTo() (Closed)
Patch Set: 2016-10-19T14:44:09 Created 4 years, 2 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/FrameSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.cpp b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
index df3a10d601da448046f48b3ae3b1b655a928d5b2..d300915e5f6cd1b7ab257ea71f236d71d8a6a250 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
@@ -154,12 +154,20 @@ const VisibleSelectionInFlatTree& FrameSelection::selectionInFlatTree() const {
return visibleSelection<EditingInFlatTreeStrategy>();
}
-void FrameSelection::moveTo(const VisiblePosition& pos,
- EUserTriggered userTriggered,
- CursorAlignOnScroll align) {
- SetSelectionOptions options = CloseTyping | ClearTypingStyle | userTriggered;
- setSelection(createVisibleSelection(pos, pos, selection().isDirectional()),
- options, align);
+void FrameSelection::moveCaretSelection(const IntPoint& point) {
+ DCHECK(!document().needsLayoutTreeUpdate());
+
+ Element* const editable = rootEditableElement();
+ if (!editable)
+ return;
+
+ const VisiblePosition position =
+ visiblePositionForContentsPoint(point, frame());
+ SelectionInDOMTree::Builder builder;
+ builder.setIsDirectional(selection().isDirectional());
+ if (position.isNotNull())
+ builder.collapse(position.toPositionWithAffinity());
+ setSelection(builder.build(), CloseTyping | ClearTypingStyle | UserTriggered);
}
// TODO(xiaochengh): We should not use reference to return value.
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.h ('k') | third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698