From a7a53b8d23fee06e518488313d8082073e2d5d39 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Mon, 3 Nov 2014 14:56:26 +0100 Subject: Added Gtk3 support --- firefox-mozstub-build.patch | 12 +++ firefox.spec | 14 ++- mozilla-gtk3-tab-size.patch | 258 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 firefox-mozstub-build.patch create mode 100644 mozilla-gtk3-tab-size.patch diff --git a/firefox-mozstub-build.patch b/firefox-mozstub-build.patch new file mode 100644 index 0000000..3fe9310 --- /dev/null +++ b/firefox-mozstub-build.patch @@ -0,0 +1,12 @@ +diff -up firefox-33.0/mozilla-release/toolkit/library/libxul.mk.old firefox-33.0/mozilla-release/toolkit/library/libxul.mk +--- firefox-33.0/mozilla-release/toolkit/library/libxul.mk.old 2014-11-03 13:37:20.206772190 +0100 ++++ firefox-33.0/mozilla-release/toolkit/library/libxul.mk 2014-11-03 13:36:56.966691951 +0100 +@@ -168,7 +168,7 @@ endif + + ifdef MOZ_WIDGET_GTK + ifdef MOZ_ENABLE_GTK3 +-EXTRA_DSO_LDOPTS += $(filter-out -lgtk-3 -lgdk-3,$(TK_LIBS)) -lmozgtk_stub ++EXTRA_DSO_LDOPTS += $(filter-out -lgtk-3 -lgdk-3,$(TK_LIBS)) -L$(LIBXUL_DIST)/lib -lmozgtk_stub + else + EXTRA_DSO_LDOPTS += $(TK_LIBS) + endif diff --git a/firefox.spec b/firefox.spec index 7d7ab91..ebebe30 100644 --- a/firefox.spec +++ b/firefox.spec @@ -101,7 +101,7 @@ Summary: Mozilla Firefox Web browser Name: firefox Version: 33.0 -Release: 2%{?pre_tag}%{?dist} +Release: 3%{?pre_tag}%{?dist} URL: http://www.mozilla.org/projects/firefox/ License: MPLv1.1 or GPLv2+ or LGPLv2+ Group: Applications/Internet @@ -127,6 +127,7 @@ Patch18: xulrunner-24.0-jemalloc-ppc.patch # workaround linking issue on s390 (JSContext::updateMallocCounter(size_t) not found) Patch19: xulrunner-24.0-s390-inlines.patch Patch20: firefox-build-prbool.patch +Patch21: firefox-mozstub-build.patch # Fedora specific patches # Unable to install addons from https pages @@ -141,6 +142,9 @@ Patch301: mozilla-858919-2.patch Patch302: mozilla-858919-3.patch Patch310: mozilla-1042889.patch +# Gtk3 upstream patches +Patch402: mozilla-gtk3-tab-size.patch + %if %{official_branding} # Required by Mozilla Corporation @@ -269,6 +273,7 @@ cd %{tarballdir} %patch18 -p2 -b .jemalloc-ppc %patch19 -p2 -b .s390-inlines %patch20 -p1 -b .prbool +%patch21 -p2 -b .mozstub # For branding specific patches. @@ -287,6 +292,10 @@ cd %{tarballdir} %patch302 -p1 -b .858919 %patch310 -p1 -b .1042889 +%if %{toolkit_gtk3} +%patch402 -p1 -b .gtk3-tab-size +%endif + %if %{official_branding} # Required by Mozilla Corporation @@ -742,6 +751,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : #--------------------------------------------------------------------- %changelog +* Mon Nov 3 2014 Martin Stransky - 33.0-3 +- Added Gtk3 support + * Wed Oct 15 2014 Martin Stransky - 33.0-2 - Added patches from mozbz#858919 diff --git a/mozilla-gtk3-tab-size.patch b/mozilla-gtk3-tab-size.patch new file mode 100644 index 0000000..9a92384 --- /dev/null +++ b/mozilla-gtk3-tab-size.patch @@ -0,0 +1,258 @@ +diff -up src/widget/gtk/gtk3drawing.c.gtk3-tab-size src/widget/gtk/gtk3drawing.c +--- src/widget/gtk/gtk3drawing.c.gtk3-tab-size 2014-05-22 11:59:23.000000000 +0200 ++++ src/widget/gtk/gtk3drawing.c 2014-06-03 14:41:06.740369999 +0200 +@@ -2063,22 +2063,35 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan + * tab appear physically attached to the tabpanel; see details below. */ + + GtkStyleContext* style; ++ GdkRectangle tabRect; + GdkRectangle focusRect; + GdkRectangle backRect; ++ int initial_gap = 0; + + ensure_tab_widget(); + gtk_widget_set_direction(gTabWidget, direction); + + style = gtk_widget_get_style_context(gTabWidget); +- backRect = focusRect = *rect; +- + gtk_style_context_save(style); + ++ tabRect = *rect; ++ ++ if (flags & MOZ_GTK_TAB_FIRST) { ++ gtk_widget_style_get (gTabWidget, "initial-gap", &initial_gap, NULL); ++ tabRect.width -= initial_gap; ++ ++ if (direction != GTK_TEXT_DIR_RTL) { ++ tabRect.x += initial_gap; ++ } ++ } ++ ++ focusRect = backRect = tabRect; ++ + if ((flags & MOZ_GTK_TAB_SELECTED) == 0) { + /* Only draw the tab */ + gtk_style_context_set_state(style, GTK_STATE_FLAG_NORMAL); + gtk_render_extension(style, cr, +- rect->x, rect->y, rect->width, rect->height, ++ tabRect.x, tabRect.y, tabRect.width, tabRect.height, + (flags & MOZ_GTK_TAB_BOTTOM) ? + GTK_POS_TOP : GTK_POS_BOTTOM ); + } else { +@@ -2132,15 +2145,17 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan + gap_loffset = gap_roffset = 20; /* should be enough */ + if (flags & MOZ_GTK_TAB_FIRST) { + if (direction == GTK_TEXT_DIR_RTL) +- gap_roffset = 0; ++ gap_roffset = initial_gap; + else +- gap_loffset = 0; ++ gap_loffset = initial_gap; + } + +- gtk_style_context_set_state(style, GTK_STATE_FLAG_ACTIVE); +- + /* Adwaita theme engine crashes without it (rhbz#713764) */ +- gtk_style_context_add_region(style, GTK_STYLE_REGION_TAB, 0); ++ gtk_style_context_add_region(style, GTK_STYLE_REGION_TAB, ++ (flags & MOZ_GTK_TAB_FIRST) ? ++ GTK_REGION_FIRST : 0); ++ ++ gtk_style_context_set_state(style, GTK_STATE_FLAG_ACTIVE); + + if (flags & MOZ_GTK_TAB_BOTTOM) { + /* Draw the tab on bottom */ +@@ -2148,8 +2163,8 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan + focusRect.height -= gap_voffset; + + gtk_render_extension(style, cr, +- rect->x, rect->y + gap_voffset, rect->width, +- rect->height - gap_voffset, GTK_POS_TOP); ++ tabRect.x, tabRect.y + gap_voffset, tabRect.width, ++ tabRect.height - gap_voffset, GTK_POS_TOP); + + gtk_style_context_remove_region(style, GTK_STYLE_REGION_TAB); + +@@ -2165,38 +2180,39 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan + cairo_clip(cr); + + gtk_render_frame_gap(style, cr, +- rect->x - gap_loffset, +- rect->y + gap_voffset - 3 * gap_height, +- rect->width + gap_loffset + gap_roffset, ++ tabRect.x - gap_loffset, ++ tabRect.y + gap_voffset - 3 * gap_height, ++ tabRect.width + gap_loffset + gap_roffset, + 3 * gap_height, GTK_POS_BOTTOM, +- gap_loffset, gap_loffset + rect->width); ++ gap_loffset, gap_loffset + tabRect.width); + cairo_restore(cr); + } else { + /* Draw the tab on top */ + focusRect.height -= gap_voffset; + gtk_render_extension(style, cr, +- rect->x, rect->y, rect->width, +- rect->height - gap_voffset, GTK_POS_BOTTOM); ++ tabRect.x, tabRect.y, tabRect.width, ++ tabRect.height - gap_voffset, GTK_POS_BOTTOM); + + gtk_style_context_remove_region(style, GTK_STYLE_REGION_TAB); + +- backRect.y += (rect->height - gap_voffset); ++ backRect.y += (tabRect.height - gap_voffset); + backRect.height = gap_height; + + /* Draw the gap; erase with background color before painting in + * case theme does not */ + gtk_render_background(style, cr, backRect.x, backRect.y, + backRect.width, backRect.height); ++ + cairo_save(cr); + cairo_rectangle(cr, backRect.x, backRect.y, backRect.width, backRect.height); + cairo_clip(cr); + + gtk_render_frame_gap(style, cr, +- rect->x - gap_loffset, +- rect->y + rect->height - gap_voffset, +- rect->width + gap_loffset + gap_roffset, ++ tabRect.x - gap_loffset, ++ tabRect.y + tabRect.height - gap_voffset, ++ tabRect.width + gap_loffset + gap_roffset, + 3 * gap_height, GTK_POS_TOP, +- gap_loffset, gap_loffset + rect->width); ++ gap_loffset, gap_loffset + tabRect.width); + cairo_restore(cr); + } + } +@@ -2825,10 +2841,6 @@ moz_gtk_get_widget_border(GtkThemeWidget + left, top, right, bottom); + return MOZ_GTK_SUCCESS; + } +- case MOZ_GTK_TAB: +- ensure_tab_widget(); +- w = gTabWidget; +- break; + /* These widgets have no borders, since they are not containers. */ + case MOZ_GTK_SPLITTER_HORIZONTAL: + case MOZ_GTK_SPLITTER_VERTICAL: +@@ -2871,6 +2883,58 @@ moz_gtk_get_widget_border(GtkThemeWidget + return MOZ_GTK_SUCCESS; + } + ++gint ++moz_gtk_get_tab_border(GtkThemeWidgetType widget, gint* left, gint* top, ++ gint* right, gint* bottom, GtkTextDirection direction, ++ GtkTabFlags flags) ++{ ++ GtkStyleContext* style; ++ int tab_curvature; ++ ++ ensure_tab_widget(); ++ ++ style = gtk_widget_get_style_context(gTabWidget); ++ gtk_style_context_save(style); ++ ++ gtk_style_context_set_state(style, ((flags & MOZ_GTK_TAB_SELECTED) == 0) ? ++ GTK_STATE_FLAG_NORMAL : ++ GTK_STATE_FLAG_ACTIVE); ++ gtk_style_context_add_region(style, GTK_STYLE_REGION_TAB, ++ (flags & MOZ_GTK_TAB_FIRST) ? ++ GTK_REGION_FIRST : 0); ++ gtk_style_context_add_class(style, (flags & MOZ_GTK_TAB_BOTTOM) ? ++ GTK_STYLE_CLASS_BOTTOM : ++ GTK_STYLE_CLASS_TOP); ++ ++ *left = *top = *right = *bottom = 0; ++ moz_gtk_add_style_border(style, left, top, right, bottom); ++ moz_gtk_add_style_padding(style, left, top, right, bottom); ++ ++ gtk_widget_style_get (gTabWidget, "tab-curvature", &tab_curvature, NULL); ++ *left += tab_curvature; ++ *right += tab_curvature; ++ ++ if (flags & MOZ_GTK_TAB_FIRST) { ++ int initial_gap; ++ gtk_widget_style_get (gTabWidget, "initial-gap", &initial_gap, NULL); ++ if (direction == GTK_TEXT_DIR_RTL) ++ *right += initial_gap; ++ else ++ *left += initial_gap; ++ } ++ ++ // Top tabs have no bottom border, bottom tabs have no top border ++ if (flags & MOZ_GTK_TAB_BOTTOM) { ++ *top = 0; ++ } else { ++ *bottom = 0; ++ } ++ ++ gtk_style_context_restore(style); ++ ++ return MOZ_GTK_SUCCESS; ++} ++ + gint + moz_gtk_get_combo_box_entry_button_size(gint* width, gint* height) + { +diff -up src/widget/gtk/gtkdrawing.h.gtk3-tab-size src/widget/gtk/gtkdrawing.h +--- src/widget/gtk/gtkdrawing.h.gtk3-tab-size 2014-04-22 17:06:04.000000000 +0200 ++++ src/widget/gtk/gtkdrawing.h 2014-06-03 14:39:09.240424957 +0200 +@@ -258,6 +258,13 @@ gint moz_gtk_get_widget_border(GtkThemeW + gint* right, gint* bottom, GtkTextDirection direction, + gboolean inhtml); + ++#if (MOZ_WIDGET_GTK == 3) ++gint ++moz_gtk_get_tab_border(GtkThemeWidgetType widget, gint* left, gint* top, ++ gint* right, gint* bottom, GtkTextDirection direction, ++ GtkTabFlags flags); ++#endif ++ + /** + * Get the desired size of a GtkCheckButton + * indicator_size: [OUT] the indicator size +diff -up src/widget/gtk/nsNativeThemeGTK.cpp.gtk3-tab-size src/widget/gtk/nsNativeThemeGTK.cpp +--- src/widget/gtk/nsNativeThemeGTK.cpp.gtk3-tab-size 2014-05-21 13:29:44.000000000 +0200 ++++ src/widget/gtk/nsNativeThemeGTK.cpp 2014-06-03 14:39:09.240424957 +0200 +@@ -915,15 +915,31 @@ nsNativeThemeGTK::GetWidgetBorder(nsDevi + // but don't reserve any space for it. + break; + case NS_THEME_TAB: +- // Top tabs have no bottom border, bottom tabs have no top border +- moz_gtk_get_widget_border(MOZ_GTK_TAB, &aResult->left, &aResult->top, +- &aResult->right, &aResult->bottom, direction, +- FALSE); +- if (IsBottomTab(aFrame)) +- aResult->top = 0; +- else +- aResult->bottom = 0; +- break; ++ { ++#if (MOZ_WIDGET_GTK == 2) ++ // Top tabs have no bottom border, bottom tabs have no top border ++ moz_gtk_get_widget_border(MOZ_GTK_TAB, &aResult->left, &aResult->top, ++ &aResult->right, &aResult->bottom, direction, ++ FALSE); ++ if (IsBottomTab(aFrame)) ++ aResult->top = 0; ++ else ++ aResult->bottom = 0; ++#else ++ GtkWidgetState state; ++ GtkThemeWidgetType gtkWidgetType; ++ gint flags; ++ ++ if (!GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, &state, ++ &flags)) ++ return NS_OK; ++ ++ moz_gtk_get_tab_border(MOZ_GTK_TAB, &aResult->left, &aResult->top, ++ &aResult->right, &aResult->bottom, direction, ++ (GtkTabFlags)flags); ++#endif ++ } ++ break; + case NS_THEME_MENUITEM: + case NS_THEME_CHECKMENUITEM: + case NS_THEME_RADIOMENUITEM: -- cgit