From ab97e1d7ecf681c72ae6df8975658e453bf52b79 Mon Sep 17 00:00:00 2001 From: estade Date: Mon, 21 Sep 2015 15:42:22 -0700 Subject: [PATCH] Vectorize sad tab image. BUG=521117 Review URL: https://codereview.chromium.org/1339433002 Cr-Commit-Position: refs/heads/master@{#350051} --- chrome/app/theme/common/sadtab.svg | 4 ++ .../{common => legacy}/sadtab.png | Bin .../{common => legacy}/sadtab.png | Bin .../theme/default_300_percent/common/sadtab.png | Bin 197 -> 0 bytes chrome/app/theme/theme_resources.grd | 4 +- chrome/browser/resources/crashes.css | 5 +- chrome/browser/ui/views/sad_tab_view.cc | 14 ++++-- ui/gfx/BUILD.gn | 1 + ui/gfx/paint_vector_icon.cc | 6 +++ ui/gfx/vector_icon_types.h | 2 + ui/gfx/vector_icons/crashed_tab.icon | 52 +++++++++++++++++++++ 11 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 chrome/app/theme/common/sadtab.svg rename chrome/app/theme/default_100_percent/{common => legacy}/sadtab.png (100%) rename chrome/app/theme/default_200_percent/{common => legacy}/sadtab.png (100%) delete mode 100644 chrome/app/theme/default_300_percent/common/sadtab.png create mode 100644 ui/gfx/vector_icons/crashed_tab.icon diff --git a/chrome/app/theme/common/sadtab.svg b/chrome/app/theme/common/sadtab.svg new file mode 100644 index 000000000000..9ce9ccbebfb5 --- /dev/null +++ b/chrome/app/theme/common/sadtab.svg @@ -0,0 +1,4 @@ + + + + diff --git a/chrome/app/theme/default_100_percent/common/sadtab.png b/chrome/app/theme/default_100_percent/legacy/sadtab.png similarity index 100% rename from chrome/app/theme/default_100_percent/common/sadtab.png rename to chrome/app/theme/default_100_percent/legacy/sadtab.png diff --git a/chrome/app/theme/default_200_percent/common/sadtab.png b/chrome/app/theme/default_200_percent/legacy/sadtab.png similarity index 100% rename from chrome/app/theme/default_200_percent/common/sadtab.png rename to chrome/app/theme/default_200_percent/legacy/sadtab.png diff --git a/chrome/app/theme/default_300_percent/common/sadtab.png b/chrome/app/theme/default_300_percent/common/sadtab.png deleted file mode 100644 index 636e879db6ba104fe552680830d78c82b10a471a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 197 zcwXxa@N?(olHy`uVBq!ia0vp^6M(pakr_y;&wnWbq}T#{LR^7#aB%R7O!faj7Gp_} zUoeBivm0qZPOhhmV@L(#(+dZA8x(k2A4>7dNHzva__`;HxP3Tr@I%eAKq2u359%{N z&z;r9vf;_WO&QLU&qcJf76%*(p4l9=&(Cw+4`+#KSzQ@L?l0Z>F6>TtW4X5eBHOgJ s7rSC395y*TSoB3qSKzhFeYZv2bB>1`%8LDO0koLG)78&qol`;+0L3Cn3jhEB diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index ce77571a1254..02b9826bedf1 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd @@ -816,7 +816,9 @@ - + + + diff --git a/chrome/browser/resources/crashes.css b/chrome/browser/resources/crashes.css index 49815193c956..1d7ab78f6791 100644 --- a/chrome/browser/resources/crashes.css +++ b/chrome/browser/resources/crashes.css @@ -8,10 +8,7 @@ body { h1 { -webkit-padding-start: 75px; - background-image: -webkit-image-set( - url(../../app/theme/default_100_percent/common/sadtab.png) 1x, - url(../../app/theme/default_200_percent/common/sadtab.png) 2x, - url(../../app/theme/default_300_percent/common/sadtab.png) 3x); + background-image: url(../../app/theme/common/sadtab.svg); background-position: left; background-repeat: no-repeat; font-size: 156%; diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/chrome/browser/ui/views/sad_tab_view.cc index e736aa715a8d..4a4821bd2587 100644 --- a/chrome/browser/ui/views/sad_tab_view.cc +++ b/chrome/browser/ui/views/sad_tab_view.cc @@ -15,9 +15,12 @@ #include "content/public/browser/navigation_controller.h" #include "content/public/browser/web_contents.h" #include "grit/components_strings.h" -#include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icons_public.h" +#include "ui/native_theme/common_theme.h" +#include "ui/native_theme/native_theme.h" #include "ui/views/background.h" #include "ui/views/controls/button/blue_button.h" #include "ui/views/controls/image_view.h" @@ -136,15 +139,18 @@ SadTabView::SadTabView(WebContents* web_contents, chrome::SadTabKind kind) columns->AddPaddingColumn(1, views::kPanelSubVerticalSpacing); views::ImageView* image = new views::ImageView(); + + SkColor icon_color; + ui::CommonThemeGetSystemColor(ui::NativeTheme::kColorId_ChromeIconGrey, + &icon_color); image->SetImage( - ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_SAD_TAB)); + gfx::CreateVectorIcon(gfx::VectorIconId::CRASHED_TAB, 48, icon_color)); layout->AddPaddingRow(1, views::kPanelVerticalSpacing); layout->StartRow(0, column_set_id); layout->AddView(image, 2, 1); - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - title_ = CreateLabel(l10n_util::GetStringUTF16(IDS_SAD_TAB_TITLE)); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); title_->SetFontList(rb.GetFontList(ui::ResourceBundle::LargeFont)); title_->SetMultiLine(true); title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn index f17b3677f1fc..f97ff610c485 100644 --- a/ui/gfx/BUILD.gn +++ b/ui/gfx/BUILD.gn @@ -429,6 +429,7 @@ action("aggregate_vector_icons") { "vector_icons/check_circle.icon", "vector_icons/code.icon", "vector_icons/cookie.icon", + "vector_icons/crashed_tab.icon", "vector_icons/extension.icon", "vector_icons/file_download.icon", "vector_icons/file_download_shelf.icon", diff --git a/ui/gfx/paint_vector_icon.cc b/ui/gfx/paint_vector_icon.cc index aaeea30f9bfc..7051fb58fdf3 100644 --- a/ui/gfx/paint_vector_icon.cc +++ b/ui/gfx/paint_vector_icon.cc @@ -31,6 +31,7 @@ CommandType CommandFromString(const std::string& source) { RETURN_IF_IS(PATH_COLOR_ARGB); RETURN_IF_IS(PATH_MODE_CLEAR); RETURN_IF_IS(STROKE); + RETURN_IF_IS(CAP_SQUARE); RETURN_IF_IS(MOVE_TO); RETURN_IF_IS(R_MOVE_TO); RETURN_IF_IS(LINE_TO); @@ -119,6 +120,11 @@ void PaintPath(Canvas* canvas, break; } + case CAP_SQUARE: { + paint.setStrokeCap(SkPaint::kSquare_Cap); + break; + } + case MOVE_TO: { SkScalar x = path_elements[++i].arg; SkScalar y = path_elements[++i].arg; diff --git a/ui/gfx/vector_icon_types.h b/ui/gfx/vector_icon_types.h index 23b58d039a2b..ced3cc034f5f 100644 --- a/ui/gfx/vector_icon_types.h +++ b/ui/gfx/vector_icon_types.h @@ -29,6 +29,8 @@ enum CommandType { // By default, the path will be filled. This changes the paint action to // stroke at the given width. STROKE, + // By default, a stroke has a round cap. This sets it to square. + CAP_SQUARE, // These correspond to pathing commands. MOVE_TO, R_MOVE_TO, diff --git a/ui/gfx/vector_icons/crashed_tab.icon b/ui/gfx/vector_icons/crashed_tab.icon new file mode 100644 index 000000000000..fa3e66235bc1 --- /dev/null +++ b/ui/gfx/vector_icons/crashed_tab.icon @@ -0,0 +1,52 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +STROKE, 3, +CAP_SQUARE, +MOVE_TO, 1.5, 8.5, +R_V_LINE_TO, 34, +R_H_LINE_TO, 45, +R_V_LINE_TO, -28, +R_MOVE_TO, -3, -3, +R_H_LINE_TO, -10, +R_V_LINE_TO, -3, +R_MOVE_TO, -3, -3, +R_H_LINE_TO, -10, +R_MOVE_TO, 15, 6, +R_H_LINE_TO, -18, +R_V_LINE_TO, -3, +R_MOVE_TO, -3, -3, +R_H_LINE_TO, -10, +NEW_PATH, +STROKE, 2, +CAP_SQUARE, +MOVE_TO, 12, 35, +R_H_LINE_TO, 2, +R_MOVE_TO, 2, -2, +R_H_LINE_TO, 12, +R_MOVE_TO, 2, 2, +R_H_LINE_TO, 3, +R_MOVE_TO, 2, 2, +R_H_LINE_TO, 3, +MOVE_TO, 11, 21, +R_LINE_TO, 0, 0, +R_MOVE_TO, 0, 4, +R_LINE_TO, 0, 0, +R_MOVE_TO, 4, 0, +R_LINE_TO, 0, 0, +R_MOVE_TO, 0, -4, +R_LINE_TO, 0, 0, +R_MOVE_TO, -2, 2, +R_LINE_TO, 0, 0, +MOVE_TO, 33, 21, +R_LINE_TO, 0, 0, +R_MOVE_TO, 0, 4, +R_LINE_TO, 0, 0, +R_MOVE_TO, 4, 0, +R_LINE_TO, 0, 0, +R_MOVE_TO, 0, -4, +R_LINE_TO, 0, 0, +R_MOVE_TO, -2, 2, +R_LINE_TO, 0, 0, +END -- 2.11.4.GIT