summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/gtk/gtk2drawing.c
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-07-08 12:51:48 +0100
committerSteve Block <steveblock@google.com>2010-07-09 15:33:40 +0100
commitca9cb53ed1119a3fd98fafa0972ffeb56dee1c24 (patch)
treebb45155550ec013adc0ad10f4d7d354c6469b022 /WebCore/platform/gtk/gtk2drawing.c
parentd4b24d9a829ed7de70381c8b99fb75a07ab40466 (diff)
downloadexternal_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.zip
external_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.tar.gz
external_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.tar.bz2
Merge WebKit at r62496: Initial merge by git
Change-Id: Ie3da0770eca22a70a632e3571f31cfabc80facb2
Diffstat (limited to 'WebCore/platform/gtk/gtk2drawing.c')
-rw-r--r--WebCore/platform/gtk/gtk2drawing.c273
1 files changed, 170 insertions, 103 deletions
diff --git a/WebCore/platform/gtk/gtk2drawing.c b/WebCore/platform/gtk/gtk2drawing.c
index 6a8af57..80e2c2a 100644
--- a/WebCore/platform/gtk/gtk2drawing.c
+++ b/WebCore/platform/gtk/gtk2drawing.c
@@ -48,6 +48,7 @@
#include "gtkdrawing.h"
#include "Assertions.h"
+#include "GtkVersioning.h"
#include <math.h>
#include <string.h>
@@ -150,7 +151,7 @@ ensure_toggle_button_widget()
gParts->toggleButtonWidget = gtk_toggle_button_new();
setup_widget_prototype(gParts->toggleButtonWidget);
/* toggle button must be set active to get the right style on hover. */
- GTK_TOGGLE_BUTTON(gParts->toggleButtonWidget)->active = TRUE;
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gParts->toggleButtonWidget), TRUE);
}
return MOZ_GTK_SUCCESS;
}
@@ -297,7 +298,7 @@ ensure_combo_box_widgets()
if (gParts->comboBoxButtonWidget) {
/* Get the widgets inside the Button */
- buttonChild = GTK_BIN(gParts->comboBoxButtonWidget)->child;
+ buttonChild = gtk_bin_get_child(GTK_BIN(gParts->comboBoxButtonWidget));
if (GTK_IS_HBOX(buttonChild)) {
/* appears-as-list = FALSE, cell-view = TRUE; the button
* contains an hbox. This hbox is there because the ComboBox
@@ -407,7 +408,7 @@ ensure_combo_box_entry_widgets()
if (gParts->comboBoxEntryButtonWidget) {
/* Get the Arrow inside the Button */
- buttonChild = GTK_BIN(gParts->comboBoxEntryButtonWidget)->child;
+ buttonChild = gtk_bin_get_child(GTK_BIN(gParts->comboBoxEntryButtonWidget));
if (GTK_IS_HBOX(buttonChild)) {
/* appears-as-list = FALSE, cell-view = TRUE; the button
* contains an hbox. This hbox is there because ComboBoxEntry
@@ -682,9 +683,14 @@ ensure_tree_header_cell_widget()
gtk_tree_view_column_set_title(lastTreeViewColumn, "M");
gtk_tree_view_append_column(GTK_TREE_VIEW(gParts->treeViewWidget), lastTreeViewColumn);
+#ifdef GTK_API_VERSION_2
/* Use the middle column's header for our button */
gParts->treeHeaderCellWidget = gParts->middleTreeViewColumn->button;
gParts->treeHeaderSortArrowWidget = gParts->middleTreeViewColumn->arrow;
+#else
+ gParts->treeHeaderCellWidget = gtk_button_new();
+ gParts->treeHeaderSortArrowWidget = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE);
+#endif
g_object_set_data(G_OBJECT(gParts->treeHeaderCellWidget),
"transparent-bg-hint", GINT_TO_POINTER(TRUE));
g_object_set_data(G_OBJECT(gParts->treeHeaderSortArrowWidget),
@@ -758,7 +764,7 @@ moz_gtk_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
GtkTextDirection direction)
{
GtkShadowType shadow_type;
- GtkStyle* style = widget->style;
+ GtkStyle* style = gtk_widget_get_style(widget);
GtkStateType button_state = ConvertGtkState(state);
gint x = rect->x, y=rect->y, width=rect->width, height=rect->height;
@@ -776,15 +782,19 @@ moz_gtk_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
gtk_widget_set_state(widget, button_state);
gtk_widget_set_direction(widget, direction);
+#ifdef GTK_API_VERSION_2
if (state->isDefault)
GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_DEFAULT);
+#endif
- GTK_BUTTON(widget)->relief = relief;
+ gtk_button_set_relief(GTK_BUTTON(widget), relief);
/* Some theme engines love to cause us pain in that gtk_paint_focus is a
no-op on buttons and button-like widgets. They only listen to this flag. */
+#ifdef GTK_API_VERSION_2
if (state->focused && !state->disabled)
GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
+#endif
if (!interior_focus && state->focused) {
x += focus_width + focus_pad;
@@ -814,10 +824,11 @@ moz_gtk_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
if (state->focused) {
if (interior_focus) {
- x += widget->style->xthickness + focus_pad;
- y += widget->style->ythickness + focus_pad;
- width -= 2 * (widget->style->xthickness + focus_pad);
- height -= 2 * (widget->style->ythickness + focus_pad);
+ GtkStyle* style = gtk_widget_get_style(widget);
+ x += style->xthickness + focus_pad;
+ y += style->ythickness + focus_pad;
+ width -= 2 * (style->xthickness + focus_pad);
+ height -= 2 * (style->ythickness + focus_pad);
} else {
x -= focus_width + focus_pad;
y -= focus_width + focus_pad;
@@ -830,8 +841,10 @@ moz_gtk_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
widget, "button", x, y, width, height);
}
+#ifdef GTK_API_VERSION_2
GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_DEFAULT);
GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
+#endif
return MOZ_GTK_SUCCESS;
}
@@ -970,12 +983,12 @@ moz_gtk_toggle_paint(GdkDrawable* drawable, GdkRectangle* rect,
focus_width = width + 2 * indicator_spacing;
focus_height = height + 2 * indicator_spacing;
- style = w->style;
+ style = gtk_widget_get_style(w);
TSOffsetStyleGCs(style, x, y);
gtk_widget_set_sensitive(w, !state->disabled);
gtk_widget_set_direction(w, direction);
- GTK_TOGGLE_BUTTON(w)->active = selected;
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), selected);
if (isradio) {
gtk_paint_option(style, drawable, state_type, shadow_type, cliprect,
@@ -1022,7 +1035,7 @@ calculate_button_inner_rect(GtkWidget* button, GdkRectangle* rect,
gint focus_width, focus_pad;
GtkStyle* style;
- style = button->style;
+ style = gtk_widget_get_style(button);
/* This mirrors gtkbutton's child positioning */
moz_gtk_button_get_inner_border(button, &inner_border);
@@ -1055,20 +1068,25 @@ calculate_arrow_rect(GtkWidget* arrow, GdkRectangle* rect,
gfloat xalign, xpad;
gint extent;
GtkMisc* misc = GTK_MISC(arrow);
+ gfloat misc_xalign, misc_yalign;
+ gint misc_xpad, misc_ypad;
if (have_arrow_scaling)
gtk_widget_style_get(arrow, "arrow_scaling", &arrow_scaling, NULL);
- extent = MIN((rect->width - misc->xpad * 2),
- (rect->height - misc->ypad * 2)) * arrow_scaling;
+ gtk_misc_get_padding(misc, &misc_xpad, &misc_ypad);
+ gtk_misc_get_alignment(misc, &misc_xalign, &misc_yalign);
- xalign = direction == GTK_TEXT_DIR_LTR ? misc->xalign : 1.0 - misc->xalign;
- xpad = misc->xpad + (rect->width - extent) * xalign;
+ extent = MIN((rect->width - misc_xpad * 2),
+ (rect->height - misc_ypad * 2)) * arrow_scaling;
+
+ xalign = direction == GTK_TEXT_DIR_LTR ? misc_xalign : 1.0 - misc_xalign;
+ xpad = misc_xpad + (rect->width - extent) * xalign;
arrow_rect->x = direction == GTK_TEXT_DIR_LTR ?
floor(rect->x + xpad) : ceil(rect->x + xpad);
- arrow_rect->y = floor(rect->y + misc->ypad +
- ((rect->height - extent) * misc->yalign));
+ arrow_rect->y = floor(rect->y + misc_ypad +
+ ((rect->height - extent) * misc_yalign));
arrow_rect->width = arrow_rect->height = extent;
@@ -1087,6 +1105,7 @@ moz_gtk_scrollbar_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
GdkRectangle arrow_rect;
GtkStyle* style;
GtkWidget *scrollbar;
+ GtkAllocation allocation;
GtkArrowType arrow_type;
gint arrow_displacement_x, arrow_displacement_y;
const char* detail = (flags & MOZ_GTK_STEPPER_VERTICAL) ?
@@ -1105,41 +1124,46 @@ moz_gtk_scrollbar_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
to determine where it should paint rounded corners on the buttons.
We need to trick them into drawing the buttons the way we want them. */
- scrollbar->allocation.x = rect->x;
- scrollbar->allocation.y = rect->y;
- scrollbar->allocation.width = rect->width;
- scrollbar->allocation.height = rect->height;
+#if GTK_CHECK_VERSION(2, 18, 0)
+ gtk_widget_get_allocation(scrollbar, &allocation);
+#else
+ allocation = scrollbar->allocation;
+#endif
+ allocation.x = rect->x;
+ allocation.y = rect->y;
+ allocation.width = rect->width;
+ allocation.height = rect->height;
if (flags & MOZ_GTK_STEPPER_VERTICAL) {
- scrollbar->allocation.height *= 5;
+ allocation.height *= 5;
if (flags & MOZ_GTK_STEPPER_DOWN) {
arrow_type = GTK_ARROW_DOWN;
if (flags & MOZ_GTK_STEPPER_BOTTOM)
- scrollbar->allocation.y -= 4 * rect->height;
+ allocation.y -= 4 * rect->height;
else
- scrollbar->allocation.y -= rect->height;
+ allocation.y -= rect->height;
} else {
arrow_type = GTK_ARROW_UP;
if (flags & MOZ_GTK_STEPPER_BOTTOM)
- scrollbar->allocation.y -= 3 * rect->height;
+ allocation.y -= 3 * rect->height;
}
} else {
- scrollbar->allocation.width *= 5;
+ allocation.width *= 5;
if (flags & MOZ_GTK_STEPPER_DOWN) {
arrow_type = GTK_ARROW_RIGHT;
if (flags & MOZ_GTK_STEPPER_BOTTOM)
- scrollbar->allocation.x -= 4 * rect->width;
+ allocation.x -= 4 * rect->width;
else
- scrollbar->allocation.x -= rect->width;
+ allocation.x -= rect->width;
} else {
arrow_type = GTK_ARROW_LEFT;
if (flags & MOZ_GTK_STEPPER_BOTTOM)
- scrollbar->allocation.x -= 3 * rect->width;
+ allocation.x -= 3 * rect->width;
}
}
- style = scrollbar->style;
+ style = gtk_widget_get_style(scrollbar);
TSOffsetStyleGCs(style, rect->x, rect->y);
@@ -1187,7 +1211,7 @@ moz_gtk_scrollbar_trough_paint(GtkThemeWidgetType widget,
gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
- style = GTK_WIDGET(scrollbar)->style;
+ style = gtk_widget_get_style(GTK_WIDGET(scrollbar));
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_ACTIVE,
@@ -1246,20 +1270,30 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWidgetType widget,
if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) {
cliprect->x -= 1;
cliprect->width += 2;
- adj->page_size = rect->width;
+ gtk_adjustment_set_page_size(adj, rect->width);
}
else {
cliprect->y -= 1;
cliprect->height += 2;
- adj->page_size = rect->height;
- }
-
+ gtk_adjustment_set_page_size(adj, rect->height);
+ }
+
+#if GTK_CHECK_VERSION(2, 14, 0)
+ gtk_adjustment_configure(adj,
+ state->curpos,
+ 0,
+ state->maxpos,
+ gtk_adjustment_get_step_increment(adj),
+ gtk_adjustment_get_page_increment(adj),
+ gtk_adjustment_get_page_size(adj));
+#else
adj->lower = 0;
adj->value = state->curpos;
adj->upper = state->maxpos;
gtk_adjustment_changed(adj);
+#endif
- style = GTK_WIDGET(scrollbar)->style;
+ style = gtk_widget_get_style(GTK_WIDGET(scrollbar));
gtk_widget_style_get(GTK_WIDGET(scrollbar), "activate-slider",
&activate_slider, NULL);
@@ -1288,7 +1322,7 @@ moz_gtk_spin_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_spin_widget();
gtk_widget_set_direction(gParts->spinWidget, direction);
- style = gParts->spinWidget->style;
+ style = gtk_widget_get_style(gParts->spinWidget);
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN, NULL,
@@ -1309,7 +1343,7 @@ moz_gtk_spin_updown_paint(GdkDrawable* drawable, GdkRectangle* rect,
GtkStyle* style;
ensure_spin_widget();
- style = gParts->spinWidget->style;
+ style = gtk_widget_get_style(gParts->spinWidget);
gtk_widget_set_direction(gParts->spinWidget, direction);
TSOffsetStyleGCs(style, rect->x, rect->y);
@@ -1347,7 +1381,7 @@ moz_gtk_scale_paint(GdkDrawable* drawable, GdkRectangle* rect,
widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gParts->hScaleWidget : gParts->vScaleWidget);
gtk_widget_set_direction(widget, direction);
- style = widget->style;
+ style = gtk_widget_get_style(widget);
if (flags == GTK_ORIENTATION_HORIZONTAL) {
x = XTHICKNESS(style);
@@ -1388,7 +1422,7 @@ moz_gtk_scale_thumb_paint(GdkDrawable* drawable, GdkRectangle* rect,
widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gParts->hScaleWidget : gParts->vScaleWidget);
gtk_widget_set_direction(widget, direction);
- style = widget->style;
+ style = gtk_widget_get_style(widget);
/* determine the thumb size, and position the thumb in the center in the opposite axis */
if (flags == GTK_ORIENTATION_HORIZONTAL) {
@@ -1422,8 +1456,8 @@ moz_gtk_gripper_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_handlebox_widget();
gtk_widget_set_direction(gParts->handleBoxWidget, direction);
- style = gParts->handleBoxWidget->style;
- shadow_type = GTK_HANDLE_BOX(gParts->handleBoxWidget)->shadow_type;
+ style = gtk_widget_get_style(gParts->handleBoxWidget);
+ shadow_type = gtk_handle_box_get_shadow_type(GTK_HANDLE_BOX(gParts->handleBoxWidget));
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_paint_box(style, drawable, state_type, shadow_type, cliprect,
@@ -1440,7 +1474,7 @@ moz_gtk_hpaned_paint(GdkDrawable* drawable, GdkRectangle* rect,
GtkStateType hpaned_state = ConvertGtkState(state);
ensure_hpaned_widget();
- gtk_paint_handle(gParts->hpanedWidget->style, drawable, hpaned_state,
+ gtk_paint_handle(gtk_widget_get_style(gParts->hpanedWidget), drawable, hpaned_state,
GTK_SHADOW_NONE, cliprect, gParts->hpanedWidget, "paned",
rect->x, rect->y, rect->width, rect->height,
GTK_ORIENTATION_VERTICAL);
@@ -1455,7 +1489,7 @@ moz_gtk_vpaned_paint(GdkDrawable* drawable, GdkRectangle* rect,
GtkStateType vpaned_state = ConvertGtkState(state);
ensure_vpaned_widget();
- gtk_paint_handle(gParts->vpanedWidget->style, drawable, vpaned_state,
+ gtk_paint_handle(gtk_widget_get_style(gParts->vpanedWidget), drawable, vpaned_state,
GTK_SHADOW_NONE, cliprect, gParts->vpanedWidget, "paned",
rect->x, rect->y, rect->width, rect->height,
GTK_ORIENTATION_HORIZONTAL);
@@ -1495,7 +1529,7 @@ moz_gtk_entry_paint(GdkDrawable* drawable, GdkRectangle* rect,
gtk_widget_set_direction(widget, direction);
- style = widget->style;
+ style = gtk_widget_get_style(widget);
gtk_widget_style_get(widget,
"interior-focus", &interior_focus,
@@ -1551,7 +1585,9 @@ moz_gtk_entry_paint(GdkDrawable* drawable, GdkRectangle* rect,
if (state->focused && !state->disabled) {
/* This will get us the lit borders that focused textboxes enjoy on
* some themes. */
+#ifdef GTK_API_VERSION_2
GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
+#endif
if (!interior_focus) {
/* Indent the border a little bit if we have exterior focus
@@ -1575,7 +1611,9 @@ moz_gtk_entry_paint(GdkDrawable* drawable, GdkRectangle* rect,
/* Now unset the focus flag. We don't want other entries to look
* like they're focused too! */
+#ifdef GTK_API_VERSION_2
GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
+#endif
}
return MOZ_GTK_SUCCESS;
@@ -1588,7 +1626,7 @@ moz_gtk_treeview_paint(GdkDrawable* drawable, GdkRectangle* rect,
{
gint xthickness, ythickness;
- GtkStyle *style;
+ GtkStyle *style, *treeview_style;
GtkStateType state_type;
ensure_tree_view_widget();
@@ -1605,16 +1643,17 @@ moz_gtk_treeview_paint(GdkDrawable* drawable, GdkRectangle* rect,
* which contains the cells to the treeview base color.
* If we don't set it here the background color will not be correct.*/
gtk_widget_modify_bg(gParts->treeViewWidget, state_type,
- &gParts->treeViewWidget->style->base[state_type]);
+ &gtk_widget_get_style(gParts->treeViewWidget)->base[state_type]);
- style = gParts->scrolledWindowWidget->style;
+ style = gtk_widget_get_style(gParts->scrolledWindowWidget);
xthickness = XTHICKNESS(style);
ythickness = YTHICKNESS(style);
- TSOffsetStyleGCs(gParts->treeViewWidget->style, rect->x, rect->y);
+ treeview_style = gtk_widget_get_style(gParts->treeViewWidget);
+ TSOffsetStyleGCs(treeview_style, rect->x, rect->y);
TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_flat_box(gParts->treeViewWidget->style, drawable, state_type,
+ gtk_paint_flat_box(treeview_style, drawable, state_type,
GTK_SHADOW_NONE, cliprect, gParts->treeViewWidget, "treeview",
rect->x + xthickness, rect->y + ythickness,
rect->width - 2 * xthickness,
@@ -1661,7 +1700,7 @@ moz_gtk_tree_header_sort_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2;
arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2;
- style = gParts->treeHeaderSortArrowWidget->style;
+ style = gtk_widget_get_style(gParts->treeHeaderSortArrowWidget);
TSOffsetStyleGCs(style, arrow_rect.x, arrow_rect.y);
gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
@@ -1684,7 +1723,7 @@ moz_gtk_treeview_expander_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_tree_view_widget();
gtk_widget_set_direction(gParts->treeViewWidget, direction);
- style = gParts->treeViewWidget->style;
+ style = gtk_widget_get_style(gParts->treeViewWidget);
/* Because the frame we get is of the entire treeview, we can't get the precise
* event state of one expander, thus rendering hover and active feedback useless. */
@@ -1709,7 +1748,7 @@ moz_gtk_expander_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_expander_widget();
gtk_widget_set_direction(gParts->expanderWidget, direction);
- style = gParts->expanderWidget->style;
+ style = gtk_widget_get_style(gParts->expanderWidget);
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_paint_expander(style, drawable, state_type, cliprect, gParts->expanderWidget, "expander",
@@ -1750,7 +1789,7 @@ moz_gtk_combo_box_paint(GdkDrawable* drawable, GdkRectangle* rect,
calculate_arrow_rect(gParts->comboBoxArrowWidget,
&arrow_rect, &real_arrow_rect, direction);
- style = gParts->comboBoxArrowWidget->style;
+ style = gtk_widget_get_style(gParts->comboBoxArrowWidget);
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_widget_size_allocate(gParts->comboBoxWidget, rect);
@@ -1765,7 +1804,7 @@ moz_gtk_combo_box_paint(GdkDrawable* drawable, GdkRectangle* rect,
if (!gParts->comboBoxSeparatorWidget)
return MOZ_GTK_SUCCESS;
- style = gParts->comboBoxSeparatorWidget->style;
+ style = gtk_widget_get_style(gParts->comboBoxSeparatorWidget);
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_widget_style_get(gParts->comboBoxSeparatorWidget,
@@ -1809,7 +1848,7 @@ moz_gtk_downarrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
GdkRectangle arrow_rect;
ensure_button_arrow_widget();
- style = gParts->buttonArrowWidget->style;
+ style = gtk_widget_get_style(gParts->buttonArrowWidget);
calculate_arrow_rect(gParts->buttonArrowWidget, rect, &arrow_rect,
GTK_TEXT_DIR_LTR);
@@ -1840,14 +1879,18 @@ moz_gtk_combo_box_entry_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
if (input_focus) {
/* Some themes draw a complementary focus ring for the dropdown button
* when the dropdown entry has focus */
+#ifdef GTK_API_VERSION_2
GTK_WIDGET_SET_FLAGS(gParts->comboBoxEntryTextareaWidget, GTK_HAS_FOCUS);
+#endif
}
moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,
gParts->comboBoxEntryButtonWidget, direction);
+#ifdef GTK_API_VERSION_2
if (input_focus)
GTK_WIDGET_UNSET_FLAGS(gParts->comboBoxEntryTextareaWidget, GTK_HAS_FOCUS);
+#endif
calculate_button_inner_rect(gParts->comboBoxEntryButtonWidget,
rect, &arrow_rect, direction, FALSE);
@@ -1863,7 +1906,7 @@ moz_gtk_combo_box_entry_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
calculate_arrow_rect(gParts->comboBoxEntryArrowWidget,
&arrow_rect, &real_arrow_rect, direction);
- style = gParts->comboBoxEntryArrowWidget->style;
+ style = gtk_widget_get_style(gParts->comboBoxEntryArrowWidget);
TSOffsetStyleGCs(style, real_arrow_rect.x, real_arrow_rect.y);
gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
@@ -1894,7 +1937,7 @@ moz_gtk_container_paint(GdkDrawable* drawable, GdkRectangle* rect,
}
gtk_widget_set_direction(widget, direction);
- style = widget->style;
+ style = gtk_widget_get_style(widget);
moz_gtk_widget_get_focus(widget, &interior_focus, &focus_width,
&focus_pad);
@@ -1951,7 +1994,7 @@ moz_gtk_toggle_label_paint(GdkDrawable* drawable, GdkRectangle* rect,
state_type = ConvertGtkState(state);
- style = widget->style;
+ style = gtk_widget_get_style(widget);
TSOffsetStyleGCs(style, rect->x, rect->y);
/* Always "checkbutton" to match gtkcheckbutton.c */
@@ -1972,7 +2015,7 @@ moz_gtk_toolbar_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_toolbar_widget();
gtk_widget_set_direction(gParts->toolbarWidget, direction);
- style = gParts->toolbarWidget->style;
+ style = gtk_widget_get_style(gParts->toolbarWidget);
TSOffsetStyleGCs(style, rect->x, rect->y);
@@ -2007,7 +2050,7 @@ moz_gtk_toolbar_separator_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_toolbar_separator_widget();
gtk_widget_set_direction(gParts->toolbarSeparatorWidget, direction);
- style = gParts->toolbarSeparatorWidget->style;
+ style = gtk_widget_get_style(gParts->toolbarSeparatorWidget);
gtk_widget_style_get(gParts->toolbarWidget,
"wide-separators", &wide_separators,
@@ -2058,7 +2101,7 @@ moz_gtk_tooltip_paint(GdkDrawable* drawable, GdkRectangle* rect,
"gtk-tooltips", "GtkWindow",
GTK_TYPE_WINDOW);
- style = gtk_style_attach(style, gParts->tooltipWidget->window);
+ style = gtk_style_attach(style, gtk_widget_get_window(gParts->tooltipWidget));
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_paint_flat_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
cliprect, gParts->tooltipWidget, "tooltip",
@@ -2078,7 +2121,7 @@ moz_gtk_resizer_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_window_widget();
gtk_widget_set_direction(gParts->protoWindow, direction);
- style = gParts->protoWindow->style;
+ style = gtk_widget_get_style(gParts->protoWindow);
TSOffsetStyleGCs(style, rect->x, rect->y);
@@ -2100,7 +2143,7 @@ moz_gtk_frame_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_frame_widget();
gtk_widget_set_direction(gParts->frameWidget, direction);
- style = gParts->frameWidget->style;
+ style = gtk_widget_get_style(gParts->frameWidget);
gtk_widget_style_get(gParts->statusbarWidget, "shadow-type", &shadow_type, NULL);
@@ -2121,7 +2164,7 @@ moz_gtk_progressbar_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_progress_widget();
gtk_widget_set_direction(gParts->progresWidget, direction);
- style = gParts->progresWidget->style;
+ style = gtk_widget_get_style(gParts->progresWidget);
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
@@ -2140,7 +2183,7 @@ moz_gtk_progress_chunk_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_progress_widget();
gtk_widget_set_direction(gParts->progresWidget, direction);
- style = gParts->progresWidget->style;
+ style = gtk_widget_get_style(gParts->progresWidget);
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_paint_box(style, drawable, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
@@ -2153,11 +2196,14 @@ moz_gtk_progress_chunk_paint(GdkDrawable* drawable, GdkRectangle* rect,
gint
moz_gtk_get_tab_thickness(void)
{
+ GtkStyle* style;
+
ensure_tab_widget();
- if (YTHICKNESS(gParts->tabWidget->style) < 2)
+ style = gtk_widget_get_style(gParts->tabWidget);
+ if (YTHICKNESS(style) < 2)
return 2; /* some themes don't set ythickness correctly */
- return YTHICKNESS(gParts->tabWidget->style);
+ return YTHICKNESS(style);
}
static gint
@@ -2175,7 +2221,7 @@ moz_gtk_tab_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_tab_widget();
gtk_widget_set_direction(gParts->tabWidget, direction);
- style = gParts->tabWidget->style;
+ style = gtk_widget_get_style(gParts->tabWidget);
TSOffsetStyleGCs(style, rect->x, rect->y);
if ((flags & MOZ_GTK_TAB_SELECTED) == 0) {
@@ -2312,7 +2358,7 @@ moz_gtk_tabpanels_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_tab_widget();
gtk_widget_set_direction(gParts->tabWidget, direction);
- style = gParts->tabWidget->style;
+ style = gtk_widget_get_style(gParts->tabWidget);
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
@@ -2338,7 +2384,7 @@ moz_gtk_tab_scroll_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_tab_widget();
- style = gParts->tabWidget->style;
+ style = gtk_widget_get_style(gParts->tabWidget);
TSOffsetStyleGCs(style, rect->x, rect->y);
if (direction == GTK_TEXT_DIR_RTL) {
@@ -2364,7 +2410,7 @@ moz_gtk_menu_bar_paint(GdkDrawable* drawable, GdkRectangle* rect,
gtk_widget_style_get(gParts->menuBarWidget, "shadow-type", &shadow_type, NULL);
- style = gParts->menuBarWidget->style;
+ style = gtk_widget_get_style(gParts->menuBarWidget);
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
@@ -2385,7 +2431,7 @@ moz_gtk_menu_popup_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_menu_popup_widget();
gtk_widget_set_direction(gParts->menuPopupWidget, direction);
- style = gParts->menuPopupWidget->style;
+ style = gtk_widget_get_style(gParts->menuPopupWidget);
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
@@ -2411,7 +2457,7 @@ moz_gtk_menu_separator_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_menu_separator_widget();
gtk_widget_set_direction(gParts->menuSeparatorWidget, direction);
- style = gParts->menuSeparatorWidget->style;
+ style = gtk_widget_get_style(gParts->menuSeparatorWidget);
gtk_widget_style_get(gParts->menuSeparatorWidget,
"wide-separators", &wide_separators,
@@ -2467,7 +2513,7 @@ moz_gtk_menu_item_paint(GdkDrawable* drawable, GdkRectangle* rect,
}
gtk_widget_set_direction(item_widget, direction);
- style = item_widget->style;
+ style = gtk_widget_get_style(item_widget);
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_widget_style_get(item_widget, "selected-shadow-type",
@@ -2492,7 +2538,7 @@ moz_gtk_menu_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_menu_item_widget();
gtk_widget_set_direction(gParts->menuItemWidget, direction);
- style = gParts->menuItemWidget->style;
+ style = gtk_widget_get_style(gParts->menuItemWidget);
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_paint_arrow(style, drawable, state_type,
@@ -2526,11 +2572,14 @@ moz_gtk_check_menu_item_paint(GdkDrawable* drawable, GdkRectangle* rect,
"indicator-size", &indicator_size,
NULL);
+#ifdef GTK_API_VERSION_2
if (checked || GTK_CHECK_MENU_ITEM(gParts->checkMenuItemWidget)->always_show_toggle) {
- style = gParts->checkMenuItemWidget->style;
+#else
+ if (checked || FALSE) {
+#endif
+ style = gtk_widget_get_style(gParts->checkMenuItemWidget);
- offset = GTK_CONTAINER(gParts->checkMenuItemWidget)->border_width +
- gParts->checkMenuItemWidget->style->xthickness + 2;
+ offset = gtk_container_get_border_width(GTK_CONTAINER(gParts->checkMenuItemWidget)) + style->xthickness + 2;
/* while normally this "3" would be the horizontal-padding style value, passing it to Gecko
as the value of menuitem padding causes problems with dropdowns (bug 406129), so in the menu.css
@@ -2566,7 +2615,7 @@ moz_gtk_window_paint(GdkDrawable* drawable, GdkRectangle* rect,
ensure_window_widget();
gtk_widget_set_direction(gParts->protoWindow, direction);
- style = gParts->protoWindow->style;
+ style = gtk_widget_get_style(gParts->protoWindow);
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_style_apply_default_background(style, drawable, TRUE,
@@ -2582,6 +2631,7 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
gboolean inhtml)
{
GtkWidget* w;
+ GtkStyle *style;
switch (widget) {
case MOZ_GTK_BUTTON:
@@ -2589,9 +2639,10 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
GtkBorder inner_border;
gboolean interior_focus;
gint focus_width, focus_pad;
+ GtkStyle *style;
ensure_button_widget();
- *left = *top = *right = *bottom = GTK_CONTAINER(gParts->buttonWidget)->border_width;
+ *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gParts->buttonWidget));
/* Don't add this padding in HTML, otherwise the buttons will
become too big and stuff the layout. */
@@ -2604,10 +2655,11 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
*bottom += focus_width + focus_pad + inner_border.bottom;
}
- *left += gParts->buttonWidget->style->xthickness;
- *right += gParts->buttonWidget->style->xthickness;
- *top += gParts->buttonWidget->style->ythickness;
- *bottom += gParts->buttonWidget->style->ythickness;
+ style = gtk_widget_get_style(gParts->buttonWidget);
+ *left += style->xthickness;
+ *right += style->xthickness;
+ *top += style->ythickness;
+ *bottom += style->ythickness;
return MOZ_GTK_SUCCESS;
}
case MOZ_GTK_ENTRY:
@@ -2629,9 +2681,10 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
GtkBorder inner_border;
gboolean interior_focus;
gint focus_width, focus_pad;
+ GtkStyle* style;
ensure_tree_header_cell_widget();
- *left = *top = *right = *bottom = GTK_CONTAINER(gParts->treeHeaderCellWidget)->border_width;
+ *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gParts->treeHeaderCellWidget));
moz_gtk_widget_get_focus(gParts->treeHeaderCellWidget, &interior_focus, &focus_width, &focus_pad);
moz_gtk_button_get_inner_border(gParts->treeHeaderCellWidget, &inner_border);
@@ -2640,10 +2693,11 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
*top += focus_width + focus_pad + inner_border.top;
*bottom += focus_width + focus_pad + inner_border.bottom;
- *left += gParts->treeHeaderCellWidget->style->xthickness;
- *right += gParts->treeHeaderCellWidget->style->xthickness;
- *top += gParts->treeHeaderCellWidget->style->ythickness;
- *bottom += gParts->treeHeaderCellWidget->style->ythickness;
+ style = gtk_widget_get_style(gParts->treeHeaderCellWidget);
+ *left += style->xthickness;
+ *right += style->xthickness;
+ *top += style->ythickness;
+ *bottom += style->ythickness;
return MOZ_GTK_SUCCESS;
}
case MOZ_GTK_TREE_HEADER_SORTARROW:
@@ -2666,10 +2720,11 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
gboolean ignored_interior_focus, wide_separators;
gint focus_width, focus_pad, separator_width;
GtkRequisition arrow_req;
+ GtkStyle* style;
ensure_combo_box_widgets();
- *left = GTK_CONTAINER(gParts->comboBoxButtonWidget)->border_width;
+ *left = gtk_container_get_border_width(GTK_CONTAINER(gParts->comboBoxButtonWidget));
if (!inhtml) {
moz_gtk_widget_get_focus(gParts->comboBoxButtonWidget,
@@ -2678,8 +2733,9 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
*left += focus_width + focus_pad;
}
- *top = *left + gParts->comboBoxButtonWidget->style->ythickness;
- *left += gParts->comboBoxButtonWidget->style->xthickness;
+ style = gtk_widget_get_style(gParts->comboBoxButtonWidget);
+ *top = *left + style->ythickness;
+ *left += style->xthickness;
*right = *left; *bottom = *top;
@@ -2693,7 +2749,7 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
if (!wide_separators)
separator_width =
- XTHICKNESS(gParts->comboBoxSeparatorWidget->style);
+ XTHICKNESS(style);
}
gtk_widget_size_request(gParts->comboBoxArrowWidget, &arrow_req);
@@ -2778,7 +2834,7 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
w = gParts->radiobuttonWidget;
}
- *left = *top = *right = *bottom = GTK_CONTAINER(w)->border_width;
+ *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(w));
if (!interior_focus) {
*left += (focus_width + focus_pad);
@@ -2843,8 +2899,9 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
return MOZ_GTK_UNKNOWN_WIDGET;
}
- *right = *left = XTHICKNESS(w->style);
- *bottom = *top = YTHICKNESS(w->style);
+ style = gtk_widget_get_style(w);
+ *right = *left = XTHICKNESS(style);
+ *bottom = *top = YTHICKNESS(style);
return MOZ_GTK_SUCCESS;
}
@@ -2904,7 +2961,7 @@ moz_gtk_get_toolbar_separator_width(gint* size)
ensure_toolbar_widget();
- style = gParts->toolbarWidget->style;
+ style = gtk_widget_get_style(gParts->toolbarWidget);
gtk_widget_style_get(gParts->toolbarWidget,
"space-size", size,
@@ -2945,6 +3002,7 @@ moz_gtk_get_menu_separator_height(gint *size)
{
gboolean wide_separators;
gint separator_height;
+ GtkStyle *style;
ensure_menu_separator_widget();
@@ -2953,10 +3011,12 @@ moz_gtk_get_menu_separator_height(gint *size)
"separator-height", &separator_height,
NULL);
+ style = gtk_widget_get_style(gParts->menuSeparatorWidget);
+
if (wide_separators)
- *size = separator_height + gParts->menuSeparatorWidget->style->ythickness;
+ *size = separator_height + style->ythickness;
else
- *size = gParts->menuSeparatorWidget->style->ythickness * 2;
+ *size = style->ythickness * 2;
return MOZ_GTK_SUCCESS;
}
@@ -2989,8 +3049,7 @@ moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics *metrics)
"stepper_spacing", &metrics->stepper_spacing,
NULL);
- metrics->min_slider_size =
- GTK_RANGE(gParts->horizScrollbarWidget)->min_slider_size;
+ metrics->min_slider_size = gtk_range_get_min_slider_size(GTK_RANGE(gParts->horizScrollbarWidget));
return MOZ_GTK_SUCCESS;
}
@@ -3247,3 +3306,11 @@ void moz_gtk_destroy_theme_parts_widgets(GtkThemeParts* parts)
parts->protoWindow = NULL;
}
}
+
+GtkWidget* moz_gtk_get_progress_widget()
+{
+ if (!is_initialized)
+ return NULL;
+ ensure_progress_widget();
+ return gParts->progresWidget;
+}