OLD | NEW |
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 } | 340 } |
341 | 341 |
342 void StatusBubbleViews::StatusView::OnPaint(gfx::Canvas* canvas) { | 342 void StatusBubbleViews::StatusView::OnPaint(gfx::Canvas* canvas) { |
343 SkPaint paint; | 343 SkPaint paint; |
344 paint.setStyle(SkPaint::kFill_Style); | 344 paint.setStyle(SkPaint::kFill_Style); |
345 paint.setFlags(SkPaint::kAntiAlias_Flag); | 345 paint.setFlags(SkPaint::kAntiAlias_Flag); |
346 SkColor toolbar_color = | 346 SkColor toolbar_color = |
347 theme_service_->GetColor(ThemeService::COLOR_TOOLBAR); | 347 theme_service_->GetColor(ThemeService::COLOR_TOOLBAR); |
348 paint.setColor(toolbar_color); | 348 paint.setColor(toolbar_color); |
349 | 349 |
350 gfx::Rect popup_bounds = popup_->GetWindowScreenBounds(); | 350 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); |
351 | 351 |
352 // Figure out how to round the bubble's four corners. | 352 // Figure out how to round the bubble's four corners. |
353 SkScalar rad[8]; | 353 SkScalar rad[8]; |
354 | 354 |
355 // Top Edges - if the bubble is in its bottom position (sticking downwards), | 355 // Top Edges - if the bubble is in its bottom position (sticking downwards), |
356 // then we square the top edges. Otherwise, we square the edges based on the | 356 // then we square the top edges. Otherwise, we square the edges based on the |
357 // position of the bubble within the window (the bubble is positioned in the | 357 // position of the bubble within the window (the bubble is positioned in the |
358 // southeast corner in RTL and in the southwest corner in LTR). | 358 // southeast corner in RTL and in the southwest corner in LTR). |
359 if (style_ == STYLE_BOTTOM) { | 359 if (style_ == STYLE_BOTTOM) { |
360 // Top Left corner. | 360 // Top Left corner. |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 return; | 648 return; |
649 } | 649 } |
650 | 650 |
651 // Reset expansion state only when bubble is completely hidden. | 651 // Reset expansion state only when bubble is completely hidden. |
652 if (view_->GetState() == StatusView::BUBBLE_HIDDEN) { | 652 if (view_->GetState() == StatusView::BUBBLE_HIDDEN) { |
653 is_expanded_ = false; | 653 is_expanded_ = false; |
654 SetBubbleWidth(GetStandardStatusBubbleWidth()); | 654 SetBubbleWidth(GetStandardStatusBubbleWidth()); |
655 } | 655 } |
656 | 656 |
657 // Set Elided Text corresponding to the GURL object. | 657 // Set Elided Text corresponding to the GURL object. |
658 gfx::Rect popup_bounds = popup_->GetWindowScreenBounds(); | 658 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); |
659 int text_width = static_cast<int>(popup_bounds.width() - | 659 int text_width = static_cast<int>(popup_bounds.width() - |
660 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); | 660 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); |
661 url_text_ = ui::ElideUrl(url, view_->Label::font(), text_width, languages); | 661 url_text_ = ui::ElideUrl(url, view_->Label::font(), text_width, languages); |
662 | 662 |
663 // An URL is always treated as a left-to-right string. On right-to-left UIs | 663 // An URL is always treated as a left-to-right string. On right-to-left UIs |
664 // we need to explicitly mark the URL as LTR to make sure it is displayed | 664 // we need to explicitly mark the URL as LTR to make sure it is displayed |
665 // correctly. | 665 // correctly. |
666 url_text_ = base::i18n::GetDisplayStringInLTRDirectionality(url_text_); | 666 url_text_ = base::i18n::GetDisplayStringInLTRDirectionality(url_text_); |
667 | 667 |
668 if (IsFrameVisible()) { | 668 if (IsFrameVisible()) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 if (!frame->IsVisible()) | 804 if (!frame->IsVisible()) |
805 return false; | 805 return false; |
806 | 806 |
807 views::Widget* window = frame->GetTopLevelWidget(); | 807 views::Widget* window = frame->GetTopLevelWidget(); |
808 return !window || !window->IsMinimized(); | 808 return !window || !window->IsMinimized(); |
809 } | 809 } |
810 | 810 |
811 void StatusBubbleViews::ExpandBubble() { | 811 void StatusBubbleViews::ExpandBubble() { |
812 // Elide URL to maximum possible size, then check actual length (it may | 812 // Elide URL to maximum possible size, then check actual length (it may |
813 // still be too long to fit) before expanding bubble. | 813 // still be too long to fit) before expanding bubble. |
814 gfx::Rect popup_bounds = popup_->GetWindowScreenBounds(); | 814 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); |
815 int max_status_bubble_width = GetMaxStatusBubbleWidth(); | 815 int max_status_bubble_width = GetMaxStatusBubbleWidth(); |
816 url_text_ = ui::ElideUrl(url_, view_->Label::font(), | 816 url_text_ = ui::ElideUrl(url_, view_->Label::font(), |
817 max_status_bubble_width, languages_); | 817 max_status_bubble_width, languages_); |
818 int expanded_bubble_width =std::max(GetStandardStatusBubbleWidth(), | 818 int expanded_bubble_width =std::max(GetStandardStatusBubbleWidth(), |
819 std::min(view_->Label::font().GetStringWidth(url_text_) + | 819 std::min(view_->Label::font().GetStringWidth(url_text_) + |
820 (kShadowThickness * 2) + kTextPositionX + | 820 (kShadowThickness * 2) + kTextPositionX + |
821 kTextHorizPadding + 1, | 821 kTextHorizPadding + 1, |
822 max_status_bubble_width)); | 822 max_status_bubble_width)); |
823 is_expanded_ = true; | 823 is_expanded_ = true; |
824 expand_view_->StartExpansion(url_text_, popup_bounds.width(), | 824 expand_view_->StartExpansion(url_text_, popup_bounds.width(), |
(...skipping 13 matching lines...) Expand all Loading... |
838 void StatusBubbleViews::SetBubbleWidth(int width) { | 838 void StatusBubbleViews::SetBubbleWidth(int width) { |
839 size_.set_width(width); | 839 size_.set_width(width); |
840 SetBounds(original_position_.x(), original_position_.y(), | 840 SetBounds(original_position_.x(), original_position_.y(), |
841 size_.width(), size_.height()); | 841 size_.width(), size_.height()); |
842 } | 842 } |
843 | 843 |
844 void StatusBubbleViews::CancelExpandTimer() { | 844 void StatusBubbleViews::CancelExpandTimer() { |
845 if (expand_timer_factory_.HasWeakPtrs()) | 845 if (expand_timer_factory_.HasWeakPtrs()) |
846 expand_timer_factory_.InvalidateWeakPtrs(); | 846 expand_timer_factory_.InvalidateWeakPtrs(); |
847 } | 847 } |
OLD | NEW |