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

Side by Side Diff: Source/core/editing/Editor.cpp

Issue 34503002: Remove code in Editor::rangeOfString() that resets the searchRange irrespective of findNext value. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 1263
1264 RefPtr<Node> shadowTreeRoot = referenceRange && referenceRange->startContain er() ? referenceRange->startContainer()->nonBoundaryShadowTreeRootNode() : 0; 1264 RefPtr<Node> shadowTreeRoot = referenceRange && referenceRange->startContain er() ? referenceRange->startContainer()->nonBoundaryShadowTreeRootNode() : 0;
1265 if (shadowTreeRoot) { 1265 if (shadowTreeRoot) {
1266 if (forward) 1266 if (forward)
1267 searchRange->setEnd(shadowTreeRoot.get(), shadowTreeRoot->childNodeC ount()); 1267 searchRange->setEnd(shadowTreeRoot.get(), shadowTreeRoot->childNodeC ount());
1268 else 1268 else
1269 searchRange->setStart(shadowTreeRoot.get(), 0); 1269 searchRange->setStart(shadowTreeRoot.get(), 0);
1270 } 1270 }
1271 1271
1272 RefPtr<Range> resultRange(findPlainText(searchRange.get(), target, options)) ; 1272 RefPtr<Range> resultRange(findPlainText(searchRange.get(), target, options)) ;
1273 // If we started in the reference range and the found range exactly matches the reference range, find again.
1274 // Build a selection with the found range to remove collapsed whitespace.
1275 // Compare ranges instead of selection objects to ignore the way that the cu rrent selection was made.
1276 if (startInReferenceRange && areRangesEqual(VisibleSelection(resultRange.get ()).toNormalizedRange().get(), referenceRange)) {
1277 searchRange = rangeOfContents(m_frame.document());
1278 if (forward)
1279 searchRange->setStart(referenceRange->endPosition());
1280 else
1281 searchRange->setEnd(referenceRange->startPosition());
1282
1283 if (shadowTreeRoot) {
1284 if (forward)
1285 searchRange->setEnd(shadowTreeRoot.get(), shadowTreeRoot->childN odeCount());
1286 else
1287 searchRange->setStart(shadowTreeRoot.get(), 0);
1288 }
1289
1290 resultRange = findPlainText(searchRange.get(), target, options);
1291 }
1292 1273
1293 // If nothing was found in the shadow tree, search in main content following the shadow tree. 1274 // If nothing was found in the shadow tree, search in main content following the shadow tree.
1294 if (resultRange->collapsed(ASSERT_NO_EXCEPTION) && shadowTreeRoot) { 1275 if (resultRange->collapsed(ASSERT_NO_EXCEPTION) && shadowTreeRoot) {
1295 searchRange = rangeOfContents(m_frame.document()); 1276 searchRange = rangeOfContents(m_frame.document());
1296 if (forward) 1277 if (forward)
1297 searchRange->setStartAfter(shadowTreeRoot->shadowHost()); 1278 searchRange->setStartAfter(shadowTreeRoot->shadowHost());
1298 else 1279 else
1299 searchRange->setEndBefore(shadowTreeRoot->shadowHost()); 1280 searchRange->setEndBefore(shadowTreeRoot->shadowHost());
1300 1281
1301 resultRange = findPlainText(searchRange.get(), target, options); 1282 resultRange = findPlainText(searchRange.get(), target, options);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 return spellChecker().isContinuousSpellCheckingEnabled(); 1321 return spellChecker().isContinuousSpellCheckingEnabled();
1341 } 1322 }
1342 1323
1343 void Editor::toggleOverwriteModeEnabled() 1324 void Editor::toggleOverwriteModeEnabled()
1344 { 1325 {
1345 m_overwriteModeEnabled = !m_overwriteModeEnabled; 1326 m_overwriteModeEnabled = !m_overwriteModeEnabled;
1346 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); 1327 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled);
1347 } 1328 }
1348 1329
1349 } // namespace WebCore 1330 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698