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

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: [For landing] Fix crash on Android 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..34213c55cf27bb0d09eb99157be40a2c95872756 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -615,8 +615,16 @@ 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>
+ InlineBox* firstBoxOfNextLine = m_textBox->root().nextRootBox()->firstChild();
+ Node* firstNodeOfNextLine = nullptr;
+ if (firstBoxOfNextLine)
joone 2016/09/16 05:04:13 |firstBoxOfNextLine| can be null on Android.
+ firstNodeOfNextLine = firstBoxOfNextLine->getLineLayoutItem().node();
+ if (!firstNodeOfNextLine || firstNodeOfNextLine->nodeValue()[0] != ' ')
+ ++subrunEnd;
+ }
}
// For leading space.
if (!emitsImageAltText() && !doesNotBreakAtReplacedElement() && !forInnerText()
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698