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

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

Issue 1315423006: Moves an implementation of LayoutView::commitPendingSelection() to PendingSelection::commit() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-07T11:06:22 Created 5 years, 3 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') | Source/core/layout/PendingSelection.h » ('j') | 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 45582708eaa583505b9eebc297d7b62d6199eda4..1ae144522dfab71b790af0525bc380d3f5dfd367 100644
--- a/Source/core/layout/LayoutView.cpp
+++ b/Source/core/layout/LayoutView.cpp
@@ -773,61 +773,9 @@ void LayoutView::setSelection(const FrameSelection& selection)
m_pendingSelection->setSelection(selection);
}
-template <typename Strategy>
-void LayoutView::commitPendingSelectionAlgorithm()
-{
- using PositionType = typename Strategy::PositionType;
-
- if (!hasPendingSelection())
- return;
- ASSERT(!needsLayout());
-
- // Skip if pending VisibilePositions became invalid before we reach here.
- if (!m_pendingSelection->isInDocument(document())) {
- m_pendingSelection->clear();
- return;
- }
-
- // Construct a new VisibleSolution, since m_selection is not necessarily valid, and the following steps
- // assume a valid selection. See <https://bugs.webkit.org/show_bug.cgi?id=69563> and <rdar://problem/10232866>.
- VisibleSelection selection = m_pendingSelection->calcVisibleSelection();
- m_pendingSelection->clear();
-
- if (!selection.isRange()) {
- clearSelection();
- return;
- }
-
- // Use the rightmost candidate for the start of the selection, and the leftmost candidate for the end of the selection.
- // 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'.
- PositionType startPos = Strategy::selectionStart(selection);
- PositionType candidate = mostForwardCaretPosition(startPos);
- if (isVisuallyEquivalentCandidate(candidate))
- startPos = candidate;
- PositionType endPos = Strategy::selectionEnd(selection);
- candidate = mostBackwardCaretPosition(endPos);
- if (isVisuallyEquivalentCandidate(candidate))
- 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() || Strategy::selectionVisibleStart(selection).deepEquivalent() == Strategy::selectionVisibleEnd(selection).deepEquivalent())
- return;
- LayoutObject* startLayoutObject = startPos.anchorNode()->layoutObject();
- LayoutObject* endLayoutObject = endPos.anchorNode()->layoutObject();
- if (!startLayoutObject || !endLayoutObject)
- return;
- ASSERT(startLayoutObject->view() == this && endLayoutObject->view() == this);
- setSelection(startLayoutObject, startPos.computeEditingOffset(), endLayoutObject, endPos.computeEditingOffset());
-}
-
void LayoutView::commitPendingSelection()
{
- if (RuntimeEnabledFeatures::selectionForComposedTreeEnabled())
- return commitPendingSelectionAlgorithm<VisibleSelection::InComposedTree>();
- commitPendingSelectionAlgorithm<VisibleSelection::InDOMTree>();
+ m_pendingSelection->commit(*this);
}
LayoutObject* LayoutView::selectionStart()
« no previous file with comments | « Source/core/layout/LayoutView.h ('k') | Source/core/layout/PendingSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698