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

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

Issue 2320533002: Restore a collapsed leading space of text used for line break (Closed)
Patch Set: Refactoring 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 | « third_party/WebKit/LayoutTests/editing/pasteboard/restore-collapsed-space-for-copy.html ('k') | no next file » | 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 19b903c012eb232169745fc4984ab74901abb395..76c7962bb74fc37bf1c58a8ac2258c158a26a7fd 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -611,12 +611,22 @@ void TextIteratorAlgorithm<Strategy>::handleTextBox()
size_t subrunEnd = str.find('\n', runStart);
if (subrunEnd == kNotFound || subrunEnd > runEnd) {
subrunEnd = runEnd;
- // Restore the collapsed trailing space for copy & paste.
+ // Restore the collapsed space for copy & paste.
// 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;
}
+ // For leading space.
+ if (m_textBox->root().prevRootBox() && m_textBox->root().firstChild() == m_textBox) {
+ InlineBox* lastChildOfPrevRoot = m_textBox->root().prevRootBox()->lastChild();
+ if (!lastChildOfPrevRoot->isText() && !lastChildOfPrevRoot->getLineLayoutItem().isBR()
+ && !lastChildOfPrevRoot->isInlineFlowBox()) {
+ if (runStart > 0 && str[0] == ' ')
+ --runStart;
+ }
+ }
}
m_offset = subrunEnd;
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/pasteboard/restore-collapsed-space-for-copy.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698