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

Side by Side Diff: webkit/api/src/WebFrameImpl.cpp

Issue 335012: Update the find result index "(m of n)" whenever there is an active selection... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: simplify test Created 11 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/find_in_page/select_changes_ordinal.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 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 else 1099 else
1100 setMarkerActive(m_activeMatch.get(), false); // Active match is changing. 1100 setMarkerActive(m_activeMatch.get(), false); // Active match is changing.
1101 1101
1102 // Starts the search from the current selection. 1102 // Starts the search from the current selection.
1103 bool startInSelection = true; 1103 bool startInSelection = true;
1104 1104
1105 // If the user has selected something since the last Find operation we want 1105 // If the user has selected something since the last Find operation we want
1106 // to start from there. Otherwise, we start searching from where the last Find 1106 // to start from there. Otherwise, we start searching from where the last Find
1107 // operation left off (either a Find or a FindNext operation). 1107 // operation left off (either a Find or a FindNext operation).
1108 VisibleSelection selection(frame()->selection()->selection()); 1108 VisibleSelection selection(frame()->selection()->selection());
1109 if (selection.isNone() && m_activeMatch) { 1109 bool activeSelection = !selection.isNone();
1110 if (!activeSelection && m_activeMatch) {
1110 selection = VisibleSelection(m_activeMatch.get()); 1111 selection = VisibleSelection(m_activeMatch.get());
1111 frame()->selection()->setSelection(selection); 1112 frame()->selection()->setSelection(selection);
1112 } 1113 }
1113 1114
1114 ASSERT(frame() && frame()->view()); 1115 ASSERT(frame() && frame()->view());
1115 bool found = frame()->findString( 1116 bool found = frame()->findString(
1116 searchText, options.forward, options.matchCase, wrapWithinFrame, 1117 searchText, options.forward, options.matchCase, wrapWithinFrame,
1117 startInSelection); 1118 startInSelection);
1118 if (found) { 1119 if (found) {
1119 // Store which frame was active. This will come in handy later when we 1120 // Store which frame was active. This will come in handy later when we
(...skipping 14 matching lines...) Expand all
1134 if (newSelection.isNone() || (newSelection.start() == newSelection.end())) 1135 if (newSelection.isNone() || (newSelection.start() == newSelection.end()))
1135 m_activeMatch = 0; 1136 m_activeMatch = 0;
1136 else { 1137 else {
1137 m_activeMatch = newSelection.toNormalizedRange(); 1138 m_activeMatch = newSelection.toNormalizedRange();
1138 currSelectionRect = m_activeMatch->boundingBox(); 1139 currSelectionRect = m_activeMatch->boundingBox();
1139 setMarkerActive(m_activeMatch.get(), true); // Active. 1140 setMarkerActive(m_activeMatch.get(), true); // Active.
1140 // WebKit draws the highlighting for all matches. 1141 // WebKit draws the highlighting for all matches.
1141 executeCommand(WebString::fromUTF8("Unselect")); 1142 executeCommand(WebString::fromUTF8("Unselect"));
1142 } 1143 }
1143 1144
1144 if (!options.findNext) { 1145 if (!options.findNext || activeSelection) {
1145 // This is a Find operation, so we set the flag to ask the scoping effort 1146 // This is either a Find operation or a Find-next from a new start point
1147 // due to a selection, so we set the flag to ask the scoping effort
1146 // to find the active rect for us so we can update the ordinal (n of m). 1148 // to find the active rect for us so we can update the ordinal (n of m).
1147 m_locatingActiveRect = true; 1149 m_locatingActiveRect = true;
1148 } else { 1150 } else {
1149 if (oldActiveFrame != this) { 1151 if (oldActiveFrame != this) {
1150 // If the active frame has changed it means that we have a multi-frame 1152 // If the active frame has changed it means that we have a multi-frame
1151 // page and we just switch to searching in a new frame. Then we just 1153 // page and we just switch to searching in a new frame. Then we just
1152 // want to reset the index. 1154 // want to reset the index.
1153 if (options.forward) 1155 if (options.forward)
1154 m_activeMatchIndex = 0; 1156 m_activeMatchIndex = 0;
1155 else 1157 else
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 1883
1882 if (!m_frame->redirectScheduler()->locationChangePending()) { 1884 if (!m_frame->redirectScheduler()->locationChangePending()) {
1883 m_frame->loader()->stopAllLoaders(); 1885 m_frame->loader()->stopAllLoaders();
1884 m_frame->loader()->begin(m_frame->loader()->url(), true, securityOrigin); 1886 m_frame->loader()->begin(m_frame->loader()->url(), true, securityOrigin);
1885 m_frame->loader()->write(scriptResult); 1887 m_frame->loader()->write(scriptResult);
1886 m_frame->loader()->end(); 1888 m_frame->loader()->end();
1887 } 1889 }
1888 } 1890 }
1889 1891
1890 } // namespace WebKit 1892 } // namespace WebKit
OLDNEW
« no previous file with comments | « chrome/test/data/find_in_page/select_changes_ordinal.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698