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

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

Issue 1184403004: Templatize extractSelectedText used by FrameSelection 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 | « no previous file | no next file » | 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..0c9e2192c4d59bce29b6fee775e41a93f43daf69 100644
--- a/Source/core/editing/FrameSelection.cpp
+++ b/Source/core/editing/FrameSelection.cpp
@@ -1663,10 +1663,22 @@ void FrameSelection::setFocusedNodeIfNeeded()
m_frame->page()->focusController().setFocusedElement(0, m_frame);
}
-static String extractSelectedText(const FrameSelection& selection, TextIteratorBehavior behavior)
+template <typename Strategy>
+String extractSelectedTextAlgorithm(const FrameSelection& selection, TextIteratorBehavior behavior)
{
+ using PositionType = typename Strategy::PositionType;
+
+ PositionType start;
+ PositionType end;
+ VisibleSelection visibleSelection = selection.selection();
+ VisibleSelection::normalizePositions(Strategy::selectionStart(visibleSelection), Strategy::selectionEnd(visibleSelection), &start, &end);
// We remove '\0' characters because they are not visibly rendered to the user.
- return plainText(selection.toNormalizedRange().get(), behavior).replace(0, "");
+ return plainText(start, end, behavior).replace(0, "");
+}
+
+static String extractSelectedText(const FrameSelection& selection, TextIteratorBehavior behavior)
+{
+ return extractSelectedTextAlgorithm<VisibleSelection::InDOMTree>(selection, behavior);
}
String FrameSelection::selectedHTMLForClipboard() const
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698