Backout f09c204296f8 (bug 627699) for bustage
authorEd Morley <bmo@edmorley.co.uk>
Thu, 06 Oct 2011 11:25:25 +0100
changeset 78875 62d490b0433f2838453a69e708bddd67928c79bd
parent 78874 f8fa25d9551c29368f3b174b3577785671f8bf35
child 78876 e5cfda41f2e8025493fd1aa3a636104761063b9b
push id506
push userclegnitto@mozilla.com
push dateWed, 09 Nov 2011 02:03:18 +0000
treeherdermozilla-aurora@63587fc7bb93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs627699
milestone10.0a1
backs outf09c204296f82d5981f4b132fde038c723c1ad28
Backout f09c204296f8 (bug 627699) for bustage
widget/src/gtk2/gtk2compat.h
widget/src/gtk2/mozcontainer.c
--- a/widget/src/gtk2/gtk2compat.h
+++ b/widget/src/gtk2/gtk2compat.h
@@ -104,80 +104,21 @@ gtk_widget_has_focus(GtkWidget *widget)
 }
 
 static inline void
 gtk_widget_get_allocation(GtkWidget *widget, GtkAllocation *allocation)
 {
   *allocation = widget->allocation;
 }
 
-static inline void
-gtk_widget_set_allocation(GtkWidget *widget, const GtkAllocation *allocation);
-{
-  widget->allocation = *allocation;
-}
-
 static inline gboolean
 gdk_window_is_destroyed(GdkWindow *window)
 {
   return GDK_WINDOW_OBJECT(window)->destroyed;
 }
-
-static inline void 
-gtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus)
-{
-  if (can_focus)
-    GTK_WIDGET_SET_FLAGS (container, GTK_CAN_FOCUS);
-  else
-    GTK_WIDGET_UNSET_FLAGS (container, GTK_CAN_FOCUS);
-}
-
-static inline gboolean
-gtk_widget_get_visible(GtkWidget *widget)
-{
-  return GTK_WIDGET_VISIBLE (widget);
-}
-
-static inline void
-gtk_widget_set_window(GtkWidget *widget, GdkWindow *window)
-{
-  widget->window = window;
-}
-#endif
-
-#if !GTK_CHECK_VERSION(2, 20, 0)
-static inline void
-gtk_widget_set_mapped(GtkWidget *widget, gboolean mapped)
-{
-  if (mapped)
-    GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-  else
-    GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-}
-
-static inline gboolean
-gtk_widget_get_mapped(GtkWidget *widget)
-{
-  return GTK_WIDGET_MAPPED (widget);
-}
-
-static inline void
-gtk_widget_set_realized(GtkWidget *widget, gboolean realized)
-{
-  if (realized)
-    GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
-  else
-    GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED);
-}
-
-static inline gboolean
-gtk_widget_get_realized(GtkWidget *widget)
-{
-  return GTK_WIDGET_REALIZED (widget);
-}
 #endif
 
 #if !GTK_CHECK_VERSION(2, 22, 0)
 static inline gint
 gdk_visual_get_depth(GdkVisual *visual)
 {
   return visual->depth;
 }
@@ -185,41 +126,38 @@ gdk_visual_get_depth(GdkVisual *visual)
 static inline GdkDragAction
 gdk_drag_context_get_actions(GdkDragContext *context)
 {
   return context->actions;
 }
 #endif
 
 #if !GTK_CHECK_VERSION(2, 24, 0)
-#ifdef GDK_WINDOW_XDISPLAY
 static inline GdkWindow *
 gdk_x11_window_lookup_for_display(GdkDisplay *display, Window window)
 {
   return gdk_window_lookup_for_display(display, window);
 }
-#endif
+
 static inline GdkDisplay *
 gdk_window_get_display(GdkWindow *window)
 {
   return gdk_drawable_get_display(GDK_DRAWABLE(window));
 }
 
 static inline GdkScreen*
 gdk_window_get_screen (GdkWindow *window)
 {
   return gdk_drawable_get_screen (window);
 }
 #endif
 
-#ifdef GDK_WINDOW_XWINDOW
 static inline Window 
 gdk_x11_window_get_xid(GdkWindow *window)
 {
   return(GDK_WINDOW_XWINDOW(window));
 }
-#endif
 
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
 
 #endif // _GTK2_COMPAT_H_
--- a/widget/src/gtk2/mozcontainer.c
+++ b/widget/src/gtk2/mozcontainer.c
@@ -40,20 +40,16 @@
 #include <gtk/gtk.h>
 #include <stdio.h>
 
 #ifdef ACCESSIBILITY
 #include <atk/atk.h>
 #include "maiRedundantObjectFactory.h"
 #endif 
 
-#if defined(MOZ_WIDGET_GTK2)
-#include "gtk2compat.h"
-#endif
-
 /* init methods */
 static void moz_container_class_init          (MozContainerClass *klass);
 static void moz_container_init                (MozContainer      *container);
 
 /* widget class methods */
 static void moz_container_map                 (GtkWidget         *widget);
 static void moz_container_unmap               (GtkWidget         *widget);
 static void moz_container_realize             (GtkWidget         *widget);
@@ -198,121 +194,109 @@ moz_container_class_init (MozContainerCl
     container_class->remove = moz_container_remove;
     container_class->forall = moz_container_forall;
     container_class->add = moz_container_add;
 }
 
 void
 moz_container_init (MozContainer *container)
 {
-    gtk_widget_set_can_focus(GTK_WIDGET(container), TRUE);
-    gtk_container_set_resize_mode(GTK_CONTAINER(container), GTK_RESIZE_IMMEDIATE);
-    gtk_widget_set_redraw_on_allocate(GTK_WIDGET(container), FALSE);
+    GTK_WIDGET_SET_FLAGS(container, GTK_CAN_FOCUS);
+    container->container.resize_mode = GTK_RESIZE_IMMEDIATE;
+    gtk_widget_set_redraw_on_allocate(GTK_WIDGET(container),
+                                      FALSE);
 
-#if defined(MOZ_WIDGET_GTK2)
     /* Mozilla uses the the gdbrgb colormap and visual throughout the
        backend so for widgets we just use that colormap instead of the
        default one. */
     gtk_widget_set_colormap(GTK_WIDGET(container), gdk_rgb_get_colormap());
-#endif
 }
 
 void
 moz_container_map (GtkWidget *widget)
 {
     MozContainer *container;
     GList *tmp_list;
     GtkWidget *tmp_child;
 
     g_return_if_fail (IS_MOZ_CONTAINER(widget));
     container = MOZ_CONTAINER (widget);
 
-    gtk_widget_set_mapped(widget, TRUE);
+    GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
 
     tmp_list = container->children;
     while (tmp_list) {
         tmp_child = ((MozContainerChild *)tmp_list->data)->widget;
     
-        if (gtk_widget_get_visible(tmp_child)) {
-            if (!gtk_widget_get_mapped(tmp_child))
+        if (GTK_WIDGET_VISIBLE(tmp_child)) {
+            if (!GTK_WIDGET_MAPPED(tmp_child))
                 gtk_widget_map(tmp_child);
         }
         tmp_list = tmp_list->next;
     }
 
-    gdk_window_show (gtk_widget_get_window(widget));
+    gdk_window_show (widget->window);
 }
 
 void
 moz_container_unmap (GtkWidget *widget)
 {
     g_return_if_fail (IS_MOZ_CONTAINER (widget));
+  
+    GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
 
-    gtk_widget_set_mapped(widget, FALSE);
-
-    gdk_window_hide (gtk_widget_get_window(widget));
+    gdk_window_hide (widget->window);
 }
 
 void
 moz_container_realize (GtkWidget *widget)
 {
     GdkWindowAttr attributes;
     gint attributes_mask = 0;
     MozContainer *container;
-    GtkAllocation allocation;
 
     g_return_if_fail(IS_MOZ_CONTAINER(widget));
 
     container = MOZ_CONTAINER(widget);
 
-    gtk_widget_set_realized(widget, TRUE);
+    GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
 
     /* create the shell window */
 
     attributes.event_mask = (gtk_widget_get_events (widget) |
                              GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK |
                              GDK_VISIBILITY_NOTIFY_MASK |
                              GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
                              GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
 #ifdef HAVE_GTK_MOTION_HINTS
                              GDK_POINTER_MOTION_HINT_MASK |
 #endif
                              GDK_POINTER_MOTION_MASK);
-    gtk_widget_get_allocation(widget, &allocation);
-    attributes.x = allocation.x;
-    attributes.y = allocation.y;
-    attributes.width = allocation.width;
-    attributes.height = allocation.height;
+    attributes.x = widget->allocation.x;
+    attributes.y = widget->allocation.y;
+    attributes.width = widget->allocation.width;
+    attributes.height = widget->allocation.height;
     attributes.wclass = GDK_INPUT_OUTPUT;
     attributes.visual = gtk_widget_get_visual (widget);
-#if defined(MOZ_WIDGET_GTK2)    
     attributes.colormap = gtk_widget_get_colormap (widget);
-#endif
     attributes.window_type = GDK_WINDOW_CHILD;
 
-    attributes_mask |= GDK_WA_VISUAL | GDK_WA_X | GDK_WA_Y;
-#if defined(MOZ_WIDGET_GTK2)
-    attributes_mask |= GDK_WA_COLORMAP;
-#endif
+    attributes_mask |= GDK_WA_VISUAL | GDK_WA_COLORMAP |
+        GDK_WA_X | GDK_WA_Y;
 
-    gtk_widget_set_window(widget, gdk_window_new (gtk_widget_get_parent_window (widget),
-                          &attributes, attributes_mask));
+    widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
+                                     &attributes, attributes_mask);
     /*  printf("widget->window is %p\n", (void *)widget->window); */
-    gdk_window_set_user_data (gtk_widget_get_window(widget), container);
+    gdk_window_set_user_data (widget->window, container);
 
-#if defined(MOZ_WIDGET_GTK2)    
     widget->style = gtk_style_attach (widget->style, widget->window);
-#endif
 
-/* TODO GTK3? */
-#if defined(MOZ_WIDGET_GTK2)    
     /* set the back pixmap to None so that you don't end up with the gtk
        default which is BlackPixel */
     gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
-#endif
 }
 
 void
 moz_container_size_allocate (GtkWidget     *widget,
                              GtkAllocation *allocation)
 {
     MozContainer   *container;
     GList          *tmp_list;
@@ -326,43 +310,42 @@ moz_container_size_allocate (GtkWidget  
         (void *)widget,
         allocation->x,
         allocation->y,
         allocation->width,
         allocation->height); */
 
     /* short circuit if you can */
     container = MOZ_CONTAINER (widget);
-    gtk_widget_get_allocation(widget, &tmp_allocation);
     if (!container->children &&
-        tmp_allocation.x == allocation->x &&
-        tmp_allocation.y == allocation->y &&
-        tmp_allocation.width == allocation->width &&
-        tmp_allocation.height == allocation->height) {
+        widget->allocation.x == allocation->x &&
+        widget->allocation.y == allocation->y &&
+        widget->allocation.width == allocation->width &&
+        widget->allocation.height == allocation->height) {
         return;
     }
 
-    gtk_widget_set_allocation(widget, allocation);
+    widget->allocation = *allocation;
 
     tmp_list = container->children;
 
     while (tmp_list) {
         MozContainerChild *child = tmp_list->data;
 
         moz_container_allocate_child (container, child);
 
         tmp_list = tmp_list->next;
     }
 
-    if (gtk_widget_get_realized(widget)) {
-        gdk_window_move_resize(gtk_widget_get_window(widget),
-                               allocation->x,
-                               allocation->y,
-                               allocation->width,
-                               allocation->height);
+    if (GTK_WIDGET_REALIZED (widget)) {
+        gdk_window_move_resize(widget->window,
+                               widget->allocation.x,
+                               widget->allocation.y,
+                               widget->allocation.width,
+                               widget->allocation.height);
     }
 }
 
 void
 moz_container_remove (GtkContainer *container, GtkWidget *child_widget)
 {
     MozContainerChild *child;
     MozContainer *moz_container;
@@ -395,17 +378,17 @@ moz_container_remove (GtkContainer *cont
     if (parent_window) {
         /* The child_widget will always still exist because g_signal_emit,
          * which invokes this function, holds a reference.
          *
          * If parent_window is the container's root window then it will not be
          * the parent_window if the child_widget is placed in another
          * container.
          */
-        if (parent_window != gtk_widget_get_window(GTK_WIDGET(container)))
+        if (parent_window != GTK_WIDGET(container)->window)
             gtk_widget_set_parent_window(child_widget, parent_window);
 
         g_object_unref(parent_window);
     }
 
     moz_container->children = g_list_remove(moz_container->children, child);
     g_free(child);
 }
@@ -433,21 +416,22 @@ moz_container_forall (GtkContainer *cont
 
 static void
 moz_container_allocate_child (MozContainer *container,
                               MozContainerChild *child)
 {
     GtkAllocation  allocation;
     GtkRequisition requisition;
 
-    gtk_widget_get_allocation (child->widget, &allocation);
     allocation.x = child->x;
     allocation.y = child->y;
     /* gtk_widget_get_child_requisition (child->widget, &requisition); */
     /* gtk_widget_size_request (child->widget, &requisition); */
+    allocation.width = child->widget->allocation.width;
+    allocation.height = child->widget->allocation.height;
 
     gtk_widget_size_allocate (child->widget, &allocation);
 }
 
 MozContainerChild *
 moz_container_get_child (MozContainer *container, GtkWidget *child_widget)
 {
     GList *tmp_list;