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

Unified Diff: third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp

Issue 2193033004: Restore the collapsed spaces of the text when we copy it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove the copy variable in the test case Created 4 years, 4 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/iterators/TextIterator.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
index 8750da2ab573b4b8fb0b13f107437bb25f87ef9b..3ebb9f12f3a17f28b21f0838ae7aef1d33cf8287 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -609,8 +609,15 @@ void TextIteratorAlgorithm<Strategy>::handleTextBox()
m_offset = runStart + 1;
} else {
size_t subrunEnd = str.find('\n', runStart);
- if (subrunEnd == kNotFound || subrunEnd > runEnd)
+ if (subrunEnd == kNotFound || subrunEnd > runEnd) {
subrunEnd = runEnd;
+ // Don't trim the space at the end of string because we need to
+ // preserve it for copy & paste. See http://crbug.com/318925
+ if (m_node->nextSibling() && isInline(Strategy::next(*m_node))) {
esprehn 2016/08/04 20:54:27 What is this nextSibling check about? The next() t
+ if (str[str.length() - 1] == ' ' && subrunEnd == str.length() - 1 && str[subrunEnd - 1] != ' ')
+ ++subrunEnd;
+ }
+ }
m_offset = subrunEnd;
emitText(m_node, layoutObject, runStart, subrunEnd);

Powered by Google App Engine
This is Rietveld 408576698