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

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: Feedback 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 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 if (selected_web_contents) 1016 if (selected_web_contents)
1017 selected_web_contents->RestoreFocus(); 1017 selected_web_contents->RestoreFocus();
1018 } 1018 }
1019 1019
1020 void BrowserView::FullscreenStateChanged() { 1020 void BrowserView::FullscreenStateChanged() {
1021 CHECK(!IsFullscreen()); 1021 CHECK(!IsFullscreen());
1022 ProcessFullscreen(false, NORMAL_FULLSCREEN, GURL(), 1022 ProcessFullscreen(false, NORMAL_FULLSCREEN, GURL(),
1023 EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE); 1023 EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE);
1024 } 1024 }
1025 1025
1026 void BrowserView::ToolbarSizeChanged(bool is_animating) {
1027 // The call to SetMaxTopArrowHeight() below can result in reentrancy;
1028 // |call_state| tracks whether we're reentrant. We can't just early-return in
1029 // this case because we need to layout again so the infobar container's bounds
1030 // are set correctly.
1031 static CallState call_state = NORMAL;
1032
1033 // A reentrant call can (and should) use the fast resize path unless both it
1034 // and the normal call are both non-animating.
1035 bool use_fast_resize =
1036 is_animating || (call_state == REENTRANT_FORCE_FAST_RESIZE);
1037 if (use_fast_resize)
1038 contents_web_view_->SetFastResize(true);
1039 UpdateUIForContents(GetActiveWebContents());
1040 if (use_fast_resize)
1041 contents_web_view_->SetFastResize(false);
1042
1043 // Inform the InfoBarContainer that the distance to the location icon may have
1044 // changed. We have to do this after the block above so that the toolbars are
1045 // laid out correctly for calculating the maximum arrow height below.
1046 {
1047 base::AutoReset<CallState> resetter(&call_state,
1048 is_animating ? REENTRANT_FORCE_FAST_RESIZE : REENTRANT);
1049 SetMaxTopArrowHeight(GetMaxTopInfoBarArrowHeight(), infobar_container_);
1050 }
1051
1052 // When transitioning from animating to not animating we need to make sure the
1053 // contents_container_ gets layed out. If we don't do this and the bounds
1054 // haven't changed contents_container_ won't get a Layout out and we'll end up
1055 // with a gray rect because the clip wasn't updated. Note that a reentrant
1056 // call never needs to do this, because after it returns, the normal call
1057 // wrapping it will do it.
1058 if ((call_state == NORMAL) && !is_animating) {
1059 contents_web_view_->InvalidateLayout();
1060 contents_container_->Layout();
1061 }
1062 }
1063
1064 LocationBar* BrowserView::GetLocationBar() const { 1026 LocationBar* BrowserView::GetLocationBar() const {
1065 return GetLocationBarView(); 1027 return GetLocationBarView();
1066 } 1028 }
1067 1029
1068 void BrowserView::SetFocusToLocationBar(bool select_all) { 1030 void BrowserView::SetFocusToLocationBar(bool select_all) {
1069 // On Windows, changing focus to the location bar causes the browser 1031 // On Windows, changing focus to the location bar causes the browser
1070 // window to become active. This can steal focus if the user has 1032 // window to become active. This can steal focus if the user has
1071 // another window open already. On ChromeOS, changing focus makes a 1033 // another window open already. On ChromeOS, changing focus makes a
1072 // view believe it has a focus even if the widget doens't have a 1034 // view believe it has a focus even if the widget doens't have a
1073 // focus. Either cases, we need to ignore this when the browser 1035 // focus. Either cases, we need to ignore this when the browser
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 // top-of-window views revealed. 1082 // top-of-window views revealed.
1121 scoped_ptr<ImmersiveRevealedLock> focus_reveal_lock( 1083 scoped_ptr<ImmersiveRevealedLock> focus_reveal_lock(
1122 immersive_mode_controller_->GetRevealedLock( 1084 immersive_mode_controller_->GetRevealedLock(
1123 ImmersiveModeController::ANIMATE_REVEAL_YES)); 1085 ImmersiveModeController::ANIMATE_REVEAL_YES));
1124 1086
1125 // Start the traversal within the main toolbar. SetPaneFocus stores 1087 // Start the traversal within the main toolbar. SetPaneFocus stores
1126 // the current focused view before changing focus. 1088 // the current focused view before changing focus.
1127 toolbar_->SetPaneFocus(nullptr); 1089 toolbar_->SetPaneFocus(nullptr);
1128 } 1090 }
1129 1091
1092 void BrowserView::ToolbarSizeChanged(bool is_animating) {
1093 // The call to SetMaxTopArrowHeight() below can result in reentrancy;
1094 // |call_state| tracks whether we're reentrant. We can't just early-return in
1095 // this case because we need to layout again so the infobar container's bounds
1096 // are set correctly.
1097 static CallState call_state = NORMAL;
1098
1099 // A reentrant call can (and should) use the fast resize path unless both it
1100 // and the normal call are both non-animating.
1101 bool use_fast_resize =
1102 is_animating || (call_state == REENTRANT_FORCE_FAST_RESIZE);
1103 if (use_fast_resize)
1104 contents_web_view_->SetFastResize(true);
1105 UpdateUIForContents(GetActiveWebContents());
1106 if (use_fast_resize)
1107 contents_web_view_->SetFastResize(false);
1108
1109 // Inform the InfoBarContainer that the distance to the location icon may have
1110 // changed. We have to do this after the block above so that the toolbars are
1111 // laid out correctly for calculating the maximum arrow height below.
1112 {
1113 base::AutoReset<CallState> resetter(&call_state,
1114 is_animating ? REENTRANT_FORCE_FAST_RESIZE : REENTRANT);
1115 SetMaxTopArrowHeight(GetMaxTopInfoBarArrowHeight(), infobar_container_);
1116 }
1117
1118 // When transitioning from animating to not animating we need to make sure the
1119 // contents_container_ gets layed out. If we don't do this and the bounds
1120 // haven't changed contents_container_ won't get a Layout out and we'll end up
1121 // with a gray rect because the clip wasn't updated. Note that a reentrant
1122 // call never needs to do this, because after it returns, the normal call
1123 // wrapping it will do it.
1124 if ((call_state == NORMAL) && !is_animating) {
1125 contents_web_view_->InvalidateLayout();
1126 contents_container_->Layout();
1127 }
1128 }
1129
1130 void BrowserView::FocusBookmarksToolbar() { 1130 void BrowserView::FocusBookmarksToolbar() {
1131 DCHECK(!immersive_mode_controller_->IsEnabled()); 1131 DCHECK(!immersive_mode_controller_->IsEnabled());
1132 if (bookmark_bar_view_.get() && 1132 if (bookmark_bar_view_.get() &&
1133 bookmark_bar_view_->visible() && 1133 bookmark_bar_view_->visible() &&
1134 bookmark_bar_view_->GetPreferredSize().height() != 0) { 1134 bookmark_bar_view_->GetPreferredSize().height() != 0) {
1135 bookmark_bar_view_->SetPaneFocusAndFocusDefault(); 1135 bookmark_bar_view_->SetPaneFocusAndFocusDefault();
1136 } 1136 }
1137 } 1137 }
1138 1138
1139 void BrowserView::FocusInfobars() { 1139 void BrowserView::FocusInfobars() {
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after
2613 return immersive_mode_controller()->IsEnabled(); 2613 return immersive_mode_controller()->IsEnabled();
2614 } 2614 }
2615 2615
2616 views::Widget* BrowserView::GetBubbleAssociatedWidget() { 2616 views::Widget* BrowserView::GetBubbleAssociatedWidget() {
2617 return GetWidget(); 2617 return GetWidget();
2618 } 2618 }
2619 2619
2620 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { 2620 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() {
2621 return top_container_->GetBoundsInScreen(); 2621 return top_container_->GetBoundsInScreen();
2622 } 2622 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698