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

Side by Side Diff: ash/wm/immersive_fullscreen_controller.cc

Issue 1922813002: Vanquish views::BubbleDelegate{View,} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit tests Created 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/wm/immersive_fullscreen_controller.h" 5 #include "ash/wm/immersive_fullscreen_controller.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "ash/ash_constants.h" 9 #include "ash/ash_constants.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/wm/resize_handle_window_targeter.h" 11 #include "ash/wm/resize_handle_window_targeter.h"
12 #include "ash/wm/window_state.h" 12 #include "ash/wm/window_state.h"
13 #include "ash/wm/window_state_aura.h" 13 #include "ash/wm/window_state_aura.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "ui/aura/client/aura_constants.h" 15 #include "ui/aura/client/aura_constants.h"
16 #include "ui/aura/client/capture_client.h" 16 #include "ui/aura/client/capture_client.h"
17 #include "ui/aura/client/cursor_client.h" 17 #include "ui/aura/client/cursor_client.h"
18 #include "ui/aura/client/screen_position_client.h" 18 #include "ui/aura/client/screen_position_client.h"
19 #include "ui/aura/env.h" 19 #include "ui/aura/env.h"
20 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
21 #include "ui/aura/window_event_dispatcher.h" 21 #include "ui/aura/window_event_dispatcher.h"
22 #include "ui/gfx/animation/slide_animation.h" 22 #include "ui/gfx/animation/slide_animation.h"
23 #include "ui/gfx/display.h" 23 #include "ui/gfx/display.h"
24 #include "ui/gfx/geometry/point.h" 24 #include "ui/gfx/geometry/point.h"
25 #include "ui/gfx/geometry/rect.h" 25 #include "ui/gfx/geometry/rect.h"
26 #include "ui/gfx/screen.h" 26 #include "ui/gfx/screen.h"
27 #include "ui/views/bubble/bubble_delegate.h"
28 #include "ui/views/bubble/bubble_dialog_delegate.h" 27 #include "ui/views/bubble/bubble_dialog_delegate.h"
29 #include "ui/views/view.h" 28 #include "ui/views/view.h"
30 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
31 #include "ui/wm/core/transient_window_manager.h" 30 #include "ui/wm/core/transient_window_manager.h"
32 #include "ui/wm/core/window_util.h" 31 #include "ui/wm/core/window_util.h"
33 #include "ui/wm/public/activation_client.h" 32 #include "ui/wm/public/activation_client.h"
34 33
35 using views::View; 34 using views::View;
36 35
37 namespace ash { 36 namespace ash {
(...skipping 19 matching lines...) Expand all
57 // vertical. This is used to make sure that gesture is close to vertical instead 56 // vertical. This is used to make sure that gesture is close to vertical instead
58 // of just more vertical then horizontal. 57 // of just more vertical then horizontal.
59 const int kSwipeVerticalThresholdMultiplier = 3; 58 const int kSwipeVerticalThresholdMultiplier = 3;
60 59
61 // The height in pixels of the region above the top edge of the display which 60 // The height in pixels of the region above the top edge of the display which
62 // hosts the immersive fullscreen window in which mouse events are ignored 61 // hosts the immersive fullscreen window in which mouse events are ignored
63 // (cannot reveal or unreveal the top-of-window views). 62 // (cannot reveal or unreveal the top-of-window views).
64 // See ShouldIgnoreMouseEventAtLocation() for more details. 63 // See ShouldIgnoreMouseEventAtLocation() for more details.
65 const int kHeightOfDeadRegionAboveTopContainer = 10; 64 const int kHeightOfDeadRegionAboveTopContainer = 10;
66 65
67 // Returns the BubbleDelegateView corresponding to |maybe_bubble| if
68 // |maybe_bubble| is a bubble. TODO(estade): remove this when all bubbles are
69 // BubbleDialogDelegateViews, or create a common interface for the two bubble
70 // types.
71 views::BubbleDelegateView* AsBubbleDelegate(aura::Window* maybe_bubble) {
72 if (!maybe_bubble)
73 return nullptr;
74 views::Widget* widget = views::Widget::GetWidgetForNativeView(maybe_bubble);
75 if (!widget)
76 return nullptr;
77 return widget->widget_delegate()->AsBubbleDelegate();
78 }
79
80 // Returns the BubbleDialogDelegateView corresponding to |maybe_bubble| if 66 // Returns the BubbleDialogDelegateView corresponding to |maybe_bubble| if
81 // |maybe_bubble| is a bubble. 67 // |maybe_bubble| is a bubble.
82 views::BubbleDialogDelegateView* AsBubbleDialogDelegate( 68 views::BubbleDialogDelegateView* AsBubbleDialogDelegate(
83 aura::Window* maybe_bubble) { 69 aura::Window* maybe_bubble) {
84 if (!maybe_bubble) 70 if (!maybe_bubble)
85 return nullptr; 71 return nullptr;
86 views::Widget* widget = views::Widget::GetWidgetForNativeView(maybe_bubble); 72 views::Widget* widget = views::Widget::GetWidgetForNativeView(maybe_bubble);
87 if (!widget) 73 if (!widget)
88 return nullptr; 74 return nullptr;
89 return widget->widget_delegate()->AsBubbleDialogDelegate(); 75 return widget->widget_delegate()->AsBubbleDialogDelegate();
90 } 76 }
91 77
92 views::View* GetAnchorView(aura::Window* maybe_bubble) { 78 views::View* GetAnchorView(aura::Window* maybe_bubble) {
93 views::BubbleDelegateView* bubble = AsBubbleDelegate(maybe_bubble);
94 if (bubble)
95 return bubble->GetAnchorView();
96
97 views::BubbleDialogDelegateView* bubble_dialog = 79 views::BubbleDialogDelegateView* bubble_dialog =
98 AsBubbleDialogDelegate(maybe_bubble); 80 AsBubbleDialogDelegate(maybe_bubble);
99 return bubble_dialog ? bubble_dialog->GetAnchorView() : nullptr; 81 return bubble_dialog ? bubble_dialog->GetAnchorView() : nullptr;
100 } 82 }
101 83
102 // Returns true if |maybe_transient| is a transient child of |toplevel|. 84 // Returns true if |maybe_transient| is a transient child of |toplevel|.
103 bool IsWindowTransientChildOf(aura::Window* maybe_transient, 85 bool IsWindowTransientChildOf(aura::Window* maybe_transient,
104 aura::Window* toplevel) { 86 aura::Window* toplevel) {
105 if (!maybe_transient || !toplevel) 87 if (!maybe_transient || !toplevel)
106 return false; 88 return false;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 ImmersiveFullscreenController::ANIMATE_REVEAL_NO)); 212 ImmersiveFullscreenController::ANIMATE_REVEAL_NO));
231 } 213 }
232 } else { 214 } else {
233 revealed_lock_.reset(); 215 revealed_lock_.reset();
234 } 216 }
235 217
236 if (!was_revealed && revealed_lock_.get()) { 218 if (!was_revealed && revealed_lock_.get()) {
237 // Currently, there is no nice way for bubbles to reposition themselves 219 // Currently, there is no nice way for bubbles to reposition themselves
238 // whenever the anchor view moves. Tell the bubbles to reposition themselves 220 // whenever the anchor view moves. Tell the bubbles to reposition themselves
239 // explicitly instead. The hidden bubbles are also repositioned because 221 // explicitly instead. The hidden bubbles are also repositioned because
240 // BubbleDelegateView does not reposition its widget as a result of a 222 // BubbleDialogDelegateView does not reposition its widget as a result of a
241 // visibility change. 223 // visibility change.
242 for (std::set<aura::Window*>::const_iterator it = bubbles_.begin(); 224 for (std::set<aura::Window*>::const_iterator it = bubbles_.begin();
msw 2016/04/26 18:07:30 optional nit: for (auto bubble : bubbles_) and dro
Evan Stade 2016/04/26 21:23:01 Done (x3)
243 it != bubbles_.end(); ++it) { 225 it != bubbles_.end(); ++it) {
244 views::BubbleDelegateView* bubble = AsBubbleDelegate(*it); 226 AsBubbleDialogDelegate(*it)->OnAnchorBoundsChanged();
245 if (bubble)
246 bubble->OnAnchorBoundsChanged();
247 else
248 AsBubbleDialogDelegate(*it)->OnAnchorBoundsChanged();
249 } 227 }
250 } 228 }
251 } 229 }
252 230
253 void ImmersiveFullscreenController::BubbleObserver::OnWindowVisibilityChanged( 231 void ImmersiveFullscreenController::BubbleObserver::OnWindowVisibilityChanged(
254 aura::Window*, 232 aura::Window*,
255 bool visible) { 233 bool visible) {
256 UpdateRevealedLock(); 234 UpdateRevealedLock();
257 } 235 }
258 236
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 ::wm::GetTransientChildren(native_window_); 942 ::wm::GetTransientChildren(native_window_);
965 for (size_t i = 0; i < transient_children.size(); ++i) { 943 for (size_t i = 0; i < transient_children.size(); ++i) {
966 aura::Window* transient_child = transient_children[i]; 944 aura::Window* transient_child = transient_children[i];
967 views::View* anchor_view = GetAnchorView(transient_child); 945 views::View* anchor_view = GetAnchorView(transient_child);
968 if (anchor_view && top_container_->Contains(anchor_view)) 946 if (anchor_view && top_container_->Contains(anchor_view))
969 bubble_observer_->StartObserving(transient_child); 947 bubble_observer_->StartObserving(transient_child);
970 } 948 }
971 } 949 }
972 950
973 } // namespace ash 951 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/immersive_fullscreen_controller_unittest.cc » ('j') | ash/wm/immersive_fullscreen_controller_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698