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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 const VisibleSelection& FrameSelection::selection() const { 149 const VisibleSelection& FrameSelection::selection() const {
150 return visibleSelection<EditingStrategy>(); 150 return visibleSelection<EditingStrategy>();
151 } 151 }
152 152
153 const VisibleSelectionInFlatTree& FrameSelection::selectionInFlatTree() const { 153 const VisibleSelectionInFlatTree& FrameSelection::selectionInFlatTree() const {
154 return visibleSelection<EditingInFlatTreeStrategy>(); 154 return visibleSelection<EditingInFlatTreeStrategy>();
155 } 155 }
156 156
157 void FrameSelection::moveTo(const VisiblePosition& pos, 157 void FrameSelection::moveCaretSelection(const IntPoint& point) {
158 EUserTriggered userTriggered, 158 DCHECK(!document().needsLayoutTreeUpdate());
159 CursorAlignOnScroll align) { 159
160 SetSelectionOptions options = CloseTyping | ClearTypingStyle | userTriggered; 160 Element* const editable = rootEditableElement();
161 setSelection(createVisibleSelection(pos, pos, selection().isDirectional()), 161 if (!editable)
162 options, align); 162 return;
163
164 const VisiblePosition position =
165 visiblePositionForContentsPoint(point, frame());
166 SelectionInDOMTree::Builder builder;
167 builder.setIsDirectional(selection().isDirectional());
168 if (position.isNotNull())
169 builder.collapse(position.toPositionWithAffinity());
170 setSelection(builder.build(), CloseTyping | ClearTypingStyle | UserTriggered);
163 } 171 }
164 172
165 // TODO(xiaochengh): We should not use reference to return value. 173 // TODO(xiaochengh): We should not use reference to return value.
166 template <typename Strategy> 174 template <typename Strategy>
167 static void adjustEndpointsAtBidiBoundary( 175 static void adjustEndpointsAtBidiBoundary(
168 VisiblePositionTemplate<Strategy>& visibleBase, 176 VisiblePositionTemplate<Strategy>& visibleBase,
169 VisiblePositionTemplate<Strategy>& visibleExtent) { 177 VisiblePositionTemplate<Strategy>& visibleExtent) {
170 DCHECK(visibleBase.isValid()); 178 DCHECK(visibleBase.isValid());
171 DCHECK(visibleExtent.isValid()); 179 DCHECK(visibleExtent.isValid());
172 180
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 } 1509 }
1502 1510
1503 void showTree(const blink::FrameSelection* sel) { 1511 void showTree(const blink::FrameSelection* sel) {
1504 if (sel) 1512 if (sel)
1505 sel->showTreeForThis(); 1513 sel->showTreeForThis();
1506 else 1514 else
1507 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; 1515 LOG(INFO) << "Cannot showTree for <null> FrameSelection.";
1508 } 1516 }
1509 1517
1510 #endif 1518 #endif
OLDNEW
« 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