diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/gtk2drawing.c firefox-18.0/mozilla-release/widget/gtk2/gtk2drawing.c --- firefox-17.0.1/mozilla-release/widget/gtk2/gtk2drawing.c 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/gtk2drawing.c 2013-01-04 18:44:46.000000000 -0500 @@ -1606,8 +1606,13 @@ if (theme_honors_transparency) { g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE)); } else { - gdk_draw_rectangle(drawable, style->base_gc[bg_state], TRUE, - cliprect->x, cliprect->y, cliprect->width, cliprect->height); + GdkRectangle clipped_rect; + gdk_rectangle_intersect(rect, cliprect, &clipped_rect); + if (clipped_rect.width != 0) { + gdk_draw_rectangle(drawable, style->base_gc[bg_state], TRUE, + clipped_rect.x, clipped_rect.y, + clipped_rect.width, clipped_rect.height); + } g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(FALSE)); } diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/mozcontainer.c firefox-18.0/mozilla-release/widget/gtk2/mozcontainer.c --- firefox-17.0.1/mozilla-release/widget/gtk2/mozcontainer.c 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/mozcontainer.c 2013-01-04 18:44:46.000000000 -0500 @@ -171,13 +171,6 @@ 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); - -#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 diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsBidiKeyboard.cpp firefox-18.0/mozilla-release/widget/gtk2/nsBidiKeyboard.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsBidiKeyboard.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsBidiKeyboard.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -10,38 +10,40 @@ #include "nsBidiKeyboard.h" #include - -static PRLibrary *gtklib = nullptr; - +#if (MOZ_WIDGET_GTK == 2) typedef gboolean (*GdkKeymapHaveBidiLayoutsType)(GdkKeymap *keymap); static GdkKeymapHaveBidiLayoutsType GdkKeymapHaveBidiLayouts = nullptr; - +#endif NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard) nsBidiKeyboard::nsBidiKeyboard() { +#if (MOZ_WIDGET_GTK == 2) + PRLibrary *gtklib = nullptr; #if defined(MOZ_X11) - if (!gtklib) - gtklib = PR_LoadLibrary("libgtk-x11-2.0.so.0"); -#else - return; + if (!GdkKeymapHaveBidiLayouts) { + GdkKeymapHaveBidiLayouts = (GdkKeymapHaveBidiLayoutsType) + PR_FindFunctionSymbolAndLibrary("gdk_keymap_have_bidi_layouts", + >klib); + if (gtklib) + PR_UnloadLibrary(gtklib); + } #endif - if (gtklib && !GdkKeymapHaveBidiLayouts) - GdkKeymapHaveBidiLayouts = (GdkKeymapHaveBidiLayoutsType) PR_FindFunctionSymbol(gtklib, "gdk_keymap_have_bidi_layouts"); - - SetHaveBidiKeyboards(); + mHaveBidiKeyboards = false; + if (GdkKeymapHaveBidiLayouts) + mHaveBidiKeyboards = (*GdkKeymapHaveBidiLayouts)(NULL); +#else + mHaveBidiKeyboards = gdk_keymap_have_bidi_layouts(gdk_keymap_get_default()); +#endif } nsBidiKeyboard::~nsBidiKeyboard() { - if (gtklib) { - PR_UnloadLibrary(gtklib); - gtklib = nullptr; - - GdkKeymapHaveBidiLayouts = nullptr; - } +#if (MOZ_WIDGET_GTK == 2) + GdkKeymapHaveBidiLayouts = nullptr; +#endif } NS_IMETHODIMP @@ -50,20 +52,7 @@ if (!mHaveBidiKeyboards) return NS_ERROR_FAILURE; - *aIsRTL = (gdk_keymap_get_direction(NULL) == PANGO_DIRECTION_RTL); - - return NS_OK; -} - -nsresult -nsBidiKeyboard::SetHaveBidiKeyboards() -{ - mHaveBidiKeyboards = false; - - if (!gtklib || !GdkKeymapHaveBidiLayouts) - return NS_ERROR_FAILURE; - - mHaveBidiKeyboards = (*GdkKeymapHaveBidiLayouts)(NULL); + *aIsRTL = (gdk_keymap_get_direction(gdk_keymap_get_default()) == PANGO_DIRECTION_RTL); return NS_OK; } diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsBidiKeyboard.h firefox-18.0/mozilla-release/widget/gtk2/nsBidiKeyboard.h --- firefox-17.0.1/mozilla-release/widget/gtk2/nsBidiKeyboard.h 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsBidiKeyboard.h 2013-01-04 18:44:46.000000000 -0500 @@ -21,7 +21,6 @@ virtual ~nsBidiKeyboard(); bool mHaveBidiKeyboards; - nsresult SetHaveBidiKeyboards(); }; #endif // __nsBidiKeyboard diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsClipboard.cpp firefox-18.0/mozilla-release/widget/gtk2/nsClipboard.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsClipboard.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsClipboard.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -271,7 +271,7 @@ guchar *data = NULL; gint length = 0; bool foundData = false; - nsCAutoString foundFlavor; + nsAutoCString foundFlavor; // Get a list of flavors this transferable can import nsCOMPtr flavors; @@ -331,8 +331,10 @@ continue; nsCOMPtr byteStream; - NS_NewByteInputStream(getter_AddRefs(byteStream), (const char*)selectionData->data, - selectionData->length, NS_ASSIGNMENT_COPY); + NS_NewByteInputStream(getter_AddRefs(byteStream), + (const char*)gtk_selection_data_get_data(selectionData), + gtk_selection_data_get_length(selectionData), + NS_ASSIGNMENT_COPY); aTransferable->SetTransferData(flavorStr, byteStream, sizeof(nsIInputStream*)); gtk_selection_data_free(selectionData); return NS_OK; @@ -344,13 +346,14 @@ GtkSelectionData *selectionData; selectionData = wait_for_contents(clipboard, atom); if (selectionData) { - length = selectionData->length; + const guchar *clipboardData = gtk_selection_data_get_data(selectionData); + length = gtk_selection_data_get_length(selectionData); // Special case text/html since we can convert into UCS2 if (!strcmp(flavorStr, kHTMLMime)) { PRUnichar* htmlBody= nullptr; int32_t htmlBodyLen = 0; // Convert text/html into our unicode format - ConvertHTMLtoUCS2((guchar *)selectionData->data, length, + ConvertHTMLtoUCS2(const_cast(clipboardData), length, &htmlBody, htmlBodyLen); // Try next data format? if (!htmlBodyLen) @@ -361,7 +364,7 @@ data = (guchar *)nsMemory::Alloc(length); if (!data) break; - memcpy(data, selectionData->data, length); + memcpy(data, clipboardData, length); } foundData = true; foundFlavor = flavorStr; @@ -513,9 +516,10 @@ int32_t whichClipboard; // which clipboard? - if (aSelectionData->selection == GDK_SELECTION_PRIMARY) + GdkAtom selection = gtk_selection_data_get_selection(aSelectionData); + if (selection == GDK_SELECTION_PRIMARY) whichClipboard = kSelectionClipboard; - else if (aSelectionData->selection == GDK_SELECTION_CLIPBOARD) + else if (selection == GDK_SELECTION_CLIPBOARD) whichClipboard = kGlobalClipboard; else return; // THAT AIN'T NO CLIPBOARD I EVER HEARD OF @@ -534,12 +538,15 @@ nsCOMPtr item; uint32_t len; + + GdkAtom selectionTarget = gtk_selection_data_get_target(aSelectionData); + // Check to see if the selection data includes any of the string // types that we support. - if (aSelectionData->target == gdk_atom_intern ("STRING", FALSE) || - aSelectionData->target == gdk_atom_intern ("TEXT", FALSE) || - aSelectionData->target == gdk_atom_intern ("COMPOUND_TEXT", FALSE) || - aSelectionData->target == gdk_atom_intern ("UTF8_STRING", FALSE)) { + if (selectionTarget == gdk_atom_intern ("STRING", FALSE) || + selectionTarget == gdk_atom_intern ("TEXT", FALSE) || + selectionTarget == gdk_atom_intern ("COMPOUND_TEXT", FALSE) || + selectionTarget == gdk_atom_intern ("UTF8_STRING", FALSE)) { // Try to convert our internal type into a text string. Get // the transferable for this clipboard and try to get the // text/unicode type for it. @@ -567,7 +574,7 @@ } // Check to see if the selection data is an image type - if (gtk_targets_include_image(&aSelectionData->target, 1, TRUE)) { + if (gtk_targets_include_image(&selectionTarget, 1, TRUE)) { // Look through our transfer data for the image static const char* const imageMimeTypes[] = { kNativeImageMime, kPNGImageMime, kJPEGImageMime, kJPGImageMime, kGIFImageMime }; @@ -598,7 +605,7 @@ // Try to match up the selection data target to something our // transferable provides. - gchar *target_name = gdk_atom_name(aSelectionData->target); + gchar *target_name = gdk_atom_name(selectionTarget); if (!target_name) return; @@ -615,7 +622,7 @@ if (primitive_data) { // Check to see if the selection data is text/html - if (aSelectionData->target == gdk_atom_intern (kHTMLMime, FALSE)) { + if (selectionTarget == gdk_atom_intern (kHTMLMime, FALSE)) { /* * "text/html" can be encoded UCS2. It is recommended that * documents transmitted as UCS2 always begin with a ZERO-WIDTH @@ -635,7 +642,7 @@ len += sizeof(prefix); } - gtk_selection_data_set(aSelectionData, aSelectionData->target, + gtk_selection_data_set(aSelectionData, selectionTarget, 8, /* 8 bits in a unit */ (const guchar *)primitive_data, len); nsMemory::Free(primitive_data); @@ -701,7 +708,7 @@ void ConvertHTMLtoUCS2(guchar * data, int32_t dataLength, PRUnichar** unicodeData, int32_t& outUnicodeLen) { - nsCAutoString charset; + nsAutoCString charset; GetHTMLCharset(data, dataLength, charset);// get charset of HTML if (charset.EqualsLiteral("UTF-16")) {//current mozilla outUnicodeLen = (dataLength / 2) - 1; @@ -816,7 +823,7 @@ { GdkEvent event; event.selection.type = GDK_SELECTION_NOTIFY; - event.selection.window = widget->window; + event.selection.window = gtk_widget_get_window(widget); event.selection.selection = gdk_x11_xatom_to_atom(xevent->xselection.selection); event.selection.target = gdk_x11_xatom_to_atom(xevent->xselection.target); event.selection.property = gdk_x11_xatom_to_atom(xevent->xselection.property); @@ -828,10 +835,11 @@ static void DispatchPropertyNotifyEvent(GtkWidget *widget, XEvent *xevent) { - if (((GdkWindowObject *) widget->window)->event_mask & GDK_PROPERTY_CHANGE_MASK) { + GdkWindow *window = gtk_widget_get_window(widget); + if ((gdk_window_get_events(window)) & GDK_PROPERTY_CHANGE_MASK) { GdkEvent event; event.property.type = GDK_PROPERTY_NOTIFY; - event.property.window = widget->window; + event.property.window = window; event.property.atom = gdk_x11_xatom_to_atom(xevent->xproperty.atom); event.property.time = xevent->xproperty.time; event.property.state = xevent->xproperty.state; @@ -855,7 +863,9 @@ (event->xany.type == PropertyNotify && event->xproperty.atom == context->selAtom)) { - GdkWindow *cbWindow = gdk_window_lookup(event->xany.window); + GdkWindow *cbWindow = + gdk_x11_window_lookup_for_display(gdk_x11_lookup_xdisplay(display), + event->xany.window); if (cbWindow) { GtkWidget *cbWidget = NULL; gdk_window_get_user_data(cbWindow, (gpointer *)&cbWidget); @@ -878,7 +888,7 @@ if (r_context->completed) // the request completed synchronously return true; - Display *xDisplay = GDK_DISPLAY(); + Display *xDisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()) ; checkEventContext context; context.cbWidget = NULL; context.selAtom = gdk_x11_atom_to_xatom(gdk_atom_intern("GDK_SELECTION", @@ -937,7 +947,7 @@ context->completed = true; - if (selection_data->length >= 0) + if (gtk_selection_data_get_length(selection_data) >= 0) context->data = gtk_selection_data_copy(selection_data); } diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsCUPSShim.cpp firefox-18.0/mozilla-release/widget/gtk2/nsCUPSShim.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsCUPSShim.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsCUPSShim.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -45,7 +45,7 @@ *(symAddr[i]) = PR_FindSymbol(mCupsLib, gSymName[i]); if (! *(symAddr[i])) { #ifdef DEBUG - nsCAutoString msg(gSymName[i]); + nsAutoCString msg(gSymName[i]); msg.Append(" not found in CUPS library"); NS_WARNING(msg.get()); #endif diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsCUPSShim.h firefox-18.0/mozilla-release/widget/gtk2/nsCUPSShim.h --- firefox-17.0.1/mozilla-release/widget/gtk2/nsCUPSShim.h 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsCUPSShim.h 2013-01-04 18:44:46.000000000 -0500 @@ -28,24 +28,24 @@ cups_option_t *options; /* Options */ } cups_dest_t; -typedef cups_dest_t* (PR_CALLBACK *CupsGetDestType)(const char *printer, - const char *instance, - int num_dests, - cups_dest_t *dests); -typedef int (PR_CALLBACK *CupsGetDestsType)(cups_dest_t **dests); -typedef int (PR_CALLBACK *CupsFreeDestsType)(int num_dests, - cups_dest_t *dests); -typedef int (PR_CALLBACK *CupsPrintFileType)(const char *printer, - const char *filename, - const char *title, - int num_options, - cups_option_t *options); -typedef int (PR_CALLBACK *CupsTempFdType)(char *filename, - int length); -typedef int (PR_CALLBACK *CupsAddOptionType)(const char *name, - const char *value, - int num_options, - cups_option_t **options); +typedef cups_dest_t* (*CupsGetDestType)(const char *printer, + const char *instance, + int num_dests, + cups_dest_t *dests); +typedef int (*CupsGetDestsType)(cups_dest_t **dests); +typedef int (*CupsFreeDestsType)(int num_dests, + cups_dest_t *dests); +typedef int (*CupsPrintFileType)(const char *printer, + const char *filename, + const char *title, + int num_options, + cups_option_t *options); +typedef int (*CupsTempFdType)(char *filename, + int length); +typedef int (*CupsAddOptionType)(const char *name, + const char *value, + int num_options, + cups_option_t **options); struct PRLibrary; diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsDeviceContextSpecG.cpp firefox-18.0/mozilla-release/widget/gtk2/nsDeviceContextSpecG.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsDeviceContextSpecG.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsDeviceContextSpecG.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -748,7 +748,7 @@ /* Set filename */ - nsCAutoString filename; + nsAutoCString filename; if (NS_FAILED(CopyPrinterCharPref(nullptr, printerName, "filename", filename))) { const char *path; @@ -782,7 +782,7 @@ printerFeatures.SetCanChangeOrientation(true); #endif /* SET_PRINTER_FEATURES_VIA_PREFS */ - nsCAutoString orientation; + nsAutoCString orientation; if (NS_SUCCEEDED(CopyPrinterCharPref("postscript", printerName, "orientation", orientation))) { if (orientation.LowerCaseEqualsLiteral("portrait")) { @@ -840,7 +840,7 @@ #ifdef SET_PRINTER_FEATURES_VIA_PREFS printerFeatures.SetCanChangePaperSize(true); #endif /* SET_PRINTER_FEATURES_VIA_PREFS */ - nsCAutoString papername; + nsAutoCString papername; if (NS_SUCCEEDED(CopyPrinterCharPref("postscript", printerName, "paper_size", papername))) { nsPaperSizePS paper; @@ -888,7 +888,7 @@ #endif /* SET_PRINTER_FEATURES_VIA_PREFS */ if (hasSpoolerCmd) { - nsCAutoString command; + nsAutoCString command; if (NS_SUCCEEDED(CopyPrinterCharPref("postscript", printerName, "print_command", command))) { DO_PR_DEBUG_LOG(("setting default print command to '%s'\n", diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsDeviceContextSpecG.h firefox-18.0/mozilla-release/widget/gtk2/nsDeviceContextSpecG.h --- firefox-17.0.1/mozilla-release/widget/gtk2/nsDeviceContextSpecG.h 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsDeviceContextSpecG.h 2013-01-04 18:44:46.000000000 -0500 @@ -16,8 +16,12 @@ #include "nsCRT.h" /* should be ? */ #include +#if (MOZ_WIDGET_GTK == 2) #include #include +#else +#include +#endif #define NS_PORTRAIT 0 #define NS_LANDSCAPE 1 diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsDragService.cpp firefox-18.0/mozilla-release/widget/gtk2/nsDragService.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsDragService.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsDragService.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -347,7 +347,7 @@ GdkEvent event; memset(&event, 0, sizeof(GdkEvent)); event.type = GDK_BUTTON_PRESS; - event.button.window = mHiddenWidget->window; + event.button.window = gtk_widget_get_window(mHiddenWidget); event.button.time = nsWindow::GetLastUserInputTime(); // Put the drag widget in the window group of the source node so that the @@ -358,6 +358,13 @@ gtk_window_group_add_window(window_group, GTK_WINDOW(mHiddenWidget)); +#if (MOZ_WIDGET_GTK == 3) + // Get device for event source + GdkDisplay *display = gdk_display_get_default(); + GdkDeviceManager *device_manager = gdk_display_get_device_manager(display); + event.button.device = gdk_device_manager_get_client_pointer(device_manager); +#endif + // start our drag. GdkDragContext *context = gtk_drag_begin(mHiddenWidget, sourceList, @@ -398,6 +405,7 @@ int32_t aYOffset, const nsIntRect& dragRect) { +#if (MOZ_WIDGET_GTK == 2) GdkScreen* screen = gtk_widget_get_screen(mHiddenWidget); // Transparent drag icons need, like a lot of transparency-related things, @@ -439,6 +447,10 @@ aXOffset, aYOffset); g_object_unref(pixmap); return true; +#else + // TODO GTK3 + return false; +#endif } NS_IMETHODIMP @@ -970,7 +982,8 @@ // check the target context vs. this flavor, one at a time GList *tmp; - for (tmp = mTargetDragContext->targets; tmp; tmp = tmp->next) { + for (tmp = gdk_drag_context_list_targets(mTargetDragContext); + tmp; tmp = tmp->next) { /* Bug 331198 */ GdkAtom atom = GDK_POINTER_TO_ATOM(tmp->data); gchar *name = NULL; @@ -1054,15 +1067,17 @@ PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::TargetDataReceived")); TargetResetData(); mTargetDragDataReceived = true; - if (aSelectionData->length > 0) { - mTargetDragDataLen = aSelectionData->length; + gint len = gtk_selection_data_get_length(aSelectionData); + const guchar* data = gtk_selection_data_get_data(aSelectionData); + if (len > 0 && data) { + mTargetDragDataLen = len; mTargetDragData = g_malloc(mTargetDragDataLen); - memcpy(mTargetDragData, aSelectionData->data, mTargetDragDataLen); + memcpy(mTargetDragData, data, mTargetDragDataLen); } else { PR_LOG(sDragLm, PR_LOG_DEBUG, ("Failed to get data. selection data len was %d\n", - aSelectionData->length)); + mTargetDragDataLen)); } } @@ -1082,7 +1097,8 @@ // walk the list of context targets and see if one of them is a list // of items. - for (tmp = mTargetDragContext->targets; tmp; tmp = tmp->next) { + for (tmp = gdk_drag_context_list_targets(mTargetDragContext); + tmp; tmp = tmp->next) { /* Bug 331198 */ GdkAtom atom = GDK_POINTER_TO_ATOM(tmp->data); gchar *name = NULL; @@ -1359,7 +1375,8 @@ // cancelled (but no drag-failed signal would have been sent). // aContext->dest_window will be non-NULL only if the drop was sent. GdkDragAction action = - aContext->dest_window ? aContext->action : (GdkDragAction)0; + gdk_drag_context_get_dest_window(aContext) ? + gdk_drag_context_get_actions(aContext) : (GdkDragAction)0; // Only one bit of action should be set, but, just in case someone // does something funny, erring away from MOVE, and not recording @@ -1552,7 +1569,7 @@ if (tmpData) { // this copies the data gtk_selection_data_set(aSelectionData, - aSelectionData->target, + gtk_selection_data_get_target(aSelectionData), 8, (guchar *)tmpData, tmpDataLen); // this wasn't allocated with glib @@ -1565,7 +1582,7 @@ gint length; CreateUriList(mSourceDataItems, &uriList, &length); gtk_selection_data_set(aSelectionData, - aSelectionData->target, + gtk_selection_data_get_target(aSelectionData), 8, (guchar *)uriList, length); g_free(uriList); return; diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsFilePicker.cpp firefox-18.0/mozilla-release/widget/gtk2/nsFilePicker.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsFilePicker.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsFilePicker.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -157,10 +157,10 @@ gtk_file_chooser_set_preview_widget_active(file_chooser, TRUE); } -static nsCAutoString +static nsAutoCString MakeCaseInsensitiveShellGlob(const char* aPattern) { // aPattern is UTF8 - nsCAutoString result; + nsAutoCString result; unsigned int len = strlen(aPattern); for (unsigned int i = 0; i < len; i++) { @@ -272,7 +272,7 @@ return NS_OK; } - nsCAutoString filter, name; + nsAutoCString filter, name; CopyUTF16toUTF8(aFilter, filter); CopyUTF16toUTF8(aTitle, name); @@ -433,8 +433,9 @@ gtk_window_set_modal(window, TRUE); if (parent_widget) { gtk_window_set_destroy_with_parent(window, TRUE); - if (parent_widget->group) { - gtk_window_group_add_window(parent_widget->group, window); + GtkWindowGroup *parentGroup = gtk_window_get_group(parent_widget); + if (parentGroup) { + gtk_window_group_add_window(parentGroup, window); } } @@ -461,11 +462,11 @@ // Try to select the intended file. Even if it doesn't exist, GTK still switches // directories. defaultPath->AppendNative(defaultName); - nsCAutoString path; + nsAutoCString path; defaultPath->GetNativePath(path); gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(file_chooser), path.get()); } else { - nsCAutoString directory; + nsAutoCString directory; defaultPath->GetNativePath(directory); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(file_chooser), directory.get()); @@ -486,7 +487,7 @@ GtkFileFilter *filter = gtk_file_filter_new(); for (int j = 0; patterns[j] != NULL; ++j) { - nsCAutoString caseInsensitiveFilter = MakeCaseInsensitiveShellGlob(g_strstrip(patterns[j])); + nsAutoCString caseInsensitiveFilter = MakeCaseInsensitiveShellGlob(g_strstrip(patterns[j])); gtk_file_filter_add_pattern(filter, caseInsensitiveFilter.get()); } diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsGtkIMModule.cpp firefox-18.0/mozilla-release/widget/gtk2/nsGtkIMModule.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsGtkIMModule.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsGtkIMModule.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -80,7 +80,7 @@ mSimpleContext(nullptr), #endif mDummyContext(nullptr), - mCompositionStart(PR_UINT32_MAX), mProcessingKeyEvent(nullptr), + mCompositionStart(UINT32_MAX), mProcessingKeyEvent(nullptr), mCompositionState(eCompositionState_NotComposing), mIsIMFocused(false), mIgnoreNativeCompositionEvent(false) { @@ -101,7 +101,7 @@ MozContainer* container = mOwnerWindow->GetMozContainer(); NS_PRECONDITION(container, "container is null"); - GdkWindow* gdkWindow = GTK_WIDGET(container)->window; + GdkWindow* gdkWindow = gtk_widget_get_window(GTK_WIDGET(container)); // NOTE: gtk_im_*_new() abort (kill) the whole process when it fails. // So, we don't need to check the result. @@ -255,7 +255,11 @@ NS_PRECONDITION(container, "The container of the window is null"); GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT(aContext); +#if (MOZ_WIDGET_GTK == 2) GtkIMContext *slave = multicontext->slave; +#else + GtkIMContext *slave = NULL; //TODO GTK3 +#endif if (!slave) { return; } @@ -1051,7 +1055,7 @@ InitEvent(selection); mLastFocusedWindow->DispatchEvent(&selection, status); - if (!selection.mSucceeded || selection.mReply.mOffset == PR_UINT32_MAX) { + if (!selection.mSucceeded || selection.mReply.mOffset == UINT32_MAX) { PR_LOG(gGtkIMLog, PR_LOG_ALWAYS, (" FAILED, cannot query the selection offset")); return false; @@ -1135,7 +1139,7 @@ nsCOMPtr kungFuDeathGrip = mLastFocusedWindow; mLastFocusedWindow->DispatchEvent(&compEvent, status); mCompositionState = eCompositionState_NotComposing; - mCompositionStart = PR_UINT32_MAX; + mCompositionStart = UINT32_MAX; mDispatchedCompositionString.Truncate(); if (static_cast(kungFuDeathGrip.get())->IsDestroyed() || kungFuDeathGrip != mLastFocusedWindow) { @@ -1374,7 +1378,7 @@ ("GtkIMModule(%p): SetCursorPosition, aTargetOffset=%u", this, aTargetOffset)); - if (aTargetOffset == PR_UINT32_MAX) { + if (aTargetOffset == UINT32_MAX) { PR_LOG(gGtkIMLog, PR_LOG_ALWAYS, (" FAILED, aTargetOffset is wrong offset")); return; @@ -1463,9 +1467,9 @@ // XXX nsString::Find and nsString::RFind take int32_t for offset, so, // we cannot support this request when the current offset is larger - // than PR_INT32_MAX. - if (selOffset > PR_INT32_MAX || selLength > PR_INT32_MAX || - selOffset + selLength > PR_INT32_MAX) { + // than INT32_MAX. + if (selOffset > INT32_MAX || selLength > INT32_MAX || + selOffset + selLength > INT32_MAX) { PR_LOG(gGtkIMLog, PR_LOG_ALWAYS, (" FAILED, The selection is out of range")); return NS_ERROR_FAILURE; @@ -1475,7 +1479,7 @@ nsQueryContentEvent queryTextContentEvent(true, NS_QUERY_TEXT_CONTENT, mLastFocusedWindow); - queryTextContentEvent.InitForQueryTextContent(0, PR_UINT32_MAX); + queryTextContentEvent.InitForQueryTextContent(0, UINT32_MAX); mLastFocusedWindow->DispatchEvent(&queryTextContentEvent, status); NS_ENSURE_TRUE(queryTextContentEvent.mSucceeded, NS_ERROR_FAILURE); @@ -1570,7 +1574,7 @@ nsQueryContentEvent queryTextContentEvent(true, NS_QUERY_TEXT_CONTENT, mLastFocusedWindow); - queryTextContentEvent.InitForQueryTextContent(0, PR_UINT32_MAX); + queryTextContentEvent.InitForQueryTextContent(0, UINT32_MAX); mLastFocusedWindow->DispatchEvent(&queryTextContentEvent, status); NS_ENSURE_TRUE(queryTextContentEvent.mSucceeded, NS_ERROR_FAILURE); if (queryTextContentEvent.mReply.mString.IsEmpty()) { diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsGtkKeyUtils.cpp firefox-18.0/mozilla-release/widget/gtk2/nsGtkKeyUtils.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsGtkKeyUtils.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsGtkKeyUtils.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -18,6 +18,9 @@ #ifdef MOZ_X11 #include #endif /* MOZ_X11 */ +#if (MOZ_WIDGET_GTK == 3) +#include +#endif #include "nsGUIEvent.h" #include "WidgetUtils.h" #include "keysym2ucs.h" @@ -382,7 +385,7 @@ int32_t foundLevel[5]; for (uint32_t i = 0; i < ArrayLength(mod); i++) { mod[i] = NOT_MODIFIER; - foundLevel[i] = PR_INT32_MAX; + foundLevel[i] = INT32_MAX; } const uint32_t map_size = 8 * xmodmap->max_keypermod; for (uint32_t i = 0; i < map_size; i++) { @@ -621,7 +624,6 @@ case NS_WHEEL_EVENT: case NS_DRAG_EVENT: case NS_SIMPLE_GESTURE_EVENT: - case NS_MOZTOUCH_EVENT: break; default: return; diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsGTKToolkit.h firefox-18.0/mozilla-release/widget/gtk2/nsGTKToolkit.h --- firefox-17.0.1/mozilla-release/widget/gtk2/nsGTKToolkit.h 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsGTKToolkit.h 2013-01-04 18:44:46.000000000 -0500 @@ -21,7 +21,6 @@ { public: nsGTKToolkit(); - virtual ~nsGTKToolkit(); static nsGTKToolkit* GetToolkit(); @@ -30,9 +29,6 @@ gToolkit = nullptr; } - void CreateSharedGC(void); - GdkGC *GetSharedGC(void); - /** * Get/set our value of DESKTOP_STARTUP_ID. When non-empty, this is applied * to the next toplevel window to be shown or focused (and then immediately @@ -51,7 +47,6 @@ private: static nsGTKToolkit* gToolkit; - GdkGC *mSharedGC; nsCString mDesktopStartupID; uint32_t mFocusTimestamp; }; diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsIdleServiceGTK.cpp firefox-18.0/mozilla-release/widget/gtk2/nsIdleServiceGTK.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsIdleServiceGTK.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsIdleServiceGTK.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -5,13 +5,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include + #include "nsIdleServiceGTK.h" #include "nsIServiceManager.h" #include "nsDebug.h" #include "prlink.h" #include "prlog.h" - #ifdef PR_LOGGING static PRLogModuleInfo* sIdleLog = nullptr; #endif @@ -102,7 +103,7 @@ *aIdleTime = 0; // We might not have a display (cf. in xpcshell) - Display *dplay = GDK_DISPLAY(); + Display *dplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); if (!dplay) { #ifdef PR_LOGGING PR_LOG(sIdleLog, PR_LOG_WARNING, ("No display found!\n")); diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsLookAndFeel.cpp firefox-18.0/mozilla-release/widget/gtk2/nsLookAndFeel.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsLookAndFeel.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsLookAndFeel.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -721,7 +721,8 @@ bool nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName, - gfxFontStyle& aFontStyle) + gfxFontStyle& aFontStyle, + float aDevPixPerCSSPixel) { nsString *cachedFontName = NULL; gfxFontStyle *cachedFontStyle = NULL; diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsLookAndFeel.h firefox-18.0/mozilla-release/widget/gtk2/nsLookAndFeel.h --- firefox-17.0.1/mozilla-release/widget/gtk2/nsLookAndFeel.h 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsLookAndFeel.h 2013-01-04 18:44:46.000000000 -0500 @@ -23,7 +23,8 @@ virtual nsresult GetIntImpl(IntID aID, int32_t &aResult); virtual nsresult GetFloatImpl(FloatID aID, float &aResult); virtual bool GetFontImpl(FontID aID, nsString& aFontName, - gfxFontStyle& aFontStyle); + gfxFontStyle& aFontStyle, + float aDevPixPerCSSPixel); virtual void RefreshImpl(); virtual PRUnichar GetPasswordCharacterImpl(); diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsNativeKeyBindings.cpp firefox-18.0/mozilla-release/widget/gtk2/nsNativeKeyBindings.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsNativeKeyBindings.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsNativeKeyBindings.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -308,9 +308,13 @@ gCurrentCallbackData = aCallbackData; gHandled = false; - +#if (MOZ_WIDGET_GTK == 2) gtk_bindings_activate(GTK_OBJECT(mNativeTarget), aKeyCode, GdkModifierType(modifiers)); +#else + gtk_bindings_activate(G_OBJECT(mNativeTarget), + aKeyCode, GdkModifierType(modifiers)); +#endif gCurrentCallback = nullptr; gCurrentCallbackData = nullptr; diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsPrintDialogGTK.cpp firefox-18.0/mozilla-release/widget/gtk2/nsPrintDialogGTK.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsPrintDialogGTK.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsPrintDialogGTK.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -4,7 +4,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include +#if (MOZ_WIDGET_GTK == 2) #include +#else +#include +#endif #include #include "mozilla/Util.h" @@ -77,7 +81,11 @@ printBundle->GetStringFromName(NS_LITERAL_STRING("headerFooterCustom").get(), getter_Copies(intlString)); GtkWidget* prompt_dialog = gtk_dialog_new_with_buttons(NS_ConvertUTF16toUTF8(intlString).get(), printDialog, +#if (MOZ_WIDGET_GTK == 2) (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), +#else + (GtkDialogFlags)(GTK_DIALOG_MODAL), +#endif GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); @@ -110,7 +118,8 @@ gtk_container_set_border_width(GTK_CONTAINER(custom_hbox), 2); gtk_widget_show_all(custom_hbox); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(prompt_dialog)->vbox), custom_hbox, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(prompt_dialog))), + custom_hbox, FALSE, FALSE, 0); gint diag_response = gtk_dialog_run(GTK_DIALOG(prompt_dialog)); if (diag_response == GTK_RESPONSE_ACCEPT) { @@ -481,14 +490,23 @@ GtkWidget* nsPrintDialogWidgetGTK::ConstructHeaderFooterDropdown(const PRUnichar *currentString) { +#if (MOZ_WIDGET_GTK == 2) GtkWidget* dropdown = gtk_combo_box_new_text(); +#else + GtkWidget* dropdown = gtk_combo_box_text_new(); +#endif const char hf_options[][22] = {"headerFooterBlank", "headerFooterTitle", "headerFooterURL", "headerFooterDate", "headerFooterPage", "headerFooterPageTotal", "headerFooterCustom"}; for (unsigned int i = 0; i < ArrayLength(hf_options); i++) { +#if (MOZ_WIDGET_GTK == 2) gtk_combo_box_append_text(GTK_COMBO_BOX(dropdown), GetUTF8FromBundle(hf_options[i]).get()); +#else + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(dropdown), NULL, + GetUTF8FromBundle(hf_options[i]).get()); +#endif } bool shouldBeCustom = true; diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsPrintSettingsGTK.cpp firefox-18.0/mozilla-release/widget/gtk2/nsPrintSettingsGTK.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsPrintSettingsGTK.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsPrintSettingsGTK.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -421,7 +421,7 @@ NS_ENSURE_SUCCESS(rv, rv); // Convert the nsIFile to a URL - nsCAutoString url; + nsAutoCString url; rv = NS_GetURLSpecFromFile(file, url); NS_ENSURE_SUCCESS(rv, rv); diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsPrintSettingsGTK.h firefox-18.0/mozilla-release/widget/gtk2/nsPrintSettingsGTK.h --- firefox-17.0.1/mozilla-release/widget/gtk2/nsPrintSettingsGTK.h 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsPrintSettingsGTK.h 2013-01-04 18:44:46.000000000 -0500 @@ -11,8 +11,12 @@ extern "C" { #include +#if (MOZ_WIDGET_GTK == 2) #include #include +#else +#include +#endif } #define NS_PRINTSETTINGSGTK_IID \ diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsPSPrinters.cpp firefox-18.0/mozilla-release/widget/gtk2/nsPSPrinters.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsPSPrinters.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsPSPrinters.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -63,7 +63,7 @@ int num_dests = (gCupsShim.mCupsGetDests)(&dests); if (num_dests) { for (int i = 0; i < num_dests; i++) { - nsCAutoString fullName(NS_CUPS_PRINTER); + nsAutoCString fullName(NS_CUPS_PRINTER); fullName.Append(dests[i].name); if (dests[i].instance != NULL) { fullName.Append("/"); @@ -87,7 +87,7 @@ aList.AppendElement( NS_LITERAL_CSTRING(NS_POSTSCRIPT_DRIVER_NAME "default")); - nsCAutoString list(PR_GetEnv("MOZILLA_POSTSCRIPT_PRINTER_LIST")); + nsAutoCString list(PR_GetEnv("MOZILLA_POSTSCRIPT_PRINTER_LIST")); if (list.IsEmpty()) { list = Preferences::GetCString("print.printer_list"); } @@ -101,7 +101,7 @@ name = PL_strtok_r(nullptr, " ", &state) ) { if (0 != strcmp(name, "default")) { - nsCAutoString fullName(NS_POSTSCRIPT_DRIVER_NAME); + nsAutoCString fullName(NS_POSTSCRIPT_DRIVER_NAME); fullName.Append(name); aList.AppendElement(fullName); } diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsScreenGtk.cpp firefox-18.0/mozilla-release/widget/gtk2/nsScreenGtk.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsScreenGtk.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsScreenGtk.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -54,8 +54,8 @@ NS_IMETHODIMP nsScreenGtk :: GetPixelDepth(int32_t *aPixelDepth) { - GdkVisual * rgb_visual = gdk_rgb_get_visual(); - *aPixelDepth = rgb_visual->depth; + GdkVisual * visual = gdk_screen_get_system_visual(gdk_screen_get_default()); + *aPixelDepth = gdk_visual_get_depth(visual); return NS_OK; diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsScreenManagerGtk.cpp firefox-18.0/mozilla-release/widget/gtk2/nsScreenManagerGtk.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsScreenManagerGtk.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsScreenManagerGtk.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -132,9 +132,9 @@ PR_FindFunctionSymbol(mXineramalib, "XineramaQueryScreens"); // get the number of screens via xinerama - if (_XnrmIsActive && _XnrmQueryScreens && - _XnrmIsActive(GDK_DISPLAY())) { - screenInfo = _XnrmQueryScreens(GDK_DISPLAY(), &numScreens); + Display *display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); + if (_XnrmIsActive && _XnrmQueryScreens && _XnrmIsActive(display)) { + screenInfo = _XnrmQueryScreens(display, &numScreens); } } @@ -297,11 +297,18 @@ if (mCachedScreenArray.Count() > 1) { // I don't know how to go from GtkWindow to nsIScreen, especially // given xinerama and stuff, so let's just do this - gint x, y, width, height, depth; + gint x, y, width, height; +#if (MOZ_WIDGET_GTK == 2) + gint depth; +#endif x = y = width = height = 0; +#if (MOZ_WIDGET_GTK == 2) gdk_window_get_geometry(GDK_WINDOW(aWidget), &x, &y, &width, &height, &depth); +#else + gdk_window_get_geometry(GDK_WINDOW(aWidget), &x, &y, &width, &height); +#endif gdk_window_get_origin(GDK_WINDOW(aWidget), &x, &y); rv = ScreenForRect(x, y, width, height, outScreen); } else { diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsSound.cpp firefox-18.0/mozilla-release/widget/gtk2/nsSound.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsSound.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsSound.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -136,7 +136,7 @@ nsCOMPtr appInfo = do_GetService("@mozilla.org/xre/app-info;1"); if (appInfo) { - nsCAutoString version; + nsAutoCString version; appInfo->GetVersion(version); ca_context_change_props(ctx, "application.version", version.get(), NULL); @@ -232,7 +232,7 @@ if (channel) { channel->GetURI(getter_AddRefs(uri)); if (uri) { - nsCAutoString uriSpec; + nsAutoCString uriSpec; uri->GetSpec(uriSpec); printf("Failed to load %s\n", uriSpec.get()); } @@ -288,7 +288,7 @@ return NS_ERROR_OUT_OF_MEMORY; } - nsCAutoString path; + nsAutoCString path; rv = canberraFile->GetNativePath(path); if (NS_FAILED(rv)) { return rv; @@ -326,7 +326,7 @@ return NS_ERROR_OUT_OF_MEMORY; } - nsCAutoString spec; + nsAutoCString spec; rv = aURL->GetSpec(spec); if (NS_FAILED(rv)) { return rv; diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsToolkit.cpp firefox-18.0/mozilla-release/widget/gtk2/nsToolkit.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsToolkit.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsToolkit.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -16,38 +16,8 @@ // //------------------------------------------------------------------------- nsGTKToolkit::nsGTKToolkit() - : mSharedGC(nullptr), mFocusTimestamp(0) + : mFocusTimestamp(0) { - CreateSharedGC(); -} - -//------------------------------------------------------------------------- -// -// destructor -// -//------------------------------------------------------------------------- -nsGTKToolkit::~nsGTKToolkit() -{ - if (mSharedGC) { - g_object_unref(mSharedGC); - } -} - -void nsGTKToolkit::CreateSharedGC(void) -{ - GdkPixmap *pixmap; - - if (mSharedGC) - return; - - pixmap = gdk_pixmap_new(NULL, 1, 1, gdk_rgb_get_visual()->depth); - mSharedGC = gdk_gc_new(pixmap); - g_object_unref(pixmap); -} - -GdkGC *nsGTKToolkit::GetSharedGC(void) -{ - return (GdkGC *)g_object_ref(mSharedGC); } //------------------------------------------------------------------------------- diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsWindow.cpp firefox-18.0/mozilla-release/widget/gtk2/nsWindow.cpp --- firefox-17.0.1/mozilla-release/widget/gtk2/nsWindow.cpp 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsWindow.cpp 2013-01-04 18:44:46.000000000 -0500 @@ -26,7 +26,7 @@ #include "nsGtkCursors.h" #include -#if defined(MOZ_WIDGET_GTK3) +#if (MOZ_WIDGET_GTK == 3) #include #endif #ifdef MOZ_X11 @@ -34,7 +34,7 @@ #include #include #include -#if defined(MOZ_WIDGET_GTK3) +#if (MOZ_WIDGET_GTK == 3) #include #endif @@ -44,7 +44,9 @@ #include #endif +#if (MOZ_WIDGET_GTK == 2) #include "gtk2xtbin.h" +#endif #endif /* MOZ_X11 */ #include #if defined(MOZ_WIDGET_GTK2) @@ -358,6 +360,7 @@ mWindowType = eWindowType_child; mSizeState = nsSizeMode_Normal; mLastSizeMode = nsSizeMode_Normal; + mSizeConstraints.mMaxSize = GetSafeWindowSize(mSizeConstraints.mMaxSize); #ifdef MOZ_X11 mOldFocusWindow = 0; @@ -448,7 +451,7 @@ { #ifdef DEBUG debug_DumpEvent(stdout, aEvent->widget, aEvent, - nsCAutoString("something"), 0); + nsAutoCString("something"), 0); #endif aStatus = nsEventStatus_eIgnore; @@ -925,19 +928,20 @@ void nsWindow::SetSizeConstraints(const SizeConstraints& aConstraints) { - if (mShell) { - GdkGeometry geometry; - geometry.min_width = aConstraints.mMinSize.width; - geometry.min_height = aConstraints.mMinSize.height; - geometry.max_width = aConstraints.mMaxSize.width; - geometry.max_height = aConstraints.mMaxSize.height; - - uint32_t hints = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE; - gtk_window_set_geometry_hints(GTK_WINDOW(mShell), nullptr, - &geometry, GdkWindowHints(hints)); - } + mSizeConstraints.mMinSize = GetSafeWindowSize(aConstraints.mMinSize); + mSizeConstraints.mMaxSize = GetSafeWindowSize(aConstraints.mMaxSize); - nsBaseWidget::SetSizeConstraints(aConstraints); + if (mShell) { + GdkGeometry geometry; + geometry.min_width = mSizeConstraints.mMinSize.width; + geometry.min_height = mSizeConstraints.mMinSize.height; + geometry.max_width = mSizeConstraints.mMaxSize.width; + geometry.max_height = mSizeConstraints.mMaxSize.height; + + uint32_t hints = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE; + gtk_window_set_geometry_hints(GTK_WINDOW(mShell), nullptr, + &geometry, GdkWindowHints(hints)); + } } NS_IMETHODIMP @@ -1004,7 +1008,7 @@ // interpreted as frame bounds, but NativeResize treats these as window // bounds (Bug 581866). - mBounds.SizeTo(GetSafeWindowSize(nsIntSize(aWidth, aHeight))); + mBounds.SizeTo(aWidth, aHeight); if (!mCreated) return NS_OK; @@ -1080,7 +1084,7 @@ mBounds.x = aX; mBounds.y = aY; - mBounds.SizeTo(GetSafeWindowSize(nsIntSize(aWidth, aHeight))); + mBounds.SizeTo(aWidth, aHeight); mNeedsMove = true; @@ -1284,7 +1288,7 @@ if (!GTKToolkit) return; - nsCAutoString desktopStartupID; + nsAutoCString desktopStartupID; GTKToolkit->GetDesktopStartupID(&desktopStartupID); if (desktopStartupID.IsEmpty()) { // We don't have the data we need. Fall back to an @@ -1677,17 +1681,6 @@ #endif /* MOZ_X11 */ break; - case NS_NATIVE_GRAPHIC: { -#if defined(MOZ_WIDGET_GTK2) - nsGTKToolkit* toolkit = nsGTKToolkit::GetToolkit(); - NS_ASSERTION(nullptr != toolkit, "NULL toolkit, unable to get a GC"); - return toolkit->GetSharedGC(); -#else - return nullptr; -#endif - break; - } - case NS_NATIVE_SHELLWIDGET: return (void *) mShell; @@ -1728,7 +1721,7 @@ if (!mShell) return NS_OK; - nsCAutoString iconName; + nsAutoCString iconName; if (aIconSpec.EqualsLiteral("default")) { nsXPIDLString brandName; @@ -1740,7 +1733,7 @@ } nsCOMPtr iconFile; - nsCAutoString path; + nsAutoCString path; gint *iconSizes = gtk_icon_theme_get_icon_sizes(gtk_icon_theme_get_default(), @@ -2023,6 +2016,10 @@ // there is nothing left to do. if (!mGdkWindow) return TRUE; + + // The will paint notification might have killed our listener. + if (!mWidgetListener) + return FALSE; } #if defined(MOZ_WIDGET_GTK2) @@ -2076,8 +2073,22 @@ // window. region.And(region, nsIntRect(0, 0, mBounds.width, mBounds.height)); - bool translucent = eTransparencyTransparent == GetTransparencyMode(); - if (!translucent) { + bool shaped = false; + if (eTransparencyTransparent == GetTransparencyMode()) { + GdkScreen *screen = gdk_window_get_screen(mGdkWindow); + if (gdk_screen_is_composited(screen) && + gdk_window_get_visual(mGdkWindow) == + gdk_screen_get_rgba_visual(screen)) { + // Remove possible shape mask from when window manger was not + // previously compositing. + static_cast(GetTopLevelWidget())-> + ClearTransparencyBitmap(); + } else { + shaped = true; + } + } + + if (!shaped) { GList *children = gdk_window_peek_children(mGdkWindow); while (children) { @@ -2107,7 +2118,6 @@ } // If this widget uses OMTC... if (GetLayerManager()->AsShadowForwarder() && GetLayerManager()->AsShadowForwarder()->HasShadowManager()) { - nsEventStatus status; #if defined(MOZ_WIDGET_GTK2) nsRefPtr ctx = new gfxContext(GetThebesSurface()); #else @@ -2148,10 +2158,10 @@ #endif #ifdef MOZ_X11 - nsIntRect boundsRect; // for translucent only + nsIntRect boundsRect; // for shaped only ctx->NewPath(); - if (translucent) { + if (shaped) { // Collapse update area to the bounding box. This is so we only have to // call UpdateTranslucentWindowAlpha once. After we have dropped // support for non-Thebes graphics, UpdateTranslucentWindowAlpha will be @@ -2165,7 +2175,7 @@ ctx->Clip(); BufferMode layerBuffering; - if (translucent) { + if (shaped) { // The double buffering is done here to extract the shape mask. // (The shape mask won't be necessary when a visual with an alpha // channel is used on compositing window managers.) @@ -2205,7 +2215,7 @@ #ifdef MOZ_X11 // PaintWindow can Destroy us (bug 378273), avoid doing any paint // operations below if that happened - it will lead to XError and exit(). - if (translucent) { + if (shaped) { if (NS_LIKELY(!mIsDestroyed)) { if (painted) { nsRefPtr pattern = ctx->PopGroup(); @@ -2373,18 +2383,12 @@ nsIntRect rect(aAllocation->x, aAllocation->y, aAllocation->width, aAllocation->height); - ResizeTransparencyBitmap(rect.width, rect.height); - mBounds.width = rect.width; mBounds.height = rect.height; if (!mGdkWindow) return; - if (mTransparencyBitmap) { - ApplyTransparencyBitmap(); - } - if (mWidgetListener) mWidgetListener->WindowResized(this, rect.width, rect.height); } @@ -3373,6 +3377,7 @@ // save our bounds mBounds = aRect; + ConstrainSize(&mBounds.width, &mBounds.height); // figure out our parent window GtkWidget *parentMozContainer = nullptr; @@ -3456,19 +3461,35 @@ // Popups that are not noautohide are only temporary. The are used // for menus and the like and disappear when another window is used. - if (!aInitData->mNoAutoHide) { - // For most popups, use the standard GtkWindowType - // GTK_WINDOW_POPUP, which will use a Window with the - // override-redirect attribute (for temporary windows). - mShell = gtk_window_new(GTK_WINDOW_POPUP); - gtk_window_set_wmclass(GTK_WINDOW(mShell), "Popup", - gdk_get_program_class()); - } else { - // For long-lived windows, their stacking order is managed by - // the window manager, as indicated by GTK_WINDOW_TOPLEVEL ... - mShell = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_wmclass(GTK_WINDOW(mShell), "Popup", - gdk_get_program_class()); + // For most popups, use the standard GtkWindowType GTK_WINDOW_POPUP, + // which will use a Window with the override-redirect attribute + // (for temporary windows). + // For long-lived windows, their stacking order is managed by the + // window manager, as indicated by GTK_WINDOW_TOPLEVEL ... + GtkWindowType type = aInitData->mNoAutoHide ? + GTK_WINDOW_TOPLEVEL : GTK_WINDOW_POPUP; + mShell = gtk_window_new(type); + gtk_window_set_wmclass(GTK_WINDOW(mShell), "Popup", + gdk_get_program_class()); + + if (aInitData->mSupportTranslucency) { + // We need to select an ARGB visual here instead of in + // SetTransparencyMode() because it has to be done before the + // widget is realized. An ARGB visual is only useful if we + // are on a compositing window manager. + GdkScreen *screen = gtk_widget_get_screen(mShell); + if (gdk_screen_is_composited(screen)) { +#if defined(MOZ_WIDGET_GTK2) + GdkColormap *colormap = + gdk_screen_get_rgba_colormap(screen); + gtk_widget_set_colormap(mShell, colormap); +#else + GdkVisual *visual = gdk_screen_get_rgba_visual(screen); + gtk_widget_set_visual(mShell, visual); +#endif + } + } + if (aInitData->mNoAutoHide) { // ... but the window manager does not decorate this window, // nor provide a separate taskbar icon. if (mBorderStyle == eBorderStyle_default) { @@ -3815,8 +3836,6 @@ LOG(("nsWindow::NativeResize [%p] %d %d\n", (void *)this, aWidth, aHeight)); - ResizeTransparencyBitmap(aWidth, aHeight); - // clear our resize flag mNeedsResize = false; @@ -3849,8 +3868,6 @@ LOG(("nsWindow::NativeResize [%p] %d %d %d %d\n", (void *)this, aX, aY, aWidth, aHeight)); - ResizeTransparencyBitmap(aWidth, aHeight); - if (mIsTopLevel) { // aX and aY give the position of the window manager frame top-left. gtk_window_move(GTK_WINDOW(mShell), aX, aY); @@ -3871,21 +3888,9 @@ } void -nsWindow::NativeShow (bool aAction) +nsWindow::NativeShow(bool aAction) { if (aAction) { - // GTK wants us to set the window mask before we show the window - // for the first time, or setting the mask later won't work. - // GTK also wants us to NOT set the window mask if we're not really - // going to need it, because GTK won't let us unset the mask properly - // later. - // So, we delay setting the mask until the last moment: when the window - // is shown. - // XXX that may or may not be true for GTK+ 2.x - if (mTransparencyBitmap) { - ApplyTransparencyBitmap(); - } - // unset our flag now that our window has been shown mNeedsShow = false; @@ -3909,6 +3914,8 @@ if (mIsTopLevel) { gtk_widget_hide(GTK_WIDGET(mShell)); gtk_widget_hide(GTK_WIDGET(mContainer)); + + ClearTransparencyBitmap(); // Release some resources } else if (mContainer) { gtk_widget_hide(GTK_WIDGET(mContainer)); @@ -3964,14 +3971,16 @@ nsIntSize nsWindow::GetSafeWindowSize(nsIntSize aSize) { + // The X protocol uses CARD32 for window sizes, but the server (1.11.3) + // reads it as CARD16. Sizes of pixmaps, used for drawing, are (unsigned) + // CARD16 in the protocol, but the server's ProcCreatePixmap returns + // BadAlloc if dimensions cannot be represented by signed shorts. nsIntSize result = aSize; const int32_t kInt16Max = 32767; if (result.width > kInt16Max) { - NS_WARNING("Clamping huge window width"); result.width = kInt16Max; } if (result.height > kInt16Max) { - NS_WARNING("Clamping huge window height"); result.height = kInt16Max; } return result; @@ -3985,6 +3994,24 @@ } void +nsWindow::CleanLayerManagerRecursive(void) { + if (mLayerManager) { + mLayerManager->Destroy(); + mLayerManager = nullptr; + } + + DestroyCompositor(); + + GList* children = gdk_window_peek_children(mGdkWindow); + for (GList* list = children; list; list = list->next) { + nsWindow* window = get_window_for_gdk_window(GDK_WINDOW(list->data)); + if (window) { + window->CleanLayerManagerRecursive(); + } + } +} + +void nsWindow::SetTransparencyMode(nsTransparencyMode aMode) { if (!mShell) { @@ -4007,21 +4034,15 @@ return; if (!isTransparent) { - if (mTransparencyBitmap) { - delete[] mTransparencyBitmap; - mTransparencyBitmap = nullptr; - mTransparencyBitmapWidth = 0; - mTransparencyBitmapHeight = 0; -#if defined(MOZ_WIDGET_GTK2) - gtk_widget_reset_shapes(mShell); -#else - // GTK3 TODO -#endif - } + ClearTransparencyBitmap(); } // else the new default alpha values are "all 1", so we don't // need to change anything yet mIsTransparent = isTransparent; + + // Need to clean our LayerManager up while still alive because + // we don't want to use layers acceleration on shaped windows + CleanLayerManagerRecursive(); } nsTransparencyMode @@ -4181,32 +4202,25 @@ } void -nsWindow::ResizeTransparencyBitmap(int32_t aNewWidth, int32_t aNewHeight) +nsWindow::ResizeTransparencyBitmap() { if (!mTransparencyBitmap) return; - if (aNewWidth == mTransparencyBitmapWidth && - aNewHeight == mTransparencyBitmapHeight) + if (mBounds.width == mTransparencyBitmapWidth && + mBounds.height == mTransparencyBitmapHeight) return; - int32_t newSize = GetBitmapStride(aNewWidth)*aNewHeight; + int32_t newRowBytes = GetBitmapStride(mBounds.width); + int32_t newSize = newRowBytes * mBounds.height; gchar* newBits = new gchar[newSize]; - if (!newBits) { - delete[] mTransparencyBitmap; - mTransparencyBitmap = nullptr; - mTransparencyBitmapWidth = 0; - mTransparencyBitmapHeight = 0; - return; - } - // fill new mask with "opaque", first - memset(newBits, 255, newSize); + // fill new mask with "transparent", first + memset(newBits, 0, newSize); // Now copy the intersection of the old and new areas into the new mask - int32_t copyWidth = NS_MIN(aNewWidth, mTransparencyBitmapWidth); - int32_t copyHeight = NS_MIN(aNewHeight, mTransparencyBitmapHeight); + int32_t copyWidth = NS_MIN(mBounds.width, mTransparencyBitmapWidth); + int32_t copyHeight = NS_MIN(mBounds.height, mTransparencyBitmapHeight); int32_t oldRowBytes = GetBitmapStride(mTransparencyBitmapWidth); - int32_t newRowBytes = GetBitmapStride(aNewWidth); int32_t copyBytes = GetBitmapStride(copyWidth); int32_t i; @@ -4220,8 +4234,8 @@ delete[] mTransparencyBitmap; mTransparencyBitmap = newBits; - mTransparencyBitmapWidth = aNewWidth; - mTransparencyBitmapHeight = aNewHeight; + mTransparencyBitmapWidth = mBounds.width; + mTransparencyBitmapHeight = mBounds.height; } static bool @@ -4234,7 +4248,7 @@ gchar* maskBytes = aMaskBits + y*maskBytesPerRow; uint8_t* alphas = aAlphas; for (x = aRect.x; x < xMax; x++) { - bool newBit = *alphas > 0; + bool newBit = *alphas > 0x7f; alphas++; gchar maskByte = maskBytes[x >> 3]; @@ -4260,7 +4274,7 @@ gchar* maskBytes = aMaskBits + y*maskBytesPerRow; uint8_t* alphas = aAlphas; for (x = aRect.x; x < xMax; x++) { - bool newBit = *alphas > 0; + bool newBit = *alphas > 0x7f; alphas++; gchar mask = 1 << (x & 7); @@ -4320,6 +4334,32 @@ #endif // MOZ_X11 } +void +nsWindow::ClearTransparencyBitmap() +{ + if (!mTransparencyBitmap) + return; + + delete[] mTransparencyBitmap; + mTransparencyBitmap = nullptr; + mTransparencyBitmapWidth = 0; + mTransparencyBitmapHeight = 0; + + if (!mShell) + return; + +#ifdef MOZ_X11 + GdkWindow *window = gtk_widget_get_window(mShell); + if (!window) + return; + + Display* xDisplay = GDK_WINDOW_XDISPLAY(window); + Window xWindow = gdk_x11_window_get_xid(window); + + XShapeCombineMask(xDisplay, xWindow, ShapeBounding, 0, 0, None, ShapeSet); +#endif +} + nsresult nsWindow::UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect, uint8_t* aAlphas, int32_t aStride) @@ -4343,25 +4383,24 @@ if (mTransparencyBitmap == nullptr) { int32_t size = GetBitmapStride(mBounds.width)*mBounds.height; mTransparencyBitmap = new gchar[size]; - if (mTransparencyBitmap == nullptr) - return NS_ERROR_FAILURE; memset(mTransparencyBitmap, 255, size); mTransparencyBitmapWidth = mBounds.width; mTransparencyBitmapHeight = mBounds.height; + } else { + ResizeTransparencyBitmap(); } - NS_ASSERTION(aRect.x >= 0 && aRect.y >= 0 - && aRect.XMost() <= mBounds.width && aRect.YMost() <= mBounds.height, - "Rect is out of window bounds"); + nsIntRect rect; + rect.IntersectRect(aRect, nsIntRect(0, 0, mBounds.width, mBounds.height)); if (!ChangedMaskBits(mTransparencyBitmap, mBounds.width, mBounds.height, - aRect, aAlphas, aStride)) + rect, aAlphas, aStride)) // skip the expensive stuff if the mask bits haven't changed; hopefully // this is the common case return NS_OK; UpdateMaskBits(mTransparencyBitmap, mBounds.width, mBounds.height, - aRect, aAlphas, aStride); + rect, aAlphas, aStride); if (!mNeedsShow) { ApplyTransparencyBitmap(); @@ -4737,7 +4776,7 @@ // if we're dealing with menus, we probably have submenus and // we don't want to rollup if the click is in a parent menu of // the current submenu - uint32_t popupsToRollup = PR_UINT32_MAX; + uint32_t popupsToRollup = UINT32_MAX; if (!aAlwaysRollup) { nsAutoTArray widgetChain; uint32_t sameTypeCount = gRollupListener->GetSubmenuWidgetChain(&widgetChain); @@ -4765,7 +4804,7 @@ // if we've determined that we should still rollup, do it. if (rollup) { gRollupListener->Rollup(popupsToRollup); - if (popupsToRollup == PR_UINT32_MAX) { + if (popupsToRollup == UINT32_MAX) { retVal = true; } } @@ -6144,6 +6183,20 @@ return NS_OK; } +nsIWidget::LayerManager* +nsWindow::GetLayerManager(PLayersChild* aShadowManager, + LayersBackend aBackendHint, + LayerManagerPersistence aPersistence, + bool* aAllowRetaining) +{ + if (!mLayerManager && eTransparencyTransparent == GetTransparencyMode()) { + mLayerManager = CreateBasicLayerManager(); + } + + return nsBaseWidget::GetLayerManager(aShadowManager, aBackendHint, + aPersistence, aAllowRetaining); +} + void nsWindow::ClearCachedResources() { diff -ru firefox-17.0.1/mozilla-release/widget/gtk2/nsWindow.h firefox-18.0/mozilla-release/widget/gtk2/nsWindow.h --- firefox-17.0.1/mozilla-release/widget/gtk2/nsWindow.h 2012-11-28 23:44:34.000000000 -0500 +++ firefox-18.0/mozilla-release/widget/gtk2/nsWindow.h 2013-01-04 18:44:46.000000000 -0500 @@ -281,8 +281,11 @@ NS_IMETHOD OnIMEFocusChange(bool aFocus); NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState); - void ResizeTransparencyBitmap(int32_t aNewWidth, int32_t aNewHeight); - void ApplyTransparencyBitmap(); + // These methods are for toplevel windows only. + void ResizeTransparencyBitmap(); + void ApplyTransparencyBitmap(); + void ClearTransparencyBitmap(); + virtual void SetTransparencyMode(nsTransparencyMode aMode); virtual nsTransparencyMode GetTransparencyMode(); virtual nsresult ConfigureChildren(const nsTArray& aConfigurations); @@ -442,6 +445,14 @@ void DispatchMissedButtonReleases(GdkEventCrossing *aGdkEvent); + // nsBaseWidget + virtual LayerManager* GetLayerManager(PLayersChild* aShadowManager = nullptr, + LayersBackend aBackendHint = mozilla::layers::LAYERS_NONE, + LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT, + bool* aAllowRetaining = nullptr) MOZ_OVERRIDE; + + void CleanLayerManagerRecursive(); + /** * |mIMModule| takes all IME related stuff. *