Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/ui/gtk/location_bar_view_gtk.cc

Issue 8885016: GTK: Even more changes from raw allocation access to gtk_widget_get_allocation(). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove temporary Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/gtk/infobars/infobar_gtk.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/location_bar_view_gtk.h" 5 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 PangoFontMetrics* metrics = pango_context_get_metrics( 908 PangoFontMetrics* metrics = pango_context_get_metrics(
909 context, 909 context,
910 gtk_widget_get_style(security_info_label_)->font_desc, 910 gtk_widget_get_style(security_info_label_)->font_desc,
911 pango_context_get_language(context)); 911 pango_context_get_language(context));
912 int char_width = 912 int char_width =
913 pango_font_metrics_get_approximate_char_width(metrics) / PANGO_SCALE; 913 pango_font_metrics_get_approximate_char_width(metrics) / PANGO_SCALE;
914 914
915 // The EV label should never take up more than half the hbox. We try to 915 // The EV label should never take up more than half the hbox. We try to
916 // correct our inaccurate measurement units ("the average character width") 916 // correct our inaccurate measurement units ("the average character width")
917 // by dividing more than an even 2. 917 // by dividing more than an even 2.
918 int text_area = security_info_label_->allocation.width + 918 GtkAllocation security_label_allocation;
919 entry_box_->allocation.width; 919 gtk_widget_get_allocation(security_info_label_, &security_label_allocation);
920 GtkAllocation entry_box_allocation;
921 gtk_widget_get_allocation(entry_box_, &entry_box_allocation);
922 int text_area = security_label_allocation.width +
923 entry_box_allocation.width;
920 int max_chars = static_cast<int>(static_cast<float>(text_area) / 924 int max_chars = static_cast<int>(static_cast<float>(text_area) /
921 static_cast<float>(char_width) / 2.75); 925 static_cast<float>(char_width) / 2.75);
922 // Don't let the label be smaller than 10 characters so that the country 926 // Don't let the label be smaller than 10 characters so that the country
923 // code is always visible. 927 // code is always visible.
924 gtk_label_set_max_width_chars(GTK_LABEL(security_info_label_), 928 gtk_label_set_max_width_chars(GTK_LABEL(security_info_label_),
925 std::max(10, max_chars)); 929 std::max(10, max_chars));
926 930
927 pango_font_metrics_unref(metrics); 931 pango_font_metrics_unref(metrics);
928 } 932 }
929 933
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 1636
1633 std::string badge_text = page_action_->GetBadgeText(tab_id); 1637 std::string badge_text = page_action_->GetBadgeText(tab_id);
1634 if (badge_text.empty()) 1638 if (badge_text.empty())
1635 return FALSE; 1639 return FALSE;
1636 1640
1637 gfx::CanvasSkiaPaint canvas(event, false); 1641 gfx::CanvasSkiaPaint canvas(event, false);
1638 gfx::Rect bounding_rect(widget->allocation); 1642 gfx::Rect bounding_rect(widget->allocation);
1639 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); 1643 page_action_->PaintBadge(&canvas, bounding_rect, tab_id);
1640 return FALSE; 1644 return FALSE;
1641 } 1645 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/infobars/infobar_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698