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

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

Issue 2642913003: Select All should show handles if they were already present (Closed)
Patch Set: forgot to change enum name in test 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 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(),
173 CloseTyping | ClearTypingStyle | UserTriggered | HandleVisible); 173 CloseTyping | ClearTypingStyle | UserTriggered | ShowHandle);
174 } 174 }
175 175
176 template <typename Strategy> 176 template <typename Strategy>
177 void FrameSelection::setSelectionAlgorithm( 177 void FrameSelection::setSelectionAlgorithm(
178 const VisibleSelectionTemplate<Strategy>& newSelection, 178 const VisibleSelectionTemplate<Strategy>& newSelection,
179 SetSelectionOptions options, 179 SetSelectionOptions options,
180 CursorAlignOnScroll align, 180 CursorAlignOnScroll align,
181 TextGranularity granularity) { 181 TextGranularity granularity) {
182 DCHECK(isAvailable()); 182 DCHECK(isAvailable());
183 DCHECK(newSelection.isValidFor(document())); 183 DCHECK(newSelection.isValidFor(document()));
184 const Document& currentDocument = document(); 184 const Document& currentDocument = document();
185 if (m_granularityStrategy && 185 if (m_granularityStrategy &&
186 (options & FrameSelection::DoNotClearStrategy) == 0) 186 (options & FrameSelection::DoNotClearStrategy) == 0)
187 m_granularityStrategy->Clear(); 187 m_granularityStrategy->Clear();
188 bool closeTyping = options & CloseTyping; 188 bool closeTyping = options & CloseTyping;
189 bool shouldClearTypingStyle = options & ClearTypingStyle; 189 bool shouldClearTypingStyle = options & ClearTypingStyle;
190 const HandleVisibility handleVisibility = options & HandleVisible 190 bool showHandle = options & ShowHandle;
191 ? HandleVisibility::Visible 191 bool preserveHandle = options & PreserveHandle;
192 : HandleVisibility::NotVisible; 192 DCHECK(!(showHandle && preserveHandle));
193 const HandleVisibility handleVisibility =
194 showHandle || (preserveHandle && isHandleVisible())
195 ? HandleVisibility::Visible
196 : HandleVisibility::NotVisible;
193 EUserTriggered userTriggered = selectionOptionsToUserTriggered(options); 197 EUserTriggered userTriggered = selectionOptionsToUserTriggered(options);
194 198
195 // TODO(editing-dev): We should rename variable |s| to another name to avoid 199 // TODO(editing-dev): We should rename variable |s| to another name to avoid
196 // using one letter variable name. 200 // using one letter variable name.
197 VisibleSelectionTemplate<Strategy> s = newSelection; 201 VisibleSelectionTemplate<Strategy> s = newSelection;
198 if (shouldAlwaysUseDirectionalSelection(m_frame)) 202 if (shouldAlwaysUseDirectionalSelection(m_frame))
199 s.setIsDirectional(true); 203 s.setIsDirectional(true);
200 204
201 m_granularity = granularity; 205 m_granularity = granularity;
202 206
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 if (selectStartTarget) { 910 if (selectStartTarget) {
907 const Document& expectedDocument = document(); 911 const Document& expectedDocument = document();
908 if (selectStartTarget->dispatchEvent(Event::createCancelableBubble( 912 if (selectStartTarget->dispatchEvent(Event::createCancelableBubble(
909 EventTypeNames::selectstart)) != DispatchEventResult::NotCanceled) 913 EventTypeNames::selectstart)) != DispatchEventResult::NotCanceled)
910 return; 914 return;
911 // |root| may be detached due to selectstart event. 915 // |root| may be detached due to selectstart event.
912 if (!root->isConnected() || expectedDocument != root->document()) 916 if (!root->isConnected() || expectedDocument != root->document())
913 return; 917 return;
914 } 918 }
915 919
916 setSelection(SelectionInDOMTree::Builder().selectAllChildren(*root).build()); 920 setSelection(SelectionInDOMTree::Builder().selectAllChildren(*root).build(),
921 CloseTyping | ClearTypingStyle | PreserveHandle);
917 selectFrameElementInParentIfFullySelected(); 922 selectFrameElementInParentIfFullySelected();
918 notifyLayoutObjectOfSelectionChange(UserTriggered); 923 notifyLayoutObjectOfSelectionChange(UserTriggered);
919 } 924 }
920 925
921 bool FrameSelection::setSelectedRange(const EphemeralRange& range, 926 bool FrameSelection::setSelectedRange(const EphemeralRange& range,
922 TextAffinity affinity, 927 TextAffinity affinity,
923 SelectionDirectionalMode directional, 928 SelectionDirectionalMode directional,
924 SetSelectionOptions options) { 929 SetSelectionOptions options) {
925 if (range.isNull()) 930 if (range.isNull())
926 return false; 931 return false;
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 1352
1348 void FrameSelection::moveRangeSelectionExtent(const IntPoint& contentsPoint) { 1353 void FrameSelection::moveRangeSelectionExtent(const IntPoint& contentsPoint) {
1349 if (isNone()) 1354 if (isNone())
1350 return; 1355 return;
1351 1356
1352 VisibleSelection newSelection = 1357 VisibleSelection newSelection =
1353 granularityStrategy()->updateExtent(contentsPoint, m_frame); 1358 granularityStrategy()->updateExtent(contentsPoint, m_frame);
1354 setSelection(newSelection, 1359 setSelection(newSelection,
1355 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | 1360 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle |
1356 FrameSelection::DoNotClearStrategy | UserTriggered | 1361 FrameSelection::DoNotClearStrategy | UserTriggered |
1357 FrameSelection::HandleVisible, 1362 FrameSelection::ShowHandle,
1358 CursorAlignOnScroll::IfNeeded, CharacterGranularity); 1363 CursorAlignOnScroll::IfNeeded, CharacterGranularity);
1359 } 1364 }
1360 1365
1361 // TODO(yosin): We should make |FrameSelection::moveRangeSelection()| to take 1366 // TODO(yosin): We should make |FrameSelection::moveRangeSelection()| to take
1362 // two |IntPoint| instead of two |VisiblePosition| like 1367 // two |IntPoint| instead of two |VisiblePosition| like
1363 // |moveRangeSelectionExtent()|. 1368 // |moveRangeSelectionExtent()|.
1364 void FrameSelection::moveRangeSelection(const VisiblePosition& basePosition, 1369 void FrameSelection::moveRangeSelection(const VisiblePosition& basePosition,
1365 const VisiblePosition& extentPosition, 1370 const VisiblePosition& extentPosition,
1366 TextGranularity granularity) { 1371 TextGranularity granularity) {
1367 VisibleSelection newSelection = createVisibleSelection( 1372 VisibleSelection newSelection = createVisibleSelection(
1368 SelectionInDOMTree::Builder() 1373 SelectionInDOMTree::Builder()
1369 .setBaseAndExtentDeprecated(basePosition.deepEquivalent(), 1374 .setBaseAndExtentDeprecated(basePosition.deepEquivalent(),
1370 extentPosition.deepEquivalent()) 1375 extentPosition.deepEquivalent())
1371 .setAffinity(basePosition.affinity()) 1376 .setAffinity(basePosition.affinity())
1372 .setGranularity(granularity) 1377 .setGranularity(granularity)
1373 .build()); 1378 .build());
1374 1379
1375 if (newSelection.isNone()) 1380 if (newSelection.isNone())
1376 return; 1381 return;
1377 1382
1378 SetSelectionOptions options = CloseTyping | ClearTypingStyle; 1383 SetSelectionOptions options = CloseTyping | ClearTypingStyle | PreserveHandle;
1379 if (isHandleVisible())
1380 options |= HandleVisible;
1381 setSelection(newSelection, options, CursorAlignOnScroll::IfNeeded, 1384 setSelection(newSelection, options, CursorAlignOnScroll::IfNeeded,
1382 granularity); 1385 granularity);
1383 } 1386 }
1384 1387
1385 void FrameSelection::updateIfNeeded() { 1388 void FrameSelection::updateIfNeeded() {
1386 DCHECK(!m_frame->document()->needsLayoutTreeUpdate()); 1389 DCHECK(!m_frame->document()->needsLayoutTreeUpdate());
1387 m_selectionEditor->updateIfNeeded(); 1390 m_selectionEditor->updateIfNeeded();
1388 } 1391 }
1389 1392
1390 void FrameSelection::setCaretVisible(bool caretIsVisible) { 1393 void FrameSelection::setCaretVisible(bool caretIsVisible) {
(...skipping 30 matching lines...) Expand all
1421 } 1424 }
1422 1425
1423 void showTree(const blink::FrameSelection* sel) { 1426 void showTree(const blink::FrameSelection* sel) {
1424 if (sel) 1427 if (sel)
1425 sel->showTreeForThis(); 1428 sel->showTreeForThis();
1426 else 1429 else
1427 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; 1430 LOG(INFO) << "Cannot showTree for <null> FrameSelection.";
1428 } 1431 }
1429 1432
1430 #endif 1433 #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