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

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

Issue 2735143002: Make GranularityStrategy::updateExtent() to return SelectionInDOM instead of VisibleSelection (Closed)
Patch Set: 2017-03-09T16:45:24 rebase Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/GranularityStrategy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/GranularityStrategy.cpp
diff --git a/third_party/WebKit/Source/core/editing/GranularityStrategy.cpp b/third_party/WebKit/Source/core/editing/GranularityStrategy.cpp
index 26c3c8207862f8aec0af352b78defcea46dcf129..0b09b8b90b8991c3117626bdc69333e065f23c26 100644
--- a/third_party/WebKit/Source/core/editing/GranularityStrategy.cpp
+++ b/third_party/WebKit/Source/core/editing/GranularityStrategy.cpp
@@ -62,7 +62,7 @@ SelectionStrategy CharacterGranularityStrategy::GetType() const {
void CharacterGranularityStrategy::Clear() {}
-VisibleSelection CharacterGranularityStrategy::updateExtent(
+SelectionInDOMTree CharacterGranularityStrategy::updateExtent(
const IntPoint& extentPoint,
LocalFrame* frame) {
const VisiblePosition& extentPosition =
@@ -71,12 +71,12 @@ VisibleSelection CharacterGranularityStrategy::updateExtent(
frame->selection().computeVisibleSelectionInDOMTreeDeprecated();
if (selection.visibleBase().deepEquivalent() ==
extentPosition.deepEquivalent())
- return selection;
- return createVisibleSelection(SelectionInDOMTree::Builder()
- .collapse(selection.base())
- .extend(extentPosition.deepEquivalent())
- .setAffinity(selection.affinity())
- .build());
+ return selection.asSelection();
+ return SelectionInDOMTree::Builder()
+ .collapse(selection.base())
+ .extend(extentPosition.deepEquivalent())
+ .setAffinity(selection.affinity())
+ .build();
}
DirectionGranularityStrategy::DirectionGranularityStrategy()
@@ -97,7 +97,7 @@ void DirectionGranularityStrategy::Clear() {
m_diffExtentPointFromExtentPosition = IntSize();
}
-VisibleSelection DirectionGranularityStrategy::updateExtent(
+SelectionInDOMTree DirectionGranularityStrategy::updateExtent(
const IntPoint& extentPoint,
LocalFrame* frame) {
const VisibleSelection& selection =
@@ -144,7 +144,7 @@ VisibleSelection DirectionGranularityStrategy::updateExtent(
// Do not allow empty selection.
if (newOffsetExtentPosition.deepEquivalent() == base.deepEquivalent())
- return selection;
+ return selection.asSelection();
// The direction granularity strategy, particularly the "offset" feature
// doesn't work with non-horizontal text (e.g. when the text is rotated).
@@ -153,12 +153,11 @@ VisibleSelection DirectionGranularityStrategy::updateExtent(
// without a line change.
if (verticalChange &&
inSameLine(newOffsetExtentPosition, oldOffsetExtentPosition)) {
- return createVisibleSelection(
- SelectionInDOMTree::Builder()
- .collapse(selection.base())
- .extend(newOffsetExtentPosition.deepEquivalent())
- .setAffinity(selection.affinity())
- .build());
+ return SelectionInDOMTree::Builder()
+ .collapse(selection.base())
+ .extend(newOffsetExtentPosition.deepEquivalent())
+ .setAffinity(selection.affinity())
+ .build();
}
int oldExtentBaseOrder = selection.isBaseFirst() ? 1 : -1;
@@ -168,7 +167,7 @@ VisibleSelection DirectionGranularityStrategy::updateExtent(
if (newOffsetExtentPosition.deepEquivalent() ==
oldOffsetExtentPosition.deepEquivalent()) {
if (m_granularity == CharacterGranularity)
- return selection;
+ return selection.asSelection();
// If we are in Word granularity, we cannot exit here, since we may pass
// the middle of the word without changing the position (in which case
@@ -270,11 +269,10 @@ VisibleSelection DirectionGranularityStrategy::updateExtent(
m_diffExtentPointFromExtentPosition =
extentPoint + IntSize(m_offset, 0) - positionLocation(newSelectionExtent);
- return createVisibleSelection(
- SelectionInDOMTree::Builder(selection.asSelection())
- .collapse(selection.base())
- .extend(newSelectionExtent.deepEquivalent())
- .build());
+ return SelectionInDOMTree::Builder(selection.asSelection())
+ .collapse(selection.base())
+ .extend(newSelectionExtent.deepEquivalent())
+ .build();
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/GranularityStrategy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698