| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/debug/trace_event.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 const int kMiniTitleChangeThrobDuration = 1000; | 92 const int kMiniTitleChangeThrobDuration = 1000; |
| 93 | 93 |
| 94 const int kRecordingDurationMs = 1000; | 94 const int kRecordingDurationMs = 1000; |
| 95 | 95 |
| 96 // The horizontal offset used to position the close button in the tab. | 96 // The horizontal offset used to position the close button in the tab. |
| 97 const int kCloseButtonHorzFuzz = 4; | 97 const int kCloseButtonHorzFuzz = 4; |
| 98 | 98 |
| 99 // Gets the bounds of |widget| relative to |parent|. | 99 // Gets the bounds of |widget| relative to |parent|. |
| 100 gfx::Rect GetWidgetBoundsRelativeToParent(GtkWidget* parent, | 100 gfx::Rect GetWidgetBoundsRelativeToParent(GtkWidget* parent, |
| 101 GtkWidget* widget) { | 101 GtkWidget* widget) { |
| 102 gfx::Point parent_pos = ui::GetWidgetScreenPosition(parent); | 102 gfx::Rect bounds = ui::GetWidgetScreenBounds(widget); |
| 103 gfx::Point widget_pos = ui::GetWidgetScreenPosition(widget); | 103 bounds.Offset(-ui::GetWidgetScreenOffset(parent)); |
| 104 | 104 return bounds; |
| 105 GtkAllocation allocation; | |
| 106 gtk_widget_get_allocation(widget, &allocation); | |
| 107 | |
| 108 return gfx::Rect(widget_pos.x() - parent_pos.x(), | |
| 109 widget_pos.y() - parent_pos.y(), | |
| 110 allocation.width, allocation.height); | |
| 111 } | 105 } |
| 112 | 106 |
| 113 // Returns a GdkPixbuf after resizing the SkBitmap as necessary. Caller must | 107 // Returns a GdkPixbuf after resizing the SkBitmap as necessary. Caller must |
| 114 // g_object_unref the returned pixbuf when no longer used. | 108 // g_object_unref the returned pixbuf when no longer used. |
| 115 GdkPixbuf* GetResizedGdkPixbufFromSkBitmap(const SkBitmap& bitmap, | 109 GdkPixbuf* GetResizedGdkPixbufFromSkBitmap(const SkBitmap& bitmap, |
| 116 int src_w, | 110 int src_w, |
| 117 int src_h) { | 111 int src_h) { |
| 118 float float_src_w = static_cast<float>(src_w); | 112 float float_src_w = static_cast<float>(src_w); |
| 119 float float_src_h = static_cast<float>(src_h); | 113 float float_src_h = static_cast<float>(src_h); |
| 120 float scalable_w, scalable_h; | 114 float scalable_w, scalable_h; |
| (...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); | 1165 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); |
| 1172 close_button_width_ = gdk_pixbuf_get_width(tab_close); | 1166 close_button_width_ = gdk_pixbuf_get_width(tab_close); |
| 1173 close_button_height_ = gdk_pixbuf_get_height(tab_close); | 1167 close_button_height_ = gdk_pixbuf_get_height(tab_close); |
| 1174 | 1168 |
| 1175 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); | 1169 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); |
| 1176 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1170 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
| 1177 title_font_height_ = title_font_->GetHeight(); | 1171 title_font_height_ = title_font_->GetHeight(); |
| 1178 | 1172 |
| 1179 initialized_ = true; | 1173 initialized_ = true; |
| 1180 } | 1174 } |
| OLD | NEW |