diff options
Diffstat (limited to 'widget')
35 files changed, 539 insertions, 974 deletions
diff --git a/widget/BasicEvents.h b/widget/BasicEvents.h index da8d819ef..a6228f179 100644 --- a/widget/BasicEvents.h +++ b/widget/BasicEvents.h @@ -585,6 +585,7 @@ public: case eMouseEventClass: mFlags.mComposed = mMessage == eMouseClick || mMessage == eMouseDoubleClick || + mMessage == eMouseAuxClick || mMessage == eMouseDown || mMessage == eMouseUp || mMessage == eMouseEnter || mMessage == eMouseLeave || mMessage == eMouseOver || mMessage == eMouseOut || diff --git a/widget/EventMessageList.h b/widget/EventMessageList.h index 7903f6a26..2eed7e618 100644 --- a/widget/EventMessageList.h +++ b/widget/EventMessageList.h @@ -84,6 +84,7 @@ NS_EVENT_MESSAGE(eMouseEnterIntoWidget) NS_EVENT_MESSAGE(eMouseExitFromWidget) NS_EVENT_MESSAGE(eMouseDoubleClick) NS_EVENT_MESSAGE(eMouseClick) +NS_EVENT_MESSAGE(eMouseAuxClick) // eMouseActivate is fired when the widget is activated by a click. NS_EVENT_MESSAGE(eMouseActivate) NS_EVENT_MESSAGE(eMouseOver) diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index 5c8693957..c937f5099 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -37,10 +37,6 @@ #include "gfxConfig.h" #include "DriverCrashGuard.h" -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#endif - using namespace mozilla::widget; using namespace mozilla; using mozilla::MutexAutoLock; diff --git a/widget/GfxInfoX11.cpp b/widget/GfxInfoX11.cpp index f490bed52..48fc3dbb5 100644 --- a/widget/GfxInfoX11.cpp +++ b/widget/GfxInfoX11.cpp @@ -15,11 +15,6 @@ #include "GfxInfoX11.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" -#endif - namespace mozilla { namespace widget { @@ -28,7 +23,7 @@ NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug) #endif // these global variables will be set when firing the glxtest process -int glxtest_pipe = 0; +int glxtest_pipe = -1; pid_t glxtest_pid = 0; nsresult @@ -55,8 +50,8 @@ GfxInfo::GetData() // to understand this function, see bug 639842. We retrieve the OpenGL driver information in a // separate process to protect against bad drivers. - // if glxtest_pipe == 0, that means that we already read the information - if (!glxtest_pipe) + // if glxtest_pipe == -1, that means that we already read the information + if (glxtest_pipe == -1) return; enum { buf_size = 1024 }; @@ -65,7 +60,7 @@ GfxInfo::GetData() &buf, buf_size-1); // -1 because we'll append a zero close(glxtest_pipe); - glxtest_pipe = 0; + glxtest_pipe = -1; // bytesread < 0 would mean that the above read() call failed. // This should never happen. If it did, the outcome would be to blacklist anyway. @@ -176,9 +171,6 @@ GfxInfo::GetData() mAdapterDescription.Append(nsDependentCString(buf)); mAdapterDescription.Append('\n'); } -#ifdef MOZ_CRASHREPORTER - CrashReporter::AppendAppNotesToCrashReport(mAdapterDescription); -#endif return; } @@ -194,9 +186,6 @@ GfxInfo::GetData() if (mHasTextureFromPixmap) note.AppendLiteral(" -- texture_from_pixmap"); note.Append('\n'); -#ifdef MOZ_CRASHREPORTER - CrashReporter::AppendAppNotesToCrashReport(note); -#endif // determine the major OpenGL version. That's the first integer in the version string. mGLMajorVersion = strtol(mVersion.get(), 0, 10); diff --git a/widget/MouseEvents.h b/widget/MouseEvents.h index 643132618..442ac41e8 100644 --- a/widget/MouseEvents.h +++ b/widget/MouseEvents.h @@ -43,22 +43,31 @@ namespace dom { class WidgetPointerHelper { public: - bool convertToPointer; uint32_t pointerId; uint32_t tiltX; uint32_t tiltY; - bool retargetedByPointerCapture; + uint32_t twist; + float tangentialPressure; + bool convertToPointer; - WidgetPointerHelper() : convertToPointer(true), pointerId(0), tiltX(0), tiltY(0), - retargetedByPointerCapture(false) {} + WidgetPointerHelper() + : pointerId(0) + , tiltX(0) + , tiltY(0) + , twist(0) + , tangentialPressure(0) + , convertToPointer(true) + { + } void AssignPointerHelperData(const WidgetPointerHelper& aEvent) { - convertToPointer = aEvent.convertToPointer; pointerId = aEvent.pointerId; tiltX = aEvent.tiltX; tiltY = aEvent.tiltY; - retargetedByPointerCapture = aEvent.retargetedByPointerCapture; + twist = aEvent.twist; + tangentialPressure = aEvent.tangentialPressure; + convertToPointer = aEvent.convertToPointer; } }; diff --git a/widget/WidgetEventImpl.cpp b/widget/WidgetEventImpl.cpp index 52e2b9b40..7dd292cb0 100644 --- a/widget/WidgetEventImpl.cpp +++ b/widget/WidgetEventImpl.cpp @@ -236,6 +236,7 @@ WidgetEvent::HasMouseEventMessage() const case eMouseUp: case eMouseClick: case eMouseDoubleClick: + case eMouseAuxClick: case eMouseEnterIntoWidget: case eMouseExitFromWidget: case eMouseActivate: diff --git a/widget/android/GfxInfo.cpp b/widget/android/GfxInfo.cpp index af63184a7..181629e96 100644 --- a/widget/android/GfxInfo.cpp +++ b/widget/android/GfxInfo.cpp @@ -15,12 +15,6 @@ #include "nsIWindowWatcher.h" #include "nsServiceManagerUtils.h" -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" -#define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" -#endif - namespace mozilla { namespace widget { @@ -351,21 +345,7 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) void GfxInfo::AddCrashReportAnnotations() { -#if defined(MOZ_CRASHREPORTER) - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"), - mGLStrings->Vendor()); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"), - mGLStrings->Renderer()); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDriverVersion"), - mGLStrings->Version()); - - /* Add an App Note for now so that we get the data immediately. These - * can go away after we store the above in the socorro db */ - nsAutoCString note; - note.AppendPrintf("AdapterDescription: '%s'\n", mAdapterDescription.get()); - - CrashReporter::AppendAppNotesToCrashReport(note); -#endif + /*** STUB ***/ } const nsTArray<GfxDriverInfo>& diff --git a/widget/android/jni/Utils.cpp b/widget/android/jni/Utils.cpp index 145f7e9ea..919588851 100644 --- a/widget/android/jni/Utils.cpp +++ b/widget/android/jni/Utils.cpp @@ -9,10 +9,6 @@ #include "GeneratedJNIWrappers.h" #include "nsAppShell.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - namespace mozilla { namespace jni { @@ -192,12 +188,6 @@ bool ReportException(JNIEnv* aEnv, jthrowable aExc, jstring aStack) { bool result = true; -#ifdef MOZ_CRASHREPORTER - result &= NS_SUCCEEDED(CrashReporter::AnnotateCrashReport( - NS_LITERAL_CSTRING("JavaStackTrace"), - String::Ref::From(aStack)->ToCString())); -#endif // MOZ_CRASHREPORTER - if (sOOMErrorClass && aEnv->IsInstanceOf(aExc, sOOMErrorClass)) { NS_ABORT_OOM(0); // Unknown OOM size } diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp index fefd711d0..09548c27b 100644 --- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -53,11 +53,6 @@ #include "mozilla/Logging.h" #endif -#ifdef MOZ_CRASHREPORTER -#include "nsICrashReporter.h" -#include "nsExceptionHandler.h" -#endif - #include "AndroidAlerts.h" #include "ANRReporter.h" #include "GeckoBatteryManager.h" diff --git a/widget/cocoa/GfxInfo.mm b/widget/cocoa/GfxInfo.mm index 6789ae8b2..74333c514 100644 --- a/widget/cocoa/GfxInfo.mm +++ b/widget/cocoa/GfxInfo.mm @@ -18,12 +18,6 @@ #import <IOKit/IOKitLib.h> #import <Cocoa/Cocoa.h> -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" -#define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" -#endif - using namespace mozilla; using namespace mozilla::widget; @@ -273,33 +267,7 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) void GfxInfo::AddCrashReportAnnotations() { -#if defined(MOZ_CRASHREPORTER) - nsString deviceID, vendorID, driverVersion; - nsAutoCString narrowDeviceID, narrowVendorID, narrowDriverVersion; - - GetAdapterDeviceID(deviceID); - CopyUTF16toUTF8(deviceID, narrowDeviceID); - GetAdapterVendorID(vendorID); - CopyUTF16toUTF8(vendorID, narrowVendorID); - GetAdapterDriverVersion(driverVersion); - CopyUTF16toUTF8(driverVersion, narrowDriverVersion); - - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"), - narrowVendorID); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"), - narrowDeviceID); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDriverVersion"), - narrowDriverVersion); - /* Add an App Note for now so that we get the data immediately. These - * can go away after we store the above in the socorro db */ - nsAutoCString note; - /* AppendPrintf only supports 32 character strings, mrghh. */ - note.Append("AdapterVendorID: "); - note.Append(narrowVendorID); - note.Append(", AdapterDeviceID: "); - note.Append(narrowDeviceID); - CrashReporter::AppendAppNotesToCrashReport(note); -#endif + /*** STUB ***/ } // We don't support checking driver versions on Mac. diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 92ccd8b6c..8f72a81be 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -77,9 +77,6 @@ #include "nsAccessibilityService.h" #include "mozilla/a11y/Platform.h" #endif -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif #include "mozilla/Preferences.h" @@ -5373,31 +5370,14 @@ GetIntegerDeltaForEvent(NSEvent* aEvent) #if !defined(RELEASE_OR_BETA) || defined(DEBUG) if (!Preferences::GetBool("intl.allow-insecure-text-input", false) && mGeckoChild && mTextInputHandler && mTextInputHandler->IsFocused()) { -#ifdef MOZ_CRASHREPORTER - NSWindow* window = [self window]; - NSString* info = [NSString stringWithFormat:@"\nview [%@], window [%@], window is key %i, is fullscreen %i, app is active %i", - self, window, [window isKeyWindow], ([window styleMask] & (1 << 14)) != 0, - [NSApp isActive]]; - nsAutoCString additionalInfo([info UTF8String]); -#endif if (mGeckoChild->GetInputContext().IsPasswordEditor() && !TextInputHandler::IsSecureEventInputEnabled()) { #define CRASH_MESSAGE "A password editor has focus, but not in secure input mode" -#ifdef MOZ_CRASHREPORTER - CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("\nBug 893973: ") + - NS_LITERAL_CSTRING(CRASH_MESSAGE)); - CrashReporter::AppendAppNotesToCrashReport(additionalInfo); -#endif MOZ_CRASH(CRASH_MESSAGE); #undef CRASH_MESSAGE } else if (!mGeckoChild->GetInputContext().IsPasswordEditor() && TextInputHandler::IsSecureEventInputEnabled()) { #define CRASH_MESSAGE "A non-password editor has focus, but in secure input mode" -#ifdef MOZ_CRASHREPORTER - CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("\nBug 893973: ") + - NS_LITERAL_CSTRING(CRASH_MESSAGE)); - CrashReporter::AppendAppNotesToCrashReport(additionalInfo); -#endif MOZ_CRASH(CRASH_MESSAGE); #undef CRASH_MESSAGE } diff --git a/widget/gtk/WidgetStyleCache.cpp b/widget/gtk/WidgetStyleCache.cpp index fd099681f..f35a451aa 100644 --- a/widget/gtk/WidgetStyleCache.cpp +++ b/widget/gtk/WidgetStyleCache.cpp @@ -434,15 +434,6 @@ CreateScrolledWindowWidget() } static GtkWidget* -CreateTextViewWidget() -{ - GtkWidget* widget = gtk_text_view_new(); - gtk_container_add(GTK_CONTAINER(GetWidget(MOZ_GTK_SCROLLED_WINDOW)), - widget); - return widget; -} - -static GtkWidget* CreateMenuSeparatorWidget() { GtkWidget* widget = gtk_separator_menu_item_new(); @@ -591,8 +582,6 @@ CreateWidget(WidgetNodeType aWidgetType) return CreateEntryWidget(); case MOZ_GTK_SCROLLED_WINDOW: return CreateScrolledWindowWidget(); - case MOZ_GTK_TEXT_VIEW: - return CreateTextViewWidget(); case MOZ_GTK_TREEVIEW: return CreateTreeViewWidget(); case MOZ_GTK_TREE_HEADER_CELL: @@ -637,6 +626,24 @@ GetWidget(WidgetNodeType aWidgetType) GtkWidget* widget = sWidgetStorage[aWidgetType]; if (!widget) { widget = CreateWidget(aWidgetType); + // Some widgets (MOZ_GTK_COMBOBOX_SEPARATOR for instance) may not be + // available or implemented. + if (!widget) + return nullptr; + // In GTK versions prior to 3.18, automatic invalidation of style contexts + // for widgets was delayed until the next resize event. Gecko however, + // typically uses the style context before the resize event runs and so an + // explicit invalidation may be required. This is necessary if a style + // property was retrieved before all changes were made to the style + // context. One such situation is where gtk_button_construct_child() + // retrieves the style property "image-spacing" during construction of the + // GtkButton, before its parent is set to provide inheritance of ancestor + // properties. More recent GTK versions do not need this, but do not + // re-resolve until required and so invalidation does not trigger + // unnecessary resolution in general. + GtkStyleContext* style = gtk_widget_get_style_context(widget); + gtk_style_context_invalidate(style); + sWidgetStorage[aWidgetType] = widget; } return widget; @@ -725,6 +732,21 @@ CreateCSSNode(const char* aName, GtkStyleContext* aParentStyle, GType aType) gtk_style_context_set_parent(context, aParentStyle); gtk_widget_path_unref(path); + // In GTK 3.4, gtk_render_* functions use |theming_engine| on the style + // context without ensuring any style resolution sets it appropriately + // in style_data_lookup(). e.g. + // https://git.gnome.org/browse/gtk+/tree/gtk/gtkstylecontext.c?h=3.4.4#n3847 + // + // That can result in incorrect drawing on first draw. To work around this, + // force a style look-up to set |theming_engine|. It is sufficient to do + // this only on context creation, instead of after every modification to the + // context, because themes typically (Ambiance and oxygen-gtk, at least) set + // the "engine" property with the '*' selector. + if (GTK_MAJOR_VERSION == 3 && gtk_get_minor_version() < 6) { + GdkRGBA unused; + gtk_style_context_get_color(context, GTK_STATE_FLAG_NORMAL, &unused); + } + return context; } @@ -747,13 +769,38 @@ GetWidgetRootStyle(WidgetNodeType aNodeType) case MOZ_GTK_IMAGEMENUITEM: style = CreateStyleForWidget(gtk_image_menu_item_new(), MOZ_GTK_MENUPOPUP); break; - case MOZ_GTK_CHECKMENUITEM_CONTAINER: + case MOZ_GTK_CHECKMENUITEM: style = CreateStyleForWidget(gtk_check_menu_item_new(), MOZ_GTK_MENUPOPUP); break; - case MOZ_GTK_RADIOMENUITEM_CONTAINER: + case MOZ_GTK_RADIOMENUITEM: style = CreateStyleForWidget(gtk_radio_menu_item_new(nullptr), MOZ_GTK_MENUPOPUP); break; + case MOZ_GTK_TEXT_VIEW: + style = CreateStyleForWidget(gtk_text_view_new(), + MOZ_GTK_SCROLLED_WINDOW); + break; + case MOZ_GTK_TOOLTIP: + if (gtk_check_version(3, 20, 0) != nullptr) { + // The tooltip style class is added first in CreateTooltipWidget() + // and transfered to style in CreateStyleForWidget(). + GtkWidget* tooltipWindow = CreateTooltipWidget(); + style = CreateStyleForWidget(tooltipWindow, nullptr); + gtk_widget_destroy(tooltipWindow); // Release GtkWindow self-reference. + } else { + // We create this from the path because GtkTooltipWindow is not public. + style = CreateCSSNode("tooltip", nullptr, GTK_TYPE_TOOLTIP); + gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND); + } + break; + case MOZ_GTK_TOOLTIP_BOX: + style = CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0), + MOZ_GTK_TOOLTIP); + break; + case MOZ_GTK_TOOLTIP_BOX_LABEL: + style = CreateStyleForWidget(gtk_label_new(nullptr), + MOZ_GTK_TOOLTIP_BOX); + break; default: GtkWidget* widget = GetWidget(aNodeType); MOZ_ASSERT(widget); @@ -827,13 +874,13 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType) style = CreateChildCSSNode(GTK_STYLE_CLASS_CHECK, MOZ_GTK_CHECKBUTTON_CONTAINER); break; - case MOZ_GTK_RADIOMENUITEM: + case MOZ_GTK_RADIOMENUITEM_INDICATOR: style = CreateChildCSSNode(GTK_STYLE_CLASS_RADIO, - MOZ_GTK_RADIOMENUITEM_CONTAINER); + MOZ_GTK_RADIOMENUITEM); break; - case MOZ_GTK_CHECKMENUITEM: + case MOZ_GTK_CHECKMENUITEM_INDICATOR: style = CreateChildCSSNode(GTK_STYLE_CLASS_CHECK, - MOZ_GTK_CHECKMENUITEM_CONTAINER); + MOZ_GTK_CHECKMENUITEM); break; case MOZ_GTK_PROGRESS_TROUGH: /* Progress bar background (trough) */ @@ -844,11 +891,6 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType) style = CreateChildCSSNode("progress", MOZ_GTK_PROGRESS_TROUGH); break; - case MOZ_GTK_TOOLTIP: - // We create this from the path because GtkTooltipWindow is not public. - style = CreateCSSNode("tooltip", nullptr, GTK_TYPE_TOOLTIP); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND); - break; case MOZ_GTK_GRIPPER: // TODO - create from CSS node return GetWidgetStyleWithClass(MOZ_GTK_GRIPPER, @@ -865,10 +907,28 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType) // TODO - create from CSS node return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW, GTK_STYLE_CLASS_FRAME); - case MOZ_GTK_TEXT_VIEW: - // TODO - create from CSS node - return GetWidgetStyleWithClass(MOZ_GTK_TEXT_VIEW, - GTK_STYLE_CLASS_VIEW); + case MOZ_GTK_TEXT_VIEW_TEXT: + case MOZ_GTK_RESIZER: + style = CreateChildCSSNode("text", MOZ_GTK_TEXT_VIEW); + if (aNodeType == MOZ_GTK_RESIZER) { + // The "grip" class provides the correct builtin icon from + // gtk_render_handle(). The icon is drawn with shaded variants of + // the background color, and so a transparent background would lead to + // a transparent resizer. gtk_render_handle() also uses the + // background color to draw a background, and so this style otherwise + // matches what is used in GtkTextView to match the background with + // textarea elements. + GdkRGBA color; + gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, + &color); + if (color.alpha == 0.0) { + g_object_unref(style); + style = CreateStyleForWidget(gtk_text_view_new(), + MOZ_GTK_SCROLLED_WINDOW); + } + gtk_style_context_add_class(style, GTK_STYLE_CLASS_GRIP); + } + break; case MOZ_GTK_FRAME_BORDER: style = CreateChildCSSNode("border", MOZ_GTK_FRAME); break; @@ -971,27 +1031,20 @@ GetWidgetStyleInternal(WidgetNodeType aNodeType) case MOZ_GTK_CHECKBUTTON: return GetWidgetStyleWithClass(MOZ_GTK_CHECKBUTTON_CONTAINER, GTK_STYLE_CLASS_CHECK); - case MOZ_GTK_RADIOMENUITEM: - return GetWidgetStyleWithClass(MOZ_GTK_RADIOMENUITEM_CONTAINER, + case MOZ_GTK_RADIOMENUITEM_INDICATOR: + return GetWidgetStyleWithClass(MOZ_GTK_RADIOMENUITEM, GTK_STYLE_CLASS_RADIO); - case MOZ_GTK_CHECKMENUITEM: - return GetWidgetStyleWithClass(MOZ_GTK_CHECKMENUITEM_CONTAINER, + case MOZ_GTK_CHECKMENUITEM_INDICATOR: + return GetWidgetStyleWithClass(MOZ_GTK_CHECKMENUITEM, GTK_STYLE_CLASS_CHECK); case MOZ_GTK_PROGRESS_TROUGH: return GetWidgetStyleWithClass(MOZ_GTK_PROGRESSBAR, GTK_STYLE_CLASS_TROUGH); - case MOZ_GTK_TOOLTIP: { - GtkStyleContext* style = sStyleStorage[aNodeType]; - if (style) - return style; - - // The tooltip style class is added first in CreateTooltipWidget() so - // that gtk_widget_path_append_for_widget() in CreateStyleForWidget() - // will find it. - GtkWidget* tooltipWindow = CreateTooltipWidget(); - style = CreateStyleForWidget(tooltipWindow, nullptr); - gtk_widget_destroy(tooltipWindow); // Release GtkWindow self-reference. - sStyleStorage[aNodeType] = style; + case MOZ_GTK_PROGRESS_CHUNK: { + GtkStyleContext* style = + GetWidgetStyleWithClass(MOZ_GTK_PROGRESSBAR, + GTK_STYLE_CLASS_PROGRESSBAR); + gtk_style_context_remove_class(style, GTK_STYLE_CLASS_TROUGH); return style; } case MOZ_GTK_GRIPPER: @@ -1006,9 +1059,25 @@ GetWidgetStyleInternal(WidgetNodeType aNodeType) case MOZ_GTK_SCROLLED_WINDOW: return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW, GTK_STYLE_CLASS_FRAME); - case MOZ_GTK_TEXT_VIEW: - return GetWidgetStyleWithClass(MOZ_GTK_TEXT_VIEW, - GTK_STYLE_CLASS_VIEW); + case MOZ_GTK_TEXT_VIEW_TEXT: + case MOZ_GTK_RESIZER: { + // GTK versions prior to 3.20 do not have the view class on the root + // node, but add this to determine the background for the text window. + GtkStyleContext* style = + GetWidgetStyleWithClass(MOZ_GTK_TEXT_VIEW, GTK_STYLE_CLASS_VIEW); + if (aNodeType == MOZ_GTK_RESIZER) { + // The "grip" class provides the correct builtin icon from + // gtk_render_handle(). The icon is drawn with shaded variants of + // the background color, and so a transparent background would lead to + // a transparent resizer. gtk_render_handle() also uses the + // background color to draw a background, and so this style otherwise + // matches MOZ_GTK_TEXT_VIEW_TEXT to match the background with + // textarea elements. GtkTextView creates a separate text window and + // so the background should not be transparent. + gtk_style_context_add_class(style, GTK_STYLE_CLASS_GRIP); + } + return style; + } case MOZ_GTK_FRAME_BORDER: return GetWidgetRootStyle(MOZ_GTK_FRAME); case MOZ_GTK_TREEVIEW_VIEW: diff --git a/widget/gtk/gtk3drawing.cpp b/widget/gtk/gtk3drawing.cpp index fb95b4cc4..c592fa51c 100644 --- a/widget/gtk/gtk3drawing.cpp +++ b/widget/gtk/gtk3drawing.cpp @@ -36,6 +36,10 @@ static gboolean is_initialized; static gint moz_gtk_get_tab_thickness(GtkStyleContext *style); +static gint +moz_gtk_menu_item_paint(WidgetNodeType widget, cairo_t *cr, GdkRectangle* rect, + GtkWidgetState* state, GtkTextDirection direction); + // GetStateFlagsFromGtkWidgetState() can be safely used for the specific // GtkWidgets that set both prelight and active flags. For other widgets, // either the GtkStateFlags or Gecko's GtkWidgetState need to be carefully @@ -167,7 +171,7 @@ moz_gtk_menuitem_get_horizontal_padding(gint* horizontal_padding) gint moz_gtk_checkmenuitem_get_horizontal_padding(gint* horizontal_padding) { - GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_CHECKMENUITEM_CONTAINER); + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_CHECKMENUITEM); gtk_style_context_get_style(style, "horizontal-padding", horizontal_padding, nullptr); @@ -463,7 +467,7 @@ moz_gtk_get_widget_min_size(WidgetNodeType aGtkWidgetType, int* width, } static void -moz_gtk_rectangle_inset(GdkRectangle* rect, GtkBorder& aBorder) +Inset(GdkRectangle* rect, GtkBorder& aBorder) { MOZ_ASSERT(rect); rect->x += aBorder.left; @@ -472,17 +476,29 @@ moz_gtk_rectangle_inset(GdkRectangle* rect, GtkBorder& aBorder) rect->height -= aBorder.top + aBorder.bottom; } -/* Subtracting margin is used to inset drawing of element which can have margins, - * like scrollbar, scrollbar's trough, thumb and scrollbar's button */ +// Inset a rectangle by the margins specified in a style context. static void -moz_gtk_subtract_margin(GtkStyleContext* style, GdkRectangle* rect) +InsetByMargin(GdkRectangle* rect, GtkStyleContext* style) { MOZ_ASSERT(rect); GtkBorder margin; gtk_style_context_get_margin(style, gtk_style_context_get_state(style), &margin); - moz_gtk_rectangle_inset(rect, margin); + Inset(rect, margin); +} + +// Inset a rectangle by the border and padding specified in a style context. +static void +InsetByBorderPadding(GdkRectangle* rect, GtkStyleContext* style) +{ + GtkStateFlags state = gtk_style_context_get_state(style); + GtkBorder padding, border; + + gtk_style_context_get_padding(style, state, &padding); + Inset(rect, padding); + gtk_style_context_get_border(style, state, &border); + Inset(rect, border); } static gint @@ -528,7 +544,7 @@ moz_gtk_scrollbar_button_paint(cairo_t *cr, const GdkRectangle* aRect, if (gtk_check_version(3,20,0) == nullptr) { // The "trough-border" is not used since GTK 3.20. The stepper margin // box occupies the full width of the "contents" gadget content box. - moz_gtk_subtract_margin(style, &rect); + InsetByMargin(&rect, style); } else { // Scrollbar button has to be inset by trough_border because its DOM // element is filling width of vertical scrollbar's track (or height @@ -601,7 +617,7 @@ moz_gtk_draw_styled_frame(GtkStyleContext* style, cairo_t *cr, { GdkRectangle rect = *aRect; if (gtk_check_version(3, 6, 0) == nullptr) { - moz_gtk_subtract_margin(style, &rect); + InsetByMargin(&rect, style); } gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); gtk_render_frame(style, cr, rect.x, rect.y, rect.width, rect.height); @@ -656,7 +672,7 @@ moz_gtk_scrollbar_thumb_paint(WidgetNodeType widget, GdkRectangle rect = *aRect; GtkStyleContext* style = ClaimStyleContext(widget, direction, state_flags); - moz_gtk_subtract_margin(style, &rect); + InsetByMargin(&rect, style); gtk_render_slider(style, cr, rect.x, @@ -857,7 +873,7 @@ moz_gtk_entry_paint(cairo_t *cr, GdkRectangle* rect, } static gint -moz_gtk_text_view_paint(cairo_t *cr, GdkRectangle* rect, +moz_gtk_text_view_paint(cairo_t *cr, GdkRectangle* aRect, GtkWidgetState* state, GtkTextDirection direction) { @@ -874,24 +890,24 @@ moz_gtk_text_view_paint(cairo_t *cr, GdkRectangle* rect, GtkStyleContext* style_frame = ClaimStyleContext(MOZ_GTK_SCROLLED_WINDOW, direction, state_flags); - gtk_render_frame(style_frame, cr, rect->x, rect->y, rect->width, rect->height); + gtk_render_frame(style_frame, cr, + aRect->x, aRect->y, aRect->width, aRect->height); + + GdkRectangle rect = *aRect; + InsetByBorderPadding(&rect, style_frame); - GtkBorder border, padding; - gtk_style_context_get_border(style_frame, state_flags, &border); - gtk_style_context_get_padding(style_frame, state_flags, &padding); ReleaseStyleContext(style_frame); GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW, direction, state_flags); - - gint xthickness = border.left + padding.left; - gint ythickness = border.top + padding.top; - - gtk_render_background(style, cr, - rect->x + xthickness, rect->y + ythickness, - rect->width - 2 * xthickness, - rect->height - 2 * ythickness); - + gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); + ReleaseStyleContext(style); + // There is a separate "text" window, which usually provides the + // background behind the text. However, this is transparent in Ambiance + // for GTK 3.20, in which case the MOZ_GTK_TEXT_VIEW background is + // visible. + style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT, direction, state_flags); + gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; @@ -1013,8 +1029,7 @@ moz_gtk_treeview_expander_paint(cairo_t *cr, GdkRectangle* rect, return MOZ_GTK_SUCCESS; } -/* See gtk_separator_draw() for reference. -*/ +/* See gtk_separator_draw() for reference. */ static gint moz_gtk_combo_box_paint(cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state, @@ -1283,6 +1298,7 @@ moz_gtk_tooltip_paint(cairo_t *cr, const GdkRectangle* aRect, GdkRectangle rect = *aRect; gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); gtk_render_frame(style, cr, rect.x, rect.y, rect.width, rect.height); + ReleaseStyleContext(style); // Horizontal Box drawing // @@ -1292,33 +1308,26 @@ moz_gtk_tooltip_paint(cairo_t *cr, const GdkRectangle* aRect, // 6px margin. // For drawing Horizontal Box we have to inset drawing area by that 6px // plus its CSS margin. - GtkStyleContext* boxStyle = - CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0), style); + GtkStyleContext* boxStyle = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX, direction); rect.x += 6; rect.y += 6; rect.width -= 12; rect.height -= 12; - moz_gtk_subtract_margin(boxStyle, &rect); + InsetByMargin(&rect, boxStyle); gtk_render_background(boxStyle, cr, rect.x, rect.y, rect.width, rect.height); gtk_render_frame(boxStyle, cr, rect.x, rect.y, rect.width, rect.height); // Label drawing - GtkBorder padding, border; - gtk_style_context_get_padding(boxStyle, GTK_STATE_FLAG_NORMAL, &padding); - moz_gtk_rectangle_inset(&rect, padding); - gtk_style_context_get_border(boxStyle, GTK_STATE_FLAG_NORMAL, &border); - moz_gtk_rectangle_inset(&rect, border); + InsetByBorderPadding(&rect, boxStyle); + ReleaseStyleContext(boxStyle); GtkStyleContext* labelStyle = - CreateStyleForWidget(gtk_label_new(nullptr), boxStyle); + ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL, direction); moz_gtk_draw_styled_frame(labelStyle, cr, &rect, false); - g_object_unref(labelStyle); - - g_object_unref(boxStyle); + ReleaseStyleContext(labelStyle); - ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } @@ -1327,17 +1336,9 @@ moz_gtk_resizer_paint(cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state, GtkTextDirection direction) { - GtkStyleContext* style; - - // gtk_render_handle() draws a background, so use GtkTextView and its - // GTK_STYLE_CLASS_VIEW to match the background with textarea elements. - // The resizer is drawn with shaded variants of the background color, and - // so a transparent background would lead to a transparent resizer. - style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW, GTK_TEXT_DIR_LTR, - GetStateFlagsFromGtkWidgetState(state)); - // TODO - we need to save/restore style when gtk 3.20 CSS node path - // is used - gtk_style_context_add_class(style, GTK_STYLE_CLASS_GRIP); + GtkStyleContext* style = + ClaimStyleContext(MOZ_GTK_RESIZER, GTK_TEXT_DIR_LTR, + GetStateFlagsFromGtkWidgetState(state)); // Workaround unico not respecting the text direction for resizers. // See bug 1174248. @@ -1384,17 +1385,8 @@ moz_gtk_progress_chunk_paint(cairo_t *cr, GdkRectangle* rect, GtkTextDirection direction, WidgetNodeType widget) { - GtkStyleContext* style; - - if (gtk_check_version(3, 20, 0) != nullptr) { - /* Ask for MOZ_GTK_PROGRESS_TROUGH instead of MOZ_GTK_PROGRESSBAR - * because ClaimStyleContext() saves/restores that style */ - style = ClaimStyleContext(MOZ_GTK_PROGRESS_TROUGH, direction); - gtk_style_context_remove_class(style, GTK_STYLE_CLASS_TROUGH); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_PROGRESSBAR); - } else { - style = ClaimStyleContext(MOZ_GTK_PROGRESS_CHUNK, direction); - } + GtkStyleContext* style = + ClaimStyleContext(MOZ_GTK_PROGRESS_CHUNK, direction); if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE || widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) { @@ -1778,6 +1770,13 @@ static gint moz_gtk_menu_separator_paint(cairo_t *cr, GdkRectangle* rect, GtkTextDirection direction) { + GtkWidgetState defaultState = { 0 }; + moz_gtk_menu_item_paint(MOZ_GTK_MENUSEPARATOR, cr, rect, + &defaultState, direction); + + if (gtk_get_minor_version() >= 20) + return MOZ_GTK_SUCCESS; + GtkStyleContext* style; gboolean wide_separators; gint separator_height; @@ -1825,36 +1824,39 @@ moz_gtk_menu_item_paint(WidgetNodeType widget, cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state, GtkTextDirection direction) { gint x, y, w, h; + guint minorVersion = gtk_get_minor_version(); + GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state); - if (state->inHover && !state->disabled) { - GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state); - GtkStyleContext* style = - ClaimStyleContext(widget, direction, state_flags); - - bool pre_3_6 = gtk_check_version(3, 6, 0) != nullptr; - if (pre_3_6) { - // GTK+ 3.4 saves the style context and adds the menubar class to - // menubar children, but does each of these only when drawing, not - // during layout. - gtk_style_context_save(style); - if (widget == MOZ_GTK_MENUBARITEM) { - gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR); - } + // GTK versions prior to 3.8 render the background and frame only when not + // a separator and in hover prelight. + if (minorVersion < 8 && (widget == MOZ_GTK_MENUSEPARATOR || + !(state_flags & GTK_STATE_FLAG_PRELIGHT))) + return MOZ_GTK_SUCCESS; + + GtkStyleContext* style = ClaimStyleContext(widget, direction, state_flags); + + if (minorVersion < 6) { + // GTK+ 3.4 saves the style context and adds the menubar class to + // menubar children, but does each of these only when drawing, not + // during layout. + gtk_style_context_save(style); + if (widget == MOZ_GTK_MENUBARITEM) { + gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR); } + } - x = rect->x; - y = rect->y; - w = rect->width; - h = rect->height; + x = rect->x; + y = rect->y; + w = rect->width; + h = rect->height; - gtk_render_background(style, cr, x, y, w, h); - gtk_render_frame(style, cr, x, y, w, h); + gtk_render_background(style, cr, x, y, w, h); + gtk_render_frame(style, cr, x, y, w, h); - if (pre_3_6) { - gtk_style_context_restore(style); - } - ReleaseStyleContext(style); + if (minorVersion < 6) { + gtk_style_context_restore(style); } + ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } @@ -1874,16 +1876,16 @@ moz_gtk_menu_arrow_paint(cairo_t *cr, GdkRectangle* rect, return MOZ_GTK_SUCCESS; } -// See gtk_real_check_menu_item_draw_indicator() for reference. +// For reference, see gtk_check_menu_item_size_allocate() in GTK versions after +// 3.20 and gtk_real_check_menu_item_draw_indicator() in earlier versions. static gint -moz_gtk_check_menu_item_paint(cairo_t *cr, GdkRectangle* rect, +moz_gtk_check_menu_item_paint(WidgetNodeType widgetType, + cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state, - gboolean checked, gboolean isradio, - GtkTextDirection direction) + gboolean checked, GtkTextDirection direction) { GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state); GtkStyleContext* style; - GtkBorder padding; gint indicator_size, horizontal_padding; gint x, y; @@ -1893,35 +1895,44 @@ moz_gtk_check_menu_item_paint(cairo_t *cr, GdkRectangle* rect, state_flags = static_cast<GtkStateFlags>(state_flags|checkbox_check_state); } - style = ClaimStyleContext(isradio ? MOZ_GTK_RADIOMENUITEM_CONTAINER : - MOZ_GTK_CHECKMENUITEM_CONTAINER, - direction); + bool pre_3_20 = gtk_get_minor_version() < 20; + gint offset; + style = ClaimStyleContext(widgetType, direction); gtk_style_context_get_style(style, "indicator-size", &indicator_size, "horizontal-padding", &horizontal_padding, NULL); + if (pre_3_20) { + GtkBorder padding; + gtk_style_context_get_padding(style, state_flags, &padding); + offset = horizontal_padding + padding.left + 2; + } else { + GdkRectangle r = { 0 }; + InsetByMargin(&r, style); + InsetByBorderPadding(&r, style); + offset = r.x; + } ReleaseStyleContext(style); - style = ClaimStyleContext(isradio ? MOZ_GTK_RADIOMENUITEM : - MOZ_GTK_CHECKMENUITEM, - direction, state_flags); - gtk_style_context_get_padding(style, state_flags, &padding); - gint offset = padding.left + 2; + bool isRadio = (widgetType == MOZ_GTK_RADIOMENUITEM); + WidgetNodeType indicatorType = isRadio ? MOZ_GTK_RADIOMENUITEM_INDICATOR + : MOZ_GTK_CHECKMENUITEM_INDICATOR; + style = ClaimStyleContext(indicatorType, direction, state_flags); if (direction == GTK_TEXT_DIR_RTL) { - x = rect->width - indicator_size - offset - horizontal_padding; + x = rect->width - indicator_size - offset; } else { - x = rect->x + offset + horizontal_padding; + x = rect->x + offset; } y = rect->y + (rect->height - indicator_size) / 2; - if (gtk_check_version(3, 20, 0) == nullptr) { + if (!pre_3_20) { gtk_render_background(style, cr, x, y, indicator_size, indicator_size); gtk_render_frame(style, cr, x, y, indicator_size, indicator_size); } - if (isradio) { + if (isRadio) { gtk_render_option(style, cr, x, y, indicator_size, indicator_size); } else { gtk_render_check(style, cr, x, y, indicator_size, indicator_size); @@ -2166,12 +2177,15 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top, { // Bug 1274143 for MOZ_GTK_MENUBARITEM WidgetNodeType type = - widget == MOZ_GTK_MENUBARITEM || widget == MOZ_GTK_MENUITEM ? - MOZ_GTK_MENUITEM : MOZ_GTK_CHECKMENUITEM_CONTAINER; + widget == MOZ_GTK_MENUBARITEM ? MOZ_GTK_MENUITEM : widget; style = ClaimStyleContext(type); - moz_gtk_add_style_padding(style, left, top, right, bottom); - + if (gtk_get_minor_version() < 20) { + moz_gtk_add_style_padding(style, left, top, right, bottom); + } else { + moz_gtk_add_margin_border_padding(style, + left, top, right, bottom); + } ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } @@ -2180,7 +2194,6 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top, break; case MOZ_GTK_TOOLTIP: { - style = ClaimStyleContext(MOZ_GTK_TOOLTIP); // In GTK 3 there are 6 pixels of additional margin around the box. // See details there: // https://github.com/GNOME/gtk/blob/5ea69a136bd7e4970b3a800390e20314665aaed2/gtk/ui/gtktooltipwindow.ui#L11 @@ -2189,21 +2202,16 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top, // We also need to add margin/padding/borders from Tooltip content. // Tooltip contains horizontal box, where icon and label is put. // We ignore icon as long as we don't have support for it. - GtkStyleContext* boxStyle = - CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0), - style); + GtkStyleContext* boxStyle = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX); moz_gtk_add_margin_border_padding(boxStyle, left, top, right, bottom); + ReleaseStyleContext(boxStyle); - GtkStyleContext* labelStyle = - CreateStyleForWidget(gtk_label_new(nullptr), boxStyle); + GtkStyleContext* labelStyle = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL); moz_gtk_add_margin_border_padding(labelStyle, left, top, right, bottom); + ReleaseStyleContext(labelStyle); - g_object_unref(labelStyle); - g_object_unref(boxStyle); - - ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } case MOZ_GTK_SCROLLBAR_VERTICAL: @@ -2492,11 +2500,11 @@ void moz_gtk_get_scale_metrics(GtkOrientation orient, gint* scale_width, gint* scale_height) { - WidgetNodeType widget = (orient == GTK_ORIENTATION_HORIZONTAL) ? - MOZ_GTK_SCALE_HORIZONTAL : - MOZ_GTK_SCALE_VERTICAL; - if (gtk_check_version(3, 20, 0) != nullptr) { + WidgetNodeType widget = (orient == GTK_ORIENTATION_HORIZONTAL) ? + MOZ_GTK_SCALE_HORIZONTAL : + MOZ_GTK_SCALE_VERTICAL; + gint thumb_length, thumb_height, trough_border; moz_gtk_get_scalethumb_metrics(orient, &thumb_length, &thumb_height); @@ -2512,12 +2520,10 @@ moz_gtk_get_scale_metrics(GtkOrientation orient, gint* scale_width, } ReleaseStyleContext(style); } else { - GtkStyleContext* style = ClaimStyleContext(widget); - gtk_style_context_get(style, gtk_style_context_get_state(style), - "min-width", scale_width, - "min-height", scale_height, - nullptr); - ReleaseStyleContext(style); + WidgetNodeType widget = (orient == GTK_ORIENTATION_HORIZONTAL) ? + MOZ_GTK_SCALE_TROUGH_HORIZONTAL : + MOZ_GTK_SCALE_TROUGH_VERTICAL; + moz_gtk_get_widget_min_size(widget, scale_width, scale_height); } } @@ -2540,10 +2546,27 @@ moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* MOZ_GTK_SCALE_THUMB_HORIZONTAL: MOZ_GTK_SCALE_THUMB_VERTICAL; GtkStyleContext* style = ClaimStyleContext(widget); - gtk_style_context_get(style, gtk_style_context_get_state(style), - "min-width", thumb_length, - "min-height", thumb_height, + gint min_width, min_height; + GtkStateFlags state = gtk_style_context_get_state(style); + gtk_style_context_get(style, state, + "min-width", &min_width, + "min-height", &min_height, nullptr); + GtkBorder margin; + gtk_style_context_get_margin(style, state, &margin); + gint margin_width = margin.left + margin.right; + gint margin_height = margin.top + margin.bottom; + + // Negative margin of slider element also determines its minimal size + // so use bigger of those two values. + if (min_width < -margin_width) + min_width = -margin_width; + if (min_height < -margin_height) + min_height = -margin_height; + + *thumb_length = min_width; + *thumb_height = min_height; + ReleaseStyleContext(style); } @@ -2786,10 +2809,8 @@ moz_gtk_widget_paint(WidgetNodeType widget, cairo_t *cr, break; case MOZ_GTK_CHECKMENUITEM: case MOZ_GTK_RADIOMENUITEM: - return moz_gtk_check_menu_item_paint(cr, rect, state, - (gboolean) flags, - (widget == MOZ_GTK_RADIOMENUITEM), - direction); + return moz_gtk_check_menu_item_paint(widget, cr, rect, state, + (gboolean) flags, direction); break; case MOZ_GTK_SPLITTER_HORIZONTAL: return moz_gtk_vpaned_paint(cr, rect, state); diff --git a/widget/gtk/gtkdrawing.h b/widget/gtk/gtkdrawing.h index 9bbfdefe9..7db5db043 100644 --- a/widget/gtk/gtkdrawing.h +++ b/widget/gtk/gtkdrawing.h @@ -145,8 +145,11 @@ typedef enum { MOZ_GTK_ENTRY, /* Paints a GtkExpander. */ MOZ_GTK_EXPANDER, - /* Paints a GtkTextView. */ + /* Paints a GtkTextView or gets the style context corresponding to the + root node of a GtkTextView. */ MOZ_GTK_TEXT_VIEW, + /* The "text" window or node of a GtkTextView */ + MOZ_GTK_TEXT_VIEW_TEXT, /* Paints a GtkOptionMenu. */ MOZ_GTK_DROPDOWN, /* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */ @@ -160,11 +163,15 @@ typedef enum { MOZ_GTK_TOOLBAR_SEPARATOR, /* Paints a GtkToolTip */ MOZ_GTK_TOOLTIP, + /* Paints a GtkBox from GtkToolTip */ + MOZ_GTK_TOOLTIP_BOX, + /* Paints a GtkLabel of GtkToolTip */ + MOZ_GTK_TOOLTIP_BOX_LABEL, /* Paints a GtkFrame (e.g. a status bar panel). */ MOZ_GTK_FRAME, /* Paints the border of a GtkFrame */ MOZ_GTK_FRAME_BORDER, - /* Paints a resize grip for a GtkWindow */ + /* Paints a resize grip for a GtkTextView */ MOZ_GTK_RESIZER, /* Paints a GtkProgressBar. */ MOZ_GTK_PROGRESSBAR, @@ -211,10 +218,13 @@ typedef enum { /* Paints items of popup menus. */ MOZ_GTK_MENUITEM, MOZ_GTK_IMAGEMENUITEM, - MOZ_GTK_CHECKMENUITEM_CONTAINER, - MOZ_GTK_RADIOMENUITEM_CONTAINER, + /* Paints a menuitem with check indicator, or the gets the style context for + a menuitem that contains a checkbox. */ MOZ_GTK_CHECKMENUITEM, + /* Gets the style context for a checkbox in a check menuitem. */ + MOZ_GTK_CHECKMENUITEM_INDICATOR, MOZ_GTK_RADIOMENUITEM, + MOZ_GTK_RADIOMENUITEM_INDICATOR, MOZ_GTK_MENUSEPARATOR, /* GtkVPaned base class */ MOZ_GTK_SPLITTER_HORIZONTAL, diff --git a/widget/gtk/nsLookAndFeel.cpp b/widget/gtk/nsLookAndFeel.cpp index 53430dfbb..d2b82e495 100644 --- a/widget/gtk/nsLookAndFeel.cpp +++ b/widget/gtk/nsLookAndFeel.cpp @@ -47,9 +47,6 @@ nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel(), #if (MOZ_WIDGET_GTK == 2) mStyle(nullptr), -#else - mBackgroundStyle(nullptr), - mButtonStyle(nullptr), #endif mDefaultFontCached(false), mButtonFontCached(false), mFieldFontCached(false), mMenuFontCached(false) @@ -61,13 +58,27 @@ nsLookAndFeel::~nsLookAndFeel() { #if (MOZ_WIDGET_GTK == 2) g_object_unref(mStyle); -#else - g_object_unref(mBackgroundStyle); - g_object_unref(mButtonStyle); #endif } #if MOZ_WIDGET_GTK != 2 +// Modifies color |*aDest| as if a pattern of color |aSource| was painted with +// CAIRO_OPERATOR_OVER to a surface with color |*aDest|. +static void +ApplyColorOver(const GdkRGBA& aSource, GdkRGBA* aDest) { + gdouble sourceCoef = aSource.alpha; + gdouble destCoef = aDest->alpha * (1.0 - sourceCoef); + gdouble resultAlpha = sourceCoef + destCoef; + if (resultAlpha != 0.0) { // don't divide by zero + destCoef /= resultAlpha; + sourceCoef /= resultAlpha; + aDest->red = sourceCoef * aSource.red + destCoef * aDest->red; + aDest->green = sourceCoef * aSource.green + destCoef * aDest->green; + aDest->blue = sourceCoef * aSource.blue + destCoef * aDest->blue; + aDest->alpha = resultAlpha; + } +} + static void GetLightAndDarkness(const GdkRGBA& aColor, double* aLightness, double* aDarkness) @@ -377,30 +388,39 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) break; #else // css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors - case eColorID_activeborder: + case eColorID_activeborder: { // active window border - gtk_style_context_get_border_color(mBackgroundStyle, + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_WINDOW); + gtk_style_context_get_border_color(style, GTK_STATE_FLAG_NORMAL, &gdk_color); aColor = GDK_RGBA_TO_NS_RGBA(gdk_color); + ReleaseStyleContext(style); break; - case eColorID_inactiveborder: + } + case eColorID_inactiveborder: { // inactive window border - gtk_style_context_get_border_color(mBackgroundStyle, - GTK_STATE_FLAG_INSENSITIVE, + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_WINDOW); + gtk_style_context_get_border_color(style, + GTK_STATE_FLAG_INSENSITIVE, &gdk_color); aColor = GDK_RGBA_TO_NS_RGBA(gdk_color); + ReleaseStyleContext(style); break; + } case eColorID_graytext: // disabled text in windows, menus, etc. case eColorID_inactivecaptiontext: // text in inactive window caption aColor = sMenuTextInactive; break; - case eColorID_inactivecaption: + case eColorID_inactivecaption: { // inactive window caption - gtk_style_context_get_background_color(mBackgroundStyle, + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_WINDOW); + gtk_style_context_get_background_color(style, GTK_STATE_FLAG_INSENSITIVE, &gdk_color); aColor = GDK_RGBA_TO_NS_RGBA(gdk_color); + ReleaseStyleContext(style); break; + } #endif case eColorID_infobackground: // tooltip background color @@ -521,18 +541,24 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) case eColorID__moz_fieldtext: aColor = sMozFieldText; break; - case eColorID__moz_buttondefault: - // default button border color - gtk_style_context_get_border_color(mButtonStyle, + case eColorID__moz_buttondefault: { + // default button border color + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_BUTTON); + gtk_style_context_get_border_color(style, GTK_STATE_FLAG_NORMAL, &gdk_color); aColor = GDK_RGBA_TO_NS_RGBA(gdk_color); + ReleaseStyleContext(style); break; - case eColorID__moz_buttonhoverface: - gtk_style_context_get_background_color(mButtonStyle, + } + case eColorID__moz_buttonhoverface: { + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_BUTTON); + gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT, &gdk_color); aColor = GDK_RGBA_TO_NS_RGBA(gdk_color); + ReleaseStyleContext(style); break; + } case eColorID__moz_buttonhovertext: aColor = sButtonHoverText; break; @@ -1029,16 +1055,6 @@ nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName, return true; } -#if (MOZ_WIDGET_GTK == 3) -static GtkStyleContext* -create_context(GtkWidgetPath *path) -{ - GtkStyleContext *style = gtk_style_context_new(); - gtk_style_context_set_path(style, path); - return(style); -} -#endif - void nsLookAndFeel::Init() { @@ -1129,78 +1145,55 @@ nsLookAndFeel::Init() g_object_set(settings, dark_setting, FALSE, nullptr); } - GtkWidgetPath *path = gtk_widget_path_new(); - gtk_widget_path_append_type(path, GTK_TYPE_WINDOW); - - mBackgroundStyle = create_context(path); - gtk_style_context_add_class(mBackgroundStyle, GTK_STYLE_CLASS_BACKGROUND); - - mButtonStyle = create_context(path); - gtk_style_context_add_class(mButtonStyle, GTK_STYLE_CLASS_BUTTON); - // Scrollbar colors - style = create_context(path); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_SCROLLBAR); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_TROUGH); + style = ClaimStyleContext(MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL); gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); sMozScrollbar = GDK_RGBA_TO_NS_RGBA(color); - g_object_unref(style); + ReleaseStyleContext(style); // Window colors - style = create_context(path); - gtk_style_context_save(style); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND); + style = ClaimStyleContext(MOZ_GTK_WINDOW); gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); sMozWindowBackground = GDK_RGBA_TO_NS_RGBA(color); gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); sMozWindowText = GDK_RGBA_TO_NS_RGBA(color); - gtk_style_context_restore(style); - g_object_unref(style); + ReleaseStyleContext(style); // tooltip foreground and background style = ClaimStyleContext(MOZ_GTK_TOOLTIP); gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); sInfoBackground = GDK_RGBA_TO_NS_RGBA(color); - { - GtkStyleContext* boxStyle = - CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0), - style); - GtkStyleContext* labelStyle = - CreateStyleForWidget(gtk_label_new(nullptr), boxStyle); - gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_NORMAL, &color); - g_object_unref(labelStyle); - g_object_unref(boxStyle); - } - sInfoText = GDK_RGBA_TO_NS_RGBA(color); ReleaseStyleContext(style); - // menu foreground & menu background - GtkWidget *accel_label = gtk_accel_label_new("M"); - GtkWidget *menuitem = gtk_menu_item_new(); - GtkWidget *menu = gtk_menu_new(); - - g_object_ref_sink(menu); - - gtk_container_add(GTK_CONTAINER(menuitem), accel_label); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - - style = gtk_widget_get_style_context(accel_label); + style = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL); gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); - sMenuText = GDK_RGBA_TO_NS_RGBA(color); - gtk_style_context_get_color(style, GTK_STATE_FLAG_INSENSITIVE, &color); - sMenuTextInactive = GDK_RGBA_TO_NS_RGBA(color); + sInfoText = GDK_RGBA_TO_NS_RGBA(color); + ReleaseStyleContext(style); - style = gtk_widget_get_style_context(menu); + style = ClaimStyleContext(MOZ_GTK_MENUITEM); + { + GtkStyleContext* accelStyle = + CreateStyleForWidget(gtk_accel_label_new("M"), style); + gtk_style_context_get_color(accelStyle, GTK_STATE_FLAG_NORMAL, &color); + sMenuText = GDK_RGBA_TO_NS_RGBA(color); + gtk_style_context_get_color(accelStyle, GTK_STATE_FLAG_INSENSITIVE, &color); + sMenuTextInactive = GDK_RGBA_TO_NS_RGBA(color); + g_object_unref(accelStyle); + } + ReleaseStyleContext(style); + + style = ClaimStyleContext(MOZ_GTK_MENUPOPUP); gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); sMenuBackground = GDK_RGBA_TO_NS_RGBA(color); + ReleaseStyleContext(style); - style = gtk_widget_get_style_context(menuitem); + style = ClaimStyleContext(MOZ_GTK_MENUITEM); gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT, &color); sMenuHover = GDK_RGBA_TO_NS_RGBA(color); gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color); sMenuHoverText = GDK_RGBA_TO_NS_RGBA(color); - g_object_unref(menu); + ReleaseStyleContext(style); #endif // button styles @@ -1211,9 +1204,6 @@ nsLookAndFeel::Init() GtkWidget *combobox = gtk_combo_box_new(); GtkWidget *comboboxLabel = gtk_label_new("M"); gtk_container_add(GTK_CONTAINER(combobox), comboboxLabel); -#else - GtkWidget *combobox = gtk_combo_box_new_with_entry(); - GtkWidget *comboboxLabel = gtk_bin_get_child(GTK_BIN(combobox)); #endif GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget *treeView = gtk_tree_view_new(); @@ -1227,7 +1217,9 @@ nsLookAndFeel::Init() gtk_container_add(GTK_CONTAINER(parent), button); gtk_container_add(GTK_CONTAINER(parent), treeView); gtk_container_add(GTK_CONTAINER(parent), linkButton); +#if (MOZ_WIDGET_GTK == 2) gtk_container_add(GTK_CONTAINER(parent), combobox); +#endif gtk_container_add(GTK_CONTAINER(parent), menuBar); gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuBarItem); gtk_container_add(GTK_CONTAINER(window), parent); @@ -1310,11 +1302,19 @@ nsLookAndFeel::Init() } #else // Text colors - style = gtk_widget_get_style_context(textView); - gtk_style_context_save(style); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_VIEW); - gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); - sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(color); + GdkRGBA bgColor; + // If the text window background is translucent, then the background of + // the textview root node is visible. + style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW); + gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, + &bgColor); + ReleaseStyleContext(style); + + style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT); + gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, + &color); + ApplyColorOver(color, &bgColor); + sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(bgColor); gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); sMozFieldText = GDK_RGBA_TO_NS_RGBA(color); @@ -1327,26 +1327,34 @@ nsLookAndFeel::Init() static_cast<GtkStateFlags>(GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_SELECTED), &color); sTextSelectedText = GDK_RGBA_TO_NS_RGBA(color); - gtk_style_context_restore(style); + ReleaseStyleContext(style); - // Button text, background, border - style = gtk_widget_get_style_context(label); - gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); - sButtonText = GDK_RGBA_TO_NS_RGBA(color); - gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color); - sButtonHoverText = GDK_RGBA_TO_NS_RGBA(color); + // Button text color + style = ClaimStyleContext(MOZ_GTK_BUTTON); + { + GtkStyleContext* labelStyle = + CreateStyleForWidget(gtk_label_new("M"), style); + gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_NORMAL, &color); + sButtonText = GDK_RGBA_TO_NS_RGBA(color); + gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_PRELIGHT, &color); + sButtonHoverText = GDK_RGBA_TO_NS_RGBA(color); + g_object_unref(labelStyle); + } + ReleaseStyleContext(style); // Combobox text color - style = gtk_widget_get_style_context(comboboxLabel); + style = ClaimStyleContext(MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA); gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); sComboBoxText = GDK_RGBA_TO_NS_RGBA(color); + ReleaseStyleContext(style); // Menubar text and hover text colors - style = gtk_widget_get_style_context(menuBarItem); + style = ClaimStyleContext(MOZ_GTK_MENUBARITEM); gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); sMenuBarText = GDK_RGBA_TO_NS_RGBA(color); gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color); sMenuBarHoverText = GDK_RGBA_TO_NS_RGBA(color); + ReleaseStyleContext(style); // GTK's guide to fancy odd row background colors: // 1) Check if a theme explicitly defines an odd row color @@ -1354,7 +1362,7 @@ nsLookAndFeel::Init() // slightly by a hardcoded value (gtkstyle.c) // 3) If neither are defined, take the base background color and // darken that by a hardcoded value - style = gtk_widget_get_style_context(treeView); + style = ClaimStyleContext(MOZ_GTK_TREEVIEW); // Get odd row background color gtk_style_context_save(style); @@ -1362,8 +1370,7 @@ nsLookAndFeel::Init() gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); sOddCellBackground = GDK_RGBA_TO_NS_RGBA(color); gtk_style_context_restore(style); - - gtk_widget_path_free(path); + ReleaseStyleContext(style); // GtkFrame has a "border" subnode on which Adwaita draws the border. // Some themes do not draw on this node but draw a border on the widget @@ -1448,12 +1455,6 @@ nsLookAndFeel::RefreshImpl() #if (MOZ_WIDGET_GTK == 2) g_object_unref(mStyle); mStyle = nullptr; -#else - g_object_unref(mBackgroundStyle); - g_object_unref(mButtonStyle); - - mBackgroundStyle = nullptr; - mButtonStyle = nullptr; #endif Init(); diff --git a/widget/gtk/nsLookAndFeel.h b/widget/gtk/nsLookAndFeel.h index 9058250b9..726859b41 100644 --- a/widget/gtk/nsLookAndFeel.h +++ b/widget/gtk/nsLookAndFeel.h @@ -33,9 +33,6 @@ public: protected: #if (MOZ_WIDGET_GTK == 2) struct _GtkStyle *mStyle; -#else - struct _GtkStyleContext *mBackgroundStyle; - struct _GtkStyleContext *mButtonStyle; #endif // Cached fonts diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index d97b35002..e4e69c1b4 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -6627,6 +6627,22 @@ nsWindow::GetDragInfo(WidgetMouseEvent* aMouseEvent, return false; } + if (mIsX11Display) { + // Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=789054 + // To avoid crashes disable double-click on WM without _NET_WM_MOVERESIZE. + // See _should_perform_ewmh_drag() at gdkwindow-x11.c + GdkScreen* screen = gdk_window_get_screen(gdk_window); + GdkAtom atom = gdk_atom_intern("_NET_WM_MOVERESIZE", FALSE); + if (!gdk_x11_screen_supports_net_wm_hint(screen, atom)) { + static unsigned int lastTimeStamp = 0; + if (lastTimeStamp != aMouseEvent->mTime) { + lastTimeStamp = aMouseEvent->mTime; + } else { + return false; + } + } + } + // FIXME: It would be nice to have the widget position at the time // of the event, but it's relatively unlikely that the widget has // moved since the mousedown. (On the other hand, it's quite likely diff --git a/widget/moz.build b/widget/moz.build index 09192179f..f69f2d87c 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -65,7 +65,6 @@ XPIDL_SOURCES += [ 'nsIClipboardHelper.idl', 'nsIClipboardOwner.idl', 'nsIColorPicker.idl', - 'nsIDatePicker.idl', 'nsIDisplayInfo.idl', 'nsIDragService.idl', 'nsIDragSession.idl', @@ -151,7 +150,6 @@ UNIFIED_SOURCES += [ 'nsClipboardProxy.cpp', 'nsColorPickerProxy.cpp', 'nsContentProcessWidgetFactory.cpp', - 'nsDatePickerProxy.cpp', 'nsDragServiceProxy.cpp', 'nsFilePickerProxy.cpp', 'nsHTMLFormatConverter.cpp', diff --git a/widget/nsBaseAppShell.cpp b/widget/nsBaseAppShell.cpp index 1557498b7..c6b88cba0 100644 --- a/widget/nsBaseAppShell.cpp +++ b/widget/nsBaseAppShell.cpp @@ -6,9 +6,6 @@ #include "base/message_loop.h" #include "nsBaseAppShell.h" -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#endif #include "nsThreadUtils.h" #include "nsIObserverService.h" #include "nsServiceManagerUtils.h" @@ -317,18 +314,12 @@ void nsBaseAppShell::IncrementEventloopNestingLevel() { ++mEventloopNestingLevel; -#if defined(MOZ_CRASHREPORTER) - CrashReporter::SetEventloopNestingLevel(mEventloopNestingLevel); -#endif } void nsBaseAppShell::DecrementEventloopNestingLevel() { --mEventloopNestingLevel; -#if defined(MOZ_CRASHREPORTER) - CrashReporter::SetEventloopNestingLevel(mEventloopNestingLevel); -#endif } // Called from the main thread diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index b820fed3c..909660f71 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -3086,6 +3086,7 @@ case _value: eventName.AssignLiteral(_name) ; break _ASSIGN_eventName(eMouseDown,"eMouseDown"); _ASSIGN_eventName(eMouseUp,"eMouseUp"); _ASSIGN_eventName(eMouseClick,"eMouseClick"); + _ASSIGN_eventName(eMouseAuxClick,"eMouseAuxClick"); _ASSIGN_eventName(eMouseDoubleClick,"eMouseDoubleClick"); _ASSIGN_eventName(eMouseMove,"eMouseMove"); _ASSIGN_eventName(eLoad,"eLoad"); diff --git a/widget/nsContentProcessWidgetFactory.cpp b/widget/nsContentProcessWidgetFactory.cpp index f8eaee250..2f00f1c83 100644 --- a/widget/nsContentProcessWidgetFactory.cpp +++ b/widget/nsContentProcessWidgetFactory.cpp @@ -9,7 +9,6 @@ #include "nsWidgetsCID.h" #include "nsClipboardProxy.h" #include "nsColorPickerProxy.h" -#include "nsDatePickerProxy.h" #include "nsDragServiceProxy.h" #include "nsFilePickerProxy.h" #include "nsScreenManagerProxy.h" @@ -22,7 +21,6 @@ using namespace mozilla::widget; NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardProxy) NS_GENERIC_FACTORY_CONSTRUCTOR(nsColorPickerProxy) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDatePickerProxy) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragServiceProxy) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePickerProxy) NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerProxy) @@ -30,7 +28,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(PuppetBidiKeyboard) NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID); NS_DEFINE_NAMED_CID(NS_COLORPICKER_CID); -NS_DEFINE_NAMED_CID(NS_DATEPICKER_CID); NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID); NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID); NS_DEFINE_NAMED_CID(PUPPETBIDIKEYBOARD_CID); @@ -41,8 +38,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = { Module::CONTENT_PROCESS_ONLY }, { &kNS_COLORPICKER_CID, false, nullptr, nsColorPickerProxyConstructor, Module::CONTENT_PROCESS_ONLY }, - { &kNS_DATEPICKER_CID, false, nullptr, nsDatePickerProxyConstructor, - Module::CONTENT_PROCESS_ONLY }, { &kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceProxyConstructor, Module::CONTENT_PROCESS_ONLY }, { &kNS_FILEPICKER_CID, false, nullptr, nsFilePickerProxyConstructor, @@ -57,7 +52,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = { static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID, Module::CONTENT_PROCESS_ONLY }, { "@mozilla.org/colorpicker;1", &kNS_COLORPICKER_CID, Module::CONTENT_PROCESS_ONLY }, - { "@mozilla.org/datepicker;1", &kNS_DATEPICKER_CID, Module::CONTENT_PROCESS_ONLY }, { "@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID, Module::CONTENT_PROCESS_ONLY }, { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID, Module::CONTENT_PROCESS_ONLY }, { "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID, Module::CONTENT_PROCESS_ONLY }, diff --git a/widget/nsDatePickerProxy.cpp b/widget/nsDatePickerProxy.cpp deleted file mode 100644 index e6b88f1be..000000000 --- a/widget/nsDatePickerProxy.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * 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 "nsDatePickerProxy.h" - -#include "mozilla/dom/TabChild.h" - -using namespace mozilla::dom; - -NS_IMPL_ISUPPORTS(nsDatePickerProxy, nsIDatePicker) - -/* void init (in nsIDOMWindow parent, in AString title, in short mode); */ -NS_IMETHODIMP -nsDatePickerProxy::Init(mozIDOMWindowProxy* aParent, const nsAString& aTitle, - const nsAString& aInitialDate) -{ - TabChild* tabChild = TabChild::GetFrom(aParent); - if (!tabChild) { - return NS_ERROR_FAILURE; - } - - tabChild->SendPDatePickerConstructor(this, - nsString(aTitle), - nsString(aInitialDate)); - NS_ADDREF_THIS(); //Released in DeallocPDatePickerChild - return NS_OK; -} - -/* void open (in nsIDatePickerShownCallback aDatePickerShownCallback); */ -NS_IMETHODIMP -nsDatePickerProxy::Open(nsIDatePickerShownCallback* aDatePickerShownCallback) -{ - NS_ENSURE_STATE(!mCallback); - mCallback = aDatePickerShownCallback; - - SendOpen(); - return NS_OK; -} - -bool -nsDatePickerProxy::RecvCancel() -{ - if (mCallback) { - mCallback->Cancel(); - mCallback = nullptr; - } - return true; -} - -bool -nsDatePickerProxy::Recv__delete__(const nsString& aDate) -{ - if (mCallback) { - mCallback->Done(aDate); - mCallback = nullptr; - } - return true; -} diff --git a/widget/nsDatePickerProxy.h b/widget/nsDatePickerProxy.h deleted file mode 100644 index 71475932c..000000000 --- a/widget/nsDatePickerProxy.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -#ifndef nsDatePickerProxy_h -#define nsDatePickerProxy_h - -#include "nsIDatePicker.h" - -#include "mozilla/dom/PDatePickerChild.h" - -class nsDatePickerProxy final : public nsIDatePicker, - public mozilla::dom::PDatePickerChild -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIDATEPICKER - - nsDatePickerProxy() {} - - virtual bool RecvCancel() override; - virtual bool Recv__delete__(const nsString& aDate) override; - -private: - ~nsDatePickerProxy() {} - - nsCOMPtr<nsIDatePickerShownCallback> mCallback; - nsString mTitle; - nsString mInitialDate; -}; - -#endif // nsDatePickerProxy_h diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index 7a9d870d9..e45189bb1 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -219,6 +219,34 @@ struct ParamTraits<mozilla::WidgetWheelEvent> }; template<> +struct ParamTraits<mozilla::WidgetPointerHelper> +{ + typedef mozilla::WidgetPointerHelper paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, aParam.pointerId); + WriteParam(aMsg, aParam.tiltX); + WriteParam(aMsg, aParam.tiltY); + WriteParam(aMsg, aParam.twist); + WriteParam(aMsg, aParam.tangentialPressure); + // We don't serialize convertToPointer since it's temporarily variable and + // should be reset to default. + } + + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) + { + bool rv; + rv = ReadParam(aMsg, aIter, &aResult->pointerId) && + ReadParam(aMsg, aIter, &aResult->tiltX) && + ReadParam(aMsg, aIter, &aResult->tiltY) && + ReadParam(aMsg, aIter, &aResult->twist) && + ReadParam(aMsg, aIter, &aResult->tangentialPressure); + return rv; + } +}; + +template<> struct ParamTraits<mozilla::WidgetMouseEvent> { typedef mozilla::WidgetMouseEvent paramType; @@ -226,13 +254,13 @@ struct ParamTraits<mozilla::WidgetMouseEvent> static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, static_cast<mozilla::WidgetMouseEventBase>(aParam)); + WriteParam(aMsg, static_cast<mozilla::WidgetPointerHelper>(aParam)); WriteParam(aMsg, aParam.mIgnoreRootScrollFrame); WriteParam(aMsg, static_cast<paramType::ReasonType>(aParam.mReason)); WriteParam(aMsg, static_cast<paramType::ContextMenuTriggerType>( aParam.mContextMenuTrigger)); WriteParam(aMsg, static_cast<paramType::ExitFromType>(aParam.mExitFrom)); WriteParam(aMsg, aParam.mClickCount); - WriteParam(aMsg, aParam.pointerId); } static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) @@ -243,12 +271,13 @@ struct ParamTraits<mozilla::WidgetMouseEvent> paramType::ExitFromType exitFrom = 0; rv = ReadParam(aMsg, aIter, static_cast<mozilla::WidgetMouseEventBase*>(aResult)) && + ReadParam(aMsg, aIter, + static_cast<mozilla::WidgetPointerHelper*>(aResult)) && ReadParam(aMsg, aIter, &aResult->mIgnoreRootScrollFrame) && ReadParam(aMsg, aIter, &reason) && ReadParam(aMsg, aIter, &contextMenuTrigger) && ReadParam(aMsg, aIter, &exitFrom) && - ReadParam(aMsg, aIter, &aResult->mClickCount) && - ReadParam(aMsg, aIter, &aResult->pointerId); + ReadParam(aMsg, aIter, &aResult->mClickCount); aResult->mReason = static_cast<paramType::Reason>(reason); aResult->mContextMenuTrigger = static_cast<paramType::ContextMenuTrigger>(contextMenuTrigger); @@ -290,8 +319,6 @@ struct ParamTraits<mozilla::WidgetPointerEvent> WriteParam(aMsg, static_cast<mozilla::WidgetMouseEvent>(aParam)); WriteParam(aMsg, aParam.mWidth); WriteParam(aMsg, aParam.mHeight); - WriteParam(aMsg, aParam.tiltX); - WriteParam(aMsg, aParam.tiltY); WriteParam(aMsg, aParam.mIsPrimary); } @@ -301,8 +328,6 @@ struct ParamTraits<mozilla::WidgetPointerEvent> ReadParam(aMsg, aIter, static_cast<mozilla::WidgetMouseEvent*>(aResult)) && ReadParam(aMsg, aIter, &aResult->mWidth) && ReadParam(aMsg, aIter, &aResult->mHeight) && - ReadParam(aMsg, aIter, &aResult->tiltX) && - ReadParam(aMsg, aIter, &aResult->tiltY) && ReadParam(aMsg, aIter, &aResult->mIsPrimary); return rv; } diff --git a/widget/nsIDatePicker.idl b/widget/nsIDatePicker.idl deleted file mode 100644 index d6be60c95..000000000 --- a/widget/nsIDatePicker.idl +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * 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 "nsISupports.idl" - -interface mozIDOMWindowProxy; - -[scriptable, uuid(13388a28-1b0b-4218-a31b-588f7a4ec26c)] -interface nsIDatePickerShownCallback : nsISupports -{ - /** - * Callback called when the user selects cancel in the date picker - * This callback can not be called after done() is called. - */ - void cancel(); - - /** - * Callback called when the user has finished selecting the date - * - * @param date The new selected date value following the format "YYYY-MM-DD" - */ - void done(in AString date); -}; - -[scriptable, uuid(7becfc64-966b-4d53-87d2-9161f36bd3b3)] -interface nsIDatePicker : nsISupports -{ - /** - * Initialize the date picker widget. The date picker will not be shown until - * open() is called. - * If the initialDate parameter does not follow the format "YYYY-MM-DD" then - * the behavior will be unspecified. - * - * @param parent nsIDOMWindow parent. This dialog will be dependent - * on this parent. parent may be null. - * @param title The title for the date picker widget. - * @param initialDate The date to show when the widget is opened. The - * parameter has to follow the format "YYYY-MM-DD" - */ - void init(in mozIDOMWindowProxy parent, in AString title, in AString initialDate); - - /** - * Opens the date dialog asynchrounously. - * The results are provided via the callback object. - */ - void open(in nsIDatePickerShownCallback callback); -}; diff --git a/widget/nsWidgetsCID.h b/widget/nsWidgetsCID.h index 2589b59e0..54ebe63ab 100644 --- a/widget/nsWidgetsCID.h +++ b/widget/nsWidgetsCID.h @@ -33,11 +33,6 @@ { 0x0f872c8c, 0x3ee6, 0x46bd, \ { 0x92, 0xa2, 0x69, 0x65, 0x2c, 0x6b, 0x47, 0x4e } } -/* 0ca832f8-978a-4dc7-a57d-adb803925d39 */ -#define NS_DATEPICKER_CID \ -{ 0x0ca832f8, 0x978a, 0x4dc7, \ - { 0xa5, 0x7d, 0xad, 0xb8, 0x03, 0x92, 0x5d, 0x39 } } - /* 2d96b3df-c051-11d1-a827-0040959a28c9 */ #define NS_APPSHELL_CID \ { 0x2d96b3df, 0xc051, 0x11d1, \ diff --git a/widget/windows/GfxInfo.cpp b/widget/windows/GfxInfo.cpp index bfea41851..8a429ad32 100644 --- a/widget/windows/GfxInfo.cpp +++ b/widget/windows/GfxInfo.cpp @@ -21,12 +21,6 @@ #include "nsPrintfCString.h" #include "jsapi.h" -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" -#define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" -#endif - using namespace mozilla; using namespace mozilla::gfx; using namespace mozilla::widget; @@ -721,102 +715,10 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) return NS_OK; } -#if defined(MOZ_CRASHREPORTER) -/* Cisco's VPN software can cause corruption of the floating point state. - * Make a note of this in our crash reports so that some weird crashes - * make more sense */ -static void -CheckForCiscoVPN() { - LONG result; - HKEY key; - /* This will give false positives, but hopefully no false negatives */ - result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Cisco Systems\\VPN Client", 0, KEY_QUERY_VALUE, &key); - if (result == ERROR_SUCCESS) { - RegCloseKey(key); - CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("Cisco VPN\n")); - } -} -#endif - void GfxInfo::AddCrashReportAnnotations() { -#if defined(MOZ_CRASHREPORTER) - CheckForCiscoVPN(); - - if (mHasDriverVersionMismatch) { - CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("DriverVersionMismatch\n")); - } - - nsString deviceID, vendorID, driverVersion, subsysID; - nsCString narrowDeviceID, narrowVendorID, narrowDriverVersion, narrowSubsysID; - - GetAdapterDeviceID(deviceID); - CopyUTF16toUTF8(deviceID, narrowDeviceID); - GetAdapterVendorID(vendorID); - CopyUTF16toUTF8(vendorID, narrowVendorID); - GetAdapterDriverVersion(driverVersion); - CopyUTF16toUTF8(driverVersion, narrowDriverVersion); - GetAdapterSubsysID(subsysID); - CopyUTF16toUTF8(subsysID, narrowSubsysID); - - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"), - narrowVendorID); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"), - narrowDeviceID); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDriverVersion"), - narrowDriverVersion); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterSubsysID"), - narrowSubsysID); - - /* Add an App Note for now so that we get the data immediately. These - * can go away after we store the above in the socorro db */ - nsAutoCString note; - /* AppendPrintf only supports 32 character strings, mrghh. */ - note.AppendLiteral("AdapterVendorID: "); - note.Append(narrowVendorID); - note.AppendLiteral(", AdapterDeviceID: "); - note.Append(narrowDeviceID); - note.AppendLiteral(", AdapterSubsysID: "); - note.Append(narrowSubsysID); - note.AppendLiteral(", AdapterDriverVersion: "); - note.Append(NS_LossyConvertUTF16toASCII(driverVersion)); - - if (vendorID == GfxDriverInfo::GetDeviceVendor(VendorAll)) { - /* if we didn't find a valid vendorID lets append the mDeviceID string to try to find out why */ - note.AppendLiteral(", "); - LossyAppendUTF16toASCII(mDeviceID, note); - note.AppendLiteral(", "); - LossyAppendUTF16toASCII(mDeviceKeyDebug, note); - LossyAppendUTF16toASCII(mDeviceKeyDebug, note); - } - note.Append("\n"); - - if (mHasDualGPU) { - nsString deviceID2, vendorID2, subsysID2; - nsAutoString adapterDriverVersionString2; - nsCString narrowDeviceID2, narrowVendorID2, narrowSubsysID2; - - note.AppendLiteral("Has dual GPUs. GPU #2: "); - GetAdapterDeviceID2(deviceID2); - CopyUTF16toUTF8(deviceID2, narrowDeviceID2); - GetAdapterVendorID2(vendorID2); - CopyUTF16toUTF8(vendorID2, narrowVendorID2); - GetAdapterDriverVersion2(adapterDriverVersionString2); - GetAdapterSubsysID(subsysID2); - CopyUTF16toUTF8(subsysID2, narrowSubsysID2); - note.AppendLiteral("AdapterVendorID2: "); - note.Append(narrowVendorID2); - note.AppendLiteral(", AdapterDeviceID2: "); - note.Append(narrowDeviceID2); - note.AppendLiteral(", AdapterSubsysID2: "); - note.Append(narrowSubsysID2); - note.AppendLiteral(", AdapterDriverVersion2: "); - note.Append(NS_LossyConvertUTF16toASCII(adapterDriverVersionString2)); - } - CrashReporter::AppendAppNotesToCrashReport(note); - -#endif + /*** STUB ***/ } static OperatingSystem diff --git a/widget/windows/KeyboardLayout.cpp b/widget/windows/KeyboardLayout.cpp index 341a40c18..9166d97d7 100644 --- a/widget/windows/KeyboardLayout.cpp +++ b/widget/windows/KeyboardLayout.cpp @@ -13,9 +13,6 @@ #include "mozilla/WindowsVersion.h" #include "nsAlgorithm.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif #include "nsGkAtoms.h" #include "nsIDOMKeyEvent.h" #include "nsIIdleServiceInternal.h" @@ -2740,42 +2737,6 @@ NativeKey::NeedsToHandleWithoutFollowingCharMessages() const return mIsPrintableKey; } -#ifdef MOZ_CRASHREPORTER - -static nsCString -GetResultOfInSendMessageEx() -{ - DWORD ret = ::InSendMessageEx(nullptr); - if (!ret) { - return NS_LITERAL_CSTRING("ISMEX_NOSEND"); - } - nsAutoCString result; - if (ret & ISMEX_CALLBACK) { - result = "ISMEX_CALLBACK"; - } - if (ret & ISMEX_NOTIFY) { - if (!result.IsEmpty()) { - result += " | "; - } - result += "ISMEX_NOTIFY"; - } - if (ret & ISMEX_REPLIED) { - if (!result.IsEmpty()) { - result += " | "; - } - result += "ISMEX_REPLIED"; - } - if (ret & ISMEX_SEND) { - if (!result.IsEmpty()) { - result += " | "; - } - result += "ISMEX_SEND"; - } - return result; -} - -#endif // #ifdef MOZ_CRASHREPORTER - bool NativeKey::MayBeSameCharMessage(const MSG& aCharMsg1, const MSG& aCharMsg2) const @@ -3019,33 +2980,6 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) } if (doCrash) { -#ifdef MOZ_CRASHREPORTER - nsPrintfCString info("\nPeekMessage() failed to remove char message! " - "\nActive keyboard layout=0x%08X (%s), " - "\nHandling message: %s, InSendMessageEx()=%s, " - "\nFound message: %s, " - "\nWM_NULL has been removed: %d, " - "\nNext key message in all windows: %s, " - "time=%d, ", - KeyboardLayout::GetActiveLayout(), - KeyboardLayout::GetActiveLayoutName().get(), - ToString(mMsg).get(), - GetResultOfInSendMessageEx().get(), - ToString(kFoundCharMsg).get(), i, - ToString(nextKeyMsgInAllWindows).get(), - nextKeyMsgInAllWindows.time); - CrashReporter::AppendAppNotesToCrashReport(info); - MSG nextMsg; - if (WinUtils::PeekMessage(&nextMsg, 0, 0, 0, - PM_NOREMOVE | PM_NOYIELD)) { - nsPrintfCString info("\nNext message in all windows: %s, time=%d", - ToString(nextMsg).get(), nextMsg.time); - CrashReporter::AppendAppNotesToCrashReport(info); - } else { - CrashReporter::AppendAppNotesToCrashReport( - NS_LITERAL_CSTRING("\nThere is no message in any window")); - } -#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("We lost the following char message"); } @@ -3164,63 +3098,12 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) "nextKeyMsg=%s, kFoundCharMsg=%s", this, ToString(removedMsg).get(), ToString(nextKeyMsg).get(), ToString(kFoundCharMsg).get())); -#ifdef MOZ_CRASHREPORTER - nsPrintfCString info("\nPeekMessage() removed unexpcted char message! " - "\nActive keyboard layout=0x%08X (%s), " - "\nHandling message: %s, InSendMessageEx()=%s, " - "\nFound message: %s, " - "\nRemoved message: %s, ", - KeyboardLayout::GetActiveLayout(), - KeyboardLayout::GetActiveLayoutName().get(), - ToString(mMsg).get(), - GetResultOfInSendMessageEx().get(), - ToString(kFoundCharMsg).get(), - ToString(removedMsg).get()); - CrashReporter::AppendAppNotesToCrashReport(info); - // What's the next key message? - MSG nextKeyMsgAfter; - if (WinUtils::PeekMessage(&nextKeyMsgAfter, mMsg.hwnd, - WM_KEYFIRST, WM_KEYLAST, - PM_NOREMOVE | PM_NOYIELD)) { - nsPrintfCString info("\nNext key message after unexpected char message " - "removed: %s, ", - ToString(nextKeyMsgAfter).get()); - CrashReporter::AppendAppNotesToCrashReport(info); - } else { - CrashReporter::AppendAppNotesToCrashReport( - NS_LITERAL_CSTRING("\nThere is no key message after unexpected char " - "message removed, ")); - } - // Another window has a key message? - if (WinUtils::PeekMessage(&nextKeyMsgInAllWindows, 0, - WM_KEYFIRST, WM_KEYLAST, - PM_NOREMOVE | PM_NOYIELD)) { - nsPrintfCString info("\nNext key message in all windows: %s.", - ToString(nextKeyMsgInAllWindows).get()); - CrashReporter::AppendAppNotesToCrashReport(info); - } else { - CrashReporter::AppendAppNotesToCrashReport( - NS_LITERAL_CSTRING("\nThere is no key message in any windows.")); - } -#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("PeekMessage() removed unexpected message"); } MOZ_LOG(sNativeKeyLogger, LogLevel::Error, ("%p NativeKey::GetFollowingCharMessage(), FAILED, removed messages " "are all WM_NULL, nextKeyMsg=%s", this, ToString(nextKeyMsg).get())); -#ifdef MOZ_CRASHREPORTER - nsPrintfCString info("\nWe lost following char message! " - "\nActive keyboard layout=0x%08X (%s), " - "\nHandling message: %s, InSendMessageEx()=%s, \n" - "Found message: %s, removed a lot of WM_NULL", - KeyboardLayout::GetActiveLayout(), - KeyboardLayout::GetActiveLayoutName().get(), - ToString(mMsg).get(), - GetResultOfInSendMessageEx().get(), - ToString(kFoundCharMsg).get()); - CrashReporter::AppendAppNotesToCrashReport(info); -#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("We lost the following char message"); return false; } diff --git a/widget/windows/LSPAnnotator.cpp b/widget/windows/LSPAnnotator.cpp deleted file mode 100644 index 97f6e5b50..000000000 --- a/widget/windows/LSPAnnotator.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -/** - * LSPs are evil little bits of code that are allowed to inject into our - * networking stack by Windows. Once they have wormed into our process - * they gnaw at our innards until we crash. Here we force the buggers - * into the light by recording them in our crash information. - * We do the enumeration on a thread because I'm concerned about startup perf - * on machines with several LSPs. - */ - -#include "nsICrashReporter.h" -#include "nsISupportsImpl.h" -#include "nsServiceManagerUtils.h" -#include "nsThreadUtils.h" -#include "nsQueryObject.h" -#include "nsWindowsHelpers.h" -#include <windows.h> -#include <rpc.h> -#include <ws2spi.h> - -namespace mozilla { -namespace crashreporter { - -class LSPAnnotationGatherer : public Runnable -{ - ~LSPAnnotationGatherer() {} - -public: - NS_DECL_THREADSAFE_ISUPPORTS - NS_DECL_NSIRUNNABLE - - void Annotate(); - nsCString mString; - nsCOMPtr<nsIThread> mThread; -}; - -NS_IMPL_ISUPPORTS(LSPAnnotationGatherer, nsIRunnable) - -void -LSPAnnotationGatherer::Annotate() -{ - nsCOMPtr<nsICrashReporter> cr = - do_GetService("@mozilla.org/toolkit/crash-reporter;1"); - bool enabled; - if (cr && NS_SUCCEEDED(cr->GetEnabled(&enabled)) && enabled) { - cr->AnnotateCrashReport(NS_LITERAL_CSTRING("Winsock_LSP"), mString); - } - mThread->AsyncShutdown(); -} - -NS_IMETHODIMP -LSPAnnotationGatherer::Run() -{ - PR_SetCurrentThreadName("LSP Annotator"); - - mThread = NS_GetCurrentThread(); - - DWORD size = 0; - int err; - // Get the size of the buffer we need - if (SOCKET_ERROR != WSCEnumProtocols(nullptr, nullptr, &size, &err) || - err != WSAENOBUFS) { - // Er, what? - NS_NOTREACHED("WSCEnumProtocols suceeded when it should have failed ..."); - return NS_ERROR_FAILURE; - } - - auto byteArray = MakeUnique<char[]>(size); - WSAPROTOCOL_INFOW* providers = - reinterpret_cast<WSAPROTOCOL_INFOW*>(byteArray.get()); - - int n = WSCEnumProtocols(nullptr, providers, &size, &err); - if (n == SOCKET_ERROR) { - // Lame. We provided the right size buffer; we'll just give up now. - NS_WARNING("Could not get LSP list"); - return NS_ERROR_FAILURE; - } - - nsCString str; - for (int i = 0; i < n; i++) { - AppendUTF16toUTF8(nsDependentString(providers[i].szProtocol), str); - str.AppendLiteral(" : "); - str.AppendInt(providers[i].iVersion); - str.AppendLiteral(" : "); - str.AppendInt(providers[i].iAddressFamily); - str.AppendLiteral(" : "); - str.AppendInt(providers[i].iSocketType); - str.AppendLiteral(" : "); - str.AppendInt(providers[i].iProtocol); - str.AppendLiteral(" : "); - str.AppendPrintf("0x%x", providers[i].dwServiceFlags1); - str.AppendLiteral(" : "); - str.AppendPrintf("0x%x", providers[i].dwProviderFlags); - str.AppendLiteral(" : "); - - wchar_t path[MAX_PATH]; - int pathLen = MAX_PATH; - if (!WSCGetProviderPath(&providers[i].ProviderId, path, &pathLen, &err)) { - AppendUTF16toUTF8(nsDependentString(path), str); - } - - str.AppendLiteral(" : "); - // If WSCGetProviderInfo is available, we should call it to obtain the - // category flags for this provider. When present, these flags inform - // Windows as to which order to chain the providers. - nsModuleHandle ws2_32(LoadLibraryW(L"ws2_32.dll")); - if (ws2_32) { - decltype(WSCGetProviderInfo)* pWSCGetProviderInfo = - reinterpret_cast<decltype(WSCGetProviderInfo)*>( - GetProcAddress(ws2_32, "WSCGetProviderInfo")); - if (pWSCGetProviderInfo) { - DWORD categoryInfo; - size_t categoryInfoSize = sizeof(categoryInfo); - if (!pWSCGetProviderInfo(&providers[i].ProviderId, - ProviderInfoLspCategories, - (PBYTE)&categoryInfo, &categoryInfoSize, 0, - &err)) { - str.AppendPrintf("0x%x", categoryInfo); - } - } - } - - str.AppendLiteral(" : "); - if (providers[i].ProtocolChain.ChainLen <= BASE_PROTOCOL) { - // If we're dealing with a catalog entry that identifies an individual - // base or layer provider, log its provider GUID. - RPC_CSTR provIdStr = nullptr; - if (UuidToStringA(&providers[i].ProviderId, &provIdStr) == RPC_S_OK) { - str.Append(reinterpret_cast<char*>(provIdStr)); - RpcStringFreeA(&provIdStr); - } - } - - if (i + 1 != n) { - str.AppendLiteral(" \n "); - } - } - - mString = str; - NS_DispatchToMainThread(NewRunnableMethod(this, &LSPAnnotationGatherer::Annotate)); - return NS_OK; -} - -void LSPAnnotate() -{ - nsCOMPtr<nsIThread> thread; - nsCOMPtr<nsIRunnable> runnable = - do_QueryObject(new LSPAnnotationGatherer()); - NS_NewThread(getter_AddRefs(thread), runnable); -} - -} // namespace crashreporter -} // namespace mozilla diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp index 0a57ad439..bd42e78f6 100644 --- a/widget/windows/WinUtils.cpp +++ b/widget/windows/WinUtils.cpp @@ -1138,7 +1138,8 @@ WinUtils::GetIsMouseFromTouch(EventMessage aEventMessage) const uint32_t MOZ_T_I_SIGNATURE = TABLET_INK_TOUCH | TABLET_INK_SIGNATURE; const uint32_t MOZ_T_I_CHECK_TCH = TABLET_INK_TOUCH | TABLET_INK_CHECK; return ((aEventMessage == eMouseMove || aEventMessage == eMouseDown || - aEventMessage == eMouseUp || aEventMessage == eMouseDoubleClick) && + aEventMessage == eMouseUp || aEventMessage == eMouseAuxClick || + aEventMessage == eMouseDoubleClick) && (GetMessageExtraInfo() & MOZ_T_I_SIGNATURE) == MOZ_T_I_CHECK_TCH); } diff --git a/widget/windows/moz.build b/widget/windows/moz.build index d4f089eea..1e7fc4b02 100644 --- a/widget/windows/moz.build +++ b/widget/windows/moz.build @@ -79,11 +79,6 @@ SOURCES += [ 'WinMouseScrollHandler.cpp', ] -if CONFIG['MOZ_CRASHREPORTER']: - UNIFIED_SOURCES += [ - 'LSPAnnotator.cpp', - ] - if CONFIG['NS_PRINTING']: UNIFIED_SOURCES += [ 'nsDeviceContextSpecWin.cpp', diff --git a/widget/windows/nsAppShell.cpp b/widget/windows/nsAppShell.cpp index c8820e7d1..c3e99b2d3 100644 --- a/widget/windows/nsAppShell.cpp +++ b/widget/windows/nsAppShell.cpp @@ -213,10 +213,6 @@ nsAppShell::~nsAppShell() nsresult nsAppShell::Init() { -#ifdef MOZ_CRASHREPORTER - LSPAnnotate(); -#endif - mLastNativeEventScheduled = TimeStamp::NowLoRes(); mozilla::ipc::windows::InitUIThread(); diff --git a/widget/windows/nsClipboard.cpp b/widget/windows/nsClipboard.cpp index 1afee3496..0db1dd342 100644 --- a/widget/windows/nsClipboard.cpp +++ b/widget/windows/nsClipboard.cpp @@ -65,7 +65,7 @@ nsClipboard::nsClipboard() : nsBaseClipboard() nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1"); if (observerService) - observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); + observerService->AddObserver(this, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID, PR_FALSE); } //------------------------------------------------------------------------- diff --git a/widget/windows/nsDataObj.cpp b/widget/windows/nsDataObj.cpp index 02ec3b2fe..977a87c08 100644 --- a/widget/windows/nsDataObj.cpp +++ b/widget/windows/nsDataObj.cpp @@ -443,6 +443,82 @@ STDMETHODIMP_(ULONG) nsDataObj::AddRef() return m_cRef; } +namespace { +class RemoveTempFileHelper : public nsIObserver +{ +public: + explicit RemoveTempFileHelper(nsIFile* aTempFile) + : mTempFile(aTempFile) + { + MOZ_ASSERT(mTempFile); + } + + // The attach method is seperate from the constructor as we may be addref-ing + // ourself, and we want to be sure someone has a strong reference to us. + void Attach() + { + // We need to listen to both the xpcom shutdown message and our timer, and + // fire when the first of either of these two messages is received. + nsresult rv; + mTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv); + if (NS_WARN_IF(NS_FAILED(rv))) { + return; + } + mTimer->Init(this, 500, nsITimer::TYPE_ONE_SHOT); + + nsCOMPtr<nsIObserverService> observerService = + do_GetService("@mozilla.org/observer-service;1"); + if (NS_WARN_IF(!observerService)) { + mTimer->Cancel(); + mTimer = nullptr; + return; + } + observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false); + } + + NS_DECL_ISUPPORTS + NS_DECL_NSIOBSERVER + +private: + ~RemoveTempFileHelper() + { + if (mTempFile) { + mTempFile->Remove(false); + } + } + + nsCOMPtr<nsIFile> mTempFile; + nsCOMPtr<nsITimer> mTimer; +}; + +NS_IMPL_ISUPPORTS(RemoveTempFileHelper, nsIObserver); + +NS_IMETHODIMP +RemoveTempFileHelper::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) +{ + // Let's be careful and make sure that we don't die immediately + RefPtr<RemoveTempFileHelper> grip = this; + + // Make sure that we aren't called again by destroying references to ourself. + nsCOMPtr<nsIObserverService> observerService = + do_GetService("@mozilla.org/observer-service;1"); + if (observerService) { + observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID); + } + + if (mTimer) { + mTimer->Cancel(); + mTimer = nullptr; + } + + // Remove the tempfile + if (mTempFile) { + mTempFile->Remove(false); + mTempFile = nullptr; + } + return NS_OK; +} +} // namespace //----------------------------------------------------- STDMETHODIMP_(ULONG) nsDataObj::Release() @@ -456,17 +532,12 @@ STDMETHODIMP_(ULONG) nsDataObj::Release() // We have released our last ref on this object and need to delete the // temp file. External app acting as drop target may still need to open the // temp file. Addref a timer so it can delay deleting file and destroying - // this object. Delete file anyway and destroy this obj if there's a problem. + // this object. if (mCachedTempFile) { - nsresult rv; - mTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) { - mTimer->InitWithFuncCallback(nsDataObj::RemoveTempFile, this, - 500, nsITimer::TYPE_ONE_SHOT); - return AddRef(); - } - mCachedTempFile->Remove(false); + RefPtr<RemoveTempFileHelper> helper = + new RemoveTempFileHelper(mCachedTempFile); mCachedTempFile = nullptr; + helper->Attach(); } delete this; @@ -2153,13 +2224,3 @@ HRESULT nsDataObj::GetFileContents_IStream(FORMATETC& aFE, STGMEDIUM& aSTG) return S_OK; } - -void nsDataObj::RemoveTempFile(nsITimer* aTimer, void* aClosure) -{ - nsDataObj *timedDataObj = static_cast<nsDataObj *>(aClosure); - if (timedDataObj->mCachedTempFile) { - timedDataObj->mCachedTempFile->Remove(false); - timedDataObj->mCachedTempFile = nullptr; - } - timedDataObj->Release(); -} diff --git a/widget/windows/nsDataObj.h b/widget/windows/nsDataObj.h index 2d7fb75ee..61f209e85 100644 --- a/widget/windows/nsDataObj.h +++ b/widget/windows/nsDataObj.h @@ -289,7 +289,6 @@ protected: bool LookupArbitraryFormat(FORMATETC *aFormat, LPDATAENTRY *aDataEntry, BOOL aAddorUpdate); bool CopyMediumData(STGMEDIUM *aMediumDst, STGMEDIUM *aMediumSrc, LPFORMATETC aFormat, BOOL aSetData); - static void RemoveTempFile(nsITimer* aTimer, void* aClosure); }; |