| 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/debug/trace_event.h" |
| 10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/defaults.h" | 12 #include "chrome/browser/defaults.h" |
| 12 #include "chrome/browser/extensions/extension_tab_helper.h" | 13 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 13 #include "chrome/browser/favicon/favicon_tab_helper.h" | 14 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" | 17 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" |
| 17 #include "chrome/browser/ui/gtk/custom_button.h" | 18 #include "chrome/browser/ui/gtk/custom_button.h" |
| 18 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 19 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 19 #include "chrome/browser/ui/gtk/gtk_util.h" | 20 #include "chrome/browser/ui/gtk/gtk_util.h" |
| (...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 cairo_fill(cr); | 947 cairo_fill(cr); |
| 947 | 948 |
| 948 // Draw right drop shadow | 949 // Draw right drop shadow |
| 949 gfx::CairoCachedSurface* active_image_r = | 950 gfx::CairoCachedSurface* active_image_r = |
| 950 theme_service_->GetSurfaceNamed(right_idr, widget); | 951 theme_service_->GetSurfaceNamed(right_idr, widget); |
| 951 active_image_r->SetSource(cr, widget, width() - active_image_r->Width(), 0); | 952 active_image_r->SetSource(cr, widget, width() - active_image_r->Width(), 0); |
| 952 cairo_paint(cr); | 953 cairo_paint(cr); |
| 953 } | 954 } |
| 954 | 955 |
| 955 void TabRendererGtk::PaintInactiveTabBackground(GtkWidget* widget, | 956 void TabRendererGtk::PaintInactiveTabBackground(GtkWidget* widget, |
| 956 cairo_t* cr) { | 957 cairo_t* cr) { |
| 957 int theme_id = data_.incognito ? | 958 int theme_id = data_.incognito ? |
| 958 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; | 959 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; |
| 959 | 960 |
| 960 gfx::CairoCachedSurface* tab_bg = | 961 gfx::CairoCachedSurface* tab_bg = |
| 961 theme_service_->GetSurfaceNamed(theme_id, widget); | 962 theme_service_->GetSurfaceNamed(theme_id, widget); |
| 962 | 963 |
| 963 // If the theme is providing a custom background image, then its top edge | 964 // If the theme is providing a custom background image, then its top edge |
| 964 // should be at the top of the tab. Otherwise, we assume that the background | 965 // should be at the top of the tab. Otherwise, we assume that the background |
| 965 // image is a composited foreground + frame image. | 966 // image is a composited foreground + frame image. |
| 966 int offset_y = theme_service_->HasCustomImage(theme_id) ? | 967 int offset_y = theme_service_->HasCustomImage(theme_id) ? |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 if (event->button == 2) { | 1063 if (event->button == 2) { |
| 1063 CloseButtonClicked(); | 1064 CloseButtonClicked(); |
| 1064 return TRUE; | 1065 return TRUE; |
| 1065 } | 1066 } |
| 1066 | 1067 |
| 1067 return FALSE; | 1068 return FALSE; |
| 1068 } | 1069 } |
| 1069 | 1070 |
| 1070 gboolean TabRendererGtk::OnExposeEvent(GtkWidget* widget, | 1071 gboolean TabRendererGtk::OnExposeEvent(GtkWidget* widget, |
| 1071 GdkEventExpose* event) { | 1072 GdkEventExpose* event) { |
| 1073 TRACE_EVENT0("ui::gtk", "TabRendererGtk::OnExposeEvent"); |
| 1074 |
| 1072 PaintTab(widget, event); | 1075 PaintTab(widget, event); |
| 1073 gtk_container_propagate_expose(GTK_CONTAINER(tab_.get()), | 1076 gtk_container_propagate_expose(GTK_CONTAINER(tab_.get()), |
| 1074 close_button_->widget(), event); | 1077 close_button_->widget(), event); |
| 1075 return TRUE; | 1078 return TRUE; |
| 1076 } | 1079 } |
| 1077 | 1080 |
| 1078 void TabRendererGtk::OnSizeAllocate(GtkWidget* widget, | 1081 void TabRendererGtk::OnSizeAllocate(GtkWidget* widget, |
| 1079 GtkAllocation* allocation) { | 1082 GtkAllocation* allocation) { |
| 1080 gfx::Rect bounds = gfx::Rect(allocation->x, allocation->y, | 1083 gfx::Rect bounds = gfx::Rect(allocation->x, allocation->y, |
| 1081 allocation->width, allocation->height); | 1084 allocation->width, allocation->height); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 | 1122 |
| 1120 close_button_width_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->width(); | 1123 close_button_width_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->width(); |
| 1121 close_button_height_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->height(); | 1124 close_button_height_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->height(); |
| 1122 | 1125 |
| 1123 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); | 1126 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); |
| 1124 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1127 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
| 1125 title_font_height_ = title_font_->GetHeight(); | 1128 title_font_height_ = title_font_->GetHeight(); |
| 1126 | 1129 |
| 1127 initialized_ = true; | 1130 initialized_ = true; |
| 1128 } | 1131 } |
| OLD | NEW |