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

Unified Diff: Source/core/editing/FrameSelection.cpp

Issue 1177173007: Templatize FrameSelection::setNonDirectionalSelectionIfNeede function (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-06-18T14:23:09 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/editing/FrameSelection.h ('k') | Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/FrameSelection.cpp
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp
index bdba0152fa4165f0b667948ef790bd507d0333b4..7690346d473ed25f834f84e5e1a9b3d12671ceb9 100644
--- a/Source/core/editing/FrameSelection.cpp
+++ b/Source/core/editing/FrameSelection.cpp
@@ -191,15 +191,16 @@ static void adjustEndpointsAtBidiBoundary(VisiblePosition& visibleBase, VisibleP
}
}
-void FrameSelection::setNonDirectionalSelectionIfNeeded(const VisibleSelection& passedNewSelection, TextGranularity granularity,
+template <typename Strategy>
+void FrameSelection::setNonDirectionalSelectionIfNeededAlgorithm(const VisibleSelection& passedNewSelection, TextGranularity granularity,
EndPointsAdjustmentMode endpointsAdjustmentMode)
{
VisibleSelection newSelection = passedNewSelection;
bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || newSelection.isDirectional();
- VisiblePosition base = m_originalBase.isNotNull() ? m_originalBase : newSelection.visibleBase();
+ VisiblePosition base = m_originalBase.isNotNull() ? m_originalBase : VisiblePosition(Strategy::selectionBase(newSelection));
VisiblePosition newBase = base;
- VisiblePosition extent = newSelection.visibleExtent();
+ VisiblePosition extent(Strategy::selectionExtent(newSelection));
VisiblePosition newExtent = extent;
if (endpointsAdjustmentMode == AdjustEndpointsAtBidiBoundary)
adjustEndpointsAtBidiBoundary(newBase, newExtent);
@@ -209,18 +210,23 @@ void FrameSelection::setNonDirectionalSelectionIfNeeded(const VisibleSelection&
newSelection.setBase(newBase);
newSelection.setExtent(newExtent);
} else if (m_originalBase.isNotNull()) {
- if (m_selection.base() == newSelection.base())
+ if (Strategy::selectionBase(m_selection) == Strategy::selectionBase(newSelection))
newSelection.setBase(m_originalBase);
m_originalBase.clear();
}
newSelection.setIsDirectional(isDirectional); // Adjusting base and extent will make newSelection always directional
- if (m_selection == newSelection)
+ if (Strategy::equalSelections(m_selection, newSelection))
return;
setSelection(newSelection, granularity);
}
+void FrameSelection::setNonDirectionalSelectionIfNeeded(const VisibleSelection& passedNewSelection, TextGranularity granularity, EndPointsAdjustmentMode endpointsAdjustmentMode)
+{
+ setNonDirectionalSelectionIfNeededAlgorithm<VisibleSelection::InDOMTree>(passedNewSelection, granularity, endpointsAdjustmentMode);
+}
+
void FrameSelection::setSelection(const VisibleSelection& newSelection, SetSelectionOptions options, CursorAlignOnScroll align, TextGranularity granularity)
{
if (m_granularityStrategy && (options & FrameSelection::DoNotClearStrategy) == 0)
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698