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

Unified Diff: chrome/browser/ui/touch/tabs/touch_tab.cc

Issue 7065052: Improve large tab strip by leveraging touch icons when present (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resynced (again) Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/touch/tabs/touch_tab.h ('k') | chrome/browser/ui/touch/tabs/touch_tab_strip.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/touch/tabs/touch_tab.cc
diff --git a/chrome/browser/ui/touch/tabs/touch_tab.cc b/chrome/browser/ui/touch/tabs/touch_tab.cc
index dca408a783e84522e451556d230f89f5d80e80a8..837ef5086293ecfcb7b9a90943879672bf2e6389 100644
--- a/chrome/browser/ui/touch/tabs/touch_tab.cc
+++ b/chrome/browser/ui/touch/tabs/touch_tab.cc
@@ -19,10 +19,6 @@ static const int kLeftPadding = 16;
static const int kRightPadding = 15;
static const int kDropShadowHeight = 2;
-// The size of the favicon touch area. This generally would be the same as
-// kFaviconSize in ui/gfx/favicon_size.h
-static const int kTouchTabIconSize = 32;
-
TouchTab::TouchTabImage TouchTab::tab_alpha = {0};
TouchTab::TouchTabImage TouchTab::tab_active = {0};
TouchTab::TouchTabImage TouchTab::tab_inactive = {0};
@@ -180,7 +176,6 @@ void TouchTab::PaintActiveTabBackground(gfx::Canvas* canvas) {
}
void TouchTab::PaintIcon(gfx::Canvas* canvas) {
- // TODO(wyck): use thumbnailer to get better page images
int x = favicon_bounds_.x();
int y = favicon_bounds_.y();
@@ -190,23 +185,19 @@ void TouchTab::PaintIcon(gfx::Canvas* canvas) {
x += x_base;
if (base::i18n::IsRTL()) {
- x = width() - x -
- (data().favicon.isNull() ? kFaviconSize : data().favicon.width());
+ x = width() - x - (data().favicon.isNull()
+ ? kTouchTargetIconSize : data().favicon.width());
}
- int favicon_x = x;
- if (!data().favicon.isNull() && data().favicon.width() != kFaviconSize)
- favicon_x += (data().favicon.width() - kFaviconSize) / 2;
-
if (data().network_state != TabRendererData::NETWORK_STATE_NONE) {
ui::ThemeProvider* tp = GetThemeProvider();
SkBitmap frames(*tp->GetBitmapNamed(
- (data().network_state == TabRendererData::NETWORK_STATE_WAITING) ?
- IDR_THROBBER_WAITING : IDR_THROBBER));
+ (data().network_state == TabRendererData::NETWORK_STATE_WAITING)
+ ? IDR_THROBBER_WAITING : IDR_THROBBER));
int image_size = frames.height();
int image_offset = loading_animation_frame() * image_size;
- canvas->DrawBitmapInt(frames, image_offset, 0, image_size, image_size, x, y,
- kTouchTabIconSize, kTouchTabIconSize, false);
+ canvas->DrawBitmapInt(frames, image_offset, 0, image_size, image_size, x,
+ y, kTouchTargetIconSize, kTouchTargetIconSize, false);
} else {
canvas->Save();
canvas->ClipRectInt(0, 0, width(), height());
@@ -215,33 +206,16 @@ void TouchTab::PaintIcon(gfx::Canvas* canvas) {
SkBitmap crashed_favicon(*rb.GetBitmapNamed(IDR_SAD_FAVICON));
canvas->DrawBitmapInt(crashed_favicon, 0, 0, crashed_favicon.width(),
crashed_favicon.height(), x, y + favicon_hiding_offset(),
- kTouchTabIconSize, kTouchTabIconSize, true);
+ kTouchTargetIconSize, kTouchTargetIconSize, true);
} else {
if (!data().favicon.isNull()) {
-
- if ((data().favicon.width() == kTouchTabIconSize) &&
- (data().favicon.height() == kTouchTabIconSize)) {
- canvas->DrawBitmapInt(data().favicon, 0, 0,
- data().favicon.width(), data().favicon.height(),
- x, y + favicon_hiding_offset(),
- kTouchTabIconSize, kTouchTabIconSize, true);
- } else {
- // Draw a background around target touch area in case the favicon
- // is smaller than touch area (e.g www.google.com is 16x16 now)
- canvas->DrawRectInt(
- GetThemeProvider()->GetColor(
- ThemeService::COLOR_BUTTON_BACKGROUND),
- x, y, kTouchTabIconSize, kTouchTabIconSize);
-
- // We center the image
- // TODO(saintlou): later request larger image from HistoryService
- canvas->DrawBitmapInt(data().favicon, 0, 0, data().favicon.width(),
- data().favicon.height(),
- x + ((kTouchTabIconSize - data().favicon.width()) / 2),
- y + ((kTouchTabIconSize - data().favicon.height()) / 2) +
- favicon_hiding_offset(),
- data().favicon.width(), data().favicon.height(), true);
- }
+ // We center the image since it might not be square
+ canvas->DrawBitmapInt(data().favicon,
+ 0, 0, data().favicon.width(), data().favicon.height(),
+ x + ((kTouchTargetIconSize - data().favicon.width()) / 2),
+ y + ((kTouchTargetIconSize - data().favicon.height()) / 2) +
+ favicon_hiding_offset(),
+ data().favicon.width(), data().favicon.height(), true);
}
}
canvas->Restore();
@@ -260,7 +234,6 @@ void TouchTab::InitTabResources() {
LoadTabImages();
}
-
// static
void TouchTab::LoadTabImages() {
// We're not letting people override tab images just yet.
« no previous file with comments | « chrome/browser/ui/touch/tabs/touch_tab.h ('k') | chrome/browser/ui/touch/tabs/touch_tab_strip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698