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 13 matching lines...) Expand all Loading... | |
24 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" | 24 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
27 #include "chrome/grit/generated_resources.h" | 27 #include "chrome/grit/generated_resources.h" |
28 #include "content/public/browser/user_metrics.h" | 28 #include "content/public/browser/user_metrics.h" |
29 #include "content/public/common/url_constants.h" | 29 #include "content/public/common/url_constants.h" |
30 #include "grit/components_scaled_resources.h" | 30 #include "grit/components_scaled_resources.h" |
31 #include "grit/components_strings.h" | 31 #include "grit/components_strings.h" |
32 #include "grit/theme_resources.h" | 32 #include "grit/theme_resources.h" |
33 #include "third_party/skia/include/effects/SkGradientShader.h" | 33 #include "third_party/skia/include/effects/SkGradientShader.h" |
34 #include "third_party/skia/include/effects/SkLumaColorFilter.h" | |
34 #include "third_party/skia/include/pathops/SkPathOps.h" | 35 #include "third_party/skia/include/pathops/SkPathOps.h" |
35 #include "ui/accessibility/ax_view_state.h" | 36 #include "ui/accessibility/ax_view_state.h" |
36 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
37 #include "ui/base/material_design/material_design_controller.h" | 38 #include "ui/base/material_design/material_design_controller.h" |
38 #include "ui/base/models/list_selection_model.h" | 39 #include "ui/base/models/list_selection_model.h" |
39 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
40 #include "ui/base/theme_provider.h" | 41 #include "ui/base/theme_provider.h" |
41 #include "ui/gfx/animation/animation_container.h" | 42 #include "ui/gfx/animation/animation_container.h" |
42 #include "ui/gfx/animation/throb_animation.h" | 43 #include "ui/gfx/animation/throb_animation.h" |
43 #include "ui/gfx/canvas.h" | 44 #include "ui/gfx/canvas.h" |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
890 void Tab::AlertStateChanged() { | 891 void Tab::AlertStateChanged() { |
891 Layout(); | 892 Layout(); |
892 } | 893 } |
893 | 894 |
894 bool Tab::IsSelected() const { | 895 bool Tab::IsSelected() const { |
895 return controller_->IsTabSelected(this); | 896 return controller_->IsTabSelected(this); |
896 } | 897 } |
897 | 898 |
898 void Tab::SetData(const TabRendererData& data) { | 899 void Tab::SetData(const TabRendererData& data) { |
899 DCHECK(GetWidget()); | 900 DCHECK(GetWidget()); |
900 | |
901 if (data_.Equals(data)) | 901 if (data_.Equals(data)) |
902 return; | 902 return; |
903 | 903 |
904 TabRendererData old(data_); | 904 TabRendererData old(data_); |
905 UpdateLoadingAnimation(data.network_state); | 905 UpdateLoadingAnimation(data.network_state); |
906 data_ = data; | 906 data_ = data; |
907 | 907 |
908 base::string16 title = data_.title; | 908 base::string16 title = data_.title; |
909 if (title.empty()) { | 909 if (title.empty()) { |
910 title = data_.loading ? | 910 title = data_.loading ? |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1587 const gfx::Rect& favicon_draw_bounds) { | 1587 const gfx::Rect& favicon_draw_bounds) { |
1588 // The pinned tab title changed indicator consists of two parts: | 1588 // The pinned tab title changed indicator consists of two parts: |
1589 // . a clear (totally transparent) part over the bottom right (or left in rtl) | 1589 // . a clear (totally transparent) part over the bottom right (or left in rtl) |
1590 // of the favicon. This is done by drawing the favicon to a canvas, then | 1590 // of the favicon. This is done by drawing the favicon to a canvas, then |
1591 // drawing the clear part on top of the favicon. | 1591 // drawing the clear part on top of the favicon. |
1592 // . a circle in the bottom right (or left in rtl) of the favicon. | 1592 // . a circle in the bottom right (or left in rtl) of the favicon. |
1593 if (!favicon_.isNull()) { | 1593 if (!favicon_.isNull()) { |
1594 const float kIndicatorCropRadius = 4.5; | 1594 const float kIndicatorCropRadius = 4.5; |
1595 gfx::Canvas icon_canvas(gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize), | 1595 gfx::Canvas icon_canvas(gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize), |
1596 canvas->image_scale(), false); | 1596 canvas->image_scale(), false); |
1597 icon_canvas.DrawImageInt(favicon_, 0, 0); | 1597 icon_canvas.DrawImageInt(favicon_, 0, 0); |
sky
2016/08/11 20:46:21
You'll need to update this too.
edwardjung
2016/08/12 14:42:55
Thanks, missed this, although I'm not sure when a
| |
1598 SkPaint clear_paint; | 1598 SkPaint clear_paint; |
1599 clear_paint.setAntiAlias(true); | 1599 clear_paint.setAntiAlias(true); |
1600 clear_paint.setXfermodeMode(SkXfermode::kClear_Mode); | 1600 clear_paint.setXfermodeMode(SkXfermode::kClear_Mode); |
1601 const int circle_x = base::i18n::IsRTL() ? 0 : gfx::kFaviconSize; | 1601 const int circle_x = base::i18n::IsRTL() ? 0 : gfx::kFaviconSize; |
1602 icon_canvas.DrawCircle(gfx::PointF(circle_x, gfx::kFaviconSize), | 1602 icon_canvas.DrawCircle(gfx::PointF(circle_x, gfx::kFaviconSize), |
1603 kIndicatorCropRadius, clear_paint); | 1603 kIndicatorCropRadius, clear_paint); |
1604 canvas->DrawImageInt(gfx::ImageSkia(icon_canvas.ExtractImageRep()), 0, 0, | 1604 canvas->DrawImageInt(gfx::ImageSkia(icon_canvas.ExtractImageRep()), 0, 0, |
1605 favicon_draw_bounds.width(), | 1605 favicon_draw_bounds.width(), |
1606 favicon_draw_bounds.height(), favicon_draw_bounds.x(), | 1606 favicon_draw_bounds.height(), favicon_draw_bounds.x(), |
1607 favicon_draw_bounds.y(), favicon_draw_bounds.width(), | 1607 favicon_draw_bounds.y(), favicon_draw_bounds.width(), |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1650 ShouldThemifyFaviconForUrl(data().url))) { | 1650 ShouldThemifyFaviconForUrl(data().url))) { |
1651 favicon_ = gfx::ImageSkiaOperations::CreateHSLShiftedImage( | 1651 favicon_ = gfx::ImageSkiaOperations::CreateHSLShiftedImage( |
1652 favicon_, GetThemeProvider()->GetTint(ThemeProperties::TINT_BUTTONS)); | 1652 favicon_, GetThemeProvider()->GetTint(ThemeProperties::TINT_BUTTONS)); |
1653 } | 1653 } |
1654 } | 1654 } |
1655 | 1655 |
1656 if (showing_pinned_tab_title_changed_indicator_ && | 1656 if (showing_pinned_tab_title_changed_indicator_ && |
1657 !should_display_crashed_favicon_) { | 1657 !should_display_crashed_favicon_) { |
1658 PaintPinnedTabTitleChangedIndicatorAndIcon(canvas, bounds); | 1658 PaintPinnedTabTitleChangedIndicatorAndIcon(canvas, bounds); |
1659 } else if (!favicon_.isNull()) { | 1659 } else if (!favicon_.isNull()) { |
1660 canvas->DrawImageInt(favicon_, 0, 0, bounds.width(), bounds.height(), | 1660 // Desaturate favicons of tabs with network errors. |
1661 bounds.x(), bounds.y(), bounds.width(), | 1661 if (data().network_error) { |
1662 bounds.height(), false); | 1662 SkPaint paint; |
1663 paint.setStyle(SkPaint::kFill_Style); | |
1664 paint.setAntiAlias(true); | |
1665 SkScalar desaturate[20] = {0.3086f, 0.6094f, 0.0820f, 0.0f, 0.0f, | |
1666 0.3086f, 0.6094f, 0.0820f, 0.0f, 0.0f, | |
1667 0.3086f, 0.6094f, 0.0820f, 0.0f, 0.0f, | |
1668 0.0f, 0.0f, 0.0f, 0.8f, 0.0f}; | |
1669 paint.setColorFilter( | |
1670 SkColorFilter::MakeMatrixFilterRowMajor255(desaturate)); | |
1671 canvas->DrawImageInt(favicon_, 0, 0, bounds.width(), bounds.height(), | |
1672 bounds.x(), bounds.y(), bounds.width(), | |
1673 bounds.height(), false, paint); | |
1674 } else { | |
1675 canvas->DrawImageInt(favicon_, 0, 0, bounds.width(), bounds.height(), | |
1676 bounds.x(), bounds.y(), bounds.width(), | |
1677 bounds.height(), false); | |
1678 } | |
1663 } | 1679 } |
1664 } | 1680 } |
1665 | 1681 |
1666 void Tab::AdvanceLoadingAnimation() { | 1682 void Tab::AdvanceLoadingAnimation() { |
1667 const TabRendererData::NetworkState state = data().network_state; | 1683 const TabRendererData::NetworkState state = data().network_state; |
1668 if (controller_->IsImmersiveStyle()) { | 1684 if (controller_->IsImmersiveStyle()) { |
1669 throbber_->SetVisible(false); | 1685 throbber_->SetVisible(false); |
1670 if (state == TabRendererData::NETWORK_STATE_WAITING) { | 1686 if (state == TabRendererData::NETWORK_STATE_WAITING) { |
1671 // Waiting steps backwards. | 1687 // Waiting steps backwards. |
1672 immersive_loading_step_ = | 1688 immersive_loading_step_ = |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1821 gfx::Rect Tab::GetImmersiveBarRect() const { | 1837 gfx::Rect Tab::GetImmersiveBarRect() const { |
1822 // The main bar is as wide as the normal tab's horizontal top line. | 1838 // The main bar is as wide as the normal tab's horizontal top line. |
1823 // This top line of the tab extends a few pixels left and right of the | 1839 // This top line of the tab extends a few pixels left and right of the |
1824 // center image due to pixels in the rounded corner images. | 1840 // center image due to pixels in the rounded corner images. |
1825 const int kBarPadding = 1; | 1841 const int kBarPadding = 1; |
1826 int main_bar_left = g_active_images.l_width - kBarPadding; | 1842 int main_bar_left = g_active_images.l_width - kBarPadding; |
1827 int main_bar_right = width() - g_active_images.r_width + kBarPadding; | 1843 int main_bar_right = width() - g_active_images.r_width + kBarPadding; |
1828 return gfx::Rect( | 1844 return gfx::Rect( |
1829 main_bar_left, 0, main_bar_right - main_bar_left, kImmersiveBarHeight); | 1845 main_bar_left, 0, main_bar_right - main_bar_left, kImmersiveBarHeight); |
1830 } | 1846 } |
OLD | NEW |