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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
index 1b85ca7430b2a0acc1bfa826867616810b7f1812..36f4570020c172686f3e865121eb2ec97f64e46f 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -458,8 +458,15 @@ bool TextIteratorAlgorithm<Strategy>::handleTextNode()
if (!layoutObject->style()->collapseWhiteSpace()) {
int runStart = m_offset;
if (m_lastTextNodeEndedWithCollapsedSpace && hasVisibleTextNode(layoutObject)) {
- emitCharacter(spaceCharacter, textNode, 0, runStart, runStart);
- return false;
+ if (m_behavior & TextIteratorCollapseTrailingSpace) {
+ if (runStart > 0 && str[runStart - 1] == ' ') {
+ emitCharacter(spaceCharacter, textNode, 0, runStart, runStart);
+ return false;
+ }
+ } else {
+ emitCharacter(spaceCharacter, textNode, 0, runStart, runStart);
+ return false;
+ }
}
if (!m_handledFirstLetter && layoutObject->isTextFragment() && !m_offset) {
handleTextNodeFirstLetter(toLayoutTextFragment(layoutObject));
@@ -671,7 +678,15 @@ bool TextIteratorAlgorithm<Strategy>::handleReplacedElement()
return true;
}
- if (m_lastTextNodeEndedWithCollapsedSpace) {
+ if (m_behavior & TextIteratorCollapseTrailingSpace) {
+ if (m_lastTextNode) {
+ String str = m_lastTextNode->layoutObject()->text();
+ if (m_lastTextNodeEndedWithCollapsedSpace && m_offset > 0 && str[m_offset - 1] == ' ') {
+ emitCharacter(spaceCharacter, Strategy::parent(*m_lastTextNode), m_lastTextNode, 1, 1);
+ return false;
+ }
+ }
+ } else if (m_lastTextNodeEndedWithCollapsedSpace) {
emitCharacter(spaceCharacter, Strategy::parent(*m_lastTextNode), m_lastTextNode, 1, 1);
return false;
}

Powered by Google App Engine
This is Rietveld 408576698