summaryrefslogtreecommitdiffstats
path: root/widget/gtk/MozContainer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'widget/gtk/MozContainer.cpp')
-rw-r--r--widget/gtk/MozContainer.cpp167
1 files changed, 1 insertions, 166 deletions
diff --git a/widget/gtk/MozContainer.cpp b/widget/gtk/MozContainer.cpp
index 95d32b57b4..775ae0488f 100644
--- a/widget/gtk/MozContainer.cpp
+++ b/widget/gtk/MozContainer.cpp
@@ -35,27 +35,6 @@ static void moz_container_size_allocate(GtkWidget* widget,
static void moz_container_realize(GtkWidget* widget);
static void moz_container_unrealize(GtkWidget* widget);
-/* container class methods */
-static void moz_container_remove(GtkContainer* container,
- GtkWidget* child_widget);
-static void moz_container_forall(GtkContainer* container,
- gboolean include_internals,
- GtkCallback callback, gpointer callback_data);
-static void moz_container_add(GtkContainer* container, GtkWidget* widget);
-
-typedef struct _MozContainerChild MozContainerChild;
-
-struct _MozContainerChild {
- GtkWidget* widget;
- gint x;
- gint y;
-};
-
-static void moz_container_allocate_child(MozContainer* container,
- MozContainerChild* child);
-static MozContainerChild* moz_container_get_child(MozContainer* container,
- GtkWidget* child);
-
/* public methods */
GType moz_container_get_type(void) {
@@ -92,26 +71,6 @@ GtkWidget* moz_container_new(void) {
return GTK_WIDGET(container);
}
-void moz_container_put(MozContainer* container, GtkWidget* child_widget, gint x,
- gint y) {
- MozContainerChild* child;
-
- child = g_new(MozContainerChild, 1);
-
- child->widget = child_widget;
- child->x = x;
- child->y = y;
-
- /* printf("moz_container_put %p %p %d %d\n", (void *)container,
- (void *)child_widget, x, y); */
-
- container->data.children = g_list_append(container->data.children, child);
-
- /* we assume that the caller of this function will have already set
- the parent GdkWindow because we can have many anonymous children. */
- gtk_widget_set_parent(child_widget, GTK_WIDGET(container));
-}
-
static void moz_container_destroy(GtkWidget* widget) {
auto* container = MOZ_CONTAINER(widget);
if (container->destroyed) {
@@ -126,7 +85,6 @@ static void moz_container_destroy(GtkWidget* widget) {
void moz_container_class_init(MozContainerClass* klass) {
/*GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); */
- GtkContainerClass* container_class = GTK_CONTAINER_CLASS(klass);
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(klass);
widget_class->realize = moz_container_realize;
@@ -147,10 +105,6 @@ void moz_container_class_init(MozContainerClass* klass) {
#ifdef MOZ_WAYLAND
}
#endif
-
- container_class->remove = moz_container_remove;
- container_class->forall = moz_container_forall;
- container_class->add = moz_container_add;
}
void moz_container_init(MozContainer* container) {
@@ -164,8 +118,6 @@ void moz_container_init(MozContainer* container) {
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);
@@ -175,16 +127,6 @@ void moz_container_map(GtkWidget* widget) {
gtk_widget_set_mapped(widget, TRUE);
- tmp_list = container->data.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)) gtk_widget_map(tmp_child);
- }
- tmp_list = tmp_list->next;
- }
-
if (gtk_widget_get_has_window(widget)) {
gdk_window_show(gtk_widget_get_window(widget));
}
@@ -257,8 +199,6 @@ void moz_container_unrealize(GtkWidget* widget) {
}
void moz_container_size_allocate(GtkWidget* widget, GtkAllocation* allocation) {
- MozContainer* container;
- GList* tmp_list;
GtkAllocation tmp_allocation;
g_return_if_fail(IS_MOZ_CONTAINER(widget));
@@ -269,10 +209,8 @@ void moz_container_size_allocate(GtkWidget* widget, GtkAllocation* allocation) {
allocation->height));
/* short circuit if you can */
- container = MOZ_CONTAINER(widget);
gtk_widget_get_allocation(widget, &tmp_allocation);
- if (!container->data.children && tmp_allocation.x == allocation->x &&
- tmp_allocation.y == allocation->y &&
+ if (tmp_allocation.x == allocation->x && tmp_allocation.y == allocation->y &&
tmp_allocation.width == allocation->width &&
tmp_allocation.height == allocation->height) {
return;
@@ -280,16 +218,6 @@ void moz_container_size_allocate(GtkWidget* widget, GtkAllocation* allocation) {
gtk_widget_set_allocation(widget, allocation);
- tmp_list = container->data.children;
-
- while (tmp_list) {
- MozContainerChild* child = static_cast<MozContainerChild*>(tmp_list->data);
-
- moz_container_allocate_child(container, child);
-
- tmp_list = tmp_list->next;
- }
-
if (gtk_widget_get_has_window(widget) && gtk_widget_get_realized(widget)) {
gdk_window_move_resize(gtk_widget_get_window(widget), allocation->x,
allocation->y, allocation->width,
@@ -297,99 +225,6 @@ void moz_container_size_allocate(GtkWidget* widget, GtkAllocation* allocation) {
}
}
-void moz_container_remove(GtkContainer* container, GtkWidget* child_widget) {
- MozContainerChild* child;
- MozContainer* moz_container;
- GdkWindow* parent_window;
-
- g_return_if_fail(IS_MOZ_CONTAINER(container));
- g_return_if_fail(GTK_IS_WIDGET(child_widget));
-
- moz_container = MOZ_CONTAINER(container);
-
- child = moz_container_get_child(moz_container, child_widget);
- g_return_if_fail(child);
-
- /* gtk_widget_unparent will remove the parent window (as well as the
- * parent widget), but, in Mozilla's window hierarchy, the parent window
- * may need to be kept because it may be part of a GdkWindow sub-hierarchy
- * that is being moved to another MozContainer.
- *
- * (In a conventional GtkWidget hierarchy, GdkWindows being reparented
- * would have their own GtkWidget and that widget would be the one being
- * reparented. In Mozilla's hierarchy, the parent_window needs to be
- * retained so that the GdkWindow sub-hierarchy is maintained.)
- */
- parent_window = gtk_widget_get_parent_window(child_widget);
- if (parent_window) g_object_ref(parent_window);
-
- gtk_widget_unparent(child_widget);
-
- 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))) {
- gtk_widget_set_parent_window(child_widget, parent_window);
- }
-
- g_object_unref(parent_window);
- }
-
- moz_container->data.children =
- g_list_remove(moz_container->data.children, child);
- g_free(child);
-}
-
-void moz_container_forall(GtkContainer* container, gboolean include_internals,
- GtkCallback callback, gpointer callback_data) {
- g_return_if_fail(IS_MOZ_CONTAINER(container));
- g_return_if_fail(callback);
-
- MozContainer* moz_container = MOZ_CONTAINER(container);
-
- GList* tmp_list = moz_container->data.children;
- while (tmp_list) {
- MozContainerChild* child;
- child = static_cast<MozContainerChild*>(tmp_list->data);
- tmp_list = tmp_list->next;
- (*callback)(child->widget, callback_data);
- }
-}
-
-static void moz_container_allocate_child(MozContainer* container,
- MozContainerChild* child) {
- GtkAllocation allocation;
-
- gtk_widget_get_allocation(child->widget, &allocation);
- allocation.x = child->x;
- allocation.y = child->y;
-
- gtk_widget_size_allocate(child->widget, &allocation);
-}
-
-MozContainerChild* moz_container_get_child(MozContainer* container,
- GtkWidget* child_widget) {
- GList* tmp_list = container->data.children;
- while (tmp_list) {
- MozContainerChild* child;
-
- child = static_cast<MozContainerChild*>(tmp_list->data);
- tmp_list = tmp_list->next;
-
- if (child->widget == child_widget) return child;
- }
- return nullptr;
-}
-
-static void moz_container_add(GtkContainer* container, GtkWidget* widget) {
- moz_container_put(MOZ_CONTAINER(container), widget, 0, 0);
-}
-
void moz_container_force_default_visual(MozContainer* container) {
container->data.force_default_visual = true;
}