Chromium Code Reviews| Index: chrome/browser/instant/instant_controller.cc |
| diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc |
| index 0c0f54706186ed867be074c5b94ac6579ce32d6f..4123a0be1f5fdcf661e1449b8f1e525a7ffcf90d 100644 |
| --- a/chrome/browser/instant/instant_controller.cc |
| +++ b/chrome/browser/instant/instant_controller.cc |
| @@ -152,7 +152,9 @@ InstantController::InstantController(chrome::BrowserInstantController* browser, |
| last_verbatim_(false), |
| last_transition_type_(content::PAGE_TRANSITION_LINK), |
| last_match_was_search_(false), |
| - is_omnibox_focused_(false) { |
| + is_omnibox_focused_(false), |
| + start_margin_(0), |
| + end_margin_(0) { |
| } |
| InstantController::~InstantController() { |
| @@ -315,15 +317,15 @@ bool InstantController::Update(const AutocompleteMatch& match, |
| // TODO(tonyg): This method only fires when the omnibox bounds change. It also |
| // needs to fire when the preview bounds change (e.g.: open/close info bar). |
| -void InstantController::SetOmniboxBounds(const gfx::Rect& bounds) { |
| +void InstantController::SetPopupBounds(const gfx::Rect& bounds) { |
| if (!extended_enabled_ && !instant_enabled_) |
| return; |
| - if (omnibox_bounds_ == bounds) |
| + if (popup_bounds_ == bounds) |
| return; |
| - omnibox_bounds_ = bounds; |
| - if (omnibox_bounds_.height() > last_omnibox_bounds_.height()) { |
| + popup_bounds_ = bounds; |
| + if (popup_bounds_.height() > last_popup_bounds_.height()) { |
| update_bounds_timer_.Stop(); |
| SendBoundsToPage(); |
| } else if (!update_bounds_timer_.IsRunning()) { |
| @@ -333,6 +335,16 @@ void InstantController::SetOmniboxBounds(const gfx::Rect& bounds) { |
| } |
| } |
| +void InstantController::SetMarginSize(int start, int end) { |
| + if ((start_margin_ == start && end_margin_ == end) || |
| + !GetPreviewContents() || loader_->IsPointerDownFromActivate()) |
|
sreeram
2012/11/29 19:22:49
Add "|| !extended_enabled_".
Remove "loader_->IsP
melevin
2012/11/30 23:37:09
Thanks for the explanation, I just copy-pasted it
|
| + return; |
| + |
| + start_margin_ = start; |
| + end_margin_ = end; |
| + loader_->SetMarginSize(start_margin_, end_margin_); |
| +} |
| + |
| void InstantController::HandleAutocompleteResults( |
| const std::vector<AutocompleteProvider*>& providers) { |
| if (!extended_enabled_) |
| @@ -702,10 +714,12 @@ bool InstantController::ResetLoader(const TemplateURL* template_url, |
| loader_.reset(new InstantLoader(this, instant_url, active_tab)); |
| loader_->Init(); |
| - // Ensure the searchbox API has the correct theme-related info and context. |
| + // Ensure the searchbox API has the correct theme-related info, context, |
| + // and margins dimensions. |
| if (extended_enabled_) { |
| browser_->UpdateThemeInfoForPreview(); |
| loader_->SearchModeChanged(search_mode_); |
| + loader_->SetMarginSize(start_margin_, end_margin_); |
| } |
| // Reset the loader timer. |
| @@ -751,8 +765,8 @@ void InstantController::DeleteLoader() { |
| last_match_was_search_ = false; |
| if (!extended_enabled_) |
| search_mode_.mode = chrome::search::Mode::MODE_DEFAULT; |
| - omnibox_bounds_ = gfx::Rect(); |
| - last_omnibox_bounds_ = gfx::Rect(); |
| + popup_bounds_ = gfx::Rect(); |
| + last_popup_bounds_ = gfx::Rect(); |
| update_bounds_timer_.Stop(); |
| stale_loader_timer_.Stop(); |
| url_for_history_ = GURL(); |
| @@ -819,13 +833,13 @@ void InstantController::Show(InstantShownReason reason, |
| } |
| void InstantController::SendBoundsToPage() { |
| - if (last_omnibox_bounds_ == omnibox_bounds_ || |
| + if (last_popup_bounds_ == popup_bounds_ || |
| !GetPreviewContents() || loader_->IsPointerDownFromActivate()) |
| return; |
| - last_omnibox_bounds_ = omnibox_bounds_; |
| + last_popup_bounds_ = popup_bounds_; |
| gfx::Rect preview_bounds = browser_->GetInstantBounds(); |
| - gfx::Rect intersection = gfx::IntersectRects(omnibox_bounds_, preview_bounds); |
| + gfx::Rect intersection = gfx::IntersectRects(popup_bounds_, preview_bounds); |
| // Translate into window coordinates. |
| if (!intersection.IsEmpty()) { |
| @@ -842,7 +856,7 @@ void InstantController::SendBoundsToPage() { |
| DCHECK_LE(0, intersection.width()); |
| DCHECK_LE(0, intersection.height()); |
| - loader_->SetOmniboxBounds(intersection); |
| + loader_->SetPopupBounds(intersection); |
| } |
| bool InstantController::GetInstantURL(const TemplateURL* template_url, |