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

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

Issue 2193033004: Restore the collapsed spaces of the text when we copy it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test fails Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/js/post-inc-assign-overwrites-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 if (str[runStart] == '\n') { 602 if (str[runStart] == '\n') {
603 // We need to preserve new lines in case of PRE_LINE. 603 // We need to preserve new lines in case of PRE_LINE.
604 // See bug crbug.com/317365. 604 // See bug crbug.com/317365.
605 if (layoutObject->style()->whiteSpace() == PRE_LINE) 605 if (layoutObject->style()->whiteSpace() == PRE_LINE)
606 spliceBuffer('\n', m_node, 0, runStart, runStart); 606 spliceBuffer('\n', m_node, 0, runStart, runStart);
607 else 607 else
608 spliceBuffer(spaceCharacter, m_node, 0, runStart, runSta rt + 1); 608 spliceBuffer(spaceCharacter, m_node, 0, runStart, runSta rt + 1);
609 m_offset = runStart + 1; 609 m_offset = runStart + 1;
610 } else { 610 } else {
611 size_t subrunEnd = str.find('\n', runStart); 611 size_t subrunEnd = str.find('\n', runStart);
612 if (subrunEnd == kNotFound || subrunEnd > runEnd) 612 if (subrunEnd == kNotFound || subrunEnd > runEnd) {
613 subrunEnd = runEnd; 613 subrunEnd = runEnd;
614 // Restore the collapsed space at the end of text for co py & paste.
615 // See http://crbug.com/318925
616 if (str.endsWith(' ') && subrunEnd == str.length() - 1 & & str[subrunEnd - 1] != ' ') {
617 Node* nextNode = Strategy::nextSibling(*m_node);
joone 2016/08/05 18:37:48 We should call nextSibling here, which can fix the
618 if (nextNode && isInline(nextNode))
619 ++subrunEnd;
620 }
621 }
614 622
615 m_offset = subrunEnd; 623 m_offset = subrunEnd;
616 emitText(m_node, layoutObject, runStart, subrunEnd); 624 emitText(m_node, layoutObject, runStart, subrunEnd);
617 } 625 }
618 626
619 // If we are doing a subrun that doesn't go to the end of the te xt box, 627 // If we are doing a subrun that doesn't go to the end of the te xt box,
620 // come back again to finish handling this text box; don't advan ce to the next one. 628 // come back again to finish handling this text box; don't advan ce to the next one.
621 if (static_cast<unsigned>(m_textState.positionEndOffset()) < tex tBoxEnd) 629 if (static_cast<unsigned>(m_textState.positionEndOffset()) < tex tBoxEnd)
622 return; 630 return;
623 631
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 1211
1204 String plainText(const EphemeralRangeInFlatTree& range, TextIteratorBehaviorFlag s behavior) 1212 String plainText(const EphemeralRangeInFlatTree& range, TextIteratorBehaviorFlag s behavior)
1205 { 1213 {
1206 return createPlainText<EditingInFlatTreeStrategy>(range, behavior); 1214 return createPlainText<EditingInFlatTreeStrategy>(range, behavior);
1207 } 1215 }
1208 1216
1209 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; 1217 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>;
1210 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInFlatTreeStrat egy>; 1218 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInFlatTreeStrat egy>;
1211 1219
1212 } // namespace blink 1220 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/js/post-inc-assign-overwrites-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698