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

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

Issue 2325553002: Restore a collapsed leading space of text used for line break (Closed)
Patch Set: Use plainText() 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
3 * Copyright (C) 2005 Alexey Proskuryakov. 3 * Copyright (C) 2005 Alexey Proskuryakov.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 if (subrunEnd == kNotFound || subrunEnd > runEnd) { 612 if (subrunEnd == kNotFound || subrunEnd > runEnd) {
613 subrunEnd = runEnd; 613 subrunEnd = runEnd;
614 // Restore the collapsed space for copy & paste. 614 // Restore the collapsed space for copy & paste.
615 // See http://crbug.com/318925 615 // See http://crbug.com/318925
616 // For trailing space. 616 // For trailing space.
617 if (!nextTextBox && m_textBox->root().nextRootBox() && m _textBox->root().lastChild() == m_textBox) { 617 if (!nextTextBox && m_textBox->root().nextRootBox() && m _textBox->root().lastChild() == m_textBox) {
618 if (str.endsWith(' ') && subrunEnd == str.length() - 1 && str[subrunEnd - 1] != ' ') 618 if (str.endsWith(' ') && subrunEnd == str.length() - 1 && str[subrunEnd - 1] != ' ')
619 ++subrunEnd; 619 ++subrunEnd;
620 } 620 }
621 // For leading space. 621 // For leading space.
622 if (m_textBox->root().prevRootBox() && m_textBox->root() .firstChild() == m_textBox) { 622 if (!emitsImageAltText() && !doesNotBreakAtReplacedEleme nt() && !forInnerText()
623 && m_textBox->root().prevRootBox() && m_textBox->roo t().firstChild() == m_textBox) {
623 InlineBox* lastChildOfPrevRoot = m_textBox->root().p revRootBox()->lastChild(); 624 InlineBox* lastChildOfPrevRoot = m_textBox->root().p revRootBox()->lastChild();
624 if (!lastChildOfPrevRoot->isText() && !lastChildOfPr evRoot->getLineLayoutItem().isBR() 625 if (m_textBox->getLineLayoutItem() != lastChildOfPre vRoot->getLineLayoutItem() && !lastChildOfPrevRoot->getLineLayoutItem().isBR()
625 && !lastChildOfPrevRoot->isInlineFlowBox()) { 626 && !lastChildOfPrevRoot->isInlineFlowBox()) {
626 if (runStart > 0 && str[0] == ' ') 627 if (runStart > 0 && str[0] == ' ' && str[1] != ' ')
627 --runStart; 628 --runStart;
628 } 629 }
629 } 630 }
630 } 631 }
631 632
632 m_offset = subrunEnd; 633 m_offset = subrunEnd;
633 emitText(m_node, layoutObject, runStart, subrunEnd); 634 emitText(m_node, layoutObject, runStart, subrunEnd);
634 } 635 }
635 636
636 // If we are doing a subrun that doesn't go to the end of the te xt box, 637 // If we are doing a subrun that doesn't go to the end of the te xt box,
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 1217
1217 String plainText(const EphemeralRangeInFlatTree& range, TextIteratorBehaviorFlag s behavior) 1218 String plainText(const EphemeralRangeInFlatTree& range, TextIteratorBehaviorFlag s behavior)
1218 { 1219 {
1219 return createPlainText<EditingInFlatTreeStrategy>(range, behavior); 1220 return createPlainText<EditingInFlatTreeStrategy>(range, behavior);
1220 } 1221 }
1221 1222
1222 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; 1223 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>;
1223 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInFlatTreeStrat egy>; 1224 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInFlatTreeStrat egy>;
1224 1225
1225 } // namespace blink 1226 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698