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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_container.cc

Issue 10907038: alternate ntp: clip middle omnibox when resizing browser window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-implement fix Created 8 years, 3 months 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
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/ui/views/location_bar/location_bar_container.h" 5 #include "chrome/browser/ui/views/location_bar/location_bar_container.h"
6 6
7 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 7 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
8 #include "chrome/browser/ui/webui/instant_ui.h" 8 #include "chrome/browser/ui/webui/instant_ui.h"
9 #include "ui/base/events/event.h" 9 #include "ui/base/events/event.h"
10 #include "ui/views/background.h" 10 #include "ui/views/background.h"
(...skipping 14 matching lines...) Expand all
25 native_view_host_(NULL), 25 native_view_host_(NULL),
26 in_toolbar_(true), 26 in_toolbar_(true),
27 instant_extended_api_enabled_(instant_extended_api_enabled) { 27 instant_extended_api_enabled_(instant_extended_api_enabled) {
28 parent->AddChildView(this); 28 parent->AddChildView(this);
29 animator_.set_tween_type(ui::Tween::EASE_IN_OUT); 29 animator_.set_tween_type(ui::Tween::EASE_IN_OUT);
30 PlatformInit(); 30 PlatformInit();
31 if (instant_extended_api_enabled) { 31 if (instant_extended_api_enabled) {
32 view_parent_->set_background( 32 view_parent_->set_background(
33 views::Background::CreateSolidBackground(GetBackgroundColor())); 33 views::Background::CreateSolidBackground(GetBackgroundColor()));
34 } 34 }
35 SetLayoutManager(new views::FillLayout);
36 } 35 }
37 36
38 LocationBarContainer::~LocationBarContainer() { 37 LocationBarContainer::~LocationBarContainer() {
39 } 38 }
40 39
41 void LocationBarContainer::SetLocationBarView(LocationBarView* view) { 40 void LocationBarContainer::SetLocationBarView(LocationBarView* view) {
42 DCHECK(!location_bar_view_ && view); 41 DCHECK(!location_bar_view_ && view);
43 location_bar_view_ = view; 42 location_bar_view_ = view;
44 view_parent_->AddChildView(location_bar_view_); 43 view_parent_->AddChildView(location_bar_view_);
45 DCHECK_EQ(1, view_parent_->child_count()); // Only support one child. 44 DCHECK_EQ(1, view_parent_->child_count()); // Only support one child.
46 } 45 }
47 46
48 void LocationBarContainer::AnimateTo(const gfx::Rect& bounds) { 47 void LocationBarContainer::AnimateTo(const gfx::Rect& bounds) {
49 // Animation duration can change during session. 48 // Animation duration can change during session.
50 animator_.SetAnimationDuration(GetAnimationDuration()); 49 animator_.SetAnimationDuration(GetAnimationDuration());
51 animator_.AnimateViewTo(this, bounds); 50 animator_.AnimateViewTo(this, bounds);
52 } 51 }
53 52
54 bool LocationBarContainer::IsAnimating() const { 53 bool LocationBarContainer::IsAnimating() const {
55 return animator_.IsAnimating(); 54 return animator_.IsAnimating();
56 } 55 }
57 56
58 gfx::Rect LocationBarContainer::GetTargetBounds() { 57 gfx::Rect LocationBarContainer::GetTargetBounds() {
59 return animator_.GetTargetBounds(this); 58 return animator_.GetTargetBounds(this);
60 } 59 }
61 60
61 void LocationBarContainer::SetBoundsForContainerAndView(
sky 2012/09/12 21:07:31 Why doesn't SetBounds do what you want here?
kuan 2012/09/12 21:33:04 u're right, i don't need to SetBounds for location
62 const gfx::Rect& location_bar_container_bounds,
63 const gfx::Size& location_bar_view_size) {
64 SetBoundsRect(location_bar_container_bounds);
65 DCHECK(location_bar_view_);
66 location_bar_view_->SetBounds(0, 0, location_bar_view_size.width(),
67 location_bar_view_size.height());
68 location_bar_view_size_ = location_bar_view_size;
69 }
70
62 std::string LocationBarContainer::GetClassName() const { 71 std::string LocationBarContainer::GetClassName() const {
63 return "browser/ui/views/location_bar/LocationBarContainer"; 72 return "browser/ui/views/location_bar/LocationBarContainer";
64 } 73 }
65 74
66 gfx::Size LocationBarContainer::GetPreferredSize() { 75 gfx::Size LocationBarContainer::GetPreferredSize() {
67 return location_bar_view_->GetPreferredSize(); 76 return location_bar_view_->GetPreferredSize();
68 } 77 }
69 78
79 void LocationBarContainer::Layout() {
80 // If we're animating, |location_bar_view_| fully fills out the entire
81 // container's target bounds. Otherwise, its bounds is what was last set via
82 // |SetBoundsForContainerAndView|.
83 if (IsAnimating()) {
84 gfx::Rect target_bounds = GetTargetBounds();
85 location_bar_view_->SetBounds(0, 0, target_bounds.width(),
86 target_bounds.height());
87 } else {
88 location_bar_view_->SetBounds(0, 0, location_bar_view_size_.width(),
89 location_bar_view_size_.height());
90 }
91 }
92
70 bool LocationBarContainer::SkipDefaultKeyEventProcessing( 93 bool LocationBarContainer::SkipDefaultKeyEventProcessing(
71 const ui::KeyEvent& event) { 94 const ui::KeyEvent& event) {
72 return location_bar_view_->SkipDefaultKeyEventProcessing(event); 95 return location_bar_view_->SkipDefaultKeyEventProcessing(event);
73 } 96 }
74 97
75 void LocationBarContainer::GetAccessibleState( 98 void LocationBarContainer::GetAccessibleState(
76 ui::AccessibleViewState* state) { 99 ui::AccessibleViewState* state) {
77 location_bar_view_->GetAccessibleState(state); 100 location_bar_view_->GetAccessibleState(state);
78 } 101 }
79 102
80 void LocationBarContainer::OnBoundsAnimatorDone( 103 void LocationBarContainer::OnBoundsAnimatorDone(
81 views::BoundsAnimator* animator) { 104 views::BoundsAnimator* animator) {
82 SetInToolbar(true); 105 SetInToolbar(true);
83 } 106 }
84 107
85 // static 108 // static
86 int LocationBarContainer::GetAnimationDuration() { 109 int LocationBarContainer::GetAnimationDuration() {
87 return kAnimationDuration * InstantUI::GetSlowAnimationScaleFactor(); 110 return kAnimationDuration * InstantUI::GetSlowAnimationScaleFactor();
88 } 111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698