OLD | NEW |
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/gtk/tabs/tab_renderer_gtk.h" | 5 #include "chrome/browser/gtk/tabs/tab_renderer_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 | 267 |
268 TabRendererGtk::~TabRendererGtk() { | 268 TabRendererGtk::~TabRendererGtk() { |
269 tab_.Destroy(); | 269 tab_.Destroy(); |
270 for (BitmapCache::iterator it = cached_bitmaps_.begin(); | 270 for (BitmapCache::iterator it = cached_bitmaps_.begin(); |
271 it != cached_bitmaps_.end(); ++it) { | 271 it != cached_bitmaps_.end(); ++it) { |
272 delete it->second.bitmap; | 272 delete it->second.bitmap; |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 void TabRendererGtk::UpdateData(TabContents* contents, | 276 void TabRendererGtk::UpdateData(TabContents* contents, |
277 bool phantom, | |
278 bool loading_only) { | 277 bool loading_only) { |
279 DCHECK(contents); | 278 DCHECK(contents); |
280 | 279 |
281 theme_provider_ = GtkThemeProvider::GetFrom(contents->profile()); | 280 theme_provider_ = GtkThemeProvider::GetFrom(contents->profile()); |
282 | 281 |
283 if (!loading_only) { | 282 if (!loading_only) { |
284 data_.title = contents->GetTitle(); | 283 data_.title = contents->GetTitle(); |
285 data_.off_the_record = contents->profile()->IsOffTheRecord(); | 284 data_.off_the_record = contents->profile()->IsOffTheRecord(); |
286 data_.crashed = contents->is_crashed(); | 285 data_.crashed = contents->is_crashed(); |
287 data_.favicon = contents->GetFavIcon(); | 286 data_.favicon = contents->GetFavIcon(); |
288 data_.phantom = phantom; | |
289 // This is kind of a hacky way to determine whether our icon is the default | 287 // This is kind of a hacky way to determine whether our icon is the default |
290 // favicon. But the plumbing that would be necessary to do it right would | 288 // favicon. But the plumbing that would be necessary to do it right would |
291 // be a good bit of work and would sully code for other platforms which | 289 // be a good bit of work and would sully code for other platforms which |
292 // don't care to custom-theme the favicon. Hopefully the default favicon | 290 // don't care to custom-theme the favicon. Hopefully the default favicon |
293 // will eventually be chromium-themable and this code will go away. | 291 // will eventually be chromium-themable and this code will go away. |
294 data_.is_default_favicon = | 292 data_.is_default_favicon = |
295 (data_.favicon.pixelRef() == | 293 (data_.favicon.pixelRef() == |
296 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 294 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
297 IDR_DEFAULT_FAVICON)->pixelRef()); | 295 IDR_DEFAULT_FAVICON)->pixelRef()); |
298 } | 296 } |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 if (width() < GetMinimumUnselectedSize().width() && !mini()) | 595 if (width() < GetMinimumUnselectedSize().width() && !mini()) |
598 return; | 596 return; |
599 | 597 |
600 // See if the model changes whether the icons should be painted. | 598 // See if the model changes whether the icons should be painted. |
601 const bool show_icon = ShouldShowIcon(); | 599 const bool show_icon = ShouldShowIcon(); |
602 const bool show_close_button = ShouldShowCloseBox(); | 600 const bool show_close_button = ShouldShowCloseBox(); |
603 if (show_icon != showing_icon_ || | 601 if (show_icon != showing_icon_ || |
604 show_close_button != showing_close_button_) | 602 show_close_button != showing_close_button_) |
605 Layout(); | 603 Layout(); |
606 | 604 |
607 if (!phantom()) { | 605 PaintTabBackground(canvas); |
608 // TODO: this isn't quite right. To match the Windows side we need to render | |
609 // phantom tabs to a separate layer than alpha composite that. This will do | |
610 // for now though. | |
611 PaintTabBackground(canvas); | |
612 } | |
613 | 606 |
614 if (!mini() || width() > kMiniTabRendererAsNormalTabWidth) | 607 if (!mini() || width() > kMiniTabRendererAsNormalTabWidth) |
615 PaintTitle(canvas); | 608 PaintTitle(canvas); |
616 | 609 |
617 if (show_icon) | 610 if (show_icon) |
618 PaintIcon(canvas); | 611 PaintIcon(canvas); |
619 } | 612 } |
620 | 613 |
621 SkBitmap TabRendererGtk::PaintBitmap() { | 614 SkBitmap TabRendererGtk::PaintBitmap() { |
622 gfx::Canvas canvas(width(), height(), false); | 615 gfx::Canvas canvas(width(), height(), false); |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 // Force the font size to 9pt, which matches Windows' default font size | 1052 // Force the font size to 9pt, which matches Windows' default font size |
1060 // (taken from the system). | 1053 // (taken from the system). |
1061 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); | 1054 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); |
1062 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 9)); | 1055 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 9)); |
1063 title_font_height_ = title_font_->height(); | 1056 title_font_height_ = title_font_->height(); |
1064 | 1057 |
1065 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); | 1058 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); |
1066 | 1059 |
1067 initialized_ = true; | 1060 initialized_ = true; |
1068 } | 1061 } |
OLD | NEW |