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

Side by Side Diff: ui/views/bubble/tray_bubble_view.cc

Issue 2831233003: Remove ShouldBlockShelfAutoHide(). (Closed)
Patch Set: this won't work until https://codereview.chromium.org/2834943002 lands Created 3 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
« no previous file with comments | « ui/views/bubble/tray_bubble_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/views/bubble/tray_bubble_view.h" 5 #include "ui/views/bubble/tray_bubble_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "cc/paint/paint_flags.h" 10 #include "cc/paint/paint_flags.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 TrayBubbleView::AnchorAlignment alignment) { 42 TrayBubbleView::AnchorAlignment alignment) {
43 if (alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { 43 if (alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) {
44 return base::i18n::IsRTL() ? BubbleBorder::BOTTOM_LEFT 44 return base::i18n::IsRTL() ? BubbleBorder::BOTTOM_LEFT
45 : BubbleBorder::BOTTOM_RIGHT; 45 : BubbleBorder::BOTTOM_RIGHT;
46 } 46 }
47 if (alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) 47 if (alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT)
48 return BubbleBorder::LEFT_BOTTOM; 48 return BubbleBorder::LEFT_BOTTOM;
49 return BubbleBorder::RIGHT_BOTTOM; 49 return BubbleBorder::RIGHT_BOTTOM;
50 } 50 }
51 51
52 // Only one TrayBubbleView is visible at a time, but there are cases where the
53 // lifetimes of two different bubbles can overlap briefly.
54 int g_current_tray_bubble_view_count_ = 0;
sky 2017/04/24 15:32:40 optional: name this g_current_tray_showing_count (
Evan Stade 2017/04/27 01:33:48 Done.
55
52 } // namespace 56 } // namespace
53 57
54 namespace internal { 58 namespace internal {
55 59
56 // Detects any mouse movement. This is needed to detect mouse movements by the 60 // Detects any mouse movement. This is needed to detect mouse movements by the
57 // user over the bubble if the bubble got created underneath the cursor. 61 // user over the bubble if the bubble got created underneath the cursor.
58 class MouseMoveDetectorHost : public MouseWatcherHost { 62 class MouseMoveDetectorHost : public MouseWatcherHost {
59 public: 63 public:
60 MouseMoveDetectorHost(); 64 MouseMoveDetectorHost();
61 ~MouseMoveDetectorHost() override; 65 ~MouseMoveDetectorHost() override;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 SetLayoutManager(layout_); 222 SetLayoutManager(layout_);
219 } 223 }
220 224
221 TrayBubbleView::~TrayBubbleView() { 225 TrayBubbleView::~TrayBubbleView() {
222 mouse_watcher_.reset(); 226 mouse_watcher_.reset();
223 // Inform host items (models) that their views are being destroyed. 227 // Inform host items (models) that their views are being destroyed.
224 if (delegate_) 228 if (delegate_)
225 delegate_->BubbleViewDestroyed(); 229 delegate_->BubbleViewDestroyed();
226 } 230 }
227 231
232 // static
233 bool TrayBubbleView::IsATrayBubbleOpen() {
234 return g_current_tray_bubble_view_count_ > 0;
235 }
236
228 void TrayBubbleView::InitializeAndShowBubble() { 237 void TrayBubbleView::InitializeAndShowBubble() {
229 layer()->parent()->SetMaskLayer(bubble_content_mask_->layer()); 238 layer()->parent()->SetMaskLayer(bubble_content_mask_->layer());
230 239
231 GetWidget()->Show(); 240 GetWidget()->Show();
232 GetWidget()->GetNativeWindow()->SetEventTargeter( 241 GetWidget()->GetNativeWindow()->SetEventTargeter(
233 std::unique_ptr<ui::EventTargeter>(new BubbleWindowTargeter(this))); 242 std::unique_ptr<ui::EventTargeter>(new BubbleWindowTargeter(this)));
234 UpdateBubble(); 243 UpdateBubble();
244
245 ++g_current_tray_bubble_view_count_;
235 } 246 }
236 247
237 void TrayBubbleView::UpdateBubble() { 248 void TrayBubbleView::UpdateBubble() {
238 if (GetWidget()) { 249 if (GetWidget()) {
239 SizeToContents(); 250 SizeToContents();
240 bubble_content_mask_->layer()->SetBounds(layer()->bounds()); 251 bubble_content_mask_->layer()->SetBounds(layer()->bounds());
241 GetWidget()->GetRootView()->SchedulePaint(); 252 GetWidget()->GetRootView()->SchedulePaint();
242 } 253 }
243 } 254 }
244 255
(...skipping 26 matching lines...) Expand all
271 282
272 void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params, 283 void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params,
273 Widget* bubble_widget) const { 284 Widget* bubble_widget) const {
274 if (delegate_) 285 if (delegate_)
275 delegate_->OnBeforeBubbleWidgetInit(anchor_widget(), bubble_widget, params); 286 delegate_->OnBeforeBubbleWidgetInit(anchor_widget(), bubble_widget, params);
276 // Apply a WM-provided shadow (see ui/wm/core/). 287 // Apply a WM-provided shadow (see ui/wm/core/).
277 params->shadow_type = Widget::InitParams::SHADOW_TYPE_DROP; 288 params->shadow_type = Widget::InitParams::SHADOW_TYPE_DROP;
278 params->shadow_elevation = wm::ShadowElevation::LARGE; 289 params->shadow_elevation = wm::ShadowElevation::LARGE;
279 } 290 }
280 291
292 void TrayBubbleView::OnWidgetClosing(Widget* widget) {
293 BubbleDialogDelegateView::OnWidgetClosing(widget);
294 --g_current_tray_bubble_view_count_;
295 DCHECK_GE(g_current_tray_bubble_view_count_, 0);
296 }
297
281 NonClientFrameView* TrayBubbleView::CreateNonClientFrameView(Widget* widget) { 298 NonClientFrameView* TrayBubbleView::CreateNonClientFrameView(Widget* widget) {
282 BubbleFrameView* frame = static_cast<BubbleFrameView*>( 299 BubbleFrameView* frame = static_cast<BubbleFrameView*>(
283 BubbleDialogDelegateView::CreateNonClientFrameView(widget)); 300 BubbleDialogDelegateView::CreateNonClientFrameView(widget));
284 frame->SetBubbleBorder(std::move(owned_bubble_border_)); 301 frame->SetBubbleBorder(std::move(owned_bubble_border_));
285 return frame; 302 return frame;
286 } 303 }
287 304
288 bool TrayBubbleView::WidgetHasHitTestMask() const { 305 bool TrayBubbleView::WidgetHasHitTestMask() const {
289 return true; 306 return true;
290 } 307 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 394
378 void TrayBubbleView::ViewHierarchyChanged( 395 void TrayBubbleView::ViewHierarchyChanged(
379 const ViewHierarchyChangedDetails& details) { 396 const ViewHierarchyChangedDetails& details) {
380 if (details.is_add && details.child == this) { 397 if (details.is_add && details.child == this) {
381 details.parent->SetPaintToLayer(); 398 details.parent->SetPaintToLayer();
382 details.parent->layer()->SetMasksToBounds(true); 399 details.parent->layer()->SetMasksToBounds(true);
383 } 400 }
384 } 401 }
385 402
386 } // namespace views 403 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/tray_bubble_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698