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

Side by Side Diff: chrome/browser/ui/views/status_bubble_views.cc

Issue 2751833004: Reland "Add display::GetDisplayNearestView" (Closed)
Patch Set: Created 3 years, 9 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 (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/status_bubble_views.h" 5 #include "chrome/browser/ui/views/status_bubble_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 offset = size_.height() - kShadowThickness * 2; 860 offset = size_.height() - kShadowThickness * 2;
861 view_->SetStyle(StatusView::STYLE_BOTTOM); 861 view_->SetStyle(StatusView::STYLE_BOTTOM);
862 } else if (offset > kBubbleCornerRadius / 2 - kShadowThickness) { 862 } else if (offset > kBubbleCornerRadius / 2 - kShadowThickness) {
863 view_->SetStyle(StatusView::STYLE_FLOATING); 863 view_->SetStyle(StatusView::STYLE_FLOATING);
864 } else { 864 } else {
865 view_->SetStyle(StatusView::STYLE_STANDARD); 865 view_->SetStyle(StatusView::STYLE_STANDARD);
866 } 866 }
867 867
868 // Check if the bubble sticks out from the monitor or will obscure 868 // Check if the bubble sticks out from the monitor or will obscure
869 // download shelf. 869 // download shelf.
870 gfx::NativeView window = base_view_->GetWidget()->GetNativeView(); 870 gfx::NativeView view = base_view_->GetWidget()->GetNativeView();
871 gfx::Rect monitor_rect = display::Screen::GetScreen() 871 gfx::Rect monitor_rect =
872 ->GetDisplayNearestWindow(window) 872 display::Screen::GetScreen()->GetDisplayNearestView(view).work_area();
873 .work_area();
874 const int bubble_bottom_y = top_left.y() + position_.y() + size_.height(); 873 const int bubble_bottom_y = top_left.y() + position_.y() + size_.height();
875 874
876 if (bubble_bottom_y + offset > monitor_rect.height() || 875 if (bubble_bottom_y + offset > monitor_rect.height() ||
877 (download_shelf_is_visible_ && 876 (download_shelf_is_visible_ &&
878 (view_->style() == StatusView::STYLE_FLOATING || 877 (view_->style() == StatusView::STYLE_FLOATING ||
879 view_->style() == StatusView::STYLE_BOTTOM))) { 878 view_->style() == StatusView::STYLE_BOTTOM))) {
880 // The offset is still too large. Move the bubble to the right and reset 879 // The offset is still too large. Move the bubble to the right and reset
881 // Y offset_ to zero. 880 // Y offset_ to zero.
882 view_->SetStyle(StatusView::STYLE_STANDARD_RIGHT); 881 view_->SetStyle(StatusView::STYLE_STANDARD_RIGHT);
883 offset_ = 0; 882 offset_ = 0;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 void StatusBubbleViews::SetBubbleWidth(int width) { 948 void StatusBubbleViews::SetBubbleWidth(int width) {
950 size_.set_width(width); 949 size_.set_width(width);
951 SetBounds(original_position_.x(), original_position_.y(), 950 SetBounds(original_position_.x(), original_position_.y(),
952 size_.width(), size_.height()); 951 size_.width(), size_.height());
953 } 952 }
954 953
955 void StatusBubbleViews::CancelExpandTimer() { 954 void StatusBubbleViews::CancelExpandTimer() {
956 if (expand_timer_factory_.HasWeakPtrs()) 955 if (expand_timer_factory_.HasWeakPtrs())
957 expand_timer_factory_.InvalidateWeakPtrs(); 956 expand_timer_factory_.InvalidateWeakPtrs();
958 } 957 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698