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 1483013003: Find In Page doesn't work properly when " " is searched (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing the patch Created 4 years, 11 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 & TextIteratorCollapseTrailingSpace) {
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
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 & TextIteratorCollapseTrailingSpace) {
682 if (m_lastTextNode) {
683 String str = m_lastTextNode->layoutObject()->text();
684 if (m_lastTextNodeEndedWithCollapsedSpace && m_offset > 0 && str[m_o ffset - 1] == ' ') {
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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 1140
1126 String plainText(const EphemeralRangeInComposedTree& range, TextIteratorBehavior Flags behavior) 1141 String plainText(const EphemeralRangeInComposedTree& range, TextIteratorBehavior Flags behavior)
1127 { 1142 {
1128 return createPlainText<EditingInComposedTreeStrategy>(range, behavior); 1143 return createPlainText<EditingInComposedTreeStrategy>(range, behavior);
1129 } 1144 }
1130 1145
1131 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; 1146 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>;
1132 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInComposedTreeS trategy>; 1147 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInComposedTreeS trategy>;
1133 1148
1134 } // namespace blink 1149 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698