Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/views/autocomplete/autocomplete_popup_contents_view. h" | 5 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <commctrl.h> | 8 #include <commctrl.h> |
| 9 #include <dwmapi.h> | 9 #include <dwmapi.h> |
| 10 #include <objidl.h> | 10 #include <objidl.h> |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 v->GetPreferredSize().height()); | 264 v->GetPreferredSize().height()); |
| 265 top = v->bounds().bottom(); | 265 top = v->bounds().bottom(); |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 //////////////////////////////////////////////////////////////////////////////// | 270 //////////////////////////////////////////////////////////////////////////////// |
| 271 // AutocompletePopupContentsView, AutocompletePopupView overrides: | 271 // AutocompletePopupContentsView, AutocompletePopupView overrides: |
| 272 | 272 |
| 273 bool AutocompletePopupContentsView::IsOpen() const { | 273 bool AutocompletePopupContentsView::IsOpen() const { |
| 274 return (popup_ != NULL); | 274 return (popup_ != NULL); |
|
sky
2011/10/13 15:58:02
I don't like that if ShouldHideAutocompletePopup r
Peter Kasting
2011/10/13 17:53:53
Yeah, this is bad. Besides the instant effect Sco
| |
| 275 } | 275 } |
| 276 | 276 |
| 277 void AutocompletePopupContentsView::InvalidateLine(size_t line) { | 277 void AutocompletePopupContentsView::InvalidateLine(size_t line) { |
| 278 child_at(static_cast<int>(line))->SchedulePaint(); | 278 child_at(static_cast<int>(line))->SchedulePaint(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 void AutocompletePopupContentsView::UpdatePopupAppearance() { | 281 void AutocompletePopupContentsView::UpdatePopupAppearance() { |
| 282 if (model_->result().empty()) { | 282 if (model_->result().empty()) { |
| 283 // No matches, close any existing popup. | 283 // No matches, close any existing popup. |
| 284 if (popup_ != NULL) { | 284 if (popup_ != NULL) { |
| 285 size_animation_.Stop(); | 285 size_animation_.Stop(); |
| 286 // NOTE: Do NOT use CloseNow() here, as we may be deep in a callstack | 286 // NOTE: Do NOT use CloseNow() here, as we may be deep in a callstack |
| 287 // triggered by the popup receiving a message (e.g. LBUTTONUP), and | 287 // triggered by the popup receiving a message (e.g. LBUTTONUP), and |
| 288 // destroying the popup would cause us to read garbage when we unwind back | 288 // destroying the popup would cause us to read garbage when we unwind back |
| 289 // to that level. | 289 // to that level. |
| 290 popup_->Close(); // This will eventually delete the popup. | 290 popup_->Close(); // This will eventually delete the popup. |
| 291 popup_.reset(); | 291 popup_.reset(); |
| 292 } | 292 } |
| 293 return; | 293 return; |
| 294 } | 294 } |
| 295 | 295 |
| 296 if (omnibox_view_->ShouldHideAutocompletePopup()) { | |
| 297 if (popup_) | |
| 298 popup_->Hide(); | |
| 299 return; | |
| 300 } | |
| 301 | |
| 296 // Update the match cached by each row, in the process of doing so make sure | 302 // Update the match cached by each row, in the process of doing so make sure |
| 297 // we have enough row views. | 303 // we have enough row views. |
| 298 size_t child_rv_count = child_count(); | 304 size_t child_rv_count = child_count(); |
| 299 if (opt_in_view_) { | 305 if (opt_in_view_) { |
| 300 DCHECK_GT(child_rv_count, 0u); | 306 DCHECK_GT(child_rv_count, 0u); |
| 301 child_rv_count--; | 307 child_rv_count--; |
| 302 } | 308 } |
| 303 for (size_t i = 0; i < model_->result().size(); ++i) { | 309 for (size_t i = 0; i < model_->result().size(); ++i) { |
| 304 AutocompleteResultView* result_view; | 310 AutocompleteResultView* result_view; |
| 305 if (i >= child_rv_count) { | 311 if (i >= child_rv_count) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 popup_->MoveAbove(omnibox_view_->GetRelativeWindowForPopup()); | 354 popup_->MoveAbove(omnibox_view_->GetRelativeWindowForPopup()); |
| 349 if (!popup_.get()) { | 355 if (!popup_.get()) { |
| 350 // For some IMEs GetRelativeWindowForPopup triggers the omnibox to lose | 356 // For some IMEs GetRelativeWindowForPopup triggers the omnibox to lose |
| 351 // focus, thereby closing (and destroying) the popup. | 357 // focus, thereby closing (and destroying) the popup. |
| 352 // TODO(sky): this won't be needed once we close the omnibox on input | 358 // TODO(sky): this won't be needed once we close the omnibox on input |
| 353 // window showing. | 359 // window showing. |
| 354 return; | 360 return; |
| 355 } | 361 } |
| 356 popup_->Show(); | 362 popup_->Show(); |
| 357 } else { | 363 } else { |
| 364 popup_->Show(); | |
| 358 // Animate the popup shrinking, but don't animate growing larger since that | 365 // Animate the popup shrinking, but don't animate growing larger since that |
| 359 // would make the popup feel less responsive. | 366 // would make the popup feel less responsive. |
| 360 start_bounds_ = GetWidget()->GetWindowScreenBounds(); | 367 start_bounds_ = GetWidget()->GetWindowScreenBounds(); |
| 361 if (target_bounds_.height() < start_bounds_.height()) | 368 if (target_bounds_.height() < start_bounds_.height()) |
| 362 size_animation_.Show(); | 369 size_animation_.Show(); |
| 363 else | 370 else |
| 364 start_bounds_ = target_bounds_; | 371 start_bounds_ = target_bounds_; |
| 365 popup_->SetBounds(GetPopupBounds()); | 372 popup_->SetBounds(GetPopupBounds()); |
| 366 } | 373 } |
| 367 | 374 |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 opt_in_view_ = NULL; | 693 opt_in_view_ = NULL; |
| 687 PromoCounter* counter = profile_->GetInstantPromoCounter(); | 694 PromoCounter* counter = profile_->GetInstantPromoCounter(); |
| 688 DCHECK(counter); | 695 DCHECK(counter); |
| 689 counter->Hide(); | 696 counter->Hide(); |
| 690 if (opt_in) { | 697 if (opt_in) { |
| 691 browser::ShowInstantConfirmDialogIfNecessary( | 698 browser::ShowInstantConfirmDialogIfNecessary( |
| 692 location_bar_->GetWidget()->GetNativeWindow(), profile_); | 699 location_bar_->GetWidget()->GetNativeWindow(), profile_); |
| 693 } | 700 } |
| 694 UpdatePopupAppearance(); | 701 UpdatePopupAppearance(); |
| 695 } | 702 } |
| OLD | NEW |