OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 8 |
9 #include "app/gfx/canvas_paint.h" | 9 #include "app/gfx/canvas_paint.h" |
10 #include "app/gfx/favicon_size.h" | 10 #include "app/gfx/favicon_size.h" |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 rb.GetBitmapNamed(IDR_TAB_CLOSE_MASK)); | 536 rb.GetBitmapNamed(IDR_TAB_CLOSE_MASK)); |
537 } | 537 } |
538 } | 538 } |
539 } else { | 539 } else { |
540 close_button_bounds_.SetRect(0, 0, 0, 0); | 540 close_button_bounds_.SetRect(0, 0, 0, 0); |
541 } | 541 } |
542 | 542 |
543 if (!is_pinned() || width() >= kPinnedTabRendererAsTabWidth) { | 543 if (!is_pinned() || width() >= kPinnedTabRendererAsTabWidth) { |
544 // Size the Title text to fill the remaining space. | 544 // Size the Title text to fill the remaining space. |
545 int title_left = favicon_bounds_.right() + kFavIconTitleSpacing; | 545 int title_left = favicon_bounds_.right() + kFavIconTitleSpacing; |
546 // Center the mean line of the text in the content area. | 546 // Center the text in the content area. We need to shift the text up by a |
547 int title_top = kTopPadding + | 547 // pixel to match Windows. TODO(estade): Figure out why we need to shift |
548 (content_height - title_font_->baseline()) / 2; | 548 // the text up by a pixel. http://crbug.com/18555 |
| 549 int title_top = kTopPadding + (content_height - title_font_height_) / 2 - 1; |
549 | 550 |
550 // If the user has big fonts, the title will appear rendered too far down | 551 // If the user has big fonts, the title will appear rendered too far down |
551 // on the y-axis if we use the regular top padding, so we need to adjust it | 552 // on the y-axis if we use the regular top padding, so we need to adjust it |
552 // so that the text appears centered. | 553 // so that the text appears centered. |
553 gfx::Size minimum_size = GetMinimumUnselectedSize(); | 554 gfx::Size minimum_size = GetMinimumUnselectedSize(); |
554 int text_height = title_top + title_font_height_ + kBottomPadding; | 555 int text_height = title_top + title_font_height_ + kBottomPadding; |
555 if (text_height > minimum_size.height()) | 556 if (text_height > minimum_size.height()) |
556 title_top -= (text_height - minimum_size.height()) / 2; | 557 title_top -= (text_height - minimum_size.height()) / 2; |
557 | 558 |
558 int title_width; | 559 int title_width; |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 } | 882 } |
882 | 883 |
883 // static | 884 // static |
884 void TabRendererGtk::InitResources() { | 885 void TabRendererGtk::InitResources() { |
885 if (initialized_) | 886 if (initialized_) |
886 return; | 887 return; |
887 | 888 |
888 LoadTabImages(); | 889 LoadTabImages(); |
889 | 890 |
890 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 891 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
891 // Force the font size to 8pt. | 892 // Force the font size to 9pt, which matches Windows' default font size |
| 893 // (taken from the system). |
892 gfx::Font base_font = rb.GetFont(ResourceBundle::BaseFont); | 894 gfx::Font base_font = rb.GetFont(ResourceBundle::BaseFont); |
893 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 8)); | 895 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 9)); |
894 title_font_height_ = title_font_->height(); | 896 title_font_height_ = title_font_->height(); |
895 | 897 |
896 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); | 898 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); |
897 | 899 |
898 initialized_ = true; | 900 initialized_ = true; |
899 } | 901 } |
OLD | NEW |