OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gtk/tabs/tab_renderer_gtk.h" | 5 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 *title_font_, | 838 *title_font_, |
839 title_bounds_, | 839 title_bounds_, |
840 title_bounds_, | 840 title_bounds_, |
841 title_color, | 841 title_color, |
842 base::i18n::IsRTL() ? gfx::Canvas::TEXT_ALIGN_RIGHT : | 842 base::i18n::IsRTL() ? gfx::Canvas::TEXT_ALIGN_RIGHT : |
843 gfx::Canvas::TEXT_ALIGN_LEFT); | 843 gfx::Canvas::TEXT_ALIGN_LEFT); |
844 } | 844 } |
845 | 845 |
846 void TabRendererGtk::PaintIcon(GtkWidget* widget, cairo_t* cr) { | 846 void TabRendererGtk::PaintIcon(GtkWidget* widget, cairo_t* cr) { |
847 if (loading_animation_.animation_state() != ANIMATION_NONE) { | 847 if (loading_animation_.animation_state() != ANIMATION_NONE) { |
848 PaintLoadingAnimation(widget, cr); | 848 PaintLoadingAnimation(widget, cr); |
Evan Stade
2011/10/28 20:34:25
return; instead of having rest of function in else
Elliot Glaysher
2011/10/28 20:48:42
Done.
| |
849 } else { | 849 } else { |
850 CairoCachedSurface* to_display = NULL; | |
Evan Stade
2011/10/28 20:34:25
for your consideration:
CairoCachedSurface* to_di
| |
850 if (should_display_crashed_favicon_) { | 851 if (should_display_crashed_favicon_) { |
851 theme_service_->GetSurfaceNamed(IDR_SAD_FAVICON, widget)->SetSource( | 852 to_display = theme_service_->GetSurfaceNamed(IDR_SAD_FAVICON, widget); |
852 cr, favicon_bounds_.x(), | |
853 favicon_bounds_.y() + favicon_hiding_offset_); | |
854 cairo_paint(cr); | |
855 } else { | 853 } else { |
Evan Stade
2011/10/28 20:34:25
this can be else if instead of else { if
Elliot Glaysher
2011/10/28 20:48:42
Done.
| |
856 if (!data_.favicon.isNull()) { | 854 if (!data_.favicon.isNull()) { |
857 if (data_.is_default_favicon && theme_service_->UsingNativeTheme()) { | 855 if (data_.is_default_favicon && theme_service_->UsingNativeTheme()) { |
858 GdkPixbuf* favicon = GtkThemeService::GetDefaultFavicon(true); | 856 to_display = theme_service_->GetCairoIcon( |
859 | 857 GtkThemeService::NATIVE_FAVICON, widget); |
860 // TODO(erg): Get GtkThemeService to hand us a | |
861 // CairoCachedSurface. Then we can simplify all of this. | |
862 gdk_cairo_set_source_pixbuf( | |
863 cr, favicon, favicon_bounds_.x(), | |
864 favicon_bounds_.y() + favicon_hiding_offset_); | |
865 cairo_paint(cr); | |
866 } else if (data_.cairo_favicon.valid()) { | 858 } else if (data_.cairo_favicon.valid()) { |
867 // TODO(erg): We should research whether we still need to draw app | 859 to_display = &data_.cairo_favicon; |
868 // icons larger. We don't appear to be getting larger icons. | |
869 data_.cairo_favicon.SetSource( | |
870 cr, | |
871 favicon_bounds_.x(), | |
872 favicon_bounds_.y() + favicon_hiding_offset_); | |
873 cairo_paint(cr); | |
874 } | 860 } |
875 } | 861 } |
876 } | 862 } |
863 | |
864 if (to_display) { | |
865 to_display->SetSource(cr, | |
866 favicon_bounds_.x(), | |
867 favicon_bounds_.y() + favicon_hiding_offset_); | |
868 cairo_paint(cr); | |
869 } | |
877 } | 870 } |
878 } | 871 } |
879 | 872 |
880 void TabRendererGtk::PaintTabBackground(GtkWidget* widget, cairo_t* cr) { | 873 void TabRendererGtk::PaintTabBackground(GtkWidget* widget, cairo_t* cr) { |
881 if (IsActive()) { | 874 if (IsActive()) { |
882 PaintActiveTabBackground(widget, cr); | 875 PaintActiveTabBackground(widget, cr); |
883 } else { | 876 } else { |
884 PaintInactiveTabBackground(widget, cr); | 877 PaintInactiveTabBackground(widget, cr); |
885 | 878 |
886 double throb_value = GetThrobValue(); | 879 double throb_value = GetThrobValue(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1110 | 1103 |
1111 close_button_width_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->width(); | 1104 close_button_width_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->width(); |
1112 close_button_height_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->height(); | 1105 close_button_height_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->height(); |
1113 | 1106 |
1114 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); | 1107 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); |
1115 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1108 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
1116 title_font_height_ = title_font_->GetHeight(); | 1109 title_font_height_ = title_font_->GetHeight(); |
1117 | 1110 |
1118 initialized_ = true; | 1111 initialized_ = true; |
1119 } | 1112 } |
OLD | NEW |