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..fb3197303283408f2f45db6f458c6e6de18b483b 100644 |
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp |
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp |
@@ -609,8 +609,16 @@ 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; |
+ // Restore the collapsed space at the end of text for copy & paste. |
+ // See http://crbug.com/318925 |
+ if (str.endsWith(' ') && subrunEnd == str.length() - 1 && str[subrunEnd - 1] != ' ') { |
+ Node* nextNode = Strategy::nextSibling(*m_node); |
joone
2016/08/05 18:37:48
We should call nextSibling here, which can fix the
|
+ if (nextNode && isInline(nextNode)) |
+ ++subrunEnd; |
+ } |
+ } |
m_offset = subrunEnd; |
emitText(m_node, layoutObject, runStart, subrunEnd); |