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

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

Issue 2186113002: Fix find-in-page re-scope across frame boundaries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix in test. 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
1993 bool result = false; 1992 bool result = false;
1994 bool activeNow = false; 1993 bool activeNow = false;
1995 1994
1996 // Search for an active match only if this frame is focused or if this is a 1995 // Search for an active match only if this frame is focused or if this is a
1997 // find next request. 1996 // find next request.
1998 if (isFocused() || options.findNext) { 1997 if (isFocused() || options.findNext) {
1999 result = find(identifier, searchText, options, false /* wrapWithinFrame */, &activeNow); 1998 result = find(identifier, searchText, options, false /* wrapWithinFrame */, &activeNow);
2000 } 1999 }
2001 2000
2002 if (result && !options.findNext) { 2001 if (result && !options.findNext) {
2003 // Indicate that at least one match has been found. 1 here means 2002 // Indicate that at least one match has been found. 1 here means
2004 // possibly more matches could be coming. 2003 // possibly more matches could be coming.
2005 client()->reportFindInPageMatchCount(identifier, 1 /* count */, false /* finalUpdate */); 2004 client()->reportFindInPageMatchCount(identifier, 1 /* count */, false /* finalUpdate */);
2006 } 2005 }
2007 2006
2008 // There are three cases in which scoping is needed: 2007 // There are three cases in which scoping is needed:
2009 // 2008 //
2010 // 1) This is an initial find request (|options.findNext| is false). This 2009 // (1) This is an initial find request (|options.findNext| is false). This
2011 // will be the first scoping effort for this find session. 2010 // will be the first scoping effort for this find session.
2012 // 2011 //
2013 // 2) Something has been selected since the last search. This means that we 2012 // (2) Something has been selected since the last search. This means that we
2014 // cannot just increment the current match ordinal; we need to re-generate 2013 // cannot just increment the current match ordinal; we need to re-generate
2015 // it. 2014 // it.
2016 // 2015 //
2017 // 3) TextFinder::Find() could not locate the next active find match, so it 2016 // (3) TextFinder::Find() found what should be the next match (|result| is
2018 // needs to be re-scoped. 2017 // true), but was unable to activate it (|activeNow| is false). This means
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.
2019 // 2022 //
2020 // If none of these cases are true, then we just report the current match 2023 // If none of these cases are true, then we just report the current match
2021 // count without scoping. 2024 // count without scoping.
2022 if (options.findNext && currentSelection.isNull() && activeNow) { 2025 if (/* (1) */ options.findNext
2026 && /* (2) */ currentSelection.isNull()
2027 && /* (3) */ !(result && !activeNow)) {
2023 // Force report of the actual count. 2028 // Force report of the actual count.
2024 increaseMatchCount(0, identifier); 2029 increaseMatchCount(0, identifier);
2025 return; 2030 return;
2026 } 2031 }
2027 2032
2028 // Scoping effort begins. 2033 // Scoping effort begins.
2029 ensureTextFinder().resetMatchCount(); 2034 ensureTextFinder().resetMatchCount();
2030 textFinder()->cancelPendingScopingEffort(); 2035 textFinder()->cancelPendingScopingEffort();
2031 2036
2032 // Start a new scoping request. If the scoping function determines that it 2037 // Start a new scoping request. If the scoping function determines that it
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2240 feature = UseCounter::ChromeLoadTimesNpnNegotiatedProtocol; 2245 feature = UseCounter::ChromeLoadTimesNpnNegotiatedProtocol;
2241 } else if (metric == "wasAlternateProtocolAvailable") { 2246 } else if (metric == "wasAlternateProtocolAvailable") {
2242 feature = UseCounter::ChromeLoadTimesWasAlternateProtocolAvailable; 2247 feature = UseCounter::ChromeLoadTimesWasAlternateProtocolAvailable;
2243 } else if (metric == "connectionInfo") { 2248 } else if (metric == "connectionInfo") {
2244 feature = UseCounter::ChromeLoadTimesConnectionInfo; 2249 feature = UseCounter::ChromeLoadTimesConnectionInfo;
2245 } 2250 }
2246 UseCounter::count(frame(), feature); 2251 UseCounter::count(frame(), feature);
2247 } 2252 }
2248 2253
2249 } // namespace blink 2254 } // 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