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

Unified Diff: chrome/browser/ui/gtk/menu_gtk.cc

Issue 8773025: GTK: More removal of raw GtkWidget->allocation access. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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 | « chrome/browser/ui/gtk/gtk_theme_service.cc ('k') | chrome/browser/ui/gtk/nine_box.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/menu_gtk.cc
diff --git a/chrome/browser/ui/gtk/menu_gtk.cc b/chrome/browser/ui/gtk/menu_gtk.cc
index 24a46435b248ad371e99e52addb530bd5f489090..510be61135877e81f65ac8498d31839e65b226ac 100644
--- a/chrome/browser/ui/gtk/menu_gtk.cc
+++ b/chrome/browser/ui/gtk/menu_gtk.cc
@@ -96,7 +96,7 @@ void SetupImageIcon(GtkWidget* button,
// Returns the new Y position of the popup menu.
int CalculateMenuYPosition(const GdkRectangle* screen_rect,
const GtkRequisition* menu_req,
- const GtkWidget* widget, const int y) {
+ GtkWidget* widget, const int y) {
CHECK(screen_rect);
CHECK(menu_req);
// If the menu would run off the bottom of the screen, and there is enough
@@ -107,8 +107,11 @@ int CalculateMenuYPosition(const GdkRectangle* screen_rect,
const int screen_bottom = screen_rect->y + screen_rect->height;
const int menu_bottom = y + menu_req->height;
int alternate_y = y - menu_req->height;
- if (widget)
- alternate_y -= widget->allocation.height;
+ if (widget) {
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(widget, &allocation);
+ alternate_y -= allocation.height;
+ }
if (menu_bottom >= screen_bottom && alternate_y >= screen_top)
return alternate_y;
return y;
@@ -695,11 +698,14 @@ void MenuGtk::WidgetMenuPositionFunc(GtkMenu* menu,
gdk_screen_get_monitor_geometry(screen, monitor,
&screen_rect);
- if (GTK_WIDGET_NO_WINDOW(widget)) {
- *x += widget->allocation.x;
- *y += widget->allocation.y;
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(widget, &allocation);
+
+ if (!gtk_widget_get_has_window(widget)) {
+ *x += allocation.x;
+ *y += allocation.y;
}
- *y += widget->allocation.height;
+ *y += allocation.height;
bool start_align =
!!g_object_get_data(G_OBJECT(widget), "left-align-popup");
@@ -707,7 +713,7 @@ void MenuGtk::WidgetMenuPositionFunc(GtkMenu* menu,
start_align = !start_align;
if (!start_align)
- *x += widget->allocation.width - menu_req.width;
+ *x += allocation.width - menu_req.width;
*y = CalculateMenuYPosition(&screen_rect, &menu_req, widget, *y);
« no previous file with comments | « chrome/browser/ui/gtk/gtk_theme_service.cc ('k') | chrome/browser/ui/gtk/nine_box.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698