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

Unified Diff: Source/core/layout/LayoutView.cpp

Issue 1187973007: Templatize LayoutView::commitPendingSelection function (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 | « Source/core/layout/LayoutView.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutView.cpp
diff --git a/Source/core/layout/LayoutView.cpp b/Source/core/layout/LayoutView.cpp
index 7ce7b13975e77e3ae08e1c3ba583ad8a77d68716..3034c3af7117c946acd22f826b7ce85cc912c9a3 100644
--- a/Source/core/layout/LayoutView.cpp
+++ b/Source/core/layout/LayoutView.cpp
@@ -752,8 +752,11 @@ void LayoutView::setSelection(const FrameSelection& selection)
m_pendingSelection->setSelection(selection);
}
-void LayoutView::commitPendingSelection()
+template <typename Strategy>
+void LayoutView::commitPendingSelectionAlgorithm()
{
+ using PositionType = typename Strategy::PositionType;
+
if (!hasPendingSelection())
return;
ASSERT(!needsLayout());
@@ -778,18 +781,18 @@ void LayoutView::commitPendingSelection()
// Example: foo <a>bar</a>. Imagine that a line wrap occurs after 'foo', and that 'bar' is selected. If we pass [foo, 3]
// as the start of the selection, the selection painting code will think that content on the line containing 'foo' is selected
// and will fill the gap before 'bar'.
- Position startPos = selection.start();
- Position candidate = startPos.downstream();
+ PositionType startPos = Strategy::selectionStart(selection);
+ PositionType candidate = startPos.downstream();
if (candidate.isCandidate())
startPos = candidate;
- Position endPos = selection.end();
+ PositionType endPos = Strategy::selectionEnd(selection);
candidate = endPos.upstream();
if (candidate.isCandidate())
endPos = candidate;
// We can get into a state where the selection endpoints map to the same VisiblePosition when a selection is deleted
// because we don't yet notify the FrameSelection of text removal.
- if (startPos.isNull() || endPos.isNull() || selection.visibleStart() == selection.visibleEnd())
+ if (startPos.isNull() || endPos.isNull() || Strategy::selectionVisibleStart(selection) == Strategy::selectionVisibleEnd(selection))
return;
LayoutObject* startLayoutObject = startPos.anchorNode()->layoutObject();
LayoutObject* endLayoutObject = endPos.anchorNode()->layoutObject();
@@ -799,6 +802,11 @@ void LayoutView::commitPendingSelection()
setSelection(startLayoutObject, startPos.deprecatedEditingOffset(), endLayoutObject, endPos.deprecatedEditingOffset());
}
+void LayoutView::commitPendingSelection()
+{
+ commitPendingSelectionAlgorithm<VisibleSelection::InDOMTree>();
+}
+
LayoutObject* LayoutView::selectionStart()
{
commitPendingSelection();
« no previous file with comments | « Source/core/layout/LayoutView.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698