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

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 fail in Mac and Win 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
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 // Don't trim the space at the end of string because we need to
615 // preserve it for copy & paste. See http://crbug.com/31 8925
616 if (m_node->nextSibling() && isInline(m_node->nextSiblin g())) {
joone 2016/08/02 20:31:42 This problem happens if the text node's next sibli
yosin_UTC9 2016/08/03 01:16:23 How about this case? <div><b><i>foo </i></b> bar</
joone 2016/08/03 21:50:59 Works fine. I added this case to the test file.
joone 2016/08/03 22:37:41 When we reduce the width, the same problem happens
617 if (str[str.length() - 1] == ' ' && subrunEnd == str .length() - 1 && str[subrunEnd-1] != ' ')
yosin_UTC9 2016/08/03 01:16:23 nit: s/subrunEnd-1/subrunEnd - 1/
joone 2016/08/03 21:51:00 Done.
618 ++subrunEnd;
619 }
620 }
614 621
615 m_offset = subrunEnd; 622 m_offset = subrunEnd;
616 emitText(m_node, layoutObject, runStart, subrunEnd); 623 emitText(m_node, layoutObject, runStart, subrunEnd);
617 } 624 }
618 625
619 // If we are doing a subrun that doesn't go to the end of the te xt box, 626 // 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. 627 // 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) 628 if (static_cast<unsigned>(m_textState.positionEndOffset()) < tex tBoxEnd)
622 return; 629 return;
623 630
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 1210
1204 String plainText(const EphemeralRangeInFlatTree& range, TextIteratorBehaviorFlag s behavior) 1211 String plainText(const EphemeralRangeInFlatTree& range, TextIteratorBehaviorFlag s behavior)
1205 { 1212 {
1206 return createPlainText<EditingInFlatTreeStrategy>(range, behavior); 1213 return createPlainText<EditingInFlatTreeStrategy>(range, behavior);
1207 } 1214 }
1208 1215
1209 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; 1216 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>;
1210 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInFlatTreeStrat egy>; 1217 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInFlatTreeStrat egy>;
1211 1218
1212 } // namespace blink 1219 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698