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

Side by Side Diff: chrome/browser/instant/instant_controller.cc

Issue 11270042: Add non-member non-mutating methods for common gfx::Rect operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/software_renderer.cc ('k') | chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/instant/instant_controller.h" 5 #include "chrome/browser/instant/instant_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/i18n/case_conversion.h" 8 #include "base/i18n/case_conversion.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 model_.SetDisplayState(InstantModel::QUERY_RESULTS, height, units); 737 model_.SetDisplayState(InstantModel::QUERY_RESULTS, height, units);
738 } 738 }
739 739
740 void InstantController::SendBoundsToPage() { 740 void InstantController::SendBoundsToPage() {
741 if (last_omnibox_bounds_ == omnibox_bounds_ || IsOutOfDate() || 741 if (last_omnibox_bounds_ == omnibox_bounds_ || IsOutOfDate() ||
742 !GetPreviewContents() || loader_->IsPointerDownFromActivate()) 742 !GetPreviewContents() || loader_->IsPointerDownFromActivate())
743 return; 743 return;
744 744
745 last_omnibox_bounds_ = omnibox_bounds_; 745 last_omnibox_bounds_ = omnibox_bounds_;
746 gfx::Rect preview_bounds = browser_->GetInstantBounds(); 746 gfx::Rect preview_bounds = browser_->GetInstantBounds();
747 gfx::Rect intersection = omnibox_bounds_; 747 gfx::Rect intersection = gfx::IntersectRects(omnibox_bounds_, preview_bounds);
748 intersection.Intersect(preview_bounds);
749 748
750 // Translate into window coordinates. 749 // Translate into window coordinates.
751 if (!intersection.IsEmpty()) { 750 if (!intersection.IsEmpty()) {
752 intersection.Offset(-preview_bounds.origin().x(), 751 intersection.Offset(-preview_bounds.origin().x(),
753 -preview_bounds.origin().y()); 752 -preview_bounds.origin().y());
754 } 753 }
755 754
756 // In the current Chrome UI, these must always be true so they sanity check 755 // In the current Chrome UI, these must always be true so they sanity check
757 // the above operations. In a future UI, these may be removed or adjusted. 756 // the above operations. In a future UI, these may be removed or adjusted.
758 // There is no point in sanity-checking |intersection.y()| because the omnibox 757 // There is no point in sanity-checking |intersection.y()| because the omnibox
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 iter->second > kMaxInstantSupportFailures) 814 iter->second > kMaxInstantSupportFailures)
816 return false; 815 return false;
817 816
818 return true; 817 return true;
819 } 818 }
820 819
821 bool InstantController::IsOutOfDate() const { 820 bool InstantController::IsOutOfDate() const {
822 return !last_active_tab_ || 821 return !last_active_tab_ ||
823 last_active_tab_ != browser_->GetActiveTabContents(); 822 last_active_tab_ != browser_->GetActiveTabContents();
824 } 823 }
OLDNEW
« no previous file with comments | « cc/software_renderer.cc ('k') | chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698