Index: chrome/browser/instant/instant_controller.cc |
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc |
index ef6bb1306a6e9bfaae299f321845860cd0a70acf..d884a63048774b0fc973e1486672cd2809df7055 100644 |
--- a/chrome/browser/instant/instant_controller.cc |
+++ b/chrome/browser/instant/instant_controller.cc |
@@ -259,12 +259,12 @@ 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) { |
- if (omnibox_bounds_ == bounds) |
+void InstantController::SetPopupBounds(const gfx::Rect& 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()) { |
@@ -274,6 +274,17 @@ void InstantController::SetOmniboxBounds(const gfx::Rect& bounds) { |
} |
} |
+void InstantController::SetMarginSize(int start, int end) { |
+ if ((start_margin_ == start && end_margin_ == end) || |
+ model_.preview_state() == InstantModel::NOT_READY || |
+ !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 (mode_ != EXTENDED || !GetPreviewContents()) |
@@ -329,6 +340,10 @@ void InstantController::Hide() { |
last_user_text_.clear(); |
loader_->Update(last_full_text_, true); |
} |
+ |
+ // Clear the margins so they are set when the preview is shown again. |
samarth
2012/11/16 22:08:26
Why is this necessary?
melevin
2012/11/16 22:34:43
When the SearchBox object is created it does not h
samarth
2012/11/19 21:42:44
Take a look at ResetLoader. Whenever we load a new
melevin
2012/11/20 22:32:20
I only see the instant URL being communicated to t
samarth
2012/11/20 22:47:37
I meant something like https://cs.corp.google.com/
|
+ start_margin_ = 0; |
+ end_margin_ = 0; |
} |
bool InstantController::IsCurrent() const { |
@@ -716,7 +731,7 @@ void InstantController::DeleteLoader() { |
last_verbatim_ = false; |
last_suggestion_ = InstantSuggestion(); |
last_match_was_search_ = false; |
- last_omnibox_bounds_ = gfx::Rect(); |
+ last_popup_bounds_ = gfx::Rect(); |
url_for_history_ = GURL(); |
if (GetPreviewContents()) |
model_.SetPreviewState(InstantModel::NOT_READY, 0, INSTANT_SIZE_PERCENT); |
@@ -744,14 +759,14 @@ void InstantController::Show(InstantShownReason reason, |
} |
void InstantController::SendBoundsToPage() { |
- if (last_omnibox_bounds_ == omnibox_bounds_ || |
+ if (last_popup_bounds_ == popup_bounds_ || |
model_.preview_state() == InstantModel::NOT_READY || |
!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()) { |
@@ -768,7 +783,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, |