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

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

Issue 2761963002: CANCELLED Merge SelectionAdjuster into VisibleSelection part 1 (Closed)
Patch Set: Fix typo 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
Index: third_party/WebKit/Source/core/editing/SelectionAdjuster.cpp
diff --git a/third_party/WebKit/Source/core/editing/SelectionAdjuster.cpp b/third_party/WebKit/Source/core/editing/SelectionAdjuster.cpp
index 4d77b449cacd339be95c2410fa4a0a6cd2836a65..b31245be7e826d1264dd88e5979f50d4f26e96ac 100644
--- a/third_party/WebKit/Source/core/editing/SelectionAdjuster.cpp
+++ b/third_party/WebKit/Source/core/editing/SelectionAdjuster.cpp
@@ -30,6 +30,8 @@
namespace blink {
+// TODO(xiaochengh): Move everything to VisibleSelection.cpp.
+
namespace {
Node* enclosingShadowHost(Node* node) {
@@ -153,57 +155,52 @@ Position adjustPositionForStart(const Position& currentPosition,
} // namespace
-void SelectionAdjuster::adjustSelectionToAvoidCrossingShadowBoundaries(
- VisibleSelection* selection) {
+std::pair<AdjustDirection, Position> adjustmentToAvoidCrossingShadowBoundaries(
+ const VisibleSelection& selection) {
// Note: |m_selectionType| isn't computed yet.
- DCHECK(selection->base().isNotNull());
- DCHECK(selection->extent().isNotNull());
- DCHECK(selection->start().isNotNull());
- DCHECK(selection->end().isNotNull());
+ DCHECK(selection.base().isNotNull());
+ DCHECK(selection.extent().isNotNull());
+ DCHECK(selection.start().isNotNull());
+ DCHECK(selection.end().isNotNull());
// TODO(hajimehoshi): Checking treeScope is wrong when a node is
// distributed, but we leave it as it is for backward compatibility.
- if (selection->start().anchorNode()->treeScope() ==
- selection->end().anchorNode()->treeScope())
- return;
+ if (selection.start().anchorNode()->treeScope() ==
+ selection.end().anchorNode()->treeScope())
+ return std::make_pair(AdjustDirection::kAdjustNone, Position());
- if (selection->isBaseFirst()) {
+ if (selection.isBaseFirst()) {
const Position& newEnd = adjustPositionForEnd(
- selection->end(), selection->start().computeContainerNode());
- selection->m_extent = newEnd;
- selection->m_end = newEnd;
- return;
+ selection.end(), selection.start().computeContainerNode());
+ return std::make_pair(AdjustDirection::kAdjustEnd, newEnd);
}
const Position& newStart = adjustPositionForStart(
- selection->start(), selection->end().computeContainerNode());
- selection->m_extent = newStart;
- selection->m_start = newStart;
+ selection.start(), selection.end().computeContainerNode());
+ return std::make_pair(AdjustDirection::kAdjustStart, newStart);
}
// This function is called twice. The first is called when |m_start| and |m_end|
// or |m_extent| are same, and the second when |m_start| and |m_end| are changed
// after downstream/upstream.
-void SelectionAdjuster::adjustSelectionToAvoidCrossingShadowBoundaries(
- VisibleSelectionInFlatTree* selection) {
- Node* const shadowHostStart = enclosingShadowHostForStart(selection->start());
- Node* const shadowHostEnd = enclosingShadowHostForEnd(selection->end());
+std::pair<AdjustDirection, PositionInFlatTree>
+adjustmentToAvoidCrossingShadowBoundaries(
+ const VisibleSelectionInFlatTree& selection) {
+ Node* const shadowHostStart = enclosingShadowHostForStart(selection.start());
+ Node* const shadowHostEnd = enclosingShadowHostForEnd(selection.end());
if (shadowHostStart == shadowHostEnd)
- return;
+ return std::make_pair(AdjustDirection::kAdjustNone, PositionInFlatTree());
- if (selection->isBaseFirst()) {
+ if (selection.isBaseFirst()) {
Node* const shadowHost = shadowHostStart ? shadowHostStart : shadowHostEnd;
const PositionInFlatTree& newEnd =
- adjustPositionInFlatTreeForEnd(selection->end(), shadowHost);
- selection->m_extent = newEnd;
- selection->m_end = newEnd;
- return;
+ adjustPositionInFlatTreeForEnd(selection.end(), shadowHost);
+ return std::make_pair(AdjustDirection::kAdjustEnd, newEnd);
}
Node* const shadowHost = shadowHostEnd ? shadowHostEnd : shadowHostStart;
const PositionInFlatTree& newStart =
- adjustPositionInFlatTreeForStart(selection->start(), shadowHost);
- selection->m_extent = newStart;
- selection->m_start = newStart;
+ adjustPositionInFlatTreeForStart(selection.start(), shadowHost);
+ return std::make_pair(AdjustDirection::kAdjustStart, newStart);
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/SelectionAdjuster.h ('k') | third_party/WebKit/Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698