OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |