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

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

Issue 2465803002: Get rid of VisibleSelection::expandUsingGranularity() (Closed)
Patch Set: 2016-10-31T17:16:07 Created 4 years, 1 month 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/SelectionController.cpp
diff --git a/third_party/WebKit/Source/core/editing/SelectionController.cpp b/third_party/WebKit/Source/core/editing/SelectionController.cpp
index 256c962c6425df2442f558f1501e24793ae12c03..b27c430d7abf8499522b16dbb7b17831ee28daf8 100644
--- a/third_party/WebKit/Source/core/editing/SelectionController.cpp
+++ b/third_party/WebKit/Source/core/editing/SelectionController.cpp
@@ -196,9 +196,15 @@ bool SelectionController::handleMousePressEventSingleClick(
newSelection.setExtent(pos);
}
+ // TODO(yosin): We should have |newBase| and |newExtent| instead of
+ // |newSelection|.
if (selection().granularity() != CharacterGranularity) {
granularity = selection().granularity();
- newSelection.expandUsingGranularity(selection().granularity());
+ newSelection = createVisibleSelection(
+ SelectionInFlatTree::Builder()
+ .setBaseAndExtent(newSelection.base(), newSelection.extent())
+ .setGranularity(granularity)
+ .build());
}
} else if (m_selectionState != SelectionState::ExtendedSelection) {
if (visiblePos.isNull()) {
@@ -333,8 +339,15 @@ void SelectionController::updateSelectionForMouseDrag(
newSelection.setExtent(targetPosition);
}
- if (selection().granularity() != CharacterGranularity)
- newSelection.expandUsingGranularity(selection().granularity());
+ // TODO(yosin): We should have |newBase| and |newExtent| instead of
+ // |newSelection|.
+ if (selection().granularity() != CharacterGranularity) {
+ newSelection = createVisibleSelection(
+ SelectionInFlatTree::Builder()
+ .setBaseAndExtent(newSelection.base(), newSelection.extent())
+ .setGranularity(selection().granularity())
+ .build());
+ }
setNonDirectionalSelectionIfNeeded(newSelection, selection().granularity(),
AdjustEndpointsAtBidiBoundary);
@@ -393,10 +406,11 @@ void SelectionController::selectClosestWordFromHitTestResult(
const VisiblePositionInFlatTree& pos =
visiblePositionOfHitTestResult(adjustedHitTestResult);
if (pos.isNotNull()) {
- SelectionInFlatTree::Builder builder;
- builder.collapse(pos.toPositionWithAffinity());
- newSelection = createVisibleSelection(builder.build());
- newSelection.expandUsingGranularity(WordGranularity);
+ newSelection =
+ createVisibleSelection(SelectionInFlatTree::Builder()
+ .collapse(pos.toPositionWithAffinity())
+ .setGranularity(WordGranularity)
+ .build());
}
if (selectInputEventType == SelectInputEventType::Touch) {
@@ -675,10 +689,11 @@ bool SelectionController::handleMousePressEventTripleClick(
const VisiblePositionInFlatTree& pos =
visiblePositionOfHitTestResult(event.hitTestResult());
if (pos.isNotNull()) {
- SelectionInFlatTree::Builder builder;
- builder.collapse(pos.toPositionWithAffinity());
- newSelection = createVisibleSelection(builder.build());
- newSelection.expandUsingGranularity(ParagraphGranularity);
+ newSelection =
+ createVisibleSelection(SelectionInFlatTree::Builder()
+ .collapse(pos.toPositionWithAffinity())
+ .setGranularity(ParagraphGranularity)
+ .build());
}
return updateSelectionForMouseDownDispatchingSelectStart(
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | third_party/WebKit/Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698