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

Side by Side Diff: chrome/browser/views/tabs/base_tab.cc

Issue 2811032: Revert 50784 - Canvas refactoring part 3.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/tabs/base_tab.h" 5 #include "chrome/browser/views/tabs/base_tab.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "app/animation_container.h" 9 #include "app/animation_container.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "app/resource_bundle.h" 11 #include "app/resource_bundle.h"
12 #include "app/slide_animation.h" 12 #include "app/slide_animation.h"
13 #include "app/throb_animation.h" 13 #include "app/throb_animation.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/browser.h" 16 #include "chrome/browser/browser.h"
17 #include "chrome/browser/tab_contents/tab_contents.h" 17 #include "chrome/browser/tab_contents/tab_contents.h"
18 #include "chrome/browser/views/tabs/tab_controller.h" 18 #include "chrome/browser/views/tabs/tab_controller.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "gfx/canvas_skia.h" 20 #include "gfx/canvas.h"
21 #include "gfx/favicon_size.h" 21 #include "gfx/favicon_size.h"
22 #include "gfx/font.h" 22 #include "gfx/font.h"
23 #include "gfx/skbitmap_operations.h" 23 #include "gfx/skbitmap_operations.h"
24 #include "grit/app_resources.h" 24 #include "grit/app_resources.h"
25 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
26 #include "grit/theme_resources.h" 26 #include "grit/theme_resources.h"
27 #include "views/controls/button/image_button.h" 27 #include "views/controls/button/image_button.h"
28 28
29 #ifdef WIN32 29 #ifdef WIN32
30 #include "app/win_util.h" 30 #include "app/win_util.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 SkBitmap* frames = 430 SkBitmap* frames =
431 (data().network_state == TabRendererData::NETWORK_STATE_WAITING) ? 431 (data().network_state == TabRendererData::NETWORK_STATE_WAITING) ?
432 waiting_animation_frames : loading_animation_frames; 432 waiting_animation_frames : loading_animation_frames;
433 int image_size = frames->height(); 433 int image_size = frames->height();
434 int image_offset = loading_animation_frame_ * image_size; 434 int image_offset = loading_animation_frame_ * image_size;
435 int dst_y = (height() - image_size) / 2; 435 int dst_y = (height() - image_size) / 2;
436 canvas->DrawBitmapInt(*frames, image_offset, 0, image_size, 436 canvas->DrawBitmapInt(*frames, image_offset, 0, image_size,
437 image_size, favicon_x, dst_y, image_size, image_size, 437 image_size, favicon_x, dst_y, image_size, image_size,
438 false); 438 false);
439 } else { 439 } else {
440 canvas->AsCanvasSkia()->save(); 440 canvas->save();
441 canvas->ClipRectInt(0, 0, width(), height()); 441 canvas->ClipRectInt(0, 0, width(), height());
442 if (should_display_crashed_favicon_) { 442 if (should_display_crashed_favicon_) {
443 canvas->DrawBitmapInt(*crashed_fav_icon, 0, 0, 443 canvas->DrawBitmapInt(*crashed_fav_icon, 0, 0,
444 crashed_fav_icon->width(), 444 crashed_fav_icon->width(),
445 crashed_fav_icon->height(), 445 crashed_fav_icon->height(),
446 favicon_x, 446 favicon_x,
447 (height() - crashed_fav_icon->height()) / 2 + 447 (height() - crashed_fav_icon->height()) / 2 +
448 fav_icon_hiding_offset_, 448 fav_icon_hiding_offset_,
449 kFavIconSize, kFavIconSize, 449 kFavIconSize, kFavIconSize,
450 true); 450 true);
451 } else { 451 } else {
452 if (!data().favicon.isNull()) { 452 if (!data().favicon.isNull()) {
453 // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch 453 // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch
454 // to using that class to render the favicon). 454 // to using that class to render the favicon).
455 int size = data().favicon.width(); 455 int size = data().favicon.width();
456 canvas->DrawBitmapInt(data().favicon, 0, 0, 456 canvas->DrawBitmapInt(data().favicon, 0, 0,
457 data().favicon.width(), 457 data().favicon.width(),
458 data().favicon.height(), 458 data().favicon.height(),
459 x, y + fav_icon_hiding_offset_, size, size, 459 x, y + fav_icon_hiding_offset_, size, size,
460 true); 460 true);
461 } 461 }
462 } 462 }
463 canvas->AsCanvasSkia()->restore(); 463 canvas->restore();
464 } 464 }
465 } 465 }
466 466
467 void BaseTab::PaintTitle(gfx::Canvas* canvas, SkColor title_color) { 467 void BaseTab::PaintTitle(gfx::Canvas* canvas, SkColor title_color) {
468 // Paint the Title. 468 // Paint the Title.
469 string16 title = data().title; 469 string16 title = data().title;
470 if (title.empty()) { 470 if (title.empty()) {
471 title = data().loading ? 471 title = data().loading ?
472 l10n_util::GetStringUTF16(IDS_TAB_LOADING_TITLE) : 472 l10n_util::GetStringUTF16(IDS_TAB_LOADING_TITLE) :
473 TabContents::GetDefaultTitle(); 473 TabContents::GetDefaultTitle();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 font_height_ = font_->height(); 609 font_height_ = font_->height();
610 } 610 }
611 611
612 // static 612 // static
613 void BaseTab::LoadThemeImages() { 613 void BaseTab::LoadThemeImages() {
614 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 614 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
615 loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER); 615 loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER);
616 waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING); 616 waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING);
617 loading_animation_size_ = loading_animation_frames->height(); 617 loading_animation_size_ = loading_animation_frames->height();
618 } 618 }
OLDNEW
« no previous file with comments | « chrome/browser/views/status_bubble_views.cc ('k') | chrome/browser/views/tabs/dragged_tab_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698