| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/find_request_manager.h" | 5 #include "content/browser/find_request_manager.h" |
| 6 | 6 |
| 7 #include "content/browser/frame_host/render_frame_host_impl.h" | 7 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 8 #include "content/browser/web_contents/web_contents_impl.h" | 8 #include "content/browser/web_contents/web_contents_impl.h" |
| 9 #include "content/common/frame_messages.h" | 9 #include "content/common/frame_messages.h" |
| 10 #include "content/common/input_messages.h" | 10 #include "content/common/input_messages.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // Check for an update to the number of matches. | 153 // Check for an update to the number of matches. |
| 154 if (number_of_matches != -1) { | 154 if (number_of_matches != -1) { |
| 155 DCHECK_GE(number_of_matches, 0); | 155 DCHECK_GE(number_of_matches, 0); |
| 156 auto matches_per_frame_it = matches_per_frame_.find(rfh); | 156 auto matches_per_frame_it = matches_per_frame_.find(rfh); |
| 157 if (int matches_delta = number_of_matches - matches_per_frame_it->second) { | 157 if (int matches_delta = number_of_matches - matches_per_frame_it->second) { |
| 158 // Increment the global number of matches by the number of additional | 158 // Increment the global number of matches by the number of additional |
| 159 // matches found for this frame. | 159 // matches found for this frame. |
| 160 number_of_matches_ += matches_delta; | 160 number_of_matches_ += matches_delta; |
| 161 matches_per_frame_it->second = number_of_matches; | 161 matches_per_frame_it->second = number_of_matches; |
| 162 | 162 |
| 163 // All matches may have been removed since the last find reply. |
| 164 if (rfh == active_frame_ && !number_of_matches) |
| 165 relative_active_match_ordinal_ = 0; |
| 166 |
| 163 // The active match ordinal may need updating since the number of matches | 167 // The active match ordinal may need updating since the number of matches |
| 164 // before the active match may have changed. | 168 // before the active match may have changed. |
| 165 if (rfh != active_frame_) | 169 if (rfh != active_frame_ || !number_of_matches) |
| 166 UpdateActiveMatchOrdinal(); | 170 UpdateActiveMatchOrdinal(); |
| 167 } | 171 } |
| 168 } | 172 } |
| 169 | 173 |
| 170 // Check for an update to the selection rect. | 174 // Check for an update to the selection rect. |
| 171 if (!selection_rect.IsEmpty()) | 175 if (!selection_rect.IsEmpty()) |
| 172 selection_rect_ = selection_rect; | 176 selection_rect_ = selection_rect; |
| 173 | 177 |
| 174 // Check for an update to the active match ordinal. | 178 // Check for an update to the active match ordinal. |
| 175 if (active_match_ordinal > 0) { | 179 if (active_match_ordinal > 0) { |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 aggregate_rects.end(), frame_rects.begin(), frame_rects.end()); | 642 aggregate_rects.end(), frame_rects.begin(), frame_rects.end()); |
| 639 } | 643 } |
| 640 } | 644 } |
| 641 contents_->NotifyFindMatchRectsReply( | 645 contents_->NotifyFindMatchRectsReply( |
| 642 match_rects_.known_version, aggregate_rects, match_rects_.active_rect); | 646 match_rects_.known_version, aggregate_rects, match_rects_.active_rect); |
| 643 } | 647 } |
| 644 } | 648 } |
| 645 #endif | 649 #endif |
| 646 | 650 |
| 647 } // namespace content | 651 } // namespace content |
| OLD | NEW |