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

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

Issue 2336043006: Restore only the collapsed leading space when copy text (Closed)
Patch Set: Created 4 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/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 5066087f2511b6ab5efd9ae5a543b93a0047209c..f95f9dfbd7e555b3811d676beec91e7aa7ddf8a8 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -615,8 +615,13 @@ void TextIteratorAlgorithm<Strategy>::handleTextBox()
// See http://crbug.com/318925
// For trailing space.
if (!nextTextBox && m_textBox->root().nextRootBox() && m_textBox->root().lastChild() == m_textBox) {
- if (str.endsWith(' ') && subrunEnd == str.length() - 1 && str[subrunEnd - 1] != ' ')
- ++subrunEnd;
+ if (str.endsWith(' ') && subrunEnd == str.length() - 1 && str[subrunEnd - 1] != ' ') {
+ // If there is the leading space in the next line, we don't need to restore the trailing space.
+ // Example: <div style="width: 2em;"><b><i>foo </i></b> bar</div>
+ String textOfNextline = m_textBox->root().nextRootBox()->firstChild()->getLineLayoutItem().node()->nodeValue();
+ if (textOfNextline[0] != ' ')
+ ++subrunEnd;
+ }
}
// For leading space.
if (!emitsImageAltText() && !doesNotBreakAtReplacedElement() && !forInnerText()

Powered by Google App Engine
This is Rietveld 408576698