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/tabs/tab.h" | 5 #include "chrome/browser/ui/views/tabs/tab.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <limits> | 8 #include <limits> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 button_color_(SK_ColorTRANSPARENT) { | 550 button_color_(SK_ColorTRANSPARENT) { |
551 DCHECK(controller); | 551 DCHECK(controller); |
552 InitTabResources(); | 552 InitTabResources(); |
553 | 553 |
554 // So we get don't get enter/exit on children and don't prematurely stop the | 554 // So we get don't get enter/exit on children and don't prematurely stop the |
555 // hover. | 555 // hover. |
556 set_notify_enter_exit_on_child(true); | 556 set_notify_enter_exit_on_child(true); |
557 | 557 |
558 set_id(VIEW_ID_TAB); | 558 set_id(VIEW_ID_TAB); |
559 | 559 |
560 SetBorder(views::Border::CreateEmptyBorder(GetLayoutInsets(TAB))); | 560 SetBorder(views::CreateEmptyBorder(GetLayoutInsets(TAB))); |
561 | 561 |
562 title_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); | 562 title_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); |
563 title_->SetElideBehavior(gfx::FADE_TAIL); | 563 title_->SetElideBehavior(gfx::FADE_TAIL); |
564 title_->SetHandlesTooltips(false); | 564 title_->SetHandlesTooltips(false); |
565 title_->SetAutoColorReadabilityEnabled(false); | 565 title_->SetAutoColorReadabilityEnabled(false); |
566 title_->SetText(CoreTabHelper::GetDefaultTitle()); | 566 title_->SetText(CoreTabHelper::GetDefaultTitle()); |
567 AddChildView(title_); | 567 AddChildView(title_); |
568 | 568 |
569 SetEventTargeter( | 569 SetEventTargeter( |
570 std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); | 570 std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 // If the ratio of the close button size to tab width exceeds the maximum. | 879 // If the ratio of the close button size to tab width exceeds the maximum. |
880 // The close button should be as large as possible so that there is a larger | 880 // The close button should be as large as possible so that there is a larger |
881 // hit-target for touch events. So the close button bounds extends to the | 881 // hit-target for touch events. So the close button bounds extends to the |
882 // edges of the tab. However, the larger hit-target should be active only | 882 // edges of the tab. However, the larger hit-target should be active only |
883 // for touch events, and the close-image should show up in the right place. | 883 // for touch events, and the close-image should show up in the right place. |
884 // So a border is added to the button with necessary padding. The close | 884 // So a border is added to the button with necessary padding. The close |
885 // button (Tab::TabCloseButton) makes sure the padding is a hit-target only | 885 // button (Tab::TabCloseButton) makes sure the padding is a hit-target only |
886 // for touch events. | 886 // for touch events. |
887 // TODO(pkasting): The padding should maybe be removed, see comments in | 887 // TODO(pkasting): The padding should maybe be removed, see comments in |
888 // TabCloseButton::TargetForRect(). | 888 // TabCloseButton::TargetForRect(). |
889 close_button_->SetBorder(views::Border::NullBorder()); | 889 close_button_->SetBorder(views::NullBorder()); |
890 const gfx::Size close_button_size(close_button_->GetPreferredSize()); | 890 const gfx::Size close_button_size(close_button_->GetPreferredSize()); |
891 const int top = lb.y() + (lb.height() - close_button_size.height() + 1) / 2; | 891 const int top = lb.y() + (lb.height() - close_button_size.height() + 1) / 2; |
892 const int left = kAfterTitleSpacing; | 892 const int left = kAfterTitleSpacing; |
893 const int close_button_end = lb.right(); | 893 const int close_button_end = lb.right(); |
894 close_button_->SetPosition( | 894 close_button_->SetPosition( |
895 gfx::Point(close_button_end - close_button_size.width() - left, 0)); | 895 gfx::Point(close_button_end - close_button_size.width() - left, 0)); |
896 const int bottom = height() - close_button_size.height() - top; | 896 const int bottom = height() - close_button_size.height() - top; |
897 const int right = width() - close_button_end; | 897 const int right = width() - close_button_end; |
898 close_button_->SetBorder( | 898 close_button_->SetBorder( |
899 views::Border::CreateEmptyBorder(top, left, bottom, right)); | 899 views::CreateEmptyBorder(top, left, bottom, right)); |
900 close_button_->SizeToPreferredSize(); | 900 close_button_->SizeToPreferredSize(); |
901 } | 901 } |
902 close_button_->SetVisible(showing_close_button_); | 902 close_button_->SetVisible(showing_close_button_); |
903 | 903 |
904 showing_alert_indicator_ = ShouldShowAlertIndicator(); | 904 showing_alert_indicator_ = ShouldShowAlertIndicator(); |
905 if (showing_alert_indicator_) { | 905 if (showing_alert_indicator_) { |
906 const gfx::Size image_size(alert_indicator_button_->GetPreferredSize()); | 906 const gfx::Size image_size(alert_indicator_button_->GetPreferredSize()); |
907 const int right = showing_close_button_ ? | 907 const int right = showing_close_button_ ? |
908 close_button_->x() + close_button_->GetInsets().left() : lb.right(); | 908 close_button_->x() + close_button_->GetInsets().left() : lb.right(); |
909 gfx::Rect bounds( | 909 gfx::Rect bounds( |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 SchedulePaintInRect(bounds); | 1577 SchedulePaintInRect(bounds); |
1578 } | 1578 } |
1579 | 1579 |
1580 gfx::Rect Tab::GetImmersiveBarRect() const { | 1580 gfx::Rect Tab::GetImmersiveBarRect() const { |
1581 // The main bar is as wide as the normal tab's horizontal top line. | 1581 // The main bar is as wide as the normal tab's horizontal top line. |
1582 gfx::Rect contents = GetContentsBounds(); | 1582 gfx::Rect contents = GetContentsBounds(); |
1583 contents.set_y(0); | 1583 contents.set_y(0); |
1584 contents.set_height(kImmersiveBarHeight); | 1584 contents.set_height(kImmersiveBarHeight); |
1585 return contents; | 1585 return contents; |
1586 } | 1586 } |
OLD | NEW |