OLD | NEW |
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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 trailing 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 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) { |
617 if (str.endsWith(' ') && subrunEnd == str.length() -
1 && str[subrunEnd - 1] != ' ') | 618 if (str.endsWith(' ') && subrunEnd == str.length() -
1 && str[subrunEnd - 1] != ' ') |
618 ++subrunEnd; | 619 ++subrunEnd; |
619 } | 620 } |
| 621 // For leading space. |
| 622 if (m_textBox->root().prevRootBox() && m_textBox->root()
.firstChild() == m_textBox) { |
| 623 InlineBox* lastChildOfPrevRoot = m_textBox->root().p
revRootBox()->lastChild(); |
| 624 if (!lastChildOfPrevRoot->isText() && !lastChildOfPr
evRoot->getLineLayoutItem().isBR() |
| 625 && !lastChildOfPrevRoot->isInlineFlowBox()) { |
| 626 if (runStart > 0 && str[0] == ' ') |
| 627 --runStart; |
| 628 } |
| 629 } |
620 } | 630 } |
621 | 631 |
622 m_offset = subrunEnd; | 632 m_offset = subrunEnd; |
623 emitText(m_node, layoutObject, runStart, subrunEnd); | 633 emitText(m_node, layoutObject, runStart, subrunEnd); |
624 } | 634 } |
625 | 635 |
626 // If we are doing a subrun that doesn't go to the end of the te
xt box, | 636 // If we are doing a subrun that doesn't go to the end of the te
xt box, |
627 // come back again to finish handling this text box; don't advan
ce to the next one. | 637 // come back again to finish handling this text box; don't advan
ce to the next one. |
628 if (static_cast<unsigned>(m_textState.positionEndOffset()) < tex
tBoxEnd) | 638 if (static_cast<unsigned>(m_textState.positionEndOffset()) < tex
tBoxEnd) |
629 return; | 639 return; |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 if (range.isNull()) | 1225 if (range.isNull()) |
1216 return emptyString(); | 1226 return emptyString(); |
1217 DocumentLifecycle::DisallowTransitionScope disallowTransition(range.startPos
ition().document()->lifecycle()); | 1227 DocumentLifecycle::DisallowTransitionScope disallowTransition(range.startPos
ition().document()->lifecycle()); |
1218 return createPlainText<EditingInFlatTreeStrategy>(range, behavior); | 1228 return createPlainText<EditingInFlatTreeStrategy>(range, behavior); |
1219 } | 1229 } |
1220 | 1230 |
1221 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; | 1231 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; |
1222 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInFlatTreeStrat
egy>; | 1232 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInFlatTreeStrat
egy>; |
1223 | 1233 |
1224 } // namespace blink | 1234 } // namespace blink |
OLD | NEW |