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..8198b55377b1ae2b2c4e07c2735925d23633719a 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()) |
+ return; |
+ |
+ start_margin_ = start; |
+ end_margin_ = end; |
+ loader_->SetMarginSize(start_margin_, end_margin_); |
+} |
+ |
void InstantController::HandleAutocompleteResults( |
const std::vector<AutocompleteProvider*>& providers) { |
if (!extended_enabled_) |
@@ -706,6 +718,7 @@ bool InstantController::ResetLoader(const TemplateURL* template_url, |
if (extended_enabled_) { |
browser_->UpdateThemeInfoForPreview(); |
loader_->SearchModeChanged(search_mode_); |
+ loader_->SetMarginSize(start_margin_, end_margin_); |
} |
// Reset the loader timer. |
@@ -751,8 +764,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 +832,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 +855,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, |