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

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

Issue 1377963004: Use FrameSelection::selectedText where possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check whether selection is range. 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
Index: third_party/WebKit/Source/core/editing/FrameSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.cpp b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
index 92dd256df027e44a2e9287c4f38f813934812ae8..fa21187532457bb9aa2decb813dba51890fb35c1 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
@@ -1101,6 +1101,8 @@ template <typename Strategy>
String extractSelectedTextAlgorithm(const FrameSelection& selection, TextIteratorBehavior behavior)
{
const VisibleSelectionTemplate<Strategy> visibleSelection = selection.visibleSelection<Strategy>();
+ if (!visibleSelection.isRange())
yosin_UTC9 2015/10/06 05:41:51 I think it is easier to make |normalizeRange()| to
kotenkov 2015/10/06 12:29:23 Actually, now the problem is not in |normalizeRang
yosin_UTC9 2015/10/15 07:45:46 Let's make both |normalizeRange()| and |createMark
+ return String();
const EphemeralRangeTemplate<Strategy> range = visibleSelection.toNormalizedEphemeralRange();
// We remove '\0' characters because they are not visibly rendered to the user.
return plainText(range, behavior).replace(0, "");
@@ -1117,6 +1119,8 @@ template <typename Strategy>
static String extractSelectedHTMLAlgorithm(const FrameSelection& selection)
{
const VisibleSelectionTemplate<Strategy> visibleSelection = selection.visibleSelection<Strategy>();
+ if (!visibleSelection.isRange())
+ return String();
const EphemeralRangeTemplate<Strategy> range = visibleSelection.toNormalizedEphemeralRange();
return createMarkup(range.startPosition(), range.endPosition(), AnnotateForInterchange, ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
}
@@ -1128,9 +1132,9 @@ String FrameSelection::selectedHTMLForClipboard() const
return extractSelectedHTMLAlgorithm<EditingInComposedTreeStrategy>(*this);
}
-String FrameSelection::selectedText() const
+String FrameSelection::selectedText(TextIteratorBehavior behavior) const
{
- return extractSelectedText(*this, TextIteratorDefaultBehavior);
+ return extractSelectedText(*this, behavior);
}
String FrameSelection::selectedTextForClipboard() const
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.h ('k') | third_party/WebKit/Source/core/html/HTMLTextAreaElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698