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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 1036173002: Animate showing / hiding the location bar for bookmark apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix stuffup Created 5 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 if (selected_web_contents) 1028 if (selected_web_contents)
1029 selected_web_contents->RestoreFocus(); 1029 selected_web_contents->RestoreFocus();
1030 } 1030 }
1031 1031
1032 void BrowserView::FullscreenStateChanged() { 1032 void BrowserView::FullscreenStateChanged() {
1033 CHECK(!IsFullscreen()); 1033 CHECK(!IsFullscreen());
1034 ProcessFullscreen(false, NORMAL_FULLSCREEN, GURL(), 1034 ProcessFullscreen(false, NORMAL_FULLSCREEN, GURL(),
1035 EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE); 1035 EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE);
1036 } 1036 }
1037 1037
1038 void BrowserView::ToolbarSizeChanged(bool is_animating) {
1039 // The call to SetMaxTopArrowHeight() below can result in reentrancy;
1040 // |call_state| tracks whether we're reentrant. We can't just early-return in
1041 // this case because we need to layout again so the infobar container's bounds
1042 // are set correctly.
1043 static CallState call_state = NORMAL;
1044
1045 // A reentrant call can (and should) use the fast resize path unless both it
1046 // and the normal call are both non-animating.
1047 bool use_fast_resize =
1048 is_animating || (call_state == REENTRANT_FORCE_FAST_RESIZE);
1049 if (use_fast_resize)
1050 contents_web_view_->SetFastResize(true);
1051 UpdateUIForContents(GetActiveWebContents());
1052 if (use_fast_resize)
1053 contents_web_view_->SetFastResize(false);
1054
1055 // Inform the InfoBarContainer that the distance to the location icon may have
1056 // changed. We have to do this after the block above so that the toolbars are
1057 // laid out correctly for calculating the maximum arrow height below.
1058 {
1059 base::AutoReset<CallState> resetter(&call_state,
1060 is_animating ? REENTRANT_FORCE_FAST_RESIZE : REENTRANT);
1061 SetMaxTopArrowHeight(GetMaxTopInfoBarArrowHeight(), infobar_container_);
1062 }
1063
1064 // When transitioning from animating to not animating we need to make sure the
1065 // contents_container_ gets layed out. If we don't do this and the bounds
1066 // haven't changed contents_container_ won't get a Layout out and we'll end up
1067 // with a gray rect because the clip wasn't updated. Note that a reentrant
1068 // call never needs to do this, because after it returns, the normal call
1069 // wrapping it will do it.
1070 if ((call_state == NORMAL) && !is_animating) {
1071 contents_web_view_->InvalidateLayout();
1072 contents_container_->Layout();
1073 }
1074 }
1075
1076 LocationBar* BrowserView::GetLocationBar() const { 1038 LocationBar* BrowserView::GetLocationBar() const {
1077 return GetLocationBarView(); 1039 return GetLocationBarView();
1078 } 1040 }
1079 1041
1080 void BrowserView::SetFocusToLocationBar(bool select_all) { 1042 void BrowserView::SetFocusToLocationBar(bool select_all) {
1081 // On Windows, changing focus to the location bar causes the browser 1043 // On Windows, changing focus to the location bar causes the browser
1082 // window to become active. This can steal focus if the user has 1044 // window to become active. This can steal focus if the user has
1083 // another window open already. On ChromeOS, changing focus makes a 1045 // another window open already. On ChromeOS, changing focus makes a
1084 // view believe it has a focus even if the widget doens't have a 1046 // view believe it has a focus even if the widget doens't have a
1085 // focus. Either cases, we need to ignore this when the browser 1047 // focus. Either cases, we need to ignore this when the browser
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 // top-of-window views revealed. 1094 // top-of-window views revealed.
1133 scoped_ptr<ImmersiveRevealedLock> focus_reveal_lock( 1095 scoped_ptr<ImmersiveRevealedLock> focus_reveal_lock(
1134 immersive_mode_controller_->GetRevealedLock( 1096 immersive_mode_controller_->GetRevealedLock(
1135 ImmersiveModeController::ANIMATE_REVEAL_YES)); 1097 ImmersiveModeController::ANIMATE_REVEAL_YES));
1136 1098
1137 // Start the traversal within the main toolbar. SetPaneFocus stores 1099 // Start the traversal within the main toolbar. SetPaneFocus stores
1138 // the current focused view before changing focus. 1100 // the current focused view before changing focus.
1139 toolbar_->SetPaneFocus(nullptr); 1101 toolbar_->SetPaneFocus(nullptr);
1140 } 1102 }
1141 1103
1104 void BrowserView::ToolbarSizeChanged(bool is_animating) {
1105 // The call to SetMaxTopArrowHeight() below can result in reentrancy;
1106 // |call_state| tracks whether we're reentrant. We can't just early-return in
1107 // this case because we need to layout again so the infobar container's bounds
1108 // are set correctly.
1109 static CallState call_state = NORMAL;
1110
1111 // A reentrant call can (and should) use the fast resize path unless both it
1112 // and the normal call are both non-animating.
1113 bool use_fast_resize =
1114 is_animating || (call_state == REENTRANT_FORCE_FAST_RESIZE);
1115 if (use_fast_resize)
1116 contents_web_view_->SetFastResize(true);
1117 UpdateUIForContents(GetActiveWebContents());
1118 if (use_fast_resize)
1119 contents_web_view_->SetFastResize(false);
1120
1121 // Inform the InfoBarContainer that the distance to the location icon may have
1122 // changed. We have to do this after the block above so that the toolbars are
1123 // laid out correctly for calculating the maximum arrow height below.
1124 {
1125 base::AutoReset<CallState> resetter(&call_state,
1126 is_animating ? REENTRANT_FORCE_FAST_RESIZE : REENTRANT);
1127 SetMaxTopArrowHeight(GetMaxTopInfoBarArrowHeight(), infobar_container_);
1128 }
1129
1130 // When transitioning from animating to not animating we need to make sure the
1131 // contents_container_ gets layed out. If we don't do this and the bounds
1132 // haven't changed contents_container_ won't get a Layout out and we'll end up
1133 // with a gray rect because the clip wasn't updated. Note that a reentrant
1134 // call never needs to do this, because after it returns, the normal call
1135 // wrapping it will do it.
1136 if ((call_state == NORMAL) && !is_animating) {
1137 contents_web_view_->InvalidateLayout();
1138 contents_container_->Layout();
1139 }
1140 }
1141
1142 void BrowserView::FocusBookmarksToolbar() { 1142 void BrowserView::FocusBookmarksToolbar() {
1143 DCHECK(!immersive_mode_controller_->IsEnabled()); 1143 DCHECK(!immersive_mode_controller_->IsEnabled());
1144 if (bookmark_bar_view_.get() && 1144 if (bookmark_bar_view_.get() &&
1145 bookmark_bar_view_->visible() && 1145 bookmark_bar_view_->visible() &&
1146 bookmark_bar_view_->GetPreferredSize().height() != 0) { 1146 bookmark_bar_view_->GetPreferredSize().height() != 0) {
1147 bookmark_bar_view_->SetPaneFocusAndFocusDefault(); 1147 bookmark_bar_view_->SetPaneFocusAndFocusDefault();
1148 } 1148 }
1149 } 1149 }
1150 1150
1151 void BrowserView::FocusInfobars() { 1151 void BrowserView::FocusInfobars() {
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 return immersive_mode_controller()->IsEnabled(); 2624 return immersive_mode_controller()->IsEnabled();
2625 } 2625 }
2626 2626
2627 views::Widget* BrowserView::GetBubbleAssociatedWidget() { 2627 views::Widget* BrowserView::GetBubbleAssociatedWidget() {
2628 return GetWidget(); 2628 return GetWidget();
2629 } 2629 }
2630 2630
2631 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { 2631 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() {
2632 return top_container_->GetBoundsInScreen(); 2632 return top_container_->GetBoundsInScreen();
2633 } 2633 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698