Index: chrome/browser/instant/instant_controller.cc |
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc |
index f6c77257a3a0fc552bcbffa261dddca92df7700b..6fcabbd52be5d6a42de8da634845ec15db919bbf 100644 |
--- a/chrome/browser/instant/instant_controller.cc |
+++ b/chrome/browser/instant/instant_controller.cc |
@@ -153,6 +153,8 @@ InstantController::InstantController(chrome::BrowserInstantController* browser, |
last_transition_type_(content::PAGE_TRANSITION_LINK), |
last_match_was_search_(false), |
is_omnibox_focused_(false), |
+ start_margin_(0), |
+ end_margin_(0), |
allow_preview_to_show_search_suggestions_(false) { |
} |
@@ -344,24 +346,34 @@ 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(); |
+ SendPopupBoundsToPage(); |
} else if (!update_bounds_timer_.IsRunning()) { |
update_bounds_timer_.Start(FROM_HERE, |
base::TimeDelta::FromMilliseconds(kUpdateBoundsDelayMS), this, |
- &InstantController::SendBoundsToPage); |
+ &InstantController::SendPopupBoundsToPage); |
} |
} |
+void InstantController::SetMarginSize(int start, int end) { |
+ if (!extended_enabled_ || (start_margin_ == start && end_margin_ == end) || |
+ !GetPreviewContents()) |
+ return; |
sreeram
2012/12/05 00:14:46
The margin should be sent to committed tabs too. I
melevin
2012/12/06 23:13:00
Done.
|
+ |
+ start_margin_ = start; |
+ end_margin_ = end; |
+ loader_->SetMarginSize(start_margin_, end_margin_); |
+} |
+ |
void InstantController::HandleAutocompleteResults( |
const std::vector<AutocompleteProvider*>& providers) { |
if (!extended_enabled_) |
@@ -773,6 +785,7 @@ bool InstantController::ResetLoader(const TemplateURL* template_url, |
browser_->UpdateThemeInfoForPreview(); |
loader_->SetDisplayInstantResults(instant_enabled_); |
loader_->SearchModeChanged(search_mode_); |
+ loader_->SetMarginSize(start_margin_, end_margin_); |
} |
// Restart the stale loader timer. |
@@ -923,14 +936,14 @@ void InstantController::ShowLoader(InstantShownReason reason, |
model_.SetPreviewState(search_mode_, 100, INSTANT_SIZE_PERCENT); |
} |
-void InstantController::SendBoundsToPage() { |
+void InstantController::SendPopupBoundsToPage() { |
if (last_omnibox_bounds_ == omnibox_bounds_ || !loader_ || |
sreeram
2012/12/05 00:14:46
Shouldn't this be "last_popup_bounds_ == popup_bou
melevin
2012/12/06 23:13:00
Done.
|
loader_->is_pointer_down_from_activate()) |
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()) { |
@@ -947,7 +960,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, |