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

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

Issue 165083002: Issue 318925: Copy and paste sometimes removes spaces between words (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Issue 318925: Copy and paste sometimes removes spaces between words Created 6 years, 10 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/TextIterator.h ('k') | Source/core/editing/markup.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/TextIterator.cpp
diff --git a/Source/core/editing/TextIterator.cpp b/Source/core/editing/TextIterator.cpp
index b85b148eaf9608052ac88662b451df18dd732357..bc1489664e7d454106a0d2535660358d49b5cf85 100644
--- a/Source/core/editing/TextIterator.cpp
+++ b/Source/core/editing/TextIterator.cpp
@@ -259,6 +259,7 @@ TextIterator::TextIterator(const Range* range, TextIteratorBehaviorFlags behavio
, m_shouldStop(false)
, m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText)
, m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots)
+ , m_hasNodesFollowing(behavior & TextIteratorBehavesAsIfNodesFollowing)
{
if (!range)
return;
@@ -663,9 +664,12 @@ void TextIterator::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;
-
+ bool lastSpaceCollapsedByNextNonTextBox = !nextTextBox && m_hasNodesFollowing && (str.length() > runEnd);
+ if (lastSpaceCollapsedByNextNonTextBox)
+ subrunEnd++; // runEnd stopped before last space. Increment by one to restore the space.
+ }
m_offset = subrunEnd;
emitText(m_node, renderer, runStart, subrunEnd);
}
« no previous file with comments | « Source/core/editing/TextIterator.h ('k') | Source/core/editing/markup.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698