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

Unified Diff: chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc

Issue 8743021: GTK: Move to gtk_widget_get_allocation() for some of chrome/browser/ui/gtk/ (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: comment nit Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/gtk/browser_toolbar_gtk.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc
diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc
index 8e520f1af40f610c37274daf495e4a3c2c24ae4a..2a86dba86aae12ee3a2286fa6039612a552f54d8 100644
--- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc
+++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc
@@ -296,7 +296,9 @@ void BookmarkBarGtk::SetBookmarkBarState(
}
int BookmarkBarGtk::GetHeight() {
- return event_box_->allocation.height - kBookmarkBarMinimumHeight;
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(event_box_.get(), &allocation);
+ return allocation.height - kBookmarkBarMinimumHeight;
}
bool BookmarkBarGtk::IsAnimating() {
@@ -304,7 +306,6 @@ bool BookmarkBarGtk::IsAnimating() {
}
void BookmarkBarGtk::CalculateMaxHeight() {
-
if (theme_service_->UsingNativeTheme()) {
// Get the requisition of our single child instead of the event box itself
// because the event box probably already has a size request.
@@ -488,8 +489,11 @@ void BookmarkBarGtk::SetChevronState() {
}
int extra_space = 0;
- if (gtk_widget_get_visible(overflow_button_))
- extra_space = overflow_button_->allocation.width;
+ if (gtk_widget_get_visible(overflow_button_)) {
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(overflow_button_, &allocation);
+ extra_space = allocation.width;
+ }
int overflow_idx = GetFirstHiddenBookmark(extra_space, NULL);
if (overflow_idx == -1)
@@ -571,7 +575,9 @@ int BookmarkBarGtk::GetFirstHiddenBookmark(int extra_space,
// last buttons on the bar.
// TODO(gideonwald): figure out the precise source of these extra two pixels
// and make this calculation more reliable.
- int total_width = bookmark_toolbar_.get()->allocation.width - 2;
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(bookmark_toolbar_.get(), &allocation);
+ int total_width = allocation.width - 2;
bool overflow = false;
GtkRequisition requested_size_;
GList* toolbar_items =
@@ -794,10 +800,13 @@ gboolean BookmarkBarGtk::ItemDraggedOverToolbar(GdkDragContext* context,
return TRUE;
}
-int BookmarkBarGtk::GetToolbarIndexForDragOverFolder(
- GtkWidget* button, gint x) {
- int margin = std::min(15, static_cast<int>(0.3 * button->allocation.width));
- if (x > margin && x < (button->allocation.width - margin))
+int BookmarkBarGtk::GetToolbarIndexForDragOverFolder(GtkWidget* button,
+ gint x) {
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(button, &allocation);
+
+ int margin = std::min(15, static_cast<int>(0.3 * allocation.width));
+ if (x > margin && x < (allocation.width - margin))
return -1;
gint index = gtk_toolbar_get_item_index(GTK_TOOLBAR(bookmark_toolbar_.get()),
@@ -1219,15 +1228,14 @@ gboolean BookmarkBarGtk::OnToolbarDragMotion(GtkWidget* toolbar,
void BookmarkBarGtk::OnToolbarSizeAllocate(GtkWidget* widget,
GtkAllocation* allocation) {
- if (bookmark_toolbar_.get()->allocation.width ==
- last_allocation_width_) {
+ if (allocation->width == last_allocation_width_) {
// If the width hasn't changed, then the visibility of the chevron
// doesn't need to change. This check prevents us from getting stuck in a
// loop where allocates are queued indefinitely while the visibility of
// overflow chevron toggles without actual resizes of the toolbar.
return;
}
- last_allocation_width_ = bookmark_toolbar_.get()->allocation.width;
+ last_allocation_width_ = allocation->width;
SetChevronState();
}
@@ -1384,9 +1392,12 @@ gboolean BookmarkBarGtk::OnEventBoxExpose(GtkWidget* widget,
return FALSE;
gfx::CanvasSkiaPaint canvas(event, true);
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(widget, &allocation);
+
gfx::Rect area = GTK_WIDGET_NO_WINDOW(widget) ?
- gfx::Rect(widget->allocation) :
- gfx::Rect(0, 0, widget->allocation.width, widget->allocation.height);
+ gfx::Rect(allocation) :
+ gfx::Rect(0, 0, allocation.width, allocation.height);
NtpBackgroundUtil::PaintBackgroundDetachedMode(theme_provider, &canvas,
area, tab_contents_size.height());
}
« no previous file with comments | « no previous file | chrome/browser/ui/gtk/browser_toolbar_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698