Chromium Code Reviews| 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 Text* textNode = toText(m_node); | 451 Text* textNode = toText(m_node); |
| 452 LayoutText* layoutObject = textNode->layoutObject(); | 452 LayoutText* layoutObject = textNode->layoutObject(); |
| 453 | 453 |
| 454 m_lastTextNode = textNode; | 454 m_lastTextNode = textNode; |
| 455 String str = layoutObject->text(); | 455 String str = layoutObject->text(); |
| 456 | 456 |
| 457 // handle pre-formatted text | 457 // handle pre-formatted text |
| 458 if (!layoutObject->style()->collapseWhiteSpace()) { | 458 if (!layoutObject->style()->collapseWhiteSpace()) { |
| 459 int runStart = m_offset; | 459 int runStart = m_offset; |
| 460 if (m_lastTextNodeEndedWithCollapsedSpace && hasVisibleTextNode(layoutOb ject)) { | 460 if (m_lastTextNodeEndedWithCollapsedSpace && hasVisibleTextNode(layoutOb ject)) { |
| 461 emitCharacter(spaceCharacter, textNode, 0, runStart, runStart); | 461 if (m_behavior & TextIteratorEmitExtraSpaceDeprecated) { |
| 462 return false; | 462 if (runStart > 0 && str[runStart - 1] == ' ') { |
| 463 emitCharacter(spaceCharacter, textNode, 0, runStart, runStar t); | |
| 464 return false; | |
| 465 } | |
| 466 } else { | |
| 467 emitCharacter(spaceCharacter, textNode, 0, runStart, runStart); | |
| 468 return false; | |
| 469 } | |
| 463 } | 470 } |
| 464 if (!m_handledFirstLetter && layoutObject->isTextFragment() && !m_offset ) { | 471 if (!m_handledFirstLetter && layoutObject->isTextFragment() && !m_offset ) { |
| 465 handleTextNodeFirstLetter(toLayoutTextFragment(layoutObject)); | 472 handleTextNodeFirstLetter(toLayoutTextFragment(layoutObject)); |
| 466 if (m_firstLetterText) { | 473 if (m_firstLetterText) { |
| 467 String firstLetter = m_firstLetterText->text(); | 474 String firstLetter = m_firstLetterText->text(); |
| 468 emitText(textNode, m_firstLetterText, m_offset, m_offset + first Letter.length()); | 475 emitText(textNode, m_firstLetterText, m_offset, m_offset + first Letter.length()); |
| 469 m_firstLetterText = nullptr; | 476 m_firstLetterText = nullptr; |
| 470 m_textBox = 0; | 477 m_textBox = 0; |
| 471 return false; | 478 return false; |
| 472 } | 479 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 664 | 671 |
| 665 LayoutObject* layoutObject = m_node->layoutObject(); | 672 LayoutObject* layoutObject = m_node->layoutObject(); |
| 666 if (layoutObject->style()->visibility() != VISIBLE && !ignoresStyleVisibilit y()) | 673 if (layoutObject->style()->visibility() != VISIBLE && !ignoresStyleVisibilit y()) |
| 667 return false; | 674 return false; |
| 668 | 675 |
| 669 if (emitsObjectReplacementCharacter()) { | 676 if (emitsObjectReplacementCharacter()) { |
| 670 emitCharacter(objectReplacementCharacter, Strategy::parent(*m_node), m_n ode, 0, 1); | 677 emitCharacter(objectReplacementCharacter, Strategy::parent(*m_node), m_n ode, 0, 1); |
| 671 return true; | 678 return true; |
| 672 } | 679 } |
| 673 | 680 |
| 674 if (m_lastTextNodeEndedWithCollapsedSpace) { | 681 if (m_behavior & TextIteratorEmitExtraSpaceDeprecated) { |
| 682 if (m_lastTextNode) { | |
| 683 String str = m_lastTextNode->layoutObject()->text(); | |
| 684 if (m_lastTextNodeEndedWithCollapsedSpace && m_offset > 0 && str[m_o ffset-1] == ' ') { | |
|
yosin_UTC9
2016/01/20 01:40:23
nit: need spaces around '-'
ramya.v
2016/01/20 03:42:56
Done.
| |
| 685 emitCharacter(spaceCharacter, Strategy::parent(*m_lastTextNode), m_lastTextNode, 1, 1); | |
| 686 return false; | |
| 687 } | |
| 688 } | |
| 689 } else if (m_lastTextNodeEndedWithCollapsedSpace) { | |
| 675 emitCharacter(spaceCharacter, Strategy::parent(*m_lastTextNode), m_lastT extNode, 1, 1); | 690 emitCharacter(spaceCharacter, Strategy::parent(*m_lastTextNode), m_lastT extNode, 1, 1); |
| 676 return false; | 691 return false; |
| 677 } | 692 } |
| 678 | 693 |
| 679 if (entersTextControls() && layoutObject->isTextControl()) { | 694 if (entersTextControls() && layoutObject->isTextControl()) { |
| 680 // The shadow tree should be already visited. | 695 // The shadow tree should be already visited. |
| 681 return true; | 696 return true; |
| 682 } | 697 } |
| 683 | 698 |
| 684 if (emitsCharactersBetweenAllVisiblePositions()) { | 699 if (emitsCharactersBetweenAllVisiblePositions()) { |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1119 | 1134 |
| 1120 String plainText(const EphemeralRangeInComposedTree& range, TextIteratorBehavior Flags behavior) | 1135 String plainText(const EphemeralRangeInComposedTree& range, TextIteratorBehavior Flags behavior) |
| 1121 { | 1136 { |
| 1122 return createPlainText<EditingInComposedTreeStrategy>(range, behavior); | 1137 return createPlainText<EditingInComposedTreeStrategy>(range, behavior); |
| 1123 } | 1138 } |
| 1124 | 1139 |
| 1125 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; | 1140 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; |
| 1126 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInComposedTreeS trategy>; | 1141 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInComposedTreeS trategy>; |
| 1127 | 1142 |
| 1128 } // namespace blink | 1143 } // namespace blink |
| OLD | NEW |