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

Side by Side Diff: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp

Issue 2241183003: Revert of Fix find-in-page re-scope across frame boundaries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « content/test/data/find_in_long_page.html ('k') | 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 1982
1983 void WebLocalFrameImpl::requestFind(int identifier, const WebString& searchText, const WebFindOptions& options) 1983 void WebLocalFrameImpl::requestFind(int identifier, const WebString& searchText, const WebFindOptions& options)
1984 { 1984 {
1985 // Send "no results" if this frame has no visible content. 1985 // Send "no results" if this frame has no visible content.
1986 if (!hasVisibleContent()) { 1986 if (!hasVisibleContent()) {
1987 client()->reportFindInPageMatchCount(identifier, 0 /* count */, true /* finalUpdate */); 1987 client()->reportFindInPageMatchCount(identifier, 0 /* count */, true /* finalUpdate */);
1988 return; 1988 return;
1989 } 1989 }
1990 1990
1991 WebRange currentSelection = selectionRange(); 1991 WebRange currentSelection = selectionRange();
1992
1992 bool result = false; 1993 bool result = false;
1993 bool activeNow = false; 1994 bool activeNow = false;
1994 1995
1995 // Search for an active match only if this frame is focused or if this is a 1996 // Search for an active match only if this frame is focused or if this is a
1996 // find next request. 1997 // find next request.
1997 if (isFocused() || options.findNext) { 1998 if (isFocused() || options.findNext) {
1998 result = find(identifier, searchText, options, false /* wrapWithinFrame */, &activeNow); 1999 result = find(identifier, searchText, options, false /* wrapWithinFrame */, &activeNow);
1999 } 2000 }
2000 2001
2001 if (result && !options.findNext) { 2002 if (result && !options.findNext) {
2002 // Indicate that at least one match has been found. 1 here means 2003 // Indicate that at least one match has been found. 1 here means
2003 // possibly more matches could be coming. 2004 // possibly more matches could be coming.
2004 client()->reportFindInPageMatchCount(identifier, 1 /* count */, false /* finalUpdate */); 2005 client()->reportFindInPageMatchCount(identifier, 1 /* count */, false /* finalUpdate */);
2005 } 2006 }
2006 2007
2007 // There are three cases in which scoping is needed: 2008 // There are three cases in which scoping is needed:
2008 // 2009 //
2009 // (1) This is an initial find request (|options.findNext| is false). This 2010 // 1) This is an initial find request (|options.findNext| is false). This
2010 // will be the first scoping effort for this find session. 2011 // will be the first scoping effort for this find session.
2011 // 2012 //
2012 // (2) Something has been selected since the last search. This means that we 2013 // 2) Something has been selected since the last search. This means that we
2013 // cannot just increment the current match ordinal; we need to re-generate 2014 // cannot just increment the current match ordinal; we need to re-generate
2014 // it. 2015 // it.
2015 // 2016 //
2016 // (3) TextFinder::Find() found what should be the next match (|result| is 2017 // 3) TextFinder::Find() could not locate the next active find match, so it
2017 // true), but was unable to activate it (|activeNow| is false). This means 2018 // needs to be re-scoped.
2018 // that the text containing this match was dynamically added since the last
2019 // scope of the frame. The frame needs to be re-scoped so that any matches
2020 // in the new text can be highlighted and included in the reported number of
2021 // matches.
2022 // 2019 //
2023 // If none of these cases are true, then we just report the current match 2020 // If none of these cases are true, then we just report the current match
2024 // count without scoping. 2021 // count without scoping.
2025 if (/* (1) */ options.findNext 2022 if (options.findNext && currentSelection.isNull() && activeNow) {
2026 && /* (2) */ currentSelection.isNull()
2027 && /* (3) */ !(result && !activeNow)) {
2028 // Force report of the actual count. 2023 // Force report of the actual count.
2029 increaseMatchCount(0, identifier); 2024 increaseMatchCount(0, identifier);
2030 return; 2025 return;
2031 } 2026 }
2032 2027
2033 // Scoping effort begins. 2028 // Scoping effort begins.
2034 ensureTextFinder().resetMatchCount(); 2029 ensureTextFinder().resetMatchCount();
2035 textFinder()->cancelPendingScopingEffort(); 2030 textFinder()->cancelPendingScopingEffort();
2036 2031
2037 // Start a new scoping request. If the scoping function determines that it 2032 // Start a new scoping request. If the scoping function determines that it
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 feature = UseCounter::ChromeLoadTimesNpnNegotiatedProtocol; 2240 feature = UseCounter::ChromeLoadTimesNpnNegotiatedProtocol;
2246 } else if (metric == "wasAlternateProtocolAvailable") { 2241 } else if (metric == "wasAlternateProtocolAvailable") {
2247 feature = UseCounter::ChromeLoadTimesWasAlternateProtocolAvailable; 2242 feature = UseCounter::ChromeLoadTimesWasAlternateProtocolAvailable;
2248 } else if (metric == "connectionInfo") { 2243 } else if (metric == "connectionInfo") {
2249 feature = UseCounter::ChromeLoadTimesConnectionInfo; 2244 feature = UseCounter::ChromeLoadTimesConnectionInfo;
2250 } 2245 }
2251 UseCounter::count(frame(), feature); 2246 UseCounter::count(frame(), feature);
2252 } 2247 }
2253 2248
2254 } // namespace blink 2249 } // namespace blink
OLDNEW
« no previous file with comments | « content/test/data/find_in_long_page.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698