Chromium Code Reviews| 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() |