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

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

Issue 2432383002: Get rid of flat tree version of createVisibleSelection() taking two PositionInFlatTree (Closed)
Patch Set: 2016-10-20T15:59:37 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) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
6 * Copyright (C) 2015 Google Inc. All rights reserved. 6 * Copyright (C) 2015 Google Inc. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 175 }
176 176
177 if (!m_frame->editor().behavior().shouldConsiderSelectionAsDirectional()) { 177 if (!m_frame->editor().behavior().shouldConsiderSelectionAsDirectional()) {
178 if (pos.isNotNull()) { 178 if (pos.isNotNull()) {
179 // See <rdar://problem/3668157> REGRESSION (Mail): shift-click 179 // See <rdar://problem/3668157> REGRESSION (Mail): shift-click
180 // deselects when selection was created right-to-left 180 // deselects when selection was created right-to-left
181 const PositionInFlatTree start = newSelection.start(); 181 const PositionInFlatTree start = newSelection.start();
182 const PositionInFlatTree end = newSelection.end(); 182 const PositionInFlatTree end = newSelection.end();
183 int distanceToStart = textDistance(start, pos); 183 int distanceToStart = textDistance(start, pos);
184 int distanceToEnd = textDistance(pos, end); 184 int distanceToEnd = textDistance(pos, end);
185 if (distanceToStart <= distanceToEnd) 185 newSelection = createVisibleSelection(
186 newSelection = createVisibleSelection(end, pos); 186 SelectionInFlatTree::Builder()
187 else 187 .collapse(distanceToStart <= distanceToEnd ? end : start)
188 newSelection = createVisibleSelection(start, pos); 188 .extend(pos)
189 .build());
189 } 190 }
190 } else { 191 } else {
191 newSelection.setExtent(pos); 192 newSelection.setExtent(pos);
192 } 193 }
193 194
194 if (selection().granularity() != CharacterGranularity) { 195 if (selection().granularity() != CharacterGranularity) {
195 granularity = selection().granularity(); 196 granularity = selection().granularity();
196 newSelection.expandUsingGranularity(selection().granularity()); 197 newSelection.expandUsingGranularity(selection().granularity());
197 } 198 }
198 } else if (m_selectionState != SelectionState::ExtendedSelection) { 199 } else if (m_selectionState != SelectionState::ExtendedSelection) {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 const PositionInFlatTree& markerPosition = 437 const PositionInFlatTree& markerPosition =
437 pos.deepEquivalent().parentAnchoredEquivalent(); 438 pos.deepEquivalent().parentAnchoredEquivalent();
438 DocumentMarkerVector markers = 439 DocumentMarkerVector markers =
439 innerNode->document().markers().markersInRange( 440 innerNode->document().markers().markersInRange(
440 EphemeralRange(toPositionInDOMTree(markerPosition)), 441 EphemeralRange(toPositionInDOMTree(markerPosition)),
441 DocumentMarker::MisspellingMarkers()); 442 DocumentMarker::MisspellingMarkers());
442 if (markers.size() == 1) { 443 if (markers.size() == 1) {
443 Node* containerNode = markerPosition.computeContainerNode(); 444 Node* containerNode = markerPosition.computeContainerNode();
444 const PositionInFlatTree start(containerNode, markers[0]->startOffset()); 445 const PositionInFlatTree start(containerNode, markers[0]->startOffset());
445 const PositionInFlatTree end(containerNode, markers[0]->endOffset()); 446 const PositionInFlatTree end(containerNode, markers[0]->endOffset());
446 newSelection = createVisibleSelection(start, end); 447 newSelection = createVisibleSelection(
448 SelectionInFlatTree::Builder().collapse(start).extend(end).build());
447 } 449 }
448 } 450 }
449 451
450 if (appendTrailingWhitespace == AppendTrailingWhitespace::ShouldAppend && 452 if (appendTrailingWhitespace == AppendTrailingWhitespace::ShouldAppend &&
451 newSelection.isRange()) 453 newSelection.isRange())
452 newSelection.appendTrailingWhitespace(); 454 newSelection.appendTrailingWhitespace();
453 455
454 updateSelectionForMouseDownDispatchingSelectStart( 456 updateSelectionForMouseDownDispatchingSelectStart(
455 innerNode, expandSelectionToRespectUserSelectAll(innerNode, newSelection), 457 innerNode, expandSelectionToRespectUserSelectAll(innerNode, newSelection),
456 WordGranularity); 458 WordGranularity);
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 return event.event().altKey() && event.isOverLink(); 854 return event.event().altKey() && event.isOverLink();
853 } 855 }
854 856
855 bool isExtendingSelection(const MouseEventWithHitTestResults& event) { 857 bool isExtendingSelection(const MouseEventWithHitTestResults& event) {
856 bool isMouseDownOnLinkOrImage = 858 bool isMouseDownOnLinkOrImage =
857 event.isOverLink() || event.hitTestResult().image(); 859 event.isOverLink() || event.hitTestResult().image();
858 return event.event().shiftKey() && !isMouseDownOnLinkOrImage; 860 return event.event().shiftKey() && !isMouseDownOnLinkOrImage;
859 } 861 }
860 862
861 } // namespace blink 863 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698