Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5258)

Unified Diff: chrome/browser/instant/instant_controller.cc

Issue 11359198: Implement the Instant extended API startMargin, endMargin, and rtl properties and the onmarginchang… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/instant/instant_controller.cc
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 613584314977744b0bce880412250ee2851d7567..6d3cc0d8efd9ed312f5619403f9130592c16a286 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,36 @@ 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))
+ return;
+
+ start_margin_ = start;
+ end_margin_ = end;
+ if (loader_)
+ loader_->SetMarginSize(start_margin_, end_margin_);
+ if (instant_tab_)
+ instant_tab_->SetMarginSize(start_margin_, end_margin_);
+}
+
void InstantController::HandleAutocompleteResults(
const std::vector<AutocompleteProvider*>& providers) {
if (!extended_enabled_)
@@ -779,6 +793,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.
@@ -819,6 +834,7 @@ void InstantController::ResetInstantTab() {
if (!instant_tab_ || active_tab != instant_tab_->contents()) {
instant_tab_.reset(new InstantTab(this, active_tab));
instant_tab_->Init();
+ loader_->SetMarginSize(start_margin_, end_margin_);
}
// Hide the |loader_| since we are now using |instant_tab_| instead.
@@ -929,14 +945,14 @@ void InstantController::ShowLoader(InstantShownReason reason,
model_.SetPreviewState(search_mode_, 100, INSTANT_SIZE_PERCENT);
}
-void InstantController::SendBoundsToPage() {
- if (last_omnibox_bounds_ == omnibox_bounds_ || !loader_ ||
+void InstantController::SendPopupBoundsToPage() {
+ if (last_popup_bounds_ == popup_bounds_ || !loader_ ||
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()) {
@@ -953,7 +969,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,

Powered by Google App Engine
This is Rietveld 408576698