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

Side by Side Diff: third_party/WebKit/Source/core/editing/Editor.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: Adding testcase Created 5 years 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) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
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 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 // boundaries, however we can do it without |Range| object. 1184 // boundaries, however we can do it without |Range| object.
1185 template <typename Strategy> 1185 template <typename Strategy>
1186 static PassRefPtrWillBeRawPtr<Range> findStringBetweenPositions(const String& ta rget, const EphemeralRangeTemplate<Strategy>& referenceRange, FindOptions option s) 1186 static PassRefPtrWillBeRawPtr<Range> findStringBetweenPositions(const String& ta rget, const EphemeralRangeTemplate<Strategy>& referenceRange, FindOptions option s)
1187 { 1187 {
1188 EphemeralRangeTemplate<Strategy> searchRange(referenceRange); 1188 EphemeralRangeTemplate<Strategy> searchRange(referenceRange);
1189 1189
1190 bool forward = !(options & Backwards); 1190 bool forward = !(options & Backwards);
1191 1191
1192 while (true) { 1192 while (true) {
1193 EphemeralRangeTemplate<Strategy> resultRange = findPlainText(searchRange , target, options); 1193 EphemeralRangeTemplate<Strategy> resultRange = findPlainText(searchRange , target, options);
1194 if (resultRange.isCollapsed()) 1194 if (resultRange.isCollapsed()) {
1195 if (resultRange.endPosition() != searchRange.endPosition()) {
1196 // Possibly whitespace spans over multiple TreeScopes.
1197 // We skip this match and seek for the next occurance.
1198 if (forward) {
1199 searchRange = EphemeralRangeTemplate<Strategy>(nextPositionO f(resultRange.startPosition(), PositionMoveType::CodePoint), searchRange.endPosi tion());
1200 } else {
1201 searchRange = EphemeralRangeTemplate<Strategy>(searchRange.s tartPosition(), previousPositionOf(resultRange.endPosition(), PositionMoveType:: CodePoint));
1202 }
1203 continue;
1204 }
1195 return nullptr; 1205 return nullptr;
1206 }
1196 1207
1197 RefPtrWillBeRawPtr<Range> rangeObject = Range::create(resultRange.docume nt(), toPositionInDOMTree(resultRange.startPosition()), toPositionInDOMTree(resu ltRange.endPosition())); 1208 RefPtrWillBeRawPtr<Range> rangeObject = Range::create(resultRange.docume nt(), toPositionInDOMTree(resultRange.startPosition()), toPositionInDOMTree(resu ltRange.endPosition()));
1198 if (!rangeObject->collapsed()) 1209 if (!rangeObject->collapsed())
1199 return rangeObject.release(); 1210 return rangeObject.release();
1200 1211
1201 // Found text spans over multiple TreeScopes. Since it's impossible to 1212 // Found text spans over multiple TreeScopes. Since it's impossible to
1202 // return such section as a Range, we skip this match and seek for the 1213 // return such section as a Range, we skip this match and seek for the
1203 // next occurrence. 1214 // next occurrence.
1204 // TODO(yosin) Handle this case. 1215 // TODO(yosin) Handle this case.
1205 if (forward) { 1216 if (forward) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 } 1312 }
1302 1313
1303 DEFINE_TRACE(Editor) 1314 DEFINE_TRACE(Editor)
1304 { 1315 {
1305 visitor->trace(m_frame); 1316 visitor->trace(m_frame);
1306 visitor->trace(m_lastEditCommand); 1317 visitor->trace(m_lastEditCommand);
1307 visitor->trace(m_mark); 1318 visitor->trace(m_mark);
1308 } 1319 }
1309 1320
1310 } // namespace blink 1321 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/TextFinder.cpp » ('j') | third_party/WebKit/Source/web/TextFinder.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698