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: chrome/browser/autocomplete/autocomplete.cc

Issue 372017: Fix various problems with inline autocomplete and URLs that change length dur... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/autocomplete/autocomplete.h" 5 #include "chrome/browser/autocomplete/autocomplete.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 ClassifyLocationInString(text.find(find_text), find_text.length(), 431 ClassifyLocationInString(text.find(find_text), find_text.length(),
432 text.length(), style, classification); 432 text.length(), style, classification);
433 } 433 }
434 434
435 void AutocompleteMatch::ClassifyLocationInString( 435 void AutocompleteMatch::ClassifyLocationInString(
436 size_t match_location, 436 size_t match_location,
437 size_t match_length, 437 size_t match_length,
438 size_t overall_length, 438 size_t overall_length,
439 int style, 439 int style,
440 ACMatchClassifications* classification) { 440 ACMatchClassifications* classification) {
441 // Classifying an empty match makes no sense and will lead to validation
442 // errors later.
443 DCHECK(match_length > 0);
444
445 classification->clear(); 441 classification->clear();
446 442
447 // Don't classify anything about an empty string 443 // Don't classify anything about an empty string
448 // (AutocompleteMatch::Validate() checks this). 444 // (AutocompleteMatch::Validate() checks this).
449 if (overall_length == 0) 445 if (overall_length == 0)
450 return; 446 return;
451 447
452 // Mark pre-match portion of string (if any). 448 // Mark pre-match portion of string (if any).
453 if (match_location != 0) { 449 if (match_location != 0) {
454 classification->push_back(ACMatchClassification(0, style)); 450 classification->push_back(ACMatchClassification(0, style));
455 } 451 }
456 452
457 // Mark matching portion of string. 453 // Mark matching portion of string.
458 if (match_location == std::wstring::npos) { 454 if (match_location == std::wstring::npos) {
459 // No match, above classification will suffice for whole string. 455 // No match, above classification will suffice for whole string.
460 return; 456 return;
461 } 457 }
458 // Classifying an empty match makes no sense and will lead to validation
459 // errors later.
460 DCHECK(match_length > 0);
462 classification->push_back(ACMatchClassification(match_location, 461 classification->push_back(ACMatchClassification(match_location,
463 (style | ACMatchClassification::MATCH) & ~ACMatchClassification::DIM)); 462 (style | ACMatchClassification::MATCH) & ~ACMatchClassification::DIM));
464 463
465 // Mark post-match portion of string (if any). 464 // Mark post-match portion of string (if any).
466 const size_t after_match(match_location + match_length); 465 const size_t after_match(match_location + match_length);
467 if (after_match < overall_length) { 466 if (after_match < overall_length) {
468 classification->push_back(ACMatchClassification(after_match, style)); 467 classification->push_back(ACMatchClassification(after_match, style));
469 } 468 }
470 } 469 }
471 470
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 void AutocompleteController::CheckIfDone() { 962 void AutocompleteController::CheckIfDone() {
964 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end(); 963 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end();
965 ++i) { 964 ++i) {
966 if (!(*i)->done()) { 965 if (!(*i)->done()) {
967 done_ = false; 966 done_ = false;
968 return; 967 return;
969 } 968 }
970 } 969 }
971 done_ = true; 970 done_ = true;
972 } 971 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete.h ('k') | chrome/browser/autocomplete/history_url_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698