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

Side by Side Diff: third_party/WebKit/Source/core/editing/FrameSelection.cpp

Issue 2664253002: Revert "Blink handle selection handle visibility" (Closed)
Patch Set: 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 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 Element* const editable = rootEditableElement(); 162 Element* const editable = rootEditableElement();
163 if (!editable) 163 if (!editable)
164 return; 164 return;
165 165
166 const VisiblePosition position = 166 const VisiblePosition position =
167 visiblePositionForContentsPoint(point, frame()); 167 visiblePositionForContentsPoint(point, frame());
168 SelectionInDOMTree::Builder builder; 168 SelectionInDOMTree::Builder builder;
169 builder.setIsDirectional(selection().isDirectional()); 169 builder.setIsDirectional(selection().isDirectional());
170 if (position.isNotNull()) 170 if (position.isNotNull())
171 builder.collapse(position.toPositionWithAffinity()); 171 builder.collapse(position.toPositionWithAffinity());
172 setSelection(builder.build(), 172 setSelection(builder.build(), CloseTyping | ClearTypingStyle | UserTriggered);
173 CloseTyping | ClearTypingStyle | UserTriggered | HandleVisible);
174 } 173 }
175 174
176 template <typename Strategy> 175 template <typename Strategy>
177 void FrameSelection::setSelectionAlgorithm( 176 void FrameSelection::setSelectionAlgorithm(
178 const VisibleSelectionTemplate<Strategy>& newSelection, 177 const VisibleSelectionTemplate<Strategy>& newSelection,
179 SetSelectionOptions options, 178 SetSelectionOptions options,
180 CursorAlignOnScroll align, 179 CursorAlignOnScroll align,
181 TextGranularity granularity) { 180 TextGranularity granularity) {
182 DCHECK(isAvailable()); 181 DCHECK(isAvailable());
183 DCHECK(newSelection.isValidFor(document())); 182 DCHECK(newSelection.isValidFor(document()));
184 const Document& currentDocument = document(); 183 const Document& currentDocument = document();
185 if (m_granularityStrategy && 184 if (m_granularityStrategy &&
186 (options & FrameSelection::DoNotClearStrategy) == 0) 185 (options & FrameSelection::DoNotClearStrategy) == 0)
187 m_granularityStrategy->Clear(); 186 m_granularityStrategy->Clear();
188 bool closeTyping = options & CloseTyping; 187 bool closeTyping = options & CloseTyping;
189 bool shouldClearTypingStyle = options & ClearTypingStyle; 188 bool shouldClearTypingStyle = options & ClearTypingStyle;
190 const HandleVisibility handleVisibility = options & HandleVisible
191 ? HandleVisibility::Visible
192 : HandleVisibility::NotVisible;
193 EUserTriggered userTriggered = selectionOptionsToUserTriggered(options); 189 EUserTriggered userTriggered = selectionOptionsToUserTriggered(options);
194 190
195 // TODO(editing-dev): We should rename variable |s| to another name to avoid 191 // TODO(editing-dev): We should rename variable |s| to another name to avoid
196 // using one letter variable name. 192 // using one letter variable name.
197 VisibleSelectionTemplate<Strategy> s = newSelection; 193 VisibleSelectionTemplate<Strategy> s = newSelection;
198 if (shouldAlwaysUseDirectionalSelection(m_frame)) 194 if (shouldAlwaysUseDirectionalSelection(m_frame))
199 s.setIsDirectional(true); 195 s.setIsDirectional(true);
200 196
201 m_granularity = granularity; 197 m_granularity = granularity;
202 198
203 // TODO(yosin): We should move to call |TypingCommand::closeTyping()| to 199 // TODO(yosin): We should move to call |TypingCommand::closeTyping()| to
204 // |Editor| class. 200 // |Editor| class.
205 if (closeTyping) 201 if (closeTyping)
206 TypingCommand::closeTyping(m_frame); 202 TypingCommand::closeTyping(m_frame);
207 203
208 if (shouldClearTypingStyle) 204 if (shouldClearTypingStyle)
209 clearTypingStyle(); 205 clearTypingStyle();
210 206
211 if (m_selectionEditor->visibleSelection<Strategy>() == s && 207 if (m_selectionEditor->visibleSelection<Strategy>() == s) {
212 m_handleVisibility == handleVisibility) {
213 // Even if selection was not changed, selection offsets may have been 208 // Even if selection was not changed, selection offsets may have been
214 // changed. 209 // changed.
215 m_frame->inputMethodController().cancelCompositionIfSelectionIsInvalid(); 210 m_frame->inputMethodController().cancelCompositionIfSelectionIsInvalid();
216 notifyLayoutObjectOfSelectionChange(userTriggered); 211 notifyLayoutObjectOfSelectionChange(userTriggered);
217 return; 212 return;
218 } 213 }
219 214
220 const VisibleSelectionTemplate<Strategy> oldSelection = 215 const VisibleSelectionTemplate<Strategy> oldSelection =
221 visibleSelection<Strategy>(); 216 visibleSelection<Strategy>();
222 const Position& oldSelectionStart = selection().start(); 217 const Position& oldSelectionStart = selection().start();
223 218
224 m_handleVisibility = handleVisibility;
225 m_selectionEditor->setVisibleSelection(s, options); 219 m_selectionEditor->setVisibleSelection(s, options);
226 m_frameCaret->setCaretRectNeedsUpdate(); 220 m_frameCaret->setCaretRectNeedsUpdate();
227 221
228 if (!s.isNone() && !(options & DoNotSetFocus)) { 222 if (!s.isNone() && !(options & DoNotSetFocus)) {
229 setFocusedNodeIfNeeded(); 223 setFocusedNodeIfNeeded();
230 // |setFocusedNodeIfNeeded()| dispatches sync events "FocusOut" and 224 // |setFocusedNodeIfNeeded()| dispatches sync events "FocusOut" and
231 // "FocusIn", |m_frame| may associate to another document. 225 // "FocusIn", |m_frame| may associate to another document.
232 if (!isAvailable() || document() != currentDocument) { 226 if (!isAvailable() || document() != currentDocument) {
233 // Once we get test case to reach here, we should change this 227 // Once we get test case to reach here, we should change this
234 // if-statement to |DCHECK()|. 228 // if-statement to |DCHECK()|.
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 } 1340 }
1347 1341
1348 void FrameSelection::moveRangeSelectionExtent(const IntPoint& contentsPoint) { 1342 void FrameSelection::moveRangeSelectionExtent(const IntPoint& contentsPoint) {
1349 if (isNone()) 1343 if (isNone())
1350 return; 1344 return;
1351 1345
1352 VisibleSelection newSelection = 1346 VisibleSelection newSelection =
1353 granularityStrategy()->updateExtent(contentsPoint, m_frame); 1347 granularityStrategy()->updateExtent(contentsPoint, m_frame);
1354 setSelection(newSelection, 1348 setSelection(newSelection,
1355 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | 1349 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle |
1356 FrameSelection::DoNotClearStrategy | UserTriggered | 1350 FrameSelection::DoNotClearStrategy | UserTriggered,
1357 FrameSelection::HandleVisible,
1358 CursorAlignOnScroll::IfNeeded, CharacterGranularity); 1351 CursorAlignOnScroll::IfNeeded, CharacterGranularity);
1359 } 1352 }
1360 1353
1361 // TODO(yosin): We should make |FrameSelection::moveRangeSelection()| to take 1354 // TODO(yosin): We should make |FrameSelection::moveRangeSelection()| to take
1362 // two |IntPoint| instead of two |VisiblePosition| like 1355 // two |IntPoint| instead of two |VisiblePosition| like
1363 // |moveRangeSelectionExtent()|. 1356 // |moveRangeSelectionExtent()|.
1364 void FrameSelection::moveRangeSelection(const VisiblePosition& basePosition, 1357 void FrameSelection::moveRangeSelection(const VisiblePosition& basePosition,
1365 const VisiblePosition& extentPosition, 1358 const VisiblePosition& extentPosition,
1366 TextGranularity granularity) { 1359 TextGranularity granularity) {
1367 VisibleSelection newSelection = createVisibleSelection( 1360 VisibleSelection newSelection = createVisibleSelection(
1368 SelectionInDOMTree::Builder() 1361 SelectionInDOMTree::Builder()
1369 .setBaseAndExtentDeprecated(basePosition.deepEquivalent(), 1362 .setBaseAndExtentDeprecated(basePosition.deepEquivalent(),
1370 extentPosition.deepEquivalent()) 1363 extentPosition.deepEquivalent())
1371 .setAffinity(basePosition.affinity()) 1364 .setAffinity(basePosition.affinity())
1372 .setGranularity(granularity) 1365 .setGranularity(granularity)
1373 .build()); 1366 .build());
1374 1367
1375 if (newSelection.isNone()) 1368 if (newSelection.isNone())
1376 return; 1369 return;
1377 1370
1378 SetSelectionOptions options = CloseTyping | ClearTypingStyle; 1371 setSelection(newSelection, CloseTyping | ClearTypingStyle,
1379 if (isHandleVisible()) 1372 CursorAlignOnScroll::IfNeeded, granularity);
1380 options |= HandleVisible;
1381 setSelection(newSelection, options, CursorAlignOnScroll::IfNeeded,
1382 granularity);
1383 } 1373 }
1384 1374
1385 void FrameSelection::updateIfNeeded() { 1375 void FrameSelection::updateIfNeeded() {
1386 DCHECK(!m_frame->document()->needsLayoutTreeUpdate()); 1376 DCHECK(!m_frame->document()->needsLayoutTreeUpdate());
1387 m_selectionEditor->updateIfNeeded(); 1377 m_selectionEditor->updateIfNeeded();
1388 } 1378 }
1389 1379
1390 void FrameSelection::setCaretVisible(bool caretIsVisible) { 1380 void FrameSelection::setCaretVisible(bool caretIsVisible) {
1391 m_frameCaret->setCaretVisibility(caretIsVisible ? CaretVisibility::Visible 1381 m_frameCaret->setCaretVisibility(caretIsVisible ? CaretVisibility::Visible
1392 : CaretVisibility::Hidden); 1382 : CaretVisibility::Hidden);
(...skipping 28 matching lines...) Expand all
1421 } 1411 }
1422 1412
1423 void showTree(const blink::FrameSelection* sel) { 1413 void showTree(const blink::FrameSelection* sel) {
1424 if (sel) 1414 if (sel)
1425 sel->showTreeForThis(); 1415 sel->showTreeForThis();
1426 else 1416 else
1427 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; 1417 LOG(INFO) << "Cannot showTree for <null> FrameSelection.";
1428 } 1418 }
1429 1419
1430 #endif 1420 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.h ('k') | third_party/WebKit/Source/core/editing/SelectionController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698